|
|
Line 78: |
Line 78: |
|
| |
|
| == INVOCATION == | | == INVOCATION == |
| A login shell is one whose first character of argument zero is a -, or one started with the --lo‐
| | ログインシェルとは、引数ゼロの最初の文字が - であるシェル、または --login オプションで起動されるシェルのことである。 |
| gin option.
| |
|
| |
|
| An interactive shell is one started without non-option arguments (unless -s is specified) and
| | 対話型シェルとは、(-s が指定されていない限り) オプション以外の引数を指定せず、かつ -c オプションを指定せずに、標準入力と標準エラーが ('''[https://manpages.debian.org/bookworm/manpages-dev/isatty.3.en.html isatty]'''(3) によって決定される) 端末に接続されているシェル、または -i オプションで起動されるシェルのことである。 PS1が設定され、$-がiに含まれるのは、bashが対話型である場合であり、シェル・スクリプトやスタートアップ・ファイルがこの状態をテストできるようにするためである。 |
| without the -c option whose standard input and error are both connected to terminals (as deter‐
| |
| mined by isatty(3)), or one started with the -i option. PS1 is set and $- includes i if bash is
| |
| interactive, allowing a shell script or a startup file to test this state.
| |
|
| |
|
| The following paragraphs describe how bash executes its startup files. If any of the files exist
| | 以下の段落では、bashが起動ファイルをどのように実行するかを説明する。 ファイルが存在するが読み込めない場合、bashはエラーを報告する。 チルダは、後述の''[[#EXPANSION|EXPANSION]]''セクションの「チルダの展開」で説明するように、ファイル名で展開される。 |
| but cannot be read, bash reports an error. Tildes are expanded in filenames as described below
| |
| under Tilde Expansion in the EXPANSION section.
| |
|
| |
|
| When bash is invoked as an interactive login shell, or as a non-interactive shell with the --lo‐
| | bashが対話型ログイン・シェルとして、または-loginオプションを指定して非対話型シェルとして起動されると、まず[[/etc/profile]]ファイルが存在する場合は、そのファイルからコマンドを読み込んで実行する。 |
| gin option, it first reads and executes commands from the file /etc/profile, if that file exists.
| | このファイルを読み込んだ後、~/.bash_profile、~/.bash_login、~/.profileの順に探し、最初に存在し、読み取り可能なものからコマンドを読み取って実行する。 シェルの起動時に--noprofileオプションを使用すると、この動作を抑制することができる。 |
| After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that or‐
| |
| der, and reads and executes commands from the first one that exists and is readable. The --no‐
| |
| profile option may be used when the shell is started to inhibit this behavior.
| |
|
| |
|
| When an interactive login shell exits, or a non-interactive login shell executes the exit builtin
| | 対話型ログイン・シェルが終了するとき、または非対話型ログイン・シェルがexit組み込みコマンドを実行するとき、bashは~/.bash_logoutファイルが存在すればそこからコマンドを読み込んで実行する。 |
| command, bash reads and executes commands from the file ~/.bash_logout, if it exists.
| |
|
| |
|
| When an interactive shell that is not a login shell is started, bash reads and executes commands
| | ログイン・シェルではない対話型シェルが起動されると、bashは[[/etc/bash.bashrc]]と~/.bashrcが存在する場合、これらのファイルからコマンドを読み込んで実行する。 これは--norcオプションを使うことで抑制できる。 rcfileファイル・オプションを指定すると、[[/etc/bash.bashrc]]や~/.bashrcではなく、ファイルからコマンドを読み込んで実行するようになる。 |
| from /etc/bash.bashrc and ~/.bashrc, if these files exist. This may be inhibited by using the
| |
| --norc option. The --rcfile file option will force bash to read and execute commands from file
| |
| instead of /etc/bash.bashrc and ~/.bashrc.
| |
|
| |
|
| When bash is started non-interactively, to run a shell script, for example, it looks for the
| | シェル・スクリプトを実行する場合など、bashが非対話的に起動されると、環境変数BASH_ENVを探し、その値があれば展開し、展開された値を読み込んで実行するファイル名として使用する。 Bashは以下のコマンドが実行されたかのように振る舞う: |
| variable BASH_ENV in the environment, expands its value if it appears there, and uses the ex‐
| | :<code>if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi</code> |
| panded value as the name of a file to read and execute. Bash behaves as if the following command
| | とする。しかし、'''PATH'''変数の値はファイル名の検索には使われない。 |
| were executed:
| |
| if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi
| |
| but the value of the PATH variable is not used to search for the filename.
| |
|
| |
|
| If bash is invoked with the name sh, it tries to mimic the startup behavior of historical ver‐
| | bashがshという名前で起動された場合、POSIX標準にも準拠しながら、過去のバージョンのshの起動時の動作をできるだけ忠実に模倣しようとする。 対話型ログインシェルとして起動された場合、または--loginオプションを指定した非対話型シェルとして起動された場合、まず[[/etc/profile]]と~/.profileの順にコマンドを読み込んで実行しようとする。 noprofileオプションを使用すると、この動作を抑制することができる。 対話型シェルとしてshという名前で起動されると、bashは変数ENVを探し、その値が定義されていれば展開し、展開された値を読み込み実行するファイル名として使用する。 shとして起動されたシェルは、他の起動ファイルからコマンドを読み込んで実行しようとはしないので、--rcfileオプションは効果がない。 shという名前で起動された非対話型シェルは、他の起動ファイルを読み込もうとしない。 shとして起動された場合、bashはスタートアップ・ファイルを読み込んだ後にposixモードに入る。 |
| sions of sh as closely as possible, while conforming to the POSIX standard as well. When invoked
| |
| as an interactive login shell, or a non-interactive shell with the --login option, it first at‐
| |
| tempts to read and execute commands from /etc/profile and ~/.profile, in that order. The --no‐
| |
| profile option may be used to inhibit this behavior. When invoked as an interactive shell with
| |
| the name sh, bash looks for the variable ENV, expands its value if it is defined, and uses the
| |
| expanded value as the name of a file to read and execute. Since a shell invoked as sh does not
| |
| attempt to read and execute commands from any other startup files, the --rcfile option has no ef‐
| |
| fect. A non-interactive shell invoked with the name sh does not attempt to read any other
| |
| startup files. When invoked as sh, bash enters posix mode after the startup files are read.
| |
|
| |
|
| When bash is started in posix mode, as with the --posix command line option, it follows the POSIX
| | posix コマンドラインオプション --posix のように bash が posix モードで起動されると、スタートアップファイルの POSIX 標準に従う。 このモードでは、対話型シェルはENV変数を展開し、展開された値を名前とするファイルからコマンドが読み込まれ実行される。 他のスタートアップ・ファイルは読み込まれない。 |
| standard for startup files. In this mode, interactive shells expand the ENV variable and com‐
| |
| mands are read and executed from the file whose name is the expanded value. No other startup
| |
| files are read.
| |
|
| |
|
| Bash attempts to determine when it is being run with its standard input connected to a network
| | Bashは、リモートシェルデーモン(通常は[[usr/sbin/rshd|rshd]])またはセキュアシェルデーモン[[/usr/sbin/sshd|sshd]]によって実行されるときのように、標準入力がネットワーク接続に接続された状態で実行されているかどうかを判断しようとする。 bashがこの方法で実行されていると判断した場合、~/.bashrcと~/.bashrcが存在し、これらのファイルが読み取り可能であれば、これらのファイルからコマンドを読み取り、実行する。 shとして起動した場合は、このようなことはしない。 norcオプションを使用するとこの動作を抑制でき、--rcfileオプションを使用すると別のファイルを強制的に読み込むことができるが、rshdもsshdも通常、これらのオプションを指定してシェルを起動したり、オプションを指定したりすることはできない。 |
| connection, as when executed by the remote shell daemon, usually rshd, or the secure shell daemon
| |
| sshd. If bash determines it is being run in this fashion, it reads and executes commands from
| |
| ~/.bashrc and ~/.bashrc, if these files exist and are readable. It will not do this if invoked
| |
| as sh. The --norc option may be used to inhibit this behavior, and the --rcfile option may be
| |
| used to force another file to be read, but neither rshd nor sshd generally invoke the shell with
| |
| those options or allow them to be specified.
| |
|
| |
|
| If the shell is started with the effective user (group) id not equal to the real user (group) id,
| | 有効ユーザー(グループ)IDが実ユーザー(グループ)IDに等しくない状態でシェルが起動され、-pオプションが与えられない場合、起動ファイルは読み込まれず、シェル関数は環境から継承されず、SHELLOPTS、BASHOPTS、CDPATH、GLOBIGNORE変数が環境にある場合は無視され、有効ユーザーIDが実ユーザーIDに設定される。 起動時に-pオプションが指定された場合、起動時の動作は同じであるが、実効ユーザーIDはリセットされない。 |
| and the -p option is not supplied, no startup files are read, shell functions are not inherited
| |
| from the environment, the SHELLOPTS, BASHOPTS, CDPATH, and GLOBIGNORE variables, if they appear
| |
| in the environment, are ignored, and the effective user id is set to the real user id. If the -p
| |
| option is supplied at invocation, the startup behavior is the same, but the effective user id is
| |
| not reset.
| |
|
| |
|
| == DEFINITIONS == | | == DEFINITIONS == |