Zsh tries to emulate sh or ksh when it is invoked as
sh
or ksh
respectively; more precisely, it looks at the first
letter of the name by which it was invoked, excluding any initial ‘r
’
(assumed to stand for ‘restricted’), and if that is ‘b
’, ‘s
’ or ‘k
’ it
will emulate sh or ksh. Furthermore, if invoked as su
(which
happens on certain systems when the shell is executed by the su
command), the shell will try to find an alternative name from the SHELL
environment variable and perform emulation based on that.
In sh and ksh compatibility modes the following
parameters are not special and not initialized by the shell:
ARGC
,
argv
,
cdpath
,
fignore
,
fpath
,
HISTCHARS
,
mailpath
,
MANPATH
,
manpath
,
path
,
prompt
,
PROMPT
,
PROMPT2
,
PROMPT3
,
PROMPT4
,
psvar
,
status
.
The usual zsh startup/shutdown scripts are not executed. Login shells
source /etc/profile
followed by $HOME/.profile
. If the
ENV
environment variable is set on invocation, $ENV
is sourced
after the profile scripts. The value of ENV
is subjected to
parameter expansion, command substitution, and arithmetic expansion
before being interpreted as a pathname. Note that the PRIVILEGED
option also affects the execution of startup files.
The following options are set if the shell is invoked as sh
or
ksh
:
NO_BAD_PATTERN
,
NO_BANG_HIST
,
NO_BG_NICE
,
NO_EQUALS
,
NO_FUNCTION_ARGZERO
,
GLOB_SUBST
,
NO_GLOBAL_EXPORT
,
NO_HUP
,
INTERACTIVE_COMMENTS
,
KSH_ARRAYS
,
NO_MULTIOS
,
NO_NOMATCH
,
NO_NOTIFY
,
POSIX_BUILTINS
,
NO_PROMPT_PERCENT
,
RM_STAR_SILENT
,
SH_FILE_EXPANSION
,
SH_GLOB
,
SH_OPTION_LETTERS
,
SH_WORD_SPLIT
.
Additionally the BSD_ECHO
and IGNORE_BRACES
options are set if zsh is invoked as sh
.
Also, the
KSH_OPTION_PRINT
,
LOCAL_OPTIONS
,
PROMPT_BANG
,
PROMPT_SUBST
and
SINGLE_LINE_ZLE
options are set if zsh is invoked as ksh
.
Please note that, whilst reasonable efforts are taken to address
incompatibilities when they arise, zsh does not guarantee complete
emulation of other shells, nor POSIX compliance. For more information on
the differences between zsh and other shells, please refer to chapterĀ 2
of the shell FAQ, https://www.zsh.org/FAQ/
.