Builtins — the reference¶
Every name built into the shell, grouped the way
helpgroups them, with the same synopseshelp NAMEprints — because this page IShelpoutput: regenerate it withmake docs-builtins(tools/gen_builtins_md.py), never edit it by hand. The help table itself is test-enforced against the dispatch table, so neither this page norhelpcan drift from what actually runs. 72 builtins; anything else on$PATHworks as usual —type NAMEsays which is which.
navigation¶
cd — cd [-L|-P] [dir] | cd - | cd old new
change directory (honours CDPATH, - goes back)
dirs — dirs [-c]
display the directory stack
popd — popd [+N | -N] [-n]
pop the directory stack and cd there
pushd — pushd [dir | +N | -N] [-n]
push a directory on the stack and cd there
pwd — pwd [-L|-P]
print the working directory
output¶
echo — echo [-neE] [arg ...]
write arguments (-n no newline, -e escapes)
mapfile — mapfile [-d delim] [-n n] [-O idx] [-s n] [-t] [-u fd] [array]
read lines of input into an array
printf — printf [-v var] format [arg ...]
format and print, like printf(3)
read — read [-r] [-a arr] [-d delim] [-n n] [-N n] [-p str] [-t s] [name ...]
read one line into variables
readarray — readarray [-d delim] [-n n] [-O idx] [-s n] [-t] [-u fd] [array]
same as mapfile
umask — umask [-S] [-p] [mode]
show or set the file-creation mask
variables¶
declare — declare [-aAfFgiIlnrtux] [-p] [name[=value] ...]
declare variables and give them attributes
export — export [-p] [-n] [name[=value] ...]
put variables into the environment of commands
getopts — getopts optstring name [arg ...]
parse option arguments in a loop
let — let arg [arg ...]
evaluate arithmetic; status 1 if the last is 0
local — local [name[=value] ...]
declare variables local to a function
readonly — readonly [-p] [name[=value] ...]
make variables unassignable and unremovable
typeset — typeset [-aAfFgiIlnrtux] [-p] [name[=value]...]
same as declare
unset — unset [-f|-v] [name ...]
remove variables or functions
jobs¶
bg — bg [jobspec ...]
resume a stopped job in the background
fg — fg [jobspec]
bring a job to the foreground
jobs — jobs [-l] [-p] [jobspec ...]
list background jobs
kill — kill [-s sig|-n num|-sig] pid|job ... | kill -l
send a signal to a process or job
wait — wait [-n] [id ...]
wait for background jobs to finish
control¶
break — break [n]
leave a for/while/until loop
continue — continue [n]
start the next turn of a loop
return — return [n]
return from a function or a sourced file
shift — shift [n]
drop the first n positional parameters
commands¶
alias — alias [-p] [name[=value] ...]
define or list command aliases
builtin — builtin [name [args ...]]
run a shell builtin, bypassing function lookup
command — command [-pVv] name [arg ...]
run a command, ignoring functions and aliases
hash — hash [-lr] [-p path] [-dt] [name ...]
show or change the remembered command paths
type — type [-afptP] name [name ...]
say how a name would be resolved
unalias — unalias [-a] name [name ...]
remove aliases
tests¶
: — :
do nothing; the classic no-op
[ — [ expr ]
same as test; the closing ] is required
[[ — [[ expr ]]
conditional with pattern and regex matching
false — false
do nothing, unsuccessfully
test — test expr | [ expr ]
evaluate a conditional expression
true — true
do nothing, successfully
history¶
fc — fc [-e ed] [-lnr] [first] [last] | fc -s [pat=rep]
re-edit and re-run past commands
history — history [-c] [-d n] [n] | history -anrw [file]
show or edit the command history
shell¶
. — . filename [arguments]
read and run a file in the current shell
compgen — compgen [-abcdfkv] [-A action] [-W wordlist] [word]
print the completions the shell would offer for word
complete — complete [-abcdfkv] [-A action] [-W list] [-F fn] [-pr] name ...
register what to offer when completing an argument of name
compopt — compopt [-o|+o option] [-DEI] [name ...]
change a completion spec's options, or the running one's
eval — eval [arg ...]
join the arguments and run them as a command
exec — exec [command [arg ...]] [redirection ...]
replace the shell, or apply redirections to it
exit — exit [n]
leave the shell with status n
help — help [-s] [topic ...]
this. help NAME explains one topic
pretty — pretty [-p] | list | on NAME... | off NAME... | mode NAME
named presets for the shell's behaviour knobs
set — set [-abefhkmnptuvxCH] [-o opt] [--] [arg ...]
set shell options and positional parameters
shopt — shopt [-pqsu] [-o] [optname ...]
toggle the extra (non-POSIX) shell options
source — source filename [arguments]
same as .
times — times
print user and system time for the shell
trap — trap [-lp] [[action] signal ...]
run an action on a signal or on EXIT
ulimit — ulimit [-SHabcdefiklmnpqrstuvxPT] [limit]
show or set process resource limits
update — update [--now|--check|--version]
check for a newer hellish and install it
syntax¶
Not builtins — the grammar help also explains, kept here for the same one-stop reason.
for — for NAME [in WORD ...]; do LIST; done
loop over words
select — select NAME [in WORD ...]; do LIST; done
menu loop: number the words on stderr, read a choice into NAME
for(( — for ((exp1; exp2; exp3)); do LIST; done
C-style counting loop
while — while LIST; do LIST; done
loop while a list succeeds
until — until LIST; do LIST; done
loop until a list succeeds
if — if LIST; then LIST; [elif ...] [else LIST] fi
branch on a command's exit status
case — case WORD in PATTERN) LIST ;; ... esac
branch on a pattern match
function — name () { LIST; } | function name { LIST; }
define a function
(( — (( expression ))
arithmetic; status 0 when the value is non-zero
$(( — $(( expression ))
substitute the value of an arithmetic expression
$( — $( LIST ) orLIST``
substitute a command's output
redirection — > < >> 2>&1 <<EOF <<<word /dev/tcp/host/port
send a command's input and output elsewhere
pipeline — cmd1 | cmd2 [!] cmd1 |& cmd2
feed one command's output into the next
zsh¶
Only reachable when the dialect is armed (set -o zsh, emulate zsh, or sourcing a .zsh file) — see the zsh dialect.
add-zsh-hook — add-zsh-hook hook function
run a function on an event; only chpwd fires here
autoload — autoload [-Uz] name ...
define a function from a file on $fpath
bindkey — bindkey [-M keymap] seq widget
record a key binding for a zle widget
colors — colors
define $fg[..] $bg[..] $fg_bold[..] $reset_color like zsh's colors
compdef — compdef [args ...]
not supported: hellish has no zsh completion system
emulate — emulate [-L] {zsh|sh|ksh|bash}
switch dialect; in a function it reverts on return
is-at-least — is-at-least need [have]
0 when version have (default $ZSH_VERSION) is need or newer
print — print [-nrlP] [--] [arg ...]
zsh's echo: escapes on by default, -r turns them off
setopt — setopt [name ...]
turn on zsh-named shell options
unsetopt — unsetopt [name ...]
turn off zsh-named shell options
vcs_info — vcs_info
fill $vcs_info_msg_0_ with the git branch, zstyle formats honoured
zle — zle -N widget [fn] | zle widget
register a line-editor widget; key dispatch is not wired yet
zmodload — zmodload [args ...]
not supported: hellish has no loadable modules
zstyle — zstyle [pattern style value ...]
vcs_info formats/actionformats are honoured; the rest is stubbed