Size: 1722
Comment:
|
Size: 5155
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 27: | Line 27: |
See [[Bash/JobControl|here]]. |
|
Line 39: | Line 41: |
See [[Bash/Looping|here]]. |
|
Line 45: | Line 49: |
Execute a builtin command. This is only useful when reimplementing a builtin but still need to call the original builtin within the function. |
|
Line 57: | Line 63: |
Change the current working directory to a new path. Can be a relative or absolute path, as well as the special `.` and `..` directories. Note the rules for [[Bash/Expansion#Tilde_Expansion|tilde expansion]] when using the `~` symbol here. `cd -` changes the current working directory to the previous working directory. There is also special behavior around specifying ''nothing''. `cd` is the same as `cd ~`. |
|
Line 63: | Line 77: |
Execute a command. This can be useful to call a command when there is a function with the same name. It can also be used to determine if a command is locally available. {{{ if ! command -v mypy >/dev/null 2>&1; then echo "cannot locate mypy; is it installed?" exit fi }}} |
|
Line 69: | Line 92: |
See [[Bash/Completion|here]]. |
|
Line 75: | Line 100: |
See [[Bash/Completion|here]]. |
|
Line 81: | Line 108: |
See [[Bash/Completion|here]]. |
|
Line 87: | Line 116: |
See [[Bash/Looping|here]]. |
|
Line 93: | Line 124: |
Set a variable, optionally with a value. {{{ declare a=1 b=2 c=3 }}} When used within a function definition, the variable is set to [[Bash/Function#Local_Scope|local scope]]. To create a variable that is marked for export, use: {{{ declare -x myvar }}} To create a variable that is marked for tracing, use: {{{ declare -t myvar }}} To create a read-only constant, use: {{{ declare -r myconst }}} To create an integer variable, use: {{{ declare -i myinteger }}} To create an [[Bash/Array|array]], use: {{{ declare -a myarray }}} To create an associative array, use: {{{ declare -A myarray }}} With some exceptions, these options can be combined. Additionally, options can be explicitly disabled by substituting the dash (`-`) with a plus sign (`+`). |
|
Line 123: | Line 200: |
Executes a command. This is useful when building commands through [[Bash/Expansion#Parameter_Expansion|parameter expansion]]. |
|
Line 129: | Line 208: |
Replaces the shell with the specified command. This is useful in scripts that dispatch to other commands, like `demunu(1)`. |
|
Line 135: | Line 216: |
Causes a script or shell to exit immediately with a specified exit code. If used in an interactive shell, or when used in a script that is `source`d, causes the shell session to exit. That is likely not desireable; see [[#Return|return]] instead. |
|
Line 141: | Line 226: |
Marks one or more names as variables to be included in the environment of subsequently-called commands. To set a variable and mark it simultaneously, try: {{{ export varname="some value" }}} To instead export a function, use `export -f funcname` |
|
Line 153: | Line 248: |
See [[Bash/JobControl|here]]. |
|
Line 171: | Line 268: |
Prints helpful information about a builtin command. {{{ help help }}} |
|
Line 183: | Line 286: |
See [[Bash/JobControl|here]]. |
|
Line 195: | Line 300: |
See [[Bash/Arithmetic|here]]. |
|
Line 201: | Line 308: |
Only valid within a function definition. See [[Bash/Function#Local_Scope|here]]. |
|
Line 207: | Line 316: |
Exit a login shell immediately. |
|
Line 237: | Line 348: |
Prints the current working directory. |
|
Line 261: | Line 374: |
Only valid within a function definition. See [[Bash/Function#Error_and_Return_Codes|here]]. |
|
Line 275: | Line 390: |
Renames the [[Bash/Variables#Positional_Variables|special positional variables]]. If `shift` is called with no argument, `$2` is renamed to `$1`, `$3` is renamed to `$2`, and so on. `shift N` causes `$N+1` to be renamed to `$N`, `$N+2` to be renamed to `$N+1`, and so on. |
|
Line 325: | Line 446: |
See [[Bash/Alias|here]]. |
|
Line 331: | Line 454: |
See [[Bash/ShellOptions|here]]. |
|
Line 336: | Line 461: |
---- CategoryRicottone |
Builtin Commands
Contents
-
Builtin Commands
- :
- Alias
- Bg
- Bind
- Break
- Builtin
- Caller
- Cd
- Command
- CompGen
- Complete
- CompOpt
- Continue
- Declare
- Dirs
- Disown
- Echo
- Enable
- Eval
- Exec
- Exit
- Export
- Fc
- Fg
- GetOpts
- Hash
- Help
- History
- Jobs
- Kill
- Let
- Local
- LogOut
- MapFile
- PopD
- PrintF
- PushD
- Pwd
- Read
- ReadArray
- ReadOnly
- Return
- Set
- Shift
- ShOpt
- Source
- Test
- Time
- Trap
- TypeSet
- UnAlias
- UnSet
- Wait
:
Does nothing; arguments passed to it are expanded but immediately discarded.
Alias
See here.
Bg
See here.
Bind
Break
See here.
Builtin
Execute a builtin command. This is only useful when reimplementing a builtin but still need to call the original builtin within the function.
Caller
Cd
Change the current working directory to a new path. Can be a relative or absolute path, as well as the special . and .. directories.
Note the rules for tilde expansion when using the ~ symbol here.
cd - changes the current working directory to the previous working directory.
There is also special behavior around specifying nothing. cd is the same as cd ~.
Command
Execute a command. This can be useful to call a command when there is a function with the same name. It can also be used to determine if a command is locally available.
if ! command -v mypy >/dev/null 2>&1; then echo "cannot locate mypy; is it installed?" exit fi
CompGen
See here.
Complete
See here.
CompOpt
See here.
Continue
See here.
Declare
Set a variable, optionally with a value.
declare a=1 b=2 c=3
When used within a function definition, the variable is set to local scope.
To create a variable that is marked for export, use:
declare -x myvar
To create a variable that is marked for tracing, use:
declare -t myvar
To create a read-only constant, use:
declare -r myconst
To create an integer variable, use:
declare -i myinteger
To create an array, use:
declare -a myarray
To create an associative array, use:
declare -A myarray
With some exceptions, these options can be combined. Additionally, options can be explicitly disabled by substituting the dash (-) with a plus sign (+).
Dirs
Disown
Echo
Enable
Eval
Executes a command. This is useful when building commands through parameter expansion.
Exec
Replaces the shell with the specified command. This is useful in scripts that dispatch to other commands, like demunu(1).
Exit
Causes a script or shell to exit immediately with a specified exit code.
If used in an interactive shell, or when used in a script that is sourced, causes the shell session to exit. That is likely not desireable; see return instead.
Export
Marks one or more names as variables to be included in the environment of subsequently-called commands.
To set a variable and mark it simultaneously, try:
export varname="some value"
To instead export a function, use export -f funcname
Fc
Fg
See here.
GetOpts
Hash
Help
Prints helpful information about a builtin command.
help help
History
Jobs
See here.
Kill
Let
See here.
Local
Only valid within a function definition. See here.
LogOut
Exit a login shell immediately.
MapFile
PopD
PrintF
PushD
Pwd
Prints the current working directory.
Read
ReadArray
ReadOnly
Return
Only valid within a function definition. See here.
Set
See here.
Shift
Renames the special positional variables.
If shift is called with no argument, $2 is renamed to $1, $3 is renamed to $2, and so on.
shift N causes $N+1 to be renamed to $N, $N+2 to be renamed to $N+1, and so on.
ShOpt
See here.
Source
Aliased to ..
Test
Aliased to [.
See here.
Time
Trap
TypeSet
UnAlias
See here.
UnSet
See here.