<HTML> <HEAD> <!-- Created by texi2html 1.56k from ./zsh.texi on 26 June 2001 --> <TITLE>zsh - Invocation</TITLE> </HEAD> <BODY> Go to the <A HREF="zsh_1.html">first</A>, <A HREF="zsh_2.html">previous</A>, <A HREF="zsh_4.html">next</A>, <A HREF="zsh_29.html">last</A> section, <A HREF="zsh_toc.html">table of contents</A>. <P><HR><P> <H1><A NAME="SEC11" HREF="zsh_toc.html#TOC11">Invocation</A></H1> <P> <A NAME="IDX6"></A> <H2><A NAME="SEC12" HREF="zsh_toc.html#TOC12">Invocation Options</A></H2> <P> <A NAME="IDX7"></A> <A NAME="IDX8"></A> The following flags are interpreted by the shell when invoked to determine where the shell will read commands from: <P> <DL COMPACT> <DT><TT>-c</TT> <DD> Take the first argument as a command to execute, rather than reading commands from a script or standard input. If any further arguments are given, the first one is assigned to <TT>$0</TT>, rather than being used as a positional parameter. <DT><TT>-i</TT> <DD> Force shell to be interactive. <DT><TT>-s</TT> <DD> Force shell to read commands from the standard input. If the <TT>-s</TT> flag is not present and an argument is given, the first argument is taken to be the pathname of a script to execute. </DL> <P> After the first one or two arguments have been appropriated as described above, the remaining arguments are assigned to the positional parameters. <P> For further options, which are common to invocation and the <TT>set</TT> builtin, see section <A HREF="zsh_15.html#SEC75">Options</A>. <P> Options may be specified by name using the <TT>-o</TT> option. <TT>-o</TT> acts like a single-letter option, but takes a following string as the option name. For example, <P> <PRE> zsh -x -o shwordsplit scr </PRE> <P> runs the script <TT>scr</TT>, setting the <TT>XTRACE</TT> option by the corresponding letter `<TT>-x</TT>' and the <TT>SH_WORD_SPLIT</TT> option by name. Options may be turned <EM>off</EM> by name by using <TT>+o</TT> instead of <TT>-o</TT>. <TT>-o</TT> can be stacked up with preceding single-letter options, so for example `<TT>-xo shwordsplit</TT>' or `<TT>-xoshwordsplit</TT>' is equivalent to `<TT>-x -o shwordsplit</TT>'. <P> Options may also be specified by name in GNU long option style, `<TT>--</TT><VAR>option-name</VAR>'. When this is done, `<TT>-</TT>' characters in the option name are permitted: they are translated into `<TT>_</TT>', and thus ignored. So, for example, `<TT>zsh --sh-word-split</TT>' invokes zsh with the <TT>SH_WORD_SPLIT</TT> option turned on. Like other option syntaxes, options can be turned off by replacing the initial `<TT>-</TT>' with a `<TT>+</TT>'; thus `<TT>+-sh-word-split</TT>' is equivalent to `<TT>--no-sh-word-split</TT>'. Unlike other option syntaxes, GNU-style long options cannot be stacked with any other options, so for example `<TT>-x-shwordsplit</TT>' is an error, rather than being treated like `<TT>-x --shwordsplit</TT>'. <P> The special GNU-style option `<TT>--version</TT>' is handled; it sends to standard output the shell's version information, then exits successfully. `<TT>--help</TT>' is also handled; it sends to standard output a list of options that can be used when invoking the shell, then exits successfully. <P> Option processing may be finished, allowing following arguments that start with `<TT>-</TT>' or `<TT>+</TT>' to be treated as normal arguments, in two ways. Firstly, a lone `<TT>-</TT>' (or `<TT>+</TT>') as an argument by itself ends option processing. Secondly, a special option `<TT>--</TT>' (or `<TT>+-</TT>'), which may be specified on its own (which is the standard POSIX usage) or may be stacked with preceding options (so `<TT>-x-</TT>' is equivalent to `<TT>-x --</TT>'). Options are not permitted to be stacked after `<TT>--</TT>' (so `<TT>-x-f</TT>' is an error), but note the GNU-style option form discussed above, where `<TT>--shwordsplit</TT>' is permitted and does not end option processing. <P> Except when the <CITE>sh</CITE>/<CITE>ksh</CITE> emulation single-letter options are in effect, the option `<TT>-b</TT>' (or `<TT>+b</TT>') ends option processing. `<TT>-b</TT>' is like `<TT>--</TT>', except that further single-letter options can be stacked after the `<TT>-b</TT>' and will take effect as normal. <P> <P> <H2><A NAME="SEC13" HREF="zsh_toc.html#TOC13">Compatibility</A></H2> <P> <A NAME="IDX9"></A> <A NAME="IDX10"></A> <A NAME="IDX11"></A> Zsh tries to emulate <CITE>sh</CITE> or <CITE>ksh</CITE> when it is invoked as <TT>sh</TT> or <TT>ksh</TT> respectively; more precisely, it looks at the first letter of the name by which it was invoked, excluding any initial `<TT>r</TT>' (assumed to stand for `restricted'), and if that is `<TT>s</TT>' or `<TT>k</TT>' it will emulate <CITE>sh</CITE> or <CITE>ksh</CITE>. Furthermore, if invoked as <TT>su</TT> (which happens on certain systems when the shell is executed by the <TT>su</TT> command), the shell will try to find an alternative name from the <TT>SHELL</TT> environment variable and perform emulation based on that. <P> In <CITE>sh</CITE> and <CITE>ksh</CITE> compatibility modes the following parameters are not special and not initialized by the shell: <TT>ARGC</TT>, <TT>argv</TT>, <TT>cdpath</TT>, <TT>fignore</TT>, <TT>fpath</TT>, <TT>HISTCHARS</TT>, <TT>mailpath</TT>, <TT>MANPATH</TT>, <TT>manpath</TT>, <TT>path</TT>, <TT>prompt</TT>, <TT>PROMPT</TT>, <TT>PROMPT2</TT>, <TT>PROMPT3</TT>, <TT>PROMPT4</TT>, <TT>psvar</TT>, <TT>status</TT>, <TT>watch</TT>. <P> The usual zsh startup/shutdown scripts are not executed. Login shells source <TT>/etc/profile</TT> followed by <TT>$HOME/.profile</TT>. If the <TT>ENV</TT> environment variable is set on invocation, <TT>$ENV</TT> is sourced after the profile scripts. The value of <TT>ENV</TT> is subjected to parameter expansion, command substitution, and arithmetic expansion before being interpreted as a pathname. Note that the <TT>PRIVILEGED</TT> option also affects the execution of startup files. <P> The following options are set if the shell is invoked as <TT>sh</TT> or <TT>ksh</TT>: <TT>NO_BAD_PATTERN</TT>, <TT>NO_BANG_HIST</TT>, <TT>NO_BG_NICE</TT>, <TT>NO_EQUALS</TT>, <TT>NO_FUNCTION_ARGZERO</TT>, <TT>GLOB_SUBST</TT>, <TT>NO_GLOBAL_EXPORT</TT>, <TT>NO_HUP</TT>, <TT>INTERACTIVE_COMMENTS</TT>, <TT>KSH_ARRAYS</TT>, <TT>NO_MULTIOS</TT>, <TT>NO_NOMATCH</TT>, <TT>NO_NOTIFY</TT>, <TT>POSIX_BUILTINS</TT>, <TT>NO_PROMPT_PERCENT</TT>, <TT>RM_STAR_SILENT</TT>, <TT>SH_FILE_EXPANSION</TT>, <TT>SH_GLOB</TT>, <TT>SH_OPTION_LETTERS</TT>, <TT>SH_WORD_SPLIT</TT>. Additionally the <TT>BSD_ECHO</TT> and <TT>IGNORE_BRACES</TT> options are set if zsh is invoked as <TT>sh</TT>. Also, the <TT>KSH_OPTION_PRINT</TT>, <TT>LOCAL_OPTIONS</TT>, <TT>PROMPT_BANG</TT>, <TT>PROMPT_SUBST</TT> and <TT>SINGLE_LINE_ZLE</TT> options are set if zsh is invoked as <TT>ksh</TT>. <H2><A NAME="SEC14" HREF="zsh_toc.html#TOC14">Restricted Shell</A></H2> <P> <A NAME="IDX12"></A> <A NAME="IDX13"></A> When the basename of the command used to invoke zsh starts with the letter `<TT>r</TT>' or the `<TT>-r</TT>' command line option is supplied at invocation, the shell becomes restricted. Emulation mode is determined after stripping the letter `<TT>r</TT>' from the invocation name. The following are disabled in restricted mode: <P> <UL> <LI> changing directories with the <TT>cd</TT> builtin <LI> changing or unsetting the <TT>PATH</TT>, <TT>path</TT>, <TT>MODULE_PATH</TT>, <TT>module_path</TT>, <TT>SHELL</TT>, <TT>HISTFILE</TT>, <TT>HISTSIZE</TT>, <TT>GID</TT>, <TT>EGID</TT>, <TT>UID</TT>, <TT>EUID</TT>, <TT>USERNAME</TT>, <TT>LD_LIBRARY_PATH</TT>, <TT>LD_AOUT_LIBRARY_PATH</TT>, <TT>LD_PRELOAD</TT> and <TT>LD_AOUT_PRELOAD</TT> parameters <LI> specifying command names containing <TT>/</TT> <LI> specifying command pathnames using <TT>hash</TT> <LI> redirecting output to files <LI> using the <TT>exec</TT> builtin command to replace the shell with another command <LI> using <TT>jobs -Z</TT> to overwrite the shell process' argument and environment space <LI> using the <TT>ARGV0</TT> parameter to override <TT>argv[0]</TT> for external commands <LI> turning off restricted mode with <TT>set +r</TT> or <TT>unsetopt RESTRICTED</TT> </UL> <P> These restrictions are enforced after processing the startup files. The startup files should set up <TT>PATH</TT> to point to a directory of commands which can be safely invoked in the restricted environment. They may also add further restrictions by disabling selected builtins. <P> Restricted mode can also be activated any time by setting the <TT>RESTRICTED</TT> option. This immediately enables all the restrictions described above even if the shell still has not processed all startup files. <P><HR><P> Go to the <A HREF="zsh_1.html">first</A>, <A HREF="zsh_2.html">previous</A>, <A HREF="zsh_4.html">next</A>, <A HREF="zsh_29.html">last</A> section, <A HREF="zsh_toc.html">table of contents</A>. </BODY> </HTML>