Previous Section  < Day Day Up >  Next Section

B.1. Invocation

Table B-1 and Table B-2 list the options you can use when invoking current versions of bash and the older 1.x version, respectively.[1] The multicharacter options must appear on the command line before the single-character options. In addition to these, any set option can be used on the command line; see Table B-7. Login shells are usually invoked with the options -i (interactive), -s (read from standard input), and -m (enable job control).

[1] At the time of writing, the old 1.x versions of bash are still used. We strongly recommend that you upgrade to the latest version. We have included a table of old options (Table B-2) just in case you encounter an old version of the shell.

Table B-1. Command-line options

Option

Meaning

-c string

Commands are read from string, if present. Any arguments after string are interpreted as positional parameters, starting with $0.

-D

A list of all double-quoted strings preceded by $ is printed on the standard ouput. These are the strings that are subject to language translation when the current locale is not C or POSIX. This also turns on the -n option.

-i

Interactive shell. Ignores signals TERM, INT, and QUIT. With job control in effect, TTIN, TTOU, and TSTP are also ignored.

-l

Makes bash act as if invoked as a login shell.

-o option

Takes the same arguments as set -o.

-O, +O shopt-option

shopt-option is one of the shell options accepted by the shopt builtin. If shopt-option is present, -O sets the value of that option; +O unsets it. If shopt-option is not supplied, the names and values of the shell options accepted by shopt are printed on the standard output. If the invocation option is +O, the output is displayed in a format that may be reused as input.

-s

Reads commands from the standard input. If an argument is given to bash, this flag takes precedence (i.e., the argument won't be treated as a script name and standard input will be read).

-r

Restricted shell. See Chapter 10.

-v

Prints shell input lines as they're read.

-

Signals the end of options and disables further option processing. Any options after this are treated as filenames and arguments. is synonymous with -.

—debugger

Arranges for the debugger profile to be executed before the shell starts. Turns on extended debugging mode and shell function tracing.[2]

—dump-strings

Does the same as -D.

—dump-po-strings

Does the same as -D but the output is in the GNU gettext po (portable object) file format.

—help

Displays a usage message and exits.

—login

Makes bash act as if invoked as a login shell. Same as -l.

—noediting

Does not use the GNU readline library to read command lines if interactive.

—noprofile

Does not read the startup file /etc/profile or any of the personal initialization files.

—norc

Does not read the initialization file ~/.bashrc if the shell is interactive. This is on by default if the shell is invoked as sh.

—posix

Changes the behavior of bash to follow the POSIX guidelines more closely where the default operation of bash is different.

—quiet

Shows no information on shell startup. This is the default.

—rcfile file, —init-file file

Executes commands read from file instead of the initialization file ~/.bashrc, if the shell is interactive.

—verbose

Equivalent to -v.

—version

Shows the version number of this instance of bash and then exits.


[2] Only available in bash version 3.0 and later.

Table B-2. Old command-line options

Option

Meaning

-c string

Commands are read from string, if present. Any arguments after string are interpreted as positional parameters, starting with $0.

-i

Interactive shell. Ignores signals TERM, INT, and QUIT. With job control in effect, TTIN, TTOU, and TSTP are also ignored.

-s

Reads commands from the standard input. If an argument is given to bash, this flag takes precedence (i.e., the argument won't be treated as a script name and standard input will be read).

-r

Restricted shell. See Chapter 10.

-

Signals the end of options and disables further option processing. Any options after this are treated as filenames and arguments. is synonymous with -.

-norc

Does not read the initialization file ~/.bashrc if the shell is interactive. This is on by default if the shell is invoked as sh.

-noprofile

Does not read the startup file /etc/profile or any of the personal initialization files.

-rcfile file

Executes commands read from file instead of the initialization file ~/.bashrc, if the shell is interactive.

-version

Shows the version number of this instance of bash when starting.

-quiet

Shows no information on shell startup. This is the default.

-login

Makes bash act as if invoked as a login shell.

-nobraceexpansion

Does not perform curly brace expansion.

-nolineediting

Does not use the GNU readline library to read command lines if interactive.

-posix

Changes the behavior of bash to follow the POSIX guidelines more closely where the default operation of bash is different.


    Previous Section  < Day Day Up >  Next Section