From ced5cb22f6fde0ad118140f83b8775c5f9072b85 Mon Sep 17 00:00:00 2001 From: Alejandro Cervera <96702705+tricantivu@users.noreply.github.com> Date: Fri, 29 Dec 2023 08:07:58 -0500 Subject: [PATCH] common/*: update pages of POSIX special Built-In utilities (#11858) * eval, exec, exit, export, readonly, set, shift, trap: use Open Group links * exec, export, trap: split Linux and POSIX --- pages/common/eval.md | 2 +- pages/common/exec.md | 14 +------------- pages/common/exit.md | 2 +- pages/common/export.md | 10 +--------- pages/common/readonly.md | 2 +- pages/common/set.md | 2 +- pages/common/shift.md | 2 +- pages/common/trap.md | 8 ++------ pages/linux/exec.md | 20 ++++++++++++++++++++ pages/linux/export.md | 20 ++++++++++++++++++++ pages/linux/trap.md | 21 +++++++++++++++++++++ 11 files changed, 70 insertions(+), 33 deletions(-) create mode 100644 pages/linux/exec.md create mode 100644 pages/linux/export.md create mode 100644 pages/linux/trap.md diff --git a/pages/common/eval.md b/pages/common/eval.md index ab466ad4d..cf7f60502 100644 --- a/pages/common/eval.md +++ b/pages/common/eval.md @@ -1,7 +1,7 @@ # eval > Execute arguments as a single command in the current shell and return its result. -> More information: . +> More information: . - Call `echo` with the "foo" argument: diff --git a/pages/common/exec.md b/pages/common/exec.md index 00d27a22f..a05af53f3 100644 --- a/pages/common/exec.md +++ b/pages/common/exec.md @@ -1,20 +1,8 @@ # exec > Replace the current process with another process. -> More information: . +> More information: . - Replace with the specified command using the current environment variables: `exec {{command -with -flags}}` - -- Replace with the specified command, clearing environment variables: - -`exec -c {{command -with -flags}}` - -- Replace with the specified command and login using the default shell: - -`exec -l {{command -with -flags}}` - -- Replace with the specified command and change the process name: - -`exec -a {{process_name}} {{command -with -flags}}` diff --git a/pages/common/exit.md b/pages/common/exit.md index 3a0f561cf..60aa9d89e 100644 --- a/pages/common/exit.md +++ b/pages/common/exit.md @@ -1,7 +1,7 @@ # exit > Exit the shell. -> More information: . +> More information: . - Exit the shell with the exit code of the last command executed: diff --git a/pages/common/export.md b/pages/common/export.md index b55408112..9336f2171 100644 --- a/pages/common/export.md +++ b/pages/common/export.md @@ -1,20 +1,12 @@ # export > Command to mark shell variables in the current environment to be exported with any newly forked child processes. -> More information: . +> More information: . - Set a new environment variable: `export {{VARIABLE}}={{value}}` -- Remove an environment variable: - -`export -n {{VARIABLE}}` - -- Mark a shell function for export: - -`export -f {{FUNCTION_NAME}}` - - Append something to the PATH variable: `export PATH=$PATH:{{path/to/append}}` diff --git a/pages/common/readonly.md b/pages/common/readonly.md index 9b66157f8..f674724c5 100644 --- a/pages/common/readonly.md +++ b/pages/common/readonly.md @@ -2,7 +2,7 @@ > Create or modify read-only variables within a shell script, preventing the variable from being changed by subsequent commands. > This is useful when you want to ensure that a variable retains a constant value throughout the execution of a script. -> More information: . +> More information: . - Create a read-only variable: diff --git a/pages/common/set.md b/pages/common/set.md index 1989a9532..c3afd93d7 100644 --- a/pages/common/set.md +++ b/pages/common/set.md @@ -1,7 +1,7 @@ # set > Display, set or unset values of shell attributes and positional parameters. -> More information: . +> More information: . - Display the names and values of shell variables: diff --git a/pages/common/shift.md b/pages/common/shift.md index ed54a1334..52cb27539 100644 --- a/pages/common/shift.md +++ b/pages/common/shift.md @@ -1,7 +1,7 @@ # shift > Shell built-in command that shifts the arguments passed to the calling function or script by a specified number of places. -> More information: . +> More information: . - Move arguments by one place dropping the first argument: diff --git a/pages/common/trap.md b/pages/common/trap.md index 98dc02d8b..2104c234d 100644 --- a/pages/common/trap.md +++ b/pages/common/trap.md @@ -2,15 +2,11 @@ > Automatically execute commands after receiving signals by processes or the operating system. > Can be used to perform cleanups for interruptions by the user or other actions. -> More information: . - -- List available signals to set traps for: - -`trap -l` +> More information: . - List active traps for the current shell: -`trap -p` +`trap` - Set a trap to execute commands when one or more signals are detected: diff --git a/pages/linux/exec.md b/pages/linux/exec.md new file mode 100644 index 000000000..00d27a22f --- /dev/null +++ b/pages/linux/exec.md @@ -0,0 +1,20 @@ +# exec + +> Replace the current process with another process. +> More information: . + +- Replace with the specified command using the current environment variables: + +`exec {{command -with -flags}}` + +- Replace with the specified command, clearing environment variables: + +`exec -c {{command -with -flags}}` + +- Replace with the specified command and login using the default shell: + +`exec -l {{command -with -flags}}` + +- Replace with the specified command and change the process name: + +`exec -a {{process_name}} {{command -with -flags}}` diff --git a/pages/linux/export.md b/pages/linux/export.md new file mode 100644 index 000000000..b55408112 --- /dev/null +++ b/pages/linux/export.md @@ -0,0 +1,20 @@ +# export + +> Command to mark shell variables in the current environment to be exported with any newly forked child processes. +> More information: . + +- Set a new environment variable: + +`export {{VARIABLE}}={{value}}` + +- Remove an environment variable: + +`export -n {{VARIABLE}}` + +- Mark a shell function for export: + +`export -f {{FUNCTION_NAME}}` + +- Append something to the PATH variable: + +`export PATH=$PATH:{{path/to/append}}` diff --git a/pages/linux/trap.md b/pages/linux/trap.md new file mode 100644 index 000000000..98dc02d8b --- /dev/null +++ b/pages/linux/trap.md @@ -0,0 +1,21 @@ +# trap + +> Automatically execute commands after receiving signals by processes or the operating system. +> Can be used to perform cleanups for interruptions by the user or other actions. +> More information: . + +- List available signals to set traps for: + +`trap -l` + +- List active traps for the current shell: + +`trap -p` + +- Set a trap to execute commands when one or more signals are detected: + +`trap 'echo "Caught signal {{SIGHUP}}"' {{SIGHUP}}` + +- Remove active traps: + +`trap - {{SIGHUP}} {{SIGINT}}`