mirror of https://github.com/CrimsonTome/tldr.git
common/*: update pages of some POSIX special built-in utilities (#11956)
* exec, export, readonly, set, shift, trap: replace command descriptions * exec, exit, export, readonly, set, shift, trap, exec, export: replace example descriptions * exec, trap: replace "More information" links * trap: remove prefix "SIG" from some command arguments Although POSIX allows implementations to specify signal names without the prefix "SIG", I will choose the most portable form. * export: replace term Co-authored-by: Vitor Henrique <87824454+vitorhcl@users.noreply.github.com> * set: replace term Co-authored-by: Vitor Henrique <87824454+vitorhcl@users.noreply.github.com> * export: replace term Co-authored-by: Vitor Henrique <87824454+vitorhcl@users.noreply.github.com> * export: replace term Co-authored-by: Vitor Henrique <87824454+vitorhcl@users.noreply.github.com> * exec: replace Open Group link Co-authored-by: Vitor Henrique <87824454+vitorhcl@users.noreply.github.com> * exit: replace Open Group link Co-authored-by: Vitor Henrique <87824454+vitorhcl@users.noreply.github.com> * export: replace Open Group link Co-authored-by: Vitor Henrique <87824454+vitorhcl@users.noreply.github.com> * readonly: replace Open Group link Co-authored-by: Vitor Henrique <87824454+vitorhcl@users.noreply.github.com> * set: replace Open Group link Co-authored-by: Vitor Henrique <87824454+vitorhcl@users.noreply.github.com> * shift: replace Open Group link Co-authored-by: Vitor Henrique <87824454+vitorhcl@users.noreply.github.com> * trap: replace Open Group link Co-authored-by: Vitor Henrique <87824454+vitorhcl@users.noreply.github.com> * exec: explain environment of child process Co-authored-by: Vitor Henrique <87824454+vitorhcl@users.noreply.github.com> --------- Co-authored-by: Vitor Henrique <87824454+vitorhcl@users.noreply.github.com>pull/23/head
parent
8f4a2aeb27
commit
0385654986
|
@ -1,8 +1,8 @@
|
||||||
# exec
|
# exec
|
||||||
|
|
||||||
> Replace the current process with another process.
|
> Execute a command without creating a child process.
|
||||||
> More information: <https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#exec>.
|
> More information: <https://manned.org/exec.1posix>.
|
||||||
|
|
||||||
- Replace with the specified command using the current environment variables:
|
- Execute a specific command using the current environment variables:
|
||||||
|
|
||||||
`exec {{command -with -flags}}`
|
`exec {{command -with -flags}}`
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
# exit
|
# exit
|
||||||
|
|
||||||
> Exit the shell.
|
> Exit the shell.
|
||||||
> More information: <https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#exit>.
|
> More information: <https://manned.org/exit.1posix>.
|
||||||
|
|
||||||
- Exit the shell with the exit code of the last command executed:
|
- Exit with the exit status of the most recently executed command:
|
||||||
|
|
||||||
`exit`
|
`exit`
|
||||||
|
|
||||||
- Exit the shell with the specified exit code:
|
- Exit with a specific exit status:
|
||||||
|
|
||||||
`exit {{exit_code}}`
|
`exit {{exit_code}}`
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
# export
|
# export
|
||||||
|
|
||||||
> Command to mark shell variables in the current environment to be exported with any newly forked child processes.
|
> Export shell variables to child processes.
|
||||||
> More information: <https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#export>.
|
> More information: <https://manned.org/export.1posix>.
|
||||||
|
|
||||||
- Set a new environment variable:
|
- Set an environment variable:
|
||||||
|
|
||||||
`export {{VARIABLE}}={{value}}`
|
`export {{VARIABLE}}={{value}}`
|
||||||
|
|
||||||
- Append something to the PATH variable:
|
- Append a pathname to the environment variable `PATH`:
|
||||||
|
|
||||||
`export PATH=$PATH:{{path/to/append}}`
|
`export PATH=$PATH:{{path/to/append}}`
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
# readonly
|
# readonly
|
||||||
|
|
||||||
> Create or modify read-only variables within a shell script, preventing the variable from being changed by subsequent commands.
|
> Set read-only shell variables.
|
||||||
> This is useful when you want to ensure that a variable retains a constant value throughout the execution of a script.
|
> More information: <https://manned.org/readonly.1posix>.
|
||||||
> More information: <https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#readonly>.
|
|
||||||
|
|
||||||
- Create a read-only variable:
|
- Set a read-only variable:
|
||||||
|
|
||||||
`readonly {{variable_name}}={{value}}`
|
`readonly {{variable_name}}={{value}}`
|
||||||
|
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
# set
|
# set
|
||||||
|
|
||||||
> Display, set or unset values of shell attributes and positional parameters.
|
> Toggle shell options or set the values of positional parameters.
|
||||||
> More information: <https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#set>.
|
> More information: <https://manned.org/set.1posix>.
|
||||||
|
|
||||||
- Display the names and values of shell variables:
|
- Display the names and values of shell variables:
|
||||||
|
|
||||||
`set`
|
`set`
|
||||||
|
|
||||||
- Mark variables that are modified or created for export:
|
- Export newly initialized variables to child processes:
|
||||||
|
|
||||||
`set -a`
|
`set -a`
|
||||||
|
|
||||||
- Notify of job termination immediately:
|
- Write formatted messages to `stderr` when jobs finish:
|
||||||
|
|
||||||
`set -b`
|
`set -b`
|
||||||
|
|
||||||
- Set various options, e.g. enable `vi` style line editing:
|
- Write and edit text in the command line with `vi`-like keybindings (e.g. `yy`):
|
||||||
|
|
||||||
`set -o {{vi}}`
|
`set -o {{vi}}`
|
||||||
|
|
||||||
- Set the shell to exit as soon as the first error is encountered (mostly used in scripts):
|
- Exit the shell when (some) commands fail:
|
||||||
|
|
||||||
`set -e`
|
`set -e`
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
# shift
|
# shift
|
||||||
|
|
||||||
> Shell built-in command that shifts the arguments passed to the calling function or script by a specified number of places.
|
> Move positional parameters.
|
||||||
> More information: <https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#shift>.
|
> More information: <https://manned.org/shift.1posix>.
|
||||||
|
|
||||||
- Move arguments by one place dropping the first argument:
|
- Remove the first positional parameter:
|
||||||
|
|
||||||
`shift`
|
`shift`
|
||||||
|
|
||||||
- Move arguments by N places dropping the first N arguments:
|
- Remove the first `N` positional parameters:
|
||||||
|
|
||||||
`shift {{N}}`
|
`shift {{N}}`
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
# trap
|
# trap
|
||||||
|
|
||||||
> Automatically execute commands after receiving signals by processes or the operating system.
|
> Execute a command upon an event.
|
||||||
> Can be used to perform cleanups for interruptions by the user or other actions.
|
> More information: <https://manned.org/trap.1posix>.
|
||||||
> More information: <https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#trap>.
|
|
||||||
|
|
||||||
- List active traps for the current shell:
|
- List the commands and the names of the expected events:
|
||||||
|
|
||||||
`trap`
|
`trap`
|
||||||
|
|
||||||
- Set a trap to execute commands when one or more signals are detected:
|
- Execute a command when a signal is received:
|
||||||
|
|
||||||
`trap 'echo "Caught signal {{SIGHUP}}"' {{SIGHUP}}`
|
`trap 'echo "Caught signal {{SIGHUP}}"' {{HUP}}`
|
||||||
|
|
||||||
- Remove active traps:
|
- Remove commands:
|
||||||
|
|
||||||
`trap - {{SIGHUP}} {{SIGINT}}`
|
`trap - {{HUP}} {{INT}}`
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
# exec
|
# exec
|
||||||
|
|
||||||
> Replace the current process with another process.
|
> Execute a command without creating a child process.
|
||||||
> More information: <https://linuxcommand.org/lc3_man_pages/exech.html>.
|
> More information: <https://www.gnu.org/software/bash/manual/bash.html#index-exec>.
|
||||||
|
|
||||||
- Replace with the specified command using the current environment variables:
|
- Execute a specific command:
|
||||||
|
|
||||||
`exec {{command -with -flags}}`
|
`exec {{command -with -flags}}`
|
||||||
|
|
||||||
- Replace with the specified command, clearing environment variables:
|
- Execute a command with a (mostly) empty environment:
|
||||||
|
|
||||||
`exec -c {{command -with -flags}}`
|
`exec -c {{command -with -flags}}`
|
||||||
|
|
||||||
- Replace with the specified command and login using the default shell:
|
- Execute a command as a login shell:
|
||||||
|
|
||||||
`exec -l {{command -with -flags}}`
|
`exec -l {{command -with -flags}}`
|
||||||
|
|
||||||
- Replace with the specified command and change the process name:
|
- Execute a command with a different name:
|
||||||
|
|
||||||
`exec -a {{process_name}} {{command -with -flags}}`
|
`exec -a {{name}} {{command -with -flags}}`
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
# export
|
# export
|
||||||
|
|
||||||
> Command to mark shell variables in the current environment to be exported with any newly forked child processes.
|
> Export shell variables to child processes.
|
||||||
> More information: <https://www.gnu.org/software/bash/manual/bash.html#index-export>.
|
> More information: <https://www.gnu.org/software/bash/manual/bash.html#index-export>.
|
||||||
|
|
||||||
- Set a new environment variable:
|
- Set an environment variable:
|
||||||
|
|
||||||
`export {{VARIABLE}}={{value}}`
|
`export {{VARIABLE}}={{value}}`
|
||||||
|
|
||||||
- Remove an environment variable:
|
- Unset an environment variable:
|
||||||
|
|
||||||
`export -n {{VARIABLE}}`
|
`export -n {{VARIABLE}}`
|
||||||
|
|
||||||
- Mark a shell function for export:
|
- Export a function to child processes:
|
||||||
|
|
||||||
`export -f {{FUNCTION_NAME}}`
|
`export -f {{FUNCTION_NAME}}`
|
||||||
|
|
||||||
- Append something to the PATH variable:
|
- Append a pathname to the environment variable `PATH`:
|
||||||
|
|
||||||
`export PATH=$PATH:{{path/to/append}}`
|
`export PATH=$PATH:{{path/to/append}}`
|
||||||
|
|
|
@ -1,21 +1,20 @@
|
||||||
# trap
|
# trap
|
||||||
|
|
||||||
> Automatically execute commands after receiving signals by processes or the operating system.
|
> Execute a command upon an event.
|
||||||
> Can be used to perform cleanups for interruptions by the user or other actions.
|
> More information: <https://www.gnu.org/software/bash/manual/bash.html#index-trap>.
|
||||||
> More information: <https://manned.org/trap>.
|
|
||||||
|
|
||||||
- List available signals to set traps for:
|
- List the available event names (e.g. `SIGWINCH`):
|
||||||
|
|
||||||
`trap -l`
|
`trap -l`
|
||||||
|
|
||||||
- List active traps for the current shell:
|
- List the commands and the names of the expected events:
|
||||||
|
|
||||||
`trap -p`
|
`trap -p`
|
||||||
|
|
||||||
- Set a trap to execute commands when one or more signals are detected:
|
- Execute a command when a signal is received:
|
||||||
|
|
||||||
`trap 'echo "Caught signal {{SIGHUP}}"' {{SIGHUP}}`
|
`trap 'echo "Caught signal {{SIGHUP}}"' {{SIGHUP}}`
|
||||||
|
|
||||||
- Remove active traps:
|
- Remove commands:
|
||||||
|
|
||||||
`trap - {{SIGHUP}} {{SIGINT}}`
|
`trap - {{SIGHUP}} {{SIGINT}}`
|
||||||
|
|
Loading…
Reference in New Issue