Section 6.2. Invoking the Shell


6.2. Invoking the Shell

The command interpreter for the Bash shell (bash) or the Korn shell (ksh) can be invoked as follows:

     bash  [options]  [arguments]     ksh   [options]  [arguments] 

ksh and Bash can execute commands from a terminal, from a file (when the first argument is an executable script), or from standard input (if no arguments remain or if -s is specified). Both shells automatically print prompts if standard input is a terminal, or if -i is given on the command line.

On Linux systems, /bin/sh is generally a link to Bash. When invoked as sh, Bash acts more like the traditional Bourne shell: Login shells read /etc/profile and ~/.profile, and regular shells read $ENV, if it's set. Full details are available on the bash(1) manpage.

6.2.1. Options

6.2.1.1 Common options

-c str

Read commands from string str.


-D

Print all $"..." strings in the program. Not ksh88.


-i

Create an interactive shell (prompt for input).


-p

Start up as a privileged user. Bash: Don't read $ENV or $BASH_ENV, don't import functions from the environment, and ignore the value of $SHELLOPTS. Korn shell: Don't process $HOME/.profile, read /etc/suid_profile instead of $ENV.


-r

Create a restricted shell.


-s

Read commands from standard input; output from built-in commands goes to file descriptor 1; all other shell output goes to file descriptor 2.


-, --

End option processing.

6.2.1.2 Bash options

-O option

Enable shopt option option.


--debugger

Read the debugging profile at startup, turn on the extdebug option to shopt, and enable function tracing. For use by the Bash debugger.


--dump-po-strings

Same as -D, but output in GNU gettext format.


--dump-strings

Same as -D.


--help

Print a usage message and exit successfully.


--init-file file


--rcfile file

Use file as the startup file instead of ~/.bashrc for interactive shells.


--login

Shell is a login shell.


--noediting

Do not use the readline library for input, even in an interactive shell.


--noprofile

Do not read /etc/profile or any of the personal startup files.


--norc

Do not read ~/.bashrc. Enabled automatically when invoked as sh.


--posix

Turn on POSIX mode.


--restricted

Same as -r.


--verbose

Same as set -v; the shell prints lines as it reads them.


--version

Print a version message and exit.

The remaining options to Bash and ksh are listed under the set built-in command.

6.2.2. Arguments

Arguments are assigned in order to the positional parameters $1, $2, etc. If the first argument is an executable script, commands are read from it, and the remaining arguments are assigned to $1, $2, etc. The name of the script is available as $0.



Linux in a Nutshell
Linux in a Nutshell
ISBN: 0596154488
EAN: 2147483647
Year: 2004
Pages: 147

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net