os_cp:scripting
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| os_cp:scripting [2023/05/31 00:20] – utworzono jkonczak | os_cp:scripting [2026/04/08 20:53] (current) – [Parameters and variables in shell] jkonczak | ||
|---|---|---|---|
| Line 54: | Line 54: | ||
| Notice that '' | Notice that '' | ||
| '' | '' | ||
| - | form the file in the current shell. | + | from the file in the current shell. |
| ====== Processing an input line by the shell ====== | ====== Processing an input line by the shell ====== | ||
| Line 66: | Line 66: | ||
| |5. sets up redirections|'' | |5. sets up redirections|'' | ||
| |6. executes the command||| | |6. executes the command||| | ||
| - | (cf. [[https:// | + | (cf. [[https:// |
| ===== Splitting line into commands ===== | ===== Splitting line into commands ===== | ||
| Line 128: | Line 128: | ||
| ===== Shell expansions ===== | ===== Shell expansions ===== | ||
| - | The shell // | + | The shell // |
| the following tokens: | the following tokens: | ||
| + | < | ||
| - the tilde in '' | - the tilde in '' | ||
| - '' | - '' | ||
| Line 140: | Line 141: | ||
| \\ | \\ | ||
| Inside single quotes no expansions are performed. | Inside single quotes no expansions are performed. | ||
| + | \\ | ||
| + | < | ||
| + | of the POSIX standard also requires expanding **'' | ||
| + | backslash-escaped sequences into characters they represent((This sanctions the | ||
| + | feature that has been there for a long time in most shells.)).</ | ||
| **Importantly, | **Importantly, | ||
| Line 163: | Line 169: | ||
| \\ | \\ | ||
| < | < | ||
| - | and '' | + | and '' |
| provide access to the environment variables.</ | provide access to the environment variables.</ | ||
| Line 169: | Line 175: | ||
| For the shell, the name | For the shell, the name | ||
| - | [[https:// | + | [[https:// |
| denotes either script/ | denotes either script/ | ||
| - | [[https:// | + | [[https:// |
| denotes an ordinary shell variable (that is closely related to an environment variable). | denotes an ordinary shell variable (that is closely related to an environment variable). | ||
| \\ | \\ | ||
| Line 198: | Line 204: | ||
| < | < | ||
| Moreover the following expansions are performed: | Moreover the following expansions are performed: | ||
| + | < | ||
| * '' | * '' | ||
| * '' | * '' | ||
| Line 207: | Line 214: | ||
| * '' | * '' | ||
| </ | </ | ||
| + | |||
| + | ++++ Examples | {{section> | ||
| ~~Exercise.# | ~~Exercise.# | ||
| Line 303: | Line 312: | ||
| |'' | |'' | ||
| - | |'' | + | |'' |
| |'' | |'' | ||
| |'' | |'' | ||
| Line 332: | Line 341: | ||
| \\ | \\ | ||
| The shell understands assignments and operators similar to those in C (cf. | The shell understands assignments and operators similar to those in C (cf. | ||
| - | [[https:// | + | [[https:// |
| \\ | \\ | ||
| Inside '' | Inside '' | ||
| Line 372: | Line 381: | ||
| ===== Aliases ===== | ===== Aliases ===== | ||
| - | [[https:// | + | [[https:// |
| are intended to provide user-defined alternative names for a command. | are intended to provide user-defined alternative names for a command. | ||
| \\ | \\ | ||
| Line 404: | Line 413: | ||
| ====== The read command ====== | ====== The read command ====== | ||
| - | The '' | + | The '' |
| command reads a line from the standard input. | command reads a line from the standard input. | ||
| \\ | \\ | ||
| Line 507: | Line 516: | ||
| ==== if ==== | ==== if ==== | ||
| - | The '' | + | The '' |
| < | < | ||
| < | < | ||
| Line 544: | Line 553: | ||
| ==== case ==== | ==== case ==== | ||
| - | The '' | + | The '' |
| < | < | ||
| < | < | ||
| Line 578: | Line 587: | ||
| ==== for ==== | ==== for ==== | ||
| - | The '' | + | The '' |
| < | < | ||
| < | < | ||
| Line 615: | Line 624: | ||
| ==== while and until ==== | ==== while and until ==== | ||
| - | < | + | < |
| < | < | ||
| < | < | ||
| Line 621: | Line 630: | ||
| < | < | ||
| </ | </ | ||
| - | and the syntax of the '' | + | and the syntax of the '' |
| < | < | ||
| < | < | ||
| Line 646: | Line 655: | ||
| ====== Functions in shell ====== | ====== Functions in shell ====== | ||
| - | To define a [[https:// | + | To define a [[https:// |
| in the shell, one has to use the following syntax: ''// | in the shell, one has to use the following syntax: ''// | ||
| where the //body// shall be a compound command such as a list of statements | where the //body// shall be a compound command such as a list of statements | ||
| Line 694: | Line 703: | ||
| ====== Signals in shell ====== | ====== Signals in shell ====== | ||
| - | The command '' | + | The command '' |
| is used to set up either handing a signal (when the // | is used to set up either handing a signal (when the // | ||
| signal) or set the statements to be executed upon terminating the shell (when the | signal) or set the statements to be executed upon terminating the shell (when the | ||
os_cp/scripting.1685492408.txt.gz · Last modified: (external edit)