Tracking Issue: List of Builtins to Implement
If you have an idea for a builtin which is not on this list, discuss it below.
Conditional Builtins
-
true
: Simply returns aSUCCESS
status -
false
: Simply returns aFAILED
status -
not <command>
: Reverses the exit status value of the given command. (@drosseau) -
contains $key @values
: Returns 0 exit status if the key is contained within the values. -
starts-with $key @values
-
ends-with $key @values
-
matches $key $regex
: A regex-based evaluator -
isatty [FD]
: Returns 0 exit status if the supplied FD is a tty -
and <command>
: Execute the command only if the shell's previous status is 0true; and echo true
-
or <command>
: The reverse ofand
.false; or echo false
-
exists -b BINARY
: Returns 0 exit status if the binary is in PATH -
exists -f PATH
: Returns 0 exit status if the path is a file -
exists -d PATH
: Returns 0 exit status if the path is a directory -
exists -s STRING
: Returns 0 exit status if the string var is not empty -
exists -a ARRAY
: Returns 0 exit status if the array var is not empty -
exists STRING
: Returns 0 exit status if the string is not empty -
is $var $value
: Returns 0 exit status if both arguments are the same -
is not $var $value
: The opposite of the above -
bool $value
: If the value is "1" or "true", return 0 exit status -
< (Polish Notation) -
<= (Polish Notation) -
> (Polish Notation) -
>= (Polish Notation) -
= (Polish Notation)
Job Control
-
jobs
: Lists available background jobs -
bg
: Sends SIGCONT to a given background job -
fg
: Does the same asbg
, but also brings it to the foreground viatcsetpgrp
-
wait
: waits until background jobs have finished -
exit
: waits until background jobs have finished, and exits -
suspend
: suspends the shell via aSIGTSTOP
Misc
-
ion-docs
: Opens the locally-installed Ion documentation in a web browser -
which
: Prints the kind and/or path of the given command
Math & Crypto
-
calc
: built-in calculator that will eventually be arbitrary precision -
random
: generate random numbers
I/O
-
echo
: Prints the evaluated expression to standard output -
read
: Stores the next line of input to standard input into a specified variable -
printf
: Implement the same as other shells -
printr
: Rusty variant maybe? -
cat
: Perhaps copycat
from coreutils into Ion.
Command Execution
-
eval
: Evaluates and executes the evaluated expression -
time
: Prints timing statistics once it's job has finished -
exec
: Replace the shell process with the specified command
Possible Builtins From POSIX Shells
-
command -v
: often used to determine if a binary exists in a PATH
Edited by matu3ba