source
|
Not a built-in (not found, status 127) |
As in zsh: ., but a name without / is looked for in the current directory before PATH, and further arguments are the positional parameters while the file runs. Special, as in zsh’s sh emulation. A file that can’t be read is an error with status 2, as for . (zsh uses 1) |
builtin
|
Not a built-in (not found, status 127) |
As in zsh and bash: runs a built-in, bypassing functions, and a missing one is status 1. A special built-in stays special for its errors, as in zsh, but its assignments (x=1 builtin export) are temporary, as in bash (zsh keeps them). builtin -- name skips the --, as in bash (zsh looks for a built-in named --) |
function
|
An ordinary word: function f { ...; } is a syntax error, and a command named function is looked for |
A reserved word (as POSIX allows), as in zsh and bash: function NAME [()] BODY defines a function whose body is a compound command, on the same line or a later one. The names needn’t be variable names (function git-up), aren’t alias-expanded, and there can be several (function f g { ...; }), as in zsh. As in bash, the body can also start right after the name with (, if, while, until, for or case (function f (cmd)), so those can’t be a second name. Unlike zsh: a name can’t be quoted or expanded, contain /, or be a special built-in (Bad function name, as for f()), and there are no anonymous functions (function { ...; } args) |
[[ ... ]]
|
[[ is looked for as a command (not found, status 127)
|
A reserved word (as POSIX allows), as in zsh and bash. The words are expanded without field splitting or globbing, and only as far as the expression is evaluated. test’s operators (-a and -o are unary: a file exists, an option is on), -v NAME (a variable or positional parameter is set), -N, !, &&, || and parentheses, with operators recognized only if unquoted. The right side of =, == and != is a pattern, as in case. < and > compare bytes, and the operands of -eq and the like are arithmetic expressions. =~ matches an extended regular expression (the C library’s), after quote removal as in zsh (in bash, quoted parts match literally), and sets MATCH, MBEGIN and MEND, with offsets from 0 as in zsh’s sh emulation (from 1 in native zsh), and for a regular expression with groups, the arrays match, mbegin and mend (zsh; empty and -1 for a group that took no part). It also sets BASH_REMATCH (the matched text, then each group’s), as bash does; a failed match changes none of them, as in zsh (bash empties BASH_REMATCH, and ignores local and readonly for it). A bad regular expression is reported, and is false. After =~, ( and | are part of the word, as in bash (=~ ^(a|b)$; zsh needs quotes). With -nt and -ot, a file that exists is newer than one that doesn’t, as in bash and test (in zsh, both must exist). -n = x compares strings, as in zsh (bash rejects it), and [[ -n ]] is a syntax error, as in bash (in zsh, an error when run). set -x shows it on one line, as zsh does. No zsh extended patterns such as (a|b) |
for ((init; cond; step))
|
A syntax error |
As in bash and zsh, an arithmetic loop (see Usage): init once, then the body while cond is non-zero, with step after each run; an empty cond is true. The ; before do is optional, and the body can be { list; }. The expressions are expanded as in $((...)), but with quotes removed, as in bash and zsh ($((...)) keeps them, as in dash). An error in an expression is a shell error (status 2, as for $((...)); zsh uses 1, and bash reports it and goes on with status 1). As in bash: more than three expressions are a syntax error (zsh runs the loop), and set -x shows each expression evaluated as (( expr )), after expansion (zsh shows the bare text, and leaves out an empty condition) |
test a == b, [ a == b ]
|
== is an error (unexpected operator, status 2)
|
As in zsh and bash: the same as =, also in how expressions are parsed |
**, ++, -- and , in arithmetic
|
** and , are syntax errors, as are x++ and x--; ++x and --x are two unary operators, so they are x
|
As in zsh and bash: ** is a power (binding tighter than *, less tightly than unary minus, and right-associative; a negative exponent is an error, as in bash), with **=; ++ and -- increment and decrement a variable or an array element, before or after its value is taken; , evaluates both sides and gives the value of the right one. Before or between numbers, ++ and -- are still two operators, as in dash and bash (--5 is 5, 5--1 is 6; zsh rejects both), but x--1 is an error, as in zsh and bash (dash: x - -1) |
disown
|
Not a built-in (not found, status 127) |
As in zsh (see help disown): removes jobs from the table, so they aren’t reported, waited for by wait, or warned about by exit, with bash’s options -a, -r and -h (the job stays, but isn’t sent SIGHUP) and process ids as well as jobs. An unknown job is status 1, as in bash (zsh: 127). Without job control, jobs have no text (as in dash), so %name can’t name them |
exit with running jobs
|
Exits |
In an interactive shell, as in zsh (checkjobs, checkrunningjobs): warns You have running jobs. and doesn’t exit, as for a stopped job, unless exit (or Ctrl-D) is repeated right away. unsetopt jobs.check_running turns it off |
SIGHUP to jobs |
Never sent: jobs keep running after the shell exits or the terminal hangs up |
In an interactive shell, as in zsh (hup): exit sends SIGHUP to the jobs (and SIGCONT to stopped ones). On a hangup the shell catches SIGHUP, sends it on to the jobs, saves the history and dies of SIGHUP, as bash does. Not to jobs that disown removed or disown -h marked. unsetopt jobs.hup turns it off |
a |& b
|
Syntax error |
As in zsh and bash: a 2>&1 | b, with the redirection after a’s own |
;&, ;| and ;;& in case
|
Syntax errors |
As in zsh and bash: after an arm’s body, ;& runs the next arm’s body too (without trying its patterns), and ;| (zsh) or ;;& (bash) goes on trying the patterns of the arms that follow |
cmd &|, cmd &!
|
Syntax errors (a &! b is a & ! b) |
As in zsh: cmd runs in the background and is disowned (see help disown). a &! b stays a & ! b, as in dash (zsh disowns a there too): &! disowns only where no command can follow it, such as at the end of a line, before ;;, } or fi, or before a comment |
let
|
Not a built-in (not found, status 127) |
As in zsh: evaluates each argument as $((...)), with status 0 if the last value is non-zero and 1 if it is zero or on an error, which doesn’t exit the shell. Arithmetic is on integers only, without zsh’s floating point or comma operator |
pushd, popd, dirs
|
Not built-ins (not found, status 127) |
As in zsh with its default options: +n and -n name entries of the stack (zsh’s sh emulation sets POSIX_CD, which makes them directory names). popd with an argument other than +n or -n is an error with status 1 (zsh usually does nothing, with status 0) |
setopt, unsetopt
|
Not built-ins (not found, status 127) |
As in zsh: set options by name (case and _ don’t matter, a no prefix inverts), dash’s and luish’s own (such as prompt.percent, whose zsh name prompt_percent also works). Without arguments they list the options that are on or off; zsh lists those that differ from their defaults |
% sequences in prompts
|
Not supported |
With setopt prompt.percent, as in zsh (after parameter expansion, as with zsh’s PROMPT_SUBST), with a subset of its sequences, and also long names (%[hostname], %[fg:red], %([status].yes.no)), which zsh doesn’t have, where an unknown name is an error. The escape sequences for attributes and colours are ANSI SGR codes rather than the terminal’s own (so turning bold off is \e[22m, where zsh writes \e[0m and restores the rest) |
RPROMPT, RPS1, RPROMPT2, RPS2
|
Ordinary variables |
In an interactive shell, a prompt at the right edge of the terminal, as in zsh (see Usage). They are separate variables, where zsh ties RPROMPT to RPS1 (and RPROMPT2 to RPS2): RPROMPT is used if set and not empty, else RPS1 |
<(list), >(list)
|
A syntax error |
Process substitution, as in zsh and bash: a word that is the path of a pipe, /dev/fd/N (N is 64 or more, so as not to clash with the descriptors that scripts use), to the standard output of list or from its standard input. It isn’t split or globbed, and can be inside a word (--input=<(list)). Unlike in bash and zsh, the shell waits for a >(list) process when the command is over (they don’t, so what it prints comes at any time); it doesn’t wait for <(list) (which ends when the command stops reading, on SIGPIPE), and exec 3< <(list) waits for neither. A command with a substitution isn’t exec’d in place when it is the last of a subshell or a pipeline, so that the pipes can be closed. The processes aren’t in the command’s process group or job |
=(list)
|
A syntax error |
As in zsh: a word that is the path of a new temporary file with the output of list, removed when the command is over. Only at the start of a word (a=(x y) is an array). The file is in $TMPDIR (or /tmp), named luish-XXXXXX, where zsh uses $TMPPREFIX (/tmp/zshXXXXXX). As in zsh, exec cmd =(list) leaves it behind |
<<< word
|
A syntax error (redirection unexpected) |
A here-string, as in zsh and bash: the word, expanded without field splitting or globbing ("$@" is joined with spaces), and a newline, on standard input (or on the fd before it, 3<<< word) |
$(<file)
|
Empty: the file is only opened (POSIX leaves it unspecified) |
As in zsh (and ksh and bash): the file’s contents, read by the shell itself, without a subshell, and with trailing newlines removed as for any $(...) (NUL bytes are dropped, as from any $(...); zsh keeps them). Also $(0<file) and `<file`; with any other redirection, or more than one, the value is empty, as in dash. The name is expanded as a redirection’s (no field splitting or globbing), in the shell itself, as in zsh and bash: $(<${f:=x}) assigns f, and an expansion error is fatal. A file that can’t be opened or read, such as a directory, is an error with status 1 (dash: 2 for a file that can’t be opened; bash reads a directory as empty, with status 0) |
**/
|
The same as */ |
With setopt glob.star (off by default), matches any number of directories, as in zsh (where it is always on) |
Brace expansion, a{b,c}, {1..10} |
Text |
With setopt expand.braces (bash’s braceexpand; off by default), as in bash and zsh, before the other expansions (as in bash) of command words, the words of for and the elements of arrays, not of assignments (also those of local and export), case, [[ ... ]] or here-documents. Where the two differ, as in bash: the command’s name is expanded, the sign of a step is ignored (zsh: a negative step reverses the order), characters can have a step ({a..e..2}), {1..a} isn’t a sequence (zsh: the characters between), {+1..3} and {1..3..0} are sequences, an empty word ({a,}) is removed as other unquoted empty words are (zsh keeps it), tilde expansion comes after (zsh’s sh emulation does it first), a stray } is text (zsh: a parse error) and a redirection to more than one word is an error (zsh writes to each). As in zsh: the ends and the step can be expansions ({1..$n}), expanded once (bash leaves them as they are), and a sequence can be of any characters, also beyond ASCII ({α..γ}), whatever the locale. There is no zsh brace_ccl ({abc}) |
Glob qualifiers, *(/) |
A syntax error |
With setopt glob.bare_qualifiers (zsh’s bareglobqual, off by default), zsh’s glob qualifiers. Subscripts count from 0, as in zsh’s sh emulation (which sets KSH_ARRAYS; native zsh counts from 1) |
setopt glob.null, glob.dots, glob.fail, glob.fail_all
|
No setopt |
zsh’s NULL_GLOB, GLOB_DOTS, NOMATCH and CSH_NULL_GLOB (and bash’s nullglob, dotglob and failglob, which shopt sets), all off by default: a pattern that matches nothing is removed, or is an error (status 1), and patterns match hidden files (see Extended globbing). As in zsh, glob.null wins over the others and glob.fail_all over glob.fail (in bash, failglob wins over nullglob). Unlike zsh and bash, the error exits a non-interactive shell also in eval (where they return 1 from eval), as other expansion errors do in dash. .* still matches . and .. with glob.dots, as without it (as in dash) |
repeat
|
An ordinary word: a command or function named repeat is run |
With setopt syntax.repeat (off by default, since the word is valid POSIX), a reserved word that starts a loop, as in zsh (whose sh emulation also drops it): repeat WORD; do list; done or repeat WORD { list }, with the ; optional. The count is expanded as case’s word is and then evaluated as an arithmetic expression (so repeat "$n" and repeat n+1 work, and a name that isn’t set counts as 0, as in zsh); zero or less runs the body not at all, and the status is the last command’s (0 if the body never runs). break and continue count it as a loop, and a redirection applies to the whole loop. In the { ... } form an unquoted } ends the command it follows (repeat 3 { echo hi }), also in the commands nested in the body, but not inside $(...), where } stays an ordinary word (in zsh } is a reserved word everywhere, which would change what echo a } means). Unlike zsh, the body can’t be empty (repeat 3 { } is a syntax error, as { } is), there is no bodyless form (repeat 3 echo hi), and typeset -f writes a repeat in a function back as the do ... done form, which needs the option to be on to be read back |
{name}>file
|
A word and a redirection: echo {fd}>f writes {fd} to f |
With setopt syntax.fd_vars (off by default, since that is valid POSIX), as in bash and zsh (whose sh emulation drops it): exec {fd}>file opens file on the lowest free fd from 10 on and puts its number in fd, with any redirection operator ({fd}<file, {fd}>>file, {fd}<>file, {fd}>&2, {fd}<<EOF, {fd}<<<word); exec {fd}>&- closes the fd whose number is in fd. The fd is inherited by commands, and isn’t closed when the command ends, also for a command other than exec (as in bash without varredir_close, and zsh). As in bash: the {name} must be right before the operator (zsh also takes {fd} >file), braces around something other than a name are text (zsh: an error), and it works after a compound command ({ ...; } {fd}>f; zsh: a parse error). Unlike both: as for every redirection in luish (and dash), the fd is opened in the shell also for an external command, so the variable is set and the fd stays open in the shell (bash and zsh open it in the child only); failing to open the file has status 2 and, for exec, exits a non-interactive shell, as other redirection errors of special built-ins do in dash (zsh carries on with status 1). A readonly name, or {fd}>&- with a fd that isn’t a number, is an error with status 1, as in both |
A directory as a command |
not found (status 127)
|
With setopt cd.auto (zsh’s autocd, off by default), changes to it when read from standard input, as in zsh |
bindkey
|
Not a built-in (not found, status 127) |
In interactive shells (and their subshells), as zsh’s for its emacs keymap and the widgets luish has; __luish_internal bindkey anywhere. Unlike zsh: Up and Down are bound to history-beginning-search-backward/-forward by default (zsh: up-line-or-history), -r gives a key back to the line editor’s own binding, vi mode can’t be changed, and keys can be named (Up, Ctrl-Right, 'Ctrl-X Ctrl-E'), so an argument such as Up is that key, not U and p (written \Up or \125p, as listings show it) |
clipcopy
|
Not a built-in (not found, status 127, or a program of that name) |
In interactive shells (and their subshells): copies its input or a file to the clipboard through the terminal (OSC 52), as oh-my-zsh’s clipcopy function does through xclip and the like; __luish_internal clipcopy anywhere |
vared
|
Not a built-in (not found, status 127, or a program of that name) |
In interactive shells (and their subshells), as zsh’s: edits a variable’s value with the line editor (see help vared); __luish_internal vared anywhere. Unlike zsh: -i and -f (luish has no widgets of the user’s own) and -t are not supported, -M takes only emacs, viins and main, and -m only vicmd; -p and -r expand % sequences whether or not prompt.percent is on; a read-only variable is refused before editing (zsh reports it after); Ctrl-D on an empty line without -e does nothing (zsh lists completions); Tab completes as in a command’s argument (zsh’s compinit completes according to the variable); subscripts count from 0 and aren’t expanded (vared 'a[i]' and vared "a[$i]" work, vared 'a[$i]' doesn’t), and keys come in the order they were added; a value that isn’t valid UTF-8 can’t be edited |
print
|
Not a built-in (not found, status 127, or a program of that name) |
In interactive shells (and their subshells), as zsh’s, with its options but -p (luish has no coprocesses, so it always fails) and -S; __luish_internal print anywhere. -P expands % sequences whether or not prompt.percent is on (in zsh, it follows PROMPT_PERCENT, which is on unless zsh emulates sh). A bad or readonly name for -v is an error with status 1, where zsh exits a non-interactive shell. -f reports bad numbers as luish’s printf does |
History file |
None (Debian’s dash has no line editor; upstream dash with libedit keeps the history in memory only) |
In zsh’s format, so the two shells can share a file (see History). Unlike zsh: without HISTFILE the file is $XDG_STATE_HOME/luish/history (zsh saves nothing), SAVEHIST defaults to HISTSIZE (zsh: 0), HISTFILE and HISTSIZE set in the startup files take effect, a command equal to the previous one is never added (zsh’s hist_ignore_dups, off there by default), and the elapsed time is always written as 0 |
History expansion, !! |
None: ! is an ordinary character |
With setopt history.expand (off by default), in interactive shells, as in zsh and bash (see History expansion). Where the two differ: as in bash, ! before " and in [!...] isn’t expanded (zsh’s !" turns history expansion off for the rest of the line, so echo "hi!" has an unclosed quote there, and zsh expands [!a]); each line of a multi-line command is echoed as it is expanded (zsh echoes the whole command once complete); ! isn’t expanded in comments (zsh’s is); :h without a /, and :r and :e without an extension, leave the text as it is (zsh’s fail). As in zsh, a ! alone before a designator (!$) is the event of the reference before it in the line (bash: the previous command); !{...} works (bash has no braces), and an empty !{} is an error (event not found; zsh leaves !}). Unlike both, an expansion of more than 1 MiB is an error (expansion too long), as !# doubles the line each time; a range keeps the text between its words (bash joins them with spaces); ! before an operator is left as it is (echo hi!;, an error in bash). Unlike both, ! isn’t expanded in $((...)). Not supported: histchars, zsh’s :c, :l, :u and :G modifiers, and bash’s histreedit |
alias, unalias options
|
No options: alias -g x=y defines an alias named -g, and lists a missing alias -g. unalias has only -a |
zsh’s options: alias -g and -s define global and suffix aliases (below), -r, -g, -s select which to list, -m takes patterns, -L prints alias commands and + prints names only; unalias -s and -m. So an argument to alias that starts with - or + is an option, and a name that starts with one needs -- before it. Plain alias lists regular and global aliases, not suffix ones. Unlike zsh: values are always quoted (as in dash), alias -L quotes names that need it, errors are dash’s (status 2 for a bad option, a message for a missing alias), unalias -a ignores further arguments (as in dash), and command -v shows a suffix alias as alias -s SUFFIX=VALUE (zsh shows its value) |
Global aliases (alias -g) |
None |
Expanded in any position, not only as a command name, as in zsh: also arguments, for and case words, redirection targets, and inside $(...), but not when quoted, and never as a reserved word (as with zsh’s posix_aliases, set by its sh emulation). Unlike zsh, a here-document delimiter isn’t expanded |
Suffix aliases (alias -s) |
None |
As in zsh: a command name TEXT.SUFFIX (TEXT not empty) becomes the alias’s value followed by the name, when it isn’t a regular alias. A blank at the end of the value makes the next word eligible, as zsh does (its manual says otherwise) |
RANDOM, SECONDS, UID, EUID, GID, EGID, HISTCMD, EPOCHSECONDS, EPOCHREALTIME, pipestatus, PIPESTATUS, path, dirstack, LUISH_VERSION, LUISH_PATCHLEVEL, MACHTYPE, HOSTTYPE, OSTYPE
|
Ordinary variables |
zsh’s special parameters, computed when read (see Special variables), with LUISH_VERSION and LUISH_PATCHLEVEL for zsh’s ZSH_VERSION and ZSH_PATCHLEVEL, and bash’s HOSTTYPE (the same as MACHTYPE, the processor, where bash’s MACHTYPE is x86_64-pc-linux-gnu); their values in the environment are ignored, as in zsh (bash takes MACHTYPE, HOSTTYPE and OSTYPE from it). Unset, they read as unset until assigned again, as in zsh. Unlike zsh: assigning to UID, EUID, GID, EGID, EPOCHSECONDS, EPOCHREALTIME, pipestatus, PIPESTATUS, LUISH_VERSION or LUISH_PATCHLEVEL makes it an ordinary variable (zsh calls setuid, refuses, or sets pipestatus until the next pipeline), so scripts that use these names still work; EPOCHREALTIME has microseconds, as in bash, and EPOCH* need no zmodload zsh/datetime; a subshell seeds RANDOM anew unless it was assigned (zsh’s subshells repeat the parent’s numbers); set doesn’t list them, and local doesn’t give a function its own SECONDS. pipestatus follows zsh, where bash’s PIPESTATUS differs: after an if, a loop or { ...; } it has that command’s status (bash’s has the last pipeline’s inside), and an assignment or [[ leaves it (bash sets it); it is empty in a new shell (bash’s is 0). path is the array of the directories in PATH, as in zsh (whose sh emulation doesn’t have it), so $path is the first directory where dash has it unset; an array assignment (path=(...), path+=(...), path[i]=x, all errors in dash) sets PATH, but unlike zsh path=x makes it an ordinary variable (zsh sets PATH to x), as do unset path (zsh unsets PATH too) and local path (zsh makes PATH local too); a path in the environment is an ordinary variable; a read-only PATH can’t be set through it (zsh ignores readonly PATH there). dirstack is the directory stack, tied in the same way: indices from 0 (as elsewhere), and dirstack=x, unset dirstack and local dirstack make it an ordinary variable (zsh’s dirstack=x sets the stack to x) |
Arrays, a=(x y), ${a[i]}, "${a[@]}" |
A syntax error (a=(), or a bad substitution when expanded (${a[i]}); a[i]=x and a+=x are commands |
As in zsh’s sh emulation (see Arrays): indices from 0, $a is ${a[0]}, no holes (unset 'a[i]' empties the element), a[i]=x past the end fills with empty elements (so does a=([i]=x)), "${a[*]/x/y}" replaces in the joined string, arrays aren’t exported, and local, export and readonly take arrays (local a=(x y)). As in bash: a string is an array of one element (zsh indexes its characters: s=abc; echo ${s[1]} prints b), an index before the start is an error (a[-9]=x; zsh prepends), and so is one of 64 Mi (67108864) or more, unset 'a[@]' unsets the array, assignments to an element before a command are temporary, as the others (a[0]=x cmd; zsh keeps them). local a keeps the global value, as local x does in dash (zsh makes a new, empty one). Errors have status 2, as other expansion errors in dash (zsh uses 1). set and readonly -p show arrays as a=('x' 'y') |
Associative arrays, typeset -A h, h[key]=v, ${h[key]} |
typeset is looked for as a command
|
As in zsh’s sh emulation and bash (see Arrays): keys are strings (also in arithmetic, $((h[x]))), h=([k]=v) and h=(k v) assign, += adds, "${h[@]}" gives the values, unset 'h[k]' removes a key, and read -A reads pairs (zsh). The values come in the order the keys were added (zsh and bash use their hash order). As in zsh: an odd number of elements, or a mix of [k]=v and pairs, is an error (bash takes an empty value, or ignores the elements without a key). As in bash: $h is ${h[0]} and h=x assigns to it (zsh reads some value, and refuses the assignment); typeset -A x makes a string the value at key 0 (zsh empties it), and an indexed array can’t become an associative one or the other way round (zsh empties it); unset 'h[k]' of a read-only one is an error (zsh removes the key). typeset -p shows them as typeset -A h=(['k']='v') |
Parameter flags, ${(o)a[@]}, ${(j:,:)a[@]}, ${(k)h[@]} |
Bad substitution when expanded |
zsh’s flags @, k, v, j:sep:, s:sep:, f, F, L, U, C, u, o, O, i, n and a (see Arrays), applied in zsh’s order whatever order they are written in, with zsh’s rules for quoting: "${(o)a[*]}" joins before sorting, s splits also in double quotes (where only the first and last words can be empty, unless @ is given), its words aren’t split again, and where the result is a single word (x=${(o)a[@]}, case, here-documents) the elements are joined first and s doesn’t split. As in zsh’s sh emulation, flags apply to what the parameter gives, so ${(k)h} is ${h[0]}: the keys are ${(k)h[@]}. Other flags (such as P, q, e, l:n:), ${(flags)#name} and nested ${(o)${...}} are bad substitutions (zsh: an error in flags, status 1), as is ${(U)} (zsh: empty). o sorts by bytes (zsh uses the locale’s collation, which is the same in the C locale), and L, U and C change only ASCII letters, as typeset -l does |
typeset, declare
|
Looked for as commands (not found, status 127) |
Built-ins, as in zsh and bash, with -a, -A, -f, -g, -i, -l, -p, -r, -u, -U (zsh) and -x (not zsh’s other options, nor zsh’s base for -i, nor -F, which is floating point in zsh and the names of functions in bash; typeset +f lists the names, as in zsh). In a function they make local variables that start unset, as in zsh, and hide a read-only one (bash refuses). As in bash: typeset -a x makes a string an array of its value (zsh empties it, and refuses typeset -a x=value). typeset -i x evaluates the value x already has (as in zsh; bash keeps it), and typeset -i applies to the elements of arrays and associative arrays (as in bash; zsh has no integer arrays). The value of an integer variable is printed in decimal (zsh uses the base of the first number assigned, 8#10 for 010). -l and -u convert values when they are assigned, as in bash (zsh converts them when they are read, so typeset +l gives back the original), and apply to the elements of arrays, as in bash (zsh leaves arrays alone). -U on PATH also applies to array assignments to path (zsh keeps them apart), and -U on a string other than PATH does nothing (zsh also dedupes its other colon-separated variables, such as FPATH). typeset -p quotes as export -p does (typeset x='1', typeset -a a=('x' 'y'); zsh quotes only where needed and writes exported strings as export x=...). typeset -f prints definitions in luish’s own layout (four-space indents, f() {; zsh indents with tabs and keeps the text of words as written, bash has its own layout), with backquotes as $(...) and here-document delimiters renamed, and refuses variable attributes and name=value with -f (as bash; zsh ignores most of them). local takes the same options (but -f and -g) too, but still keeps the value, as in dash |
read options
|
Illegal option (status 2); read without a name is an error |
bash’s (see help read): -d DELIM, -n COUNT, -N COUNT, -t TIMEOUT, -u FD, -s, -e, -E and -i TEXT; without a name the line goes to REPLY untrimmed, as in bash (zsh strips IFS whitespace). -A (zsh) and -a NAME (bash) read the fields into an array, -A with one name (reply without one, as in zsh), -a NAME ignoring other names (bash). They split as field splitting and bash do: zsh adds an empty element after a trailing delimiter (also after trailing whitespace), and makes an empty line one empty element. Where bash and zsh differ, luish follows bash: -p is a prompt (zsh: the coprocess), -e and -E are the line editor (zsh: echo what is read), -n counts (zsh: only in completion functions), and the timeout’s status is 142 (zsh: 1), with -t needing its number. zsh’s -k, -q, -z, -c, -l and name?prompt aren’t supported, nor is bash’s TMOUT. Unlike bash: -n and -N count bytes and -d takes the first byte (bash counts characters in a UTF-8 locale); -e uses the editor only when reading a terminal on standard input without -s, -n, -N, -t or -d (otherwise it reads plainly), and completes as for a command’s argument; -u refuses the shell’s own fds, as print -u does; a timeout too large to count waits for ever (bash’s overflows); a bad name has status 2, as in dash (bash: 1) |
${x:offset:length}, ${x/pattern/replacement}
|
Bad substitution when expanded |
As in zsh’s sh emulation and bash (see Parameter expansion), counting bytes. As in zsh: a negative offset before the start is the start (bash gives nothing), ${@:1:-1} works, & in the replacement is literal (bash 5.2 replaces it with the match), an unset or empty variable matches *, and "${*/a/b}" replaces in the joined string. A letter after the : starts a modifier (below), where bash evaluates ${x:i} as arithmetic, and ${x:1:} is a bad substitution |
Modifiers, ${x:h}, ${x:t}, ${x:A} |
Bad substitution when expanded |
zsh’s h, t (also with a count, :h2), r, e, a, A, u and l, one after another, as in zsh (see Parameter expansion), also in glob qualifiers. As in zsh, :a is relative to the current directory as the system has it, not PWD. Unlike zsh, .. at the root is the root (zsh’s :a gives //a for /../a); an unknown modifier is a bad substitution when expanded, with status 2 (zsh fails with status 1 when parsing); ${#x:h} is a bad substitution (zsh gives the length of ${x:h}). zsh’s q, Q, P, s, g, &, c and x are bad substitutions |
SHLVL
|
Not maintained |
Incremented at startup, as in zsh, but set to 1 when it isn’t in the environment only in an interactive shell (zsh always sets it), so scripts see dash’s environment |
Last command of sh -c |
Debian’s dash forks it (a Debian patch; upstream dash execs it) |
Replaces the shell with it unless a trap is set, as zsh, bash and upstream dash do |