Differences between revisions 3 and 11 (spanning 8 versions)
Revision 3 as of 2023-01-25 20:48:41
Size: 2174
Comment:
Revision 11 as of 2023-01-25 22:11:31
Size: 4245
Comment:
Deletions are marked like this. Additions are marked like this.
Line 39: Line 39:
See [[Bash/Looping|here]].
Line 45: Line 47:
Execute a builtin command. This is only useful when reimplementing a builtin but still need to call the original builtin within the function.
Line 71: Line 75:
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 77: Line 90:
See [[Bash/Completion|here]].
Line 83: Line 98:
See [[Bash/Completion|here]].
Line 89: Line 106:
See [[Bash/Completion|here]].
Line 95: Line 114:
See [[Bash/Looping|here]].
Line 131: Line 152:
Executes a command. This is useful when building commands through [[Bash/Expansion#Parameter_Expansion|parameter expansion]].
Line 137: Line 160:
Replaces the shell with the specified command. This is useful in scripts that dispatch to other commands, like `demunu(1)`.
Line 143: Line 168:
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 149: Line 178:
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 179: Line 218:
Prints helpful information about a builtin command.

{{{
help help
}}}
Line 203: Line 248:
See [[Bash/Arithmetic|here]].
Line 209: Line 256:
Only valid within a function definition. See [[Bash/Function#Local_Scope|here]].
Line 215: Line 264:
Exit a login shell immediately.
Line 245: Line 296:
Prints the current working directory.
Line 269: Line 322:
Only valid within a function definition. See [[Bash/Function#Error_and_Return_Codes|here]].
Line 283: Line 338:
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 333: Line 394:
See [[Bash/Alias|here]].
Line 339: Line 402:
See [[Bash/ShellOptions|here]].

Builtin Commands


:

Does nothing; arguments passed to it are expanded but immediately discarded.


Alias

See here.


Bg


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


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


GetOpts


Hash


Help

Prints helpful information about a builtin command.

help help


History


Jobs


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.


Wait


CategoryRicottone

Bash/BuiltinCommands (last edited 2025-12-19 20:18:05 by DominicRicottone)