mirror of
https://github.com/flokoe/bash-hackers-wiki.git
synced 2024-11-25 07:43:42 +01:00
commit
bb37fd043c
@ -10,8 +10,8 @@ To edit and develop locally install the following packages and run the built in
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
python3 -m venv env
|
python3 -m venv env
|
||||||
pip install mkdocs-material mkdocs-git-revision-date-localized-plugin mkdocs-awesome-pages-plugin mkdocs-minify-plugin
|
|
||||||
source env/bin/activate
|
source env/bin/activate
|
||||||
|
pip install mkdocs-material mkdocs-git-revision-date-localized-plugin mkdocs-awesome-pages-plugin mkdocs-minify-plugin
|
||||||
mkdocs serve
|
mkdocs serve
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ In the case of `eval` it isn't recommended to use this behavior,
|
|||||||
because unlike e.g. [declare](../../commands/builtin/declare.md), the initial
|
because unlike e.g. [declare](../../commands/builtin/declare.md), the initial
|
||||||
expansion is still subject to all expansions including
|
expansion is still subject to all expansions including
|
||||||
[word-splitting](../../syntax/expansion/wordsplit.md) and [pathname
|
[word-splitting](../../syntax/expansion/wordsplit.md) and [pathname
|
||||||
expansion](../../syntax/expansion/glob.md).
|
expansion](../../syntax/expansion/globs.md).
|
||||||
|
|
||||||
$ ( set -x; touch 'x+=(\[[123]\]=*)' 'x+=([3]=yo)'; eval x+=(*); echo "${x[@]}" )
|
$ ( set -x; touch 'x+=(\[[123]\]=*)' 'x+=([3]=yo)'; eval x+=(*); echo "${x[@]}" )
|
||||||
+ touch 'x+=(\[[123]\]=*)' 'x+=([3]=yo)'
|
+ touch 'x+=(\[[123]\]=*)' 'x+=([3]=yo)'
|
||||||
@ -151,7 +151,7 @@ expansion](../../syntax/expansion/glob.md).
|
|||||||
Other commands known to be affected by compound assignment arguments
|
Other commands known to be affected by compound assignment arguments
|
||||||
include: [let](../../commands/builtin/let.md),
|
include: [let](../../commands/builtin/let.md),
|
||||||
[declare](../../commands/builtin/declare.md),
|
[declare](../../commands/builtin/declare.md),
|
||||||
[typeset](../../commands/builtin/typeset.md), [local](../../commands/builtin/local.md),
|
`typeset`, [local](../../commands/builtin/local.md),
|
||||||
[export](../../commands/builtin/export.md), and
|
[export](../../commands/builtin/export.md), and
|
||||||
[readonly](../../commands/builtin/readonly.md). More oddities below show both
|
[readonly](../../commands/builtin/readonly.md). More oddities below show both
|
||||||
similarities and differences to commands like
|
similarities and differences to commands like
|
||||||
|
@ -43,4 +43,4 @@ executed the `exit` command, because the shell exits.
|
|||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [The trap builtin command](../../commands/builtin/trap.md)
|
- [The trap builtin command](../../commands/builtin/trap.md)
|
||||||
- [The exit status](../../dict/terms/exit_status.md)
|
- [The exit status](../../dict/exit_status.md)
|
||||||
|
@ -54,4 +54,4 @@ way, and takes all the same options, with 3 exceptions:
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- <http://wiki.bash-hackers.org/scripting/basics#variable_scope>
|
- [The basics of shell scripting: Variable scope](../../scripting/basics.md#variable-scope)
|
||||||
|
@ -473,4 +473,4 @@ fmt++;
|
|||||||
- [Code snip: Print a horizontal
|
- [Code snip: Print a horizontal
|
||||||
line](../../snipplets/print_horizontal_line.md) uses some `printf` examples
|
line](../../snipplets/print_horizontal_line.md) uses some `printf` examples
|
||||||
- [Greg's BashFAQ 18: How can I use numbers with leading zeros in a
|
- [Greg's BashFAQ 18: How can I use numbers with leading zeros in a
|
||||||
loop, e.g., 01, 02?](BashFAQ>018)
|
loop, e.g., 01, 02?](http://mywiki.wooledge.org/BashFAQ/018)
|
||||||
|
@ -32,4 +32,4 @@ comes back, there was a problem in doing the return.
|
|||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [The exit builtin command](../../commands/builtin/exit.md)
|
- [The exit builtin command](../../commands/builtin/exit.md)
|
||||||
- [The exit status](../../dict/terms/exit_status.md)
|
- [The exit status](../../dict/exit_status.md)
|
||||||
|
@ -62,7 +62,7 @@ There are no options.
|
|||||||
errors.`$ dash -c 'f() { if shift; then echo "$1"; else echo "no args"; fi; }; f'
|
errors.`$ dash -c 'f() { if shift; then echo "$1"; else echo "no args"; fi; }; f'
|
||||||
dash: 1: shift: can't shift that many
|
dash: 1: shift: can't shift that many
|
||||||
` In most shells, you can work around this problem using the
|
` In most shells, you can work around this problem using the
|
||||||
[command](../../commands/builtin/command.md) builtin to suppress fatal
|
`command` builtin to suppress fatal
|
||||||
errors caused by *special builtins*. <code> \$ dash -c \'f() { if
|
errors caused by *special builtins*. <code> \$ dash -c \'f() { if
|
||||||
command shift 2>/dev/null; then echo \"\$1\"; else echo \"no
|
command shift 2>/dev/null; then echo \"\$1\"; else echo \"no
|
||||||
args\"; fi; }; f\'
|
args\"; fi; }; f\'
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# Directory
|
# Directory
|
||||||
|
|
||||||
In terms of UNIX(r), a directory is a special file which contains a list
|
In terms of UNIX(r), a directory is a special file which contains a list
|
||||||
of [hardlinks](../dict/terms/hardlink.md) to other files. These other files
|
of [hardlinks](../dict/hardlink.md) to other files. These other files
|
||||||
also can be directories of course, so it's possible to create a
|
also can be directories of course, so it's possible to create a
|
||||||
\"hierarchy of directories\" - the UNIX(r)-typical filesystem structure.
|
\"hierarchy of directories\" - the UNIX(r)-typical filesystem structure.
|
||||||
|
|
||||||
@ -10,6 +10,6 @@ all other directory entries are **subdirectories** of it.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [hardlink](../dict/terms/hardlink.md)
|
- [hardlink](../dict/hardlink.md)
|
||||||
- [file](../dict/terms/file.md)
|
- [file](../dict/file.md)
|
||||||
- [special file](../dict/terms/special_file.md)
|
- [special file](../dict/special_file.md)
|
||||||
|
@ -1,24 +1,22 @@
|
|||||||
# File
|
# File
|
||||||
|
|
||||||
A file is a pool of data in the [filesystem](../dict/terms/filesystem.md). On
|
A file is a pool of data in the `filesystem`. On
|
||||||
userlevel, it's referenced using a name, a
|
userlevel, it's referenced using a name, a
|
||||||
[hardlink](../dict/terms/hardlink.md) to the file.
|
[hardlink](hardlink.md) to the file.
|
||||||
|
|
||||||
If a file is not referenced anymore (number of hardlinks to it drops to
|
If a file is not referenced anymore (number of hardlinks to it drops to
|
||||||
0) then the space allocated for that file is re-used, unless it's still
|
1) then the space allocated for that file is re-used, unless it's still
|
||||||
used by some process.
|
used by some process.
|
||||||
|
|
||||||
The file-data splits into actual payload (file contents) and some
|
The file-data splits into actual payload (file contents) and some
|
||||||
metadata like filesize, filemode or timestamps. The metadata is stored
|
metadata like filesize, filemode or timestamps. The metadata is stored
|
||||||
in the [inode](../dict/terms/inode.md).
|
in the `inode`.
|
||||||
|
|
||||||
Strictly spoken, a [hardlink](../dict/terms/hardlink.md) (also called
|
Strictly spoken, a [hardlink](hardlink.md) (also called
|
||||||
\"filename\") points to the [inode](../dict/terms/inode.md) which organizes a
|
\"filename\") points to the `inode` which organizes a
|
||||||
file, not to the file itself.
|
file, not to the file itself.
|
||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [filesystem](../dict/terms/filesystem.md)
|
- [filetimes](filetimes.md)
|
||||||
- [filetimes](../dict/terms/filetimes.md)
|
- [hardlink](hardlink.md)
|
||||||
- [hardlink](../dict/terms/hardlink.md)
|
|
||||||
- [inode](../dict/terms/inode.md)
|
|
||||||
|
@ -23,8 +23,8 @@ which serves the same purpose.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [shell](../dict/terms/shell.md)
|
- [shell](../dict/shell.md)
|
||||||
- [hardlink](../dict/terms/hardlink.md)
|
- [hardlink](../dict/hardlink.md)
|
||||||
|
|
||||||
## See also (article)
|
## See also (article)
|
||||||
|
|
||||||
|
@ -4,16 +4,16 @@ Also the article for:
|
|||||||
|
|
||||||
- filename
|
- filename
|
||||||
|
|
||||||
A hardlink associates a *filename* with a [file](../dict/terms/file.md). That
|
A hardlink associates a *filename* with a [file](../dict/file.md). That
|
||||||
name is an entry in a directory listing. Of course a file can have more
|
name is an entry in a directory listing. Of course a file can have more
|
||||||
hardlinks to it (usually the number of hardlinks to a file is limited),
|
hardlinks to it (usually the number of hardlinks to a file is limited),
|
||||||
but all hardlinks to a file must reside on the same
|
but all hardlinks to a file must reside on the same
|
||||||
[filesystem](../dict/terms/filesystem.md) as the file itself!
|
`filesystem` as the file itself!
|
||||||
|
|
||||||
What you usually call a file is just a name for that file, and thus, a
|
What you usually call a file is just a name for that file, and thus, a
|
||||||
hardlink.
|
hardlink.
|
||||||
|
|
||||||
The difference between a [symbolic link](../dict/terms/symlink.md) and a hard
|
The difference between a [symbolic link](../dict/symlink.md) and a hard
|
||||||
link is that there is no easy way to differentiate between a \'real\'
|
link is that there is no easy way to differentiate between a \'real\'
|
||||||
file and a hard link, let's take a look at the example:
|
file and a hard link, let's take a look at the example:
|
||||||
|
|
||||||
@ -46,6 +46,5 @@ is freed when the last hard link pointing to it is deleted.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [file](../dict/terms/file.md)
|
- [file](../dict/file.md)
|
||||||
- [filesystem](../dict/terms/filesystem.md)
|
- [symlink](../dict/symlink.md)
|
||||||
- [symlink](../dict/terms/symlink.md)
|
|
||||||
|
@ -13,4 +13,4 @@ behaviour of the system shell and some utilities (commands).
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- Dictionary, internal: [shell](../dict/terms/shell.md)
|
- Dictionary, internal: [shell](../dict/shell.md)
|
||||||
|
@ -14,6 +14,6 @@ too.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [file](../dict/terms/file.md)
|
- [file](../dict/file.md)
|
||||||
- [filename](../dict/terms/hardlink.md)
|
- [filename](../dict/hardlink.md)
|
||||||
- [directory](../dict/terms/directory.md)
|
- [directory](../dict/directory.md)
|
||||||
|
@ -10,6 +10,5 @@ it can
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [hardlink](../dict/terms/hardlink.md)
|
- [hardlink](../dict/hardlink.md)
|
||||||
- [filesystem](../dict/terms/filesystem.md)
|
- [directory](../dict/directory.md)
|
||||||
- [directory](../dict/terms/directory.md)
|
|
||||||
|
@ -1,6 +1,13 @@
|
|||||||
# Calculating with dc
|
---
|
||||||
|
tags:
|
||||||
|
- bash
|
||||||
|
- shell
|
||||||
|
- scripting
|
||||||
|
- arithmetic
|
||||||
|
- calculate
|
||||||
|
---
|
||||||
|
|
||||||
![](keywords>bash shell scripting arithmetic calculate)
|
# Calculating with dc
|
||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
|
|
||||||
|
@ -1,6 +1,14 @@
|
|||||||
# Collapsing Functions
|
---
|
||||||
|
tags:
|
||||||
|
- bash
|
||||||
|
- shell
|
||||||
|
- scripting
|
||||||
|
- example
|
||||||
|
- function
|
||||||
|
- collapse
|
||||||
|
---
|
||||||
|
|
||||||
![](keywords>bash shell scripting example function collapse)
|
# Collapsing Functions
|
||||||
|
|
||||||
## What is a \"Collapsing Function\"?
|
## What is a \"Collapsing Function\"?
|
||||||
|
|
||||||
|
@ -1,6 +1,15 @@
|
|||||||
# Config files for your script
|
---
|
||||||
|
tags:
|
||||||
|
- bash
|
||||||
|
- shell
|
||||||
|
- scripting
|
||||||
|
- config
|
||||||
|
- files
|
||||||
|
- include
|
||||||
|
- configuration
|
||||||
|
---
|
||||||
|
|
||||||
![](keywords>bash shell scripting config files include configuration)
|
# Config files for your script
|
||||||
|
|
||||||
## General
|
## General
|
||||||
|
|
||||||
|
@ -1,6 +1,17 @@
|
|||||||
# Editing files via scripts with ed
|
---
|
||||||
|
tags:
|
||||||
|
- bash
|
||||||
|
- shell
|
||||||
|
- scripting
|
||||||
|
- arguments
|
||||||
|
- file
|
||||||
|
- editor
|
||||||
|
- edit
|
||||||
|
- ed
|
||||||
|
- sed
|
||||||
|
---
|
||||||
|
|
||||||
![](keywords>bash shell scripting arguments file editor edit ed sed)
|
# Editing files via scripts with ed
|
||||||
|
|
||||||
## Why ed?
|
## Why ed?
|
||||||
|
|
||||||
|
@ -1,6 +1,17 @@
|
|||||||
# Small getopts tutorial
|
---
|
||||||
|
tags:
|
||||||
|
- bash
|
||||||
|
- shell
|
||||||
|
- scripting
|
||||||
|
- arguments
|
||||||
|
- positional
|
||||||
|
- parameters
|
||||||
|
- options
|
||||||
|
- getopt
|
||||||
|
- getopts
|
||||||
|
---
|
||||||
|
|
||||||
![](keywords>bash shell scripting arguments positional parameters options getopt getopts)
|
# Small getopts tutorial
|
||||||
|
|
||||||
## Description
|
## Description
|
||||||
|
|
||||||
@ -82,7 +93,7 @@ left to parse, it's easy to use in a while-loop:
|
|||||||
parsing on the first non-option argument (a string that doesn't begin
|
parsing on the first non-option argument (a string that doesn't begin
|
||||||
with a hyphen (`-`) that isn't an argument for any option in front of
|
with a hyphen (`-`) that isn't an argument for any option in front of
|
||||||
it). It will also stop parsing when it sees the `--` (double-hyphen),
|
it). It will also stop parsing when it sees the `--` (double-hyphen),
|
||||||
which means [end of options](../dict/terms/end_of_options.md).
|
which means [end of options](../dict/end_of_options.md).
|
||||||
|
|
||||||
### Used variables
|
### Used variables
|
||||||
|
|
||||||
|
@ -1,6 +1,14 @@
|
|||||||
# Lock your script (against parallel execution)
|
---
|
||||||
|
tags:
|
||||||
|
- bash
|
||||||
|
- shell
|
||||||
|
- scripting
|
||||||
|
- mutex
|
||||||
|
- locking
|
||||||
|
- run-control
|
||||||
|
---
|
||||||
|
|
||||||
![](keywords>bash shell scripting mutex locking run-control)
|
# Lock your script (against parallel execution)
|
||||||
|
|
||||||
## Why lock?
|
## Why lock?
|
||||||
|
|
||||||
@ -84,7 +92,7 @@ atomic. Maybe a while loop checking continously for the existence of the
|
|||||||
lock in the background and sending a signal such as USR1, if the
|
lock in the background and sending a signal such as USR1, if the
|
||||||
directory is not found, can be done. The signal would need to be
|
directory is not found, can be done. The signal would need to be
|
||||||
trapped. I am sure there there is a better solution than this
|
trapped. I am sure there there is a better solution than this
|
||||||
suggestion* --- *[sn18](sunny_delhi18@yahoo.com) 2009/12/19 08:24*
|
suggestion* --- **sn18** 2009/12/19 08:24*
|
||||||
|
|
||||||
**Note:** While perusing the Internet, I found some people asking if the
|
**Note:** While perusing the Internet, I found some people asking if the
|
||||||
`mkdir` method works \"on all filesystems\". Well, let's say it should.
|
`mkdir` method works \"on all filesystems\". Well, let's say it should.
|
||||||
|
@ -1,6 +1,16 @@
|
|||||||
# pax - the POSIX archiver
|
---
|
||||||
|
tags:
|
||||||
|
- bash
|
||||||
|
- shell
|
||||||
|
- scripting
|
||||||
|
- POSIX
|
||||||
|
- archive
|
||||||
|
- tar
|
||||||
|
- packing
|
||||||
|
- zip
|
||||||
|
---
|
||||||
|
|
||||||
![](keywords>bash shell scripting POSIX archive tar packing zip)
|
# pax - the POSIX archiver
|
||||||
|
|
||||||
pax can do a lot of fancy stuff, feel free to contribute more awesome
|
pax can do a lot of fancy stuff, feel free to contribute more awesome
|
||||||
pax tricks!
|
pax tricks!
|
||||||
|
@ -1,6 +1,16 @@
|
|||||||
# Illustrated Redirection Tutorial
|
---
|
||||||
|
tags:
|
||||||
|
- bash
|
||||||
|
- shell
|
||||||
|
- scripting
|
||||||
|
- tutorial
|
||||||
|
- redirection
|
||||||
|
- redirect
|
||||||
|
- file
|
||||||
|
- descriptor
|
||||||
|
---
|
||||||
|
|
||||||
![](keywords>bash shell scripting tutorial redirection redirect file descriptor)
|
# Illustrated Redirection Tutorial
|
||||||
|
|
||||||
This tutorial is not a complete guide to redirection, it will not cover
|
This tutorial is not a complete guide to redirection, it will not cover
|
||||||
here docs, here strings, name pipes etc\... I just hope it\'ll help you
|
here docs, here strings, name pipes etc\... I just hope it\'ll help you
|
||||||
@ -653,7 +663,7 @@ recommendations:
|
|||||||
<!-- -->
|
<!-- -->
|
||||||
```
|
```
|
||||||
- **Never** use the Csh `&>foo` and `>&foo` shorthand redirects. Use
|
- **Never** use the Csh `&>foo` and `>&foo` shorthand redirects. Use
|
||||||
the long form `>foo 2>&1`. (see: [obsolete](../obsolete.md))
|
the long form `>foo 2>&1`. (see: [obsolete](../scripting/obsolete.md))
|
||||||
|
|
||||||
```{=html}
|
```{=html}
|
||||||
<!-- -->
|
<!-- -->
|
||||||
|
@ -43,17 +43,16 @@ If not, see [http://www.gnu.org/licenses/](http://www.gnu.org/licenses/).
|
|||||||
- [nonportable](scripting/nonportable.md)
|
- [nonportable](scripting/nonportable.md)
|
||||||
- [debuggingtips](scripting/debuggingtips.md)
|
- [debuggingtips](scripting/debuggingtips.md)
|
||||||
- [terminalcodes](scripting/terminalcodes.md)
|
- [terminalcodes](scripting/terminalcodes.md)
|
||||||
- [tutoriallist](scripting/tutoriallist)
|
|
||||||
|
|
||||||
## Code snippets
|
## Code snippets
|
||||||
|
|
||||||
There is a [section that holds small code snippets](snipplets).
|
There is a [section that holds small code snippets](snipplets/index.md).
|
||||||
|
|
||||||
See also [some Bash source code excerpts](misc/readthesourceluke.md).
|
See also [some Bash source code excerpts](misc/readthesourceluke.md).
|
||||||
|
|
||||||
## How to
|
## How to
|
||||||
|
|
||||||
[Doing specific tasks: concepts, methods, ideas](howto/start.md):
|
Doing specific tasks: concepts, methods, ideas:
|
||||||
|
|
||||||
- [Simple locking (against parallel run.md)](howto/mutex.md)
|
- [Simple locking (against parallel run.md)](howto/mutex.md)
|
||||||
- [Rudimentary config files for your scripts](howto/conffile.md)
|
- [Rudimentary config files for your scripts](howto/conffile.md)
|
||||||
@ -164,10 +163,10 @@ These are provided directly by the shell, rather than invoked as standalone exte
|
|||||||
|
|
||||||
| Command | Description | Alt | Type |
|
| Command | Description | Alt | Type |
|
||||||
| --------------------------------------------------- | ---------------------------------------------------- | -------- | --------------- |
|
| --------------------------------------------------- | ---------------------------------------------------- | -------- | --------------- |
|
||||||
| [colon](commands/builtin/true.md) | "true" null command. | `true` | special builtin |
|
| `colon` | "true" null command. | `true` | special builtin |
|
||||||
| [dot](commands/builtin/source.md) | Source external files. | `source` | special builtin |
|
| `.` (dot) | Source external files. | `source` | special builtin |
|
||||||
| [false](commands/builtin/false.md) | Fail at doing nothing. | | builtin |
|
| `false` | Fail at doing nothing. | | builtin |
|
||||||
| [continue / break](commands/builtin/continueBreak.md) | continue with or break out of loops. | | special builtin |
|
| `continue / break` | continue with or break out of loops. | | special builtin |
|
||||||
| [let](commands/builtin/let.md) | Arithmetic evaluation simple command. | | builtin |
|
| [let](commands/builtin/let.md) | Arithmetic evaluation simple command. | | builtin |
|
||||||
| [return](commands/builtin/return.md) | Return from a function with a specified exit status. | | special builtin |
|
| [return](commands/builtin/return.md) | Return from a function with a specified exit status. | | special builtin |
|
||||||
| [[]](commands/classictest.md) | The classic `test` simple command. | `test` | builtin |
|
| [[]](commands/classictest.md) | The classic `test` simple command. | `test` | builtin |
|
||||||
@ -183,12 +182,13 @@ These are provided directly by the shell, rather than invoked as standalone exte
|
|||||||
| [exit](commands/builtin/exit.md) | Exit the shell. | | special builtin |
|
| [exit](commands/builtin/exit.md) | Exit the shell. | | special builtin |
|
||||||
| [trap](commands/builtin/trap.md) | Set signal handlers or output the current handlers. | | special builtin |
|
| [trap](commands/builtin/trap.md) | Set signal handlers or output the current handlers. | | special builtin |
|
||||||
| [kill](commands/builtin/kill.md) | Send a signal to specified process(es.md) | | builtin |
|
| [kill](commands/builtin/kill.md) | Send a signal to specified process(es.md) | | builtin |
|
||||||
| [times](commands/builtin/times.md) | Display process times. | | special builtin |
|
|`times` | Display process times. | | special builtin |
|
||||||
| [wait](commands/builtin/wait.md) | Wait for background jobs and asynchronous lists. | | builtin |
|
| [wait](commands/builtin/wait.md) | Wait for background jobs and asynchronous lists. | | builtin |
|
||||||
|
|
||||||
## Dictionary
|
## Dictionary
|
||||||
|
|
||||||
A list of expressions, words, and their meanings is [here](dict/index.md).
|
A list of expressions, words, and their meanings can be found under the *Dict*
|
||||||
|
tab.
|
||||||
|
|
||||||
## Links
|
## Links
|
||||||
|
|
||||||
@ -253,7 +253,7 @@ Visit us in [ircs://irc.libera.chat:6697](ircs://irc.libera.chat:6697), channel
|
|||||||
If you have critiques or suggestions, please feel free to send a mail using the contact form on the right.
|
If you have critiques or suggestions, please feel free to send a mail using the contact form on the right.
|
||||||
Note that there is a simple discussion option below every article.
|
Note that there is a simple discussion option below every article.
|
||||||
|
|
||||||
Please also see the [imprint](user/thebonsai/imprint.md) if you have problems with the site and its contents (legality, ...)!
|
Please also see the imprint if you have problems with the site and its contents (legality, ...)!
|
||||||
|
|
||||||
It also would be nice to drop a line when
|
It also would be nice to drop a line when
|
||||||
|
|
||||||
|
@ -1,6 +1,15 @@
|
|||||||
# List of shell options
|
---
|
||||||
|
tags:
|
||||||
|
- bash
|
||||||
|
- shell
|
||||||
|
- scripting
|
||||||
|
- options
|
||||||
|
- runtime
|
||||||
|
- variable
|
||||||
|
- behaviour
|
||||||
|
---
|
||||||
|
|
||||||
![](keywords>bash shell scripting options runtime variable behaviour)
|
# List of shell options
|
||||||
|
|
||||||
This information was taken from a Bash version \"`4.1`\", every now and
|
This information was taken from a Bash version \"`4.1`\", every now and
|
||||||
then new options are added, so likely, this list isn't complete.
|
then new options are added, so likely, this list isn't complete.
|
||||||
|
@ -1,6 +1,16 @@
|
|||||||
# Bash's behaviour
|
---
|
||||||
|
tags:
|
||||||
|
- bash
|
||||||
|
- shell
|
||||||
|
- scripting
|
||||||
|
- startup
|
||||||
|
- files
|
||||||
|
- dotfiles
|
||||||
|
- modes
|
||||||
|
- POSIX
|
||||||
|
---
|
||||||
|
|
||||||
![](keywords>bash shell scripting startup files dotfiles modes POSIX)
|
# Bash's behaviour
|
||||||
|
|
||||||
FIXME incomplete
|
FIXME incomplete
|
||||||
|
|
||||||
|
@ -1,6 +1,14 @@
|
|||||||
# The basics of shell scripting
|
---
|
||||||
|
tags:
|
||||||
|
- bash
|
||||||
|
- shell
|
||||||
|
- scripting
|
||||||
|
- basics
|
||||||
|
- learning
|
||||||
|
- tutorial
|
||||||
|
---
|
||||||
|
|
||||||
![](keywords>bash shell scripting basics learning tutorial)
|
# The basics of shell scripting
|
||||||
|
|
||||||
## Script files
|
## Script files
|
||||||
|
|
||||||
|
@ -1,6 +1,14 @@
|
|||||||
# Debugging a script
|
---
|
||||||
|
tags:
|
||||||
|
- bash
|
||||||
|
- shell
|
||||||
|
- scripting
|
||||||
|
- bug
|
||||||
|
- debug
|
||||||
|
- debugging
|
||||||
|
---
|
||||||
|
|
||||||
![](keywords>bash shell scripting bug debug debugging)
|
# Debugging a script
|
||||||
|
|
||||||
These few lines are not intended as a full-fledged debugging tutorial,
|
These few lines are not intended as a full-fledged debugging tutorial,
|
||||||
but as hints and comments about debugging a Bash script.
|
but as hints and comments about debugging a Bash script.
|
||||||
|
@ -1,6 +1,14 @@
|
|||||||
# Beginner Mistakes
|
---
|
||||||
|
tags:
|
||||||
|
- bash
|
||||||
|
- shell
|
||||||
|
- scripting
|
||||||
|
- pitfalls
|
||||||
|
- traps
|
||||||
|
- beginners
|
||||||
|
---
|
||||||
|
|
||||||
![](keywords>bash shell scripting pitfalls traps beginners)
|
# Beginner Mistakes
|
||||||
|
|
||||||
Here are some typical traps:
|
Here are some typical traps:
|
||||||
|
|
||||||
|
@ -1,6 +1,14 @@
|
|||||||
# Portability talk
|
---
|
||||||
|
tags:
|
||||||
|
- bash
|
||||||
|
- shell
|
||||||
|
- scripting
|
||||||
|
- portability
|
||||||
|
- POSIX
|
||||||
|
- portable
|
||||||
|
---
|
||||||
|
|
||||||
![](keywords>bash shell scripting portability POSIX portable)
|
# Portability talk
|
||||||
|
|
||||||
The script programming language of BASH is based on the Bourne Shell
|
The script programming language of BASH is based on the Bourne Shell
|
||||||
syntax, with some extensions and derivations.
|
syntax, with some extensions and derivations.
|
||||||
|
@ -1,6 +1,14 @@
|
|||||||
# Obsolete and deprecated syntax
|
---
|
||||||
|
tags:
|
||||||
|
- bash
|
||||||
|
- shell
|
||||||
|
- scripting
|
||||||
|
- obsolete
|
||||||
|
- deprecated
|
||||||
|
- outdated
|
||||||
|
---
|
||||||
|
|
||||||
![](keywords>bash shell scripting obsolete deprecated outdated)
|
# Obsolete and deprecated syntax
|
||||||
|
|
||||||
This (incomplete) page describes some syntax and commands considered
|
This (incomplete) page describes some syntax and commands considered
|
||||||
obsolete by some measure. A thorough discussion of the rationale is
|
obsolete by some measure. A thorough discussion of the rationale is
|
||||||
@ -74,7 +82,7 @@ surprised if you run across someone telling you not to use these.
|
|||||||
- [Non-portable syntax and command uses](../scripting/nonportable.md)
|
- [Non-portable syntax and command uses](../scripting/nonportable.md)
|
||||||
- [bashchanges](../scripting/bashchanges.md)
|
- [bashchanges](../scripting/bashchanges.md)
|
||||||
- [Greg's BashFAQ 061: List of essential features added (with the
|
- [Greg's BashFAQ 061: List of essential features added (with the
|
||||||
Bash version tag)](BashFAQ>061)
|
Bash version tag)](http://mywiki.wooledge.org/BashFAQ/061)
|
||||||
- [Bash <-> POSIX Portability guide with a focus on
|
- [Bash <-> POSIX Portability guide with a focus on
|
||||||
Dash](http://mywiki.wooledge.org/Bashism)
|
Dash](http://mywiki.wooledge.org/Bashism)
|
||||||
- <http://mywiki.wooledge.org/BashPitfalls>
|
- <http://mywiki.wooledge.org/BashPitfalls>
|
||||||
|
@ -1,6 +1,15 @@
|
|||||||
# Handling positional parameters
|
---
|
||||||
|
tags:
|
||||||
|
- bash
|
||||||
|
- shell
|
||||||
|
- scripting
|
||||||
|
- arguments
|
||||||
|
- positional
|
||||||
|
- parameters
|
||||||
|
- options
|
||||||
|
---
|
||||||
|
|
||||||
![](keywords>bash shell scripting arguments positional parameters options)
|
# Handling positional parameters
|
||||||
|
|
||||||
## Intro
|
## Intro
|
||||||
|
|
||||||
@ -25,7 +34,7 @@ Option-switch parsing (e.g. `-h` for displaying help) is not performed
|
|||||||
at this point.
|
at this point.
|
||||||
|
|
||||||
See also [the dictionary entry for
|
See also [the dictionary entry for
|
||||||
\"parameter\"](../dict/terms/parameter.md).
|
\"parameter\"](../dict/parameter.md).
|
||||||
|
|
||||||
## The first argument
|
## The first argument
|
||||||
|
|
||||||
@ -394,4 +403,4 @@ There is a [small tutorial dedicated to
|
|||||||
- Internal: [Substring expansion on a
|
- Internal: [Substring expansion on a
|
||||||
parameter](../syntax/pe.md#substring_expansion) (for equivalent syntax
|
parameter](../syntax/pe.md#substring_expansion) (for equivalent syntax
|
||||||
for mass-expansion)
|
for mass-expansion)
|
||||||
- Dictionary, internal: [parameter](../dict/terms/parameter.md)
|
- Dictionary, internal: [parameter](../dict/parameter.md)
|
||||||
|
@ -1,6 +1,15 @@
|
|||||||
# Bash and the process tree
|
---
|
||||||
|
tags:
|
||||||
|
- bash
|
||||||
|
- shell
|
||||||
|
- scripting
|
||||||
|
- processes
|
||||||
|
- pipes
|
||||||
|
- variables
|
||||||
|
- environment
|
||||||
|
---
|
||||||
|
|
||||||
![](keywords>bash shell scripting processes pipes variables environment)
|
# Bash and the process tree
|
||||||
|
|
||||||
## The process tree
|
## The process tree
|
||||||
|
|
||||||
|
@ -278,8 +278,8 @@ The basic structure of a script simply reads:
|
|||||||
|
|
||||||
### The shebang
|
### The shebang
|
||||||
|
|
||||||
If possible (I know it's not always possible!), use [a
|
If possible (I know it's not always possible!), use a
|
||||||
shebang](../dict/terms/shebang.md).
|
[shebang](../dict/interpreter_directive.md).
|
||||||
|
|
||||||
Be careful with `/bin/sh`: The argument that \"on Linux `/bin/sh` is
|
Be careful with `/bin/sh`: The argument that \"on Linux `/bin/sh` is
|
||||||
Bash\" **is a lie** (and technically irrelevant)
|
Bash\" **is a lie** (and technically irrelevant)
|
||||||
@ -358,7 +358,7 @@ Example:
|
|||||||
|
|
||||||
### Exit meaningfully
|
### Exit meaningfully
|
||||||
|
|
||||||
The [exit code](../dict/terms/exit_status.md) is your only way to directly
|
The [exit code](../dict/exit_status.md) is your only way to directly
|
||||||
communicate with the calling process without any special provisions.
|
communicate with the calling process without any special provisions.
|
||||||
|
|
||||||
If your script exits, provide a meaningful exit code. That minimally
|
If your script exits, provide a meaningful exit code. That minimally
|
||||||
|
@ -1,6 +1,16 @@
|
|||||||
# Terminal codes (ANSI/VT100) introduction
|
---
|
||||||
|
tags:
|
||||||
|
- bash
|
||||||
|
- shell
|
||||||
|
- scripting
|
||||||
|
- colors
|
||||||
|
- cursor
|
||||||
|
- control
|
||||||
|
- vt100
|
||||||
|
- ansi
|
||||||
|
---
|
||||||
|
|
||||||
![](keywords>bash shell scripting colors cursor control vt100 ansi)
|
# Terminal codes (ANSI/VT100) introduction
|
||||||
|
|
||||||
Terminal (control) codes are used to issue specific commands to your
|
Terminal (control) codes are used to issue specific commands to your
|
||||||
terminal. This can be related to switching colors or positioning the
|
terminal. This can be related to switching colors or positioning the
|
||||||
|
@ -1,6 +1,16 @@
|
|||||||
# Arithmetic expressions
|
---
|
||||||
|
tags:
|
||||||
|
- bash
|
||||||
|
- shell
|
||||||
|
- scripting
|
||||||
|
- math
|
||||||
|
- arithmetic
|
||||||
|
- C
|
||||||
|
- calculation
|
||||||
|
- integer
|
||||||
|
---
|
||||||
|
|
||||||
![](keywords>bash shell scripting math arithmetic C calculation integer)
|
# Arithmetic expressions
|
||||||
|
|
||||||
Arithmetic expressions are used in several situations:
|
Arithmetic expressions are used in several situations:
|
||||||
|
|
||||||
|
@ -1,6 +1,14 @@
|
|||||||
# Basic grammar rules of Bash
|
---
|
||||||
|
tags:
|
||||||
|
- bash
|
||||||
|
- shell
|
||||||
|
- scripting
|
||||||
|
- grammar
|
||||||
|
- syntax
|
||||||
|
- language
|
||||||
|
---
|
||||||
|
|
||||||
![](keywords>bash shell scripting grammar syntax language)
|
# Basic grammar rules of Bash
|
||||||
|
|
||||||
Bash builds its features on top of a few basic **grammar rules**. The
|
Bash builds its features on top of a few basic **grammar rules**. The
|
||||||
code you see everywhere, the code you use, is based on those rules.
|
code you see everywhere, the code you use, is based on those rules.
|
||||||
@ -55,7 +63,7 @@ name for a construct. Such a pipeline isn't necessarily a pair of
|
|||||||
commands where stdout/stdin is connected via a real pipe.
|
commands where stdout/stdin is connected via a real pipe.
|
||||||
|
|
||||||
Pipelines are one or more [simple
|
Pipelines are one or more [simple
|
||||||
commands](basicgrammar##simple_commands) (separated by the `|` symbol
|
commands](#simple-commands) (separated by the `|` symbol
|
||||||
connects their input and output), for example:
|
connects their input and output), for example:
|
||||||
|
|
||||||
ls /etc | wc -l
|
ls /etc | wc -l
|
||||||
@ -111,7 +119,7 @@ syntax:
|
|||||||
|
|
||||||
FIXME Missing an additional article about list operators
|
FIXME Missing an additional article about list operators
|
||||||
|
|
||||||
A list is a sequence of one or more [pipelines](../basicgrammar.md#pipelines)
|
A list is a sequence of one or more [pipelines](#pipelines)
|
||||||
separated by one of the operators `;`, `&`, `&&`, or `││`, and
|
separated by one of the operators `;`, `&`, `&&`, or `││`, and
|
||||||
optionally terminated by one of `;`, `&`, or `<newline>`.
|
optionally terminated by one of `;`, `&`, or `<newline>`.
|
||||||
|
|
||||||
@ -168,7 +176,7 @@ overview):
|
|||||||
FIXME Missing an additional article about shell functions
|
FIXME Missing an additional article about shell functions
|
||||||
|
|
||||||
A shell function definition makes a [compound
|
A shell function definition makes a [compound
|
||||||
command](../basicgrammar.md#compound_commands) available via a new name. When
|
command](#compound_commands) available via a new name. When
|
||||||
the function runs, it has its own \"private\" set of positional
|
the function runs, it has its own \"private\" set of positional
|
||||||
parameters and I/O descriptors. It acts like a script-within-the-script.
|
parameters and I/O descriptors. It acts like a script-within-the-script.
|
||||||
Simply stated: **You\'ve created a new command.**
|
Simply stated: **You\'ve created a new command.**
|
||||||
@ -183,7 +191,7 @@ looks like:
|
|||||||
print_help() { echo "Sorry, no help available"; }
|
print_help() { echo "Sorry, no help available"; }
|
||||||
|
|
||||||
As above, a function definition can have any [compound
|
As above, a function definition can have any [compound
|
||||||
command](../basicgrammar.md#compound_commands) as a body. Structures like
|
command](#compound_commands) as a body. Structures like
|
||||||
|
|
||||||
countme() for ((x=1;x<=9;x++)); do echo $x; done
|
countme() for ((x=1;x<=9;x++)); do echo $x; done
|
||||||
|
|
||||||
@ -265,17 +273,17 @@ Weird function names should not be used. Quote from the maintainer:
|
|||||||
|
|
||||||
## Grammar summary
|
## Grammar summary
|
||||||
|
|
||||||
- a [simple command](../basicgrammar.md#simple_commands) is just a command
|
- a [simple command](#simple_commands) is just a command
|
||||||
and its arguments
|
and its arguments
|
||||||
- a [pipeline](../basicgrammar.md#pipelines) is one or more [simple
|
- a [pipeline](#pipelines) is one or more [simple
|
||||||
command](../basicgrammar.md#simple_commands) probably connected in a pipe
|
command](#simple_commands) probably connected in a pipe
|
||||||
- a [list](../basicgrammar.md#lists) is one or more
|
- a [list](#lists) is one or more
|
||||||
[pipelines](../basicgrammar.md#pipelines) connected by special operators
|
[pipelines](#pipelines) connected by special operators
|
||||||
- a [compound command](../basicgrammar.md#compound_commands) is a
|
- a [compound command](#compound_commands) is a
|
||||||
[list](../basicgrammar.md#lists) or a special command that forms a new
|
[list](#lists) or a special command that forms a new
|
||||||
meta-command
|
meta-command
|
||||||
- a [function definition](../basicgrammar.md#shell_function_definitions)
|
- a [function definition](#shell_function_definitions)
|
||||||
makes a [compound command](../basicgrammar.md#compound_commands) available
|
makes a [compound command](#compound_commands) available
|
||||||
under a new name, and a separate environment
|
under a new name, and a separate environment
|
||||||
|
|
||||||
## Examples for classification
|
## Examples for classification
|
||||||
@ -304,12 +312,12 @@ FIXME more\...
|
|||||||
cp mymusic.mp3 /data/mp3
|
cp mymusic.mp3 /data/mp3
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- the [compound command](../basicgrammar.md#compound_commands) for the `if`
|
- the [compound command](#compound_commands) for the `if`
|
||||||
clause
|
clause
|
||||||
- the [list](../basicgrammar.md#lists) that `if` **checks** actually
|
- the [list](#lists) that `if` **checks** actually
|
||||||
contains the [simple command](../basicgrammar.md#simple_commands)
|
contains the [simple command](#simple_commands)
|
||||||
`[ -d /data/mp3 ]`
|
`[ -d /data/mp3 ]`
|
||||||
- the [list](../basicgrammar.md#lists) that `if` **executes** contains a
|
- the [list](#lists) that `if` **executes** contains a
|
||||||
simple command (`cp mymusic.mp3 /data/mp3`)
|
simple command (`cp mymusic.mp3 /data/mp3`)
|
||||||
|
|
||||||
Let's invert test command exit code, only one thing changes:
|
Let's invert test command exit code, only one thing changes:
|
||||||
@ -318,8 +326,8 @@ Let's invert test command exit code, only one thing changes:
|
|||||||
cp mymusic.mp3 /data/mp3
|
cp mymusic.mp3 /data/mp3
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- the [list](../basicgrammar.md#lists) that `if` **checks** contains a
|
- the [list](#lists) that `if` **checks** contains a
|
||||||
[pipeline](../basicgrammar.md#pipelines) now (because of the `!`)
|
[pipeline](#pipelines) now (because of the `!`)
|
||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
|
@ -51,11 +51,11 @@ behaves as if it would be 1 (**TRUE** in arithmetic context).
|
|||||||
:!: Like all loops (Both types of `for`-loop, `while` and `until`), this
|
:!: Like all loops (Both types of `for`-loop, `while` and `until`), this
|
||||||
loop can be:
|
loop can be:
|
||||||
|
|
||||||
- Terminated (broken) by the [break](../../commands/builtin/continuebreak.md)
|
- Terminated (broken) by the `break`
|
||||||
builtin, optionally as `break N` to break out of `N` levels of
|
builtin, optionally as `break N` to break out of `N` levels of
|
||||||
nested loops.
|
nested loops.
|
||||||
- Forced immediately to the next iteration using the
|
- Forced immediately to the next iteration using the
|
||||||
[continue](../../commands/builtin/continuebreak.md) builtin, optionally as
|
`continue` builtin, optionally as
|
||||||
the `continue N` analog to `break N`.
|
the `continue N` analog to `break N`.
|
||||||
|
|
||||||
The equivalent construct using a [while loop](../../syntax/ccmd/while_loop.md)
|
The equivalent construct using a [while loop](../../syntax/ccmd/while_loop.md)
|
||||||
@ -70,7 +70,7 @@ command](../../syntax/ccmd/arithmetic_eval.md) would be structured as:
|
|||||||
|
|
||||||
The equivalent `while` construct isn't exactly the same, because both,
|
The equivalent `while` construct isn't exactly the same, because both,
|
||||||
the `for` and the `while` loop behave differently in case you use the
|
the `for` and the `while` loop behave differently in case you use the
|
||||||
[continue](../../commands/builtin/continuebreak.md) command.
|
`continue` command.
|
||||||
|
|
||||||
### Alternate syntax
|
### Alternate syntax
|
||||||
|
|
||||||
|
@ -8,8 +8,8 @@ them. That is what the essential \"Bash language\" is made of.
|
|||||||
|
|
||||||
## Command grouping
|
## Command grouping
|
||||||
|
|
||||||
- grouping: [command grouping](../../grouping_plain.md)
|
- grouping: [command grouping](grouping_plain.md)
|
||||||
- grouping again: [command grouping in a subshell](../../grouping_subshell.md)
|
- grouping again: [command grouping in a subshell](grouping_subshell.md)
|
||||||
|
|
||||||
## Conditional reactions
|
## Conditional reactions
|
||||||
|
|
||||||
@ -18,18 +18,18 @@ Note that conditionals can also be scripted using
|
|||||||
commands.
|
commands.
|
||||||
|
|
||||||
- the \"new\" test command: [conditional
|
- the \"new\" test command: [conditional
|
||||||
expression](../../conditional_expression.md)
|
expression](conditional_expression.md)
|
||||||
- if-clause: [conditional branching](../../if_clause.md)
|
- if-clause: [conditional branching](if_clause.md)
|
||||||
- case statement: [pattern-based branching](../../case.md)
|
- case statement: [pattern-based branching](case.md)
|
||||||
|
|
||||||
## Loops
|
## Loops
|
||||||
|
|
||||||
- [classic for-loop](../../classic_for.md)
|
- [classic for-loop](classic_for.md)
|
||||||
- [C-style for-loop](../../c_for.md)
|
- [C-style for-loop](c_for.md)
|
||||||
- [while loop](../../while_loop.md)
|
- [while loop](while_loop.md)
|
||||||
- [until loop](../../until_loop.md)
|
- [until loop](until_loop.md)
|
||||||
|
|
||||||
## Misc
|
## Misc
|
||||||
|
|
||||||
- math: [arithmetic evaluation](../../arithmetic_eval.md)
|
- math: [arithmetic evaluation](arithmetic_eval.md)
|
||||||
- menus: [user selections](../../user_select.md)
|
- menus: [user selections](user_select.md)
|
||||||
|
@ -1,6 +1,16 @@
|
|||||||
# Brace expansion
|
---
|
||||||
|
tags:
|
||||||
|
- bash
|
||||||
|
- shell
|
||||||
|
- scripting
|
||||||
|
- expansion
|
||||||
|
- substitution
|
||||||
|
- text
|
||||||
|
- list
|
||||||
|
- brace
|
||||||
|
---
|
||||||
|
|
||||||
![](keywords>bash shell scripting expansion substitution text list brace)
|
# Brace expansion
|
||||||
|
|
||||||
{string1,string2,...,stringN}
|
{string1,string2,...,stringN}
|
||||||
{<START>..<END>}
|
{<START>..<END>}
|
||||||
|
@ -1,6 +1,22 @@
|
|||||||
# Command substitution
|
---
|
||||||
|
tags:
|
||||||
|
- bash
|
||||||
|
- shell
|
||||||
|
- scripting
|
||||||
|
- expansion
|
||||||
|
- substitution
|
||||||
|
- text
|
||||||
|
- variable
|
||||||
|
- output
|
||||||
|
- execute
|
||||||
|
- stdout
|
||||||
|
- save
|
||||||
|
- result
|
||||||
|
- return
|
||||||
|
- value
|
||||||
|
---
|
||||||
|
|
||||||
![](keywords>bash shell scripting expansion substitution text variable output execute stdout save result return value)
|
# Command substitution
|
||||||
|
|
||||||
$( <COMMANDS> )
|
$( <COMMANDS> )
|
||||||
|
|
||||||
|
@ -1,6 +1,18 @@
|
|||||||
# Expansions and substitutions
|
---
|
||||||
|
tags:
|
||||||
|
- bash
|
||||||
|
- shell
|
||||||
|
- scripting
|
||||||
|
- expansion
|
||||||
|
- substitution
|
||||||
|
- text
|
||||||
|
- variable
|
||||||
|
- filename
|
||||||
|
- macro
|
||||||
|
- wildcard
|
||||||
|
---
|
||||||
|
|
||||||
![](keywords>bash shell scripting expansion substitution text variable filename macro wildcard)
|
# Expansions and substitutions
|
||||||
|
|
||||||
Before executing your commands, Bash checks whether there are any syntax
|
Before executing your commands, Bash checks whether there are any syntax
|
||||||
elements in the command line that should be interpreted rather than
|
elements in the command line that should be interpreted rather than
|
||||||
|
@ -1,6 +1,18 @@
|
|||||||
# Process substitution
|
---
|
||||||
|
tags:
|
||||||
|
- bash
|
||||||
|
- shell
|
||||||
|
- scripting
|
||||||
|
- expansion
|
||||||
|
- substitution
|
||||||
|
- text
|
||||||
|
- stdin
|
||||||
|
- stdout
|
||||||
|
- save
|
||||||
|
- capture
|
||||||
|
---
|
||||||
|
|
||||||
![](keywords>bash shell scripting expansion substitution text stdin stdout save capture)
|
# Process substitution
|
||||||
|
|
||||||
Process substitution is a form of redirection where the input or output
|
Process substitution is a form of redirection where the input or output
|
||||||
of a process (some sequence of commands) appear as a temporary file.
|
of a process (some sequence of commands) appear as a temporary file.
|
||||||
@ -158,7 +170,7 @@ See the above section on [#scope](#scope)
|
|||||||
not (yet) pdksh derivatives (mksh). Coprocesses may be used instead.
|
not (yet) pdksh derivatives (mksh). Coprocesses may be used instead.
|
||||||
- Process substitution is supported only on systems that support
|
- Process substitution is supported only on systems that support
|
||||||
either named pipes (FIFO - a [special
|
either named pipes (FIFO - a [special
|
||||||
file](../../dict/terms/special_file.md)) or the `/dev/fd/*` method for
|
file](../../dict/special_file.md)) or the `/dev/fd/*` method for
|
||||||
accessing open files. If the system doesn't support `/dev/fd/*`,
|
accessing open files. If the system doesn't support `/dev/fd/*`,
|
||||||
Bash falls back to creating named pipes. Note that not all shells
|
Bash falls back to creating named pipes. Note that not all shells
|
||||||
that support process substitution have that fallback.
|
that support process substitution have that fallback.
|
||||||
|
@ -1,6 +1,17 @@
|
|||||||
# Tilde expansion
|
---
|
||||||
|
tags:
|
||||||
|
- bash
|
||||||
|
- shell
|
||||||
|
- scripting
|
||||||
|
- expansion
|
||||||
|
- substitution
|
||||||
|
- tilde
|
||||||
|
- home
|
||||||
|
- homedir
|
||||||
|
- shortcut
|
||||||
|
---
|
||||||
|
|
||||||
![](keywords>bash shell scripting expansion substitution tilde home homedir shortcut)
|
# Tilde expansion
|
||||||
|
|
||||||
~
|
~
|
||||||
~/...
|
~/...
|
||||||
|
@ -1,9 +1,19 @@
|
|||||||
|
---
|
||||||
|
tags:
|
||||||
|
- bash
|
||||||
|
- shell
|
||||||
|
- scripting
|
||||||
|
- syntax
|
||||||
|
- language
|
||||||
|
- behaviour
|
||||||
|
- executing
|
||||||
|
- execution
|
||||||
|
---
|
||||||
|
|
||||||
FIXME work in progress\...
|
FIXME work in progress\...
|
||||||
|
|
||||||
# Parsing and execution
|
# Parsing and execution
|
||||||
|
|
||||||
![](keywords>bash shell scripting syntax language behaviour executing execution)
|
|
||||||
|
|
||||||
Nearly everything in [Bash grammar](../../syntax/basicgrammar.md) can be broken
|
Nearly everything in [Bash grammar](../../syntax/basicgrammar.md) can be broken
|
||||||
down to a \"simple command\". The only thing Bash has to expand,
|
down to a \"simple command\". The only thing Bash has to expand,
|
||||||
evaluate and execute is the simple command.
|
evaluate and execute is the simple command.
|
||||||
|
@ -1,6 +1,17 @@
|
|||||||
# Patterns and pattern matching
|
---
|
||||||
|
tags:
|
||||||
|
- bash
|
||||||
|
- shell
|
||||||
|
- scripting
|
||||||
|
- glob
|
||||||
|
- globbing
|
||||||
|
- wildcards
|
||||||
|
- filename
|
||||||
|
- pattern
|
||||||
|
- matching
|
||||||
|
---
|
||||||
|
|
||||||
![](keywords>bash shell scripting glob globbing wildcards filename pattern matching)
|
# Patterns and pattern matching
|
||||||
|
|
||||||
A pattern is a **string description**. Bash uses them in various ways:
|
A pattern is a **string description**. Bash uses them in various ways:
|
||||||
|
|
||||||
|
@ -1,6 +1,24 @@
|
|||||||
# Parameter expansion
|
---
|
||||||
|
tags:
|
||||||
|
- bash
|
||||||
|
- shell
|
||||||
|
- scripting
|
||||||
|
- expansion
|
||||||
|
- substitution
|
||||||
|
- text
|
||||||
|
- variable
|
||||||
|
- parameter
|
||||||
|
- mangle
|
||||||
|
- substitute
|
||||||
|
- change
|
||||||
|
- check
|
||||||
|
- defined
|
||||||
|
- "null"
|
||||||
|
- array
|
||||||
|
- arrays
|
||||||
|
---
|
||||||
|
|
||||||
![](keywords>bash shell scripting expansion substitution text variable parameter mangle substitute change check defined null array arrays)
|
# Parameter expansion
|
||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
|
|
||||||
@ -28,7 +46,7 @@ applicable description mentions arrays below. Please also see the
|
|||||||
[article about arrays](../syntax/arrays.md).
|
[article about arrays](../syntax/arrays.md).
|
||||||
|
|
||||||
For a more technical view what a parameter is and which types exist,
|
For a more technical view what a parameter is and which types exist,
|
||||||
[see the dictionary entry for \"parameter\"](../dict/terms/parameter.md).
|
[see the dictionary entry for \"parameter\"](../dict/parameter.md).
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
@ -1053,4 +1071,4 @@ the difference may introduce a possible compatibility problem.
|
|||||||
- Internal: [Introduction to expansion and
|
- Internal: [Introduction to expansion and
|
||||||
substitution](../syntax/expansion/intro.md)
|
substitution](../syntax/expansion/intro.md)
|
||||||
- Internal: [Arrays](../syntax/arrays.md)
|
- Internal: [Arrays](../syntax/arrays.md)
|
||||||
- Dictionary, internal: [parameter](../dict/terms/parameter.md)
|
- Dictionary, internal: [parameter](../dict/parameter.md)
|
||||||
|
@ -1,6 +1,20 @@
|
|||||||
# Quotes and escaping
|
---
|
||||||
|
tags:
|
||||||
|
- bash
|
||||||
|
- shell
|
||||||
|
- scripting
|
||||||
|
- quoting
|
||||||
|
- quotes
|
||||||
|
- escape
|
||||||
|
- backslash
|
||||||
|
- marks
|
||||||
|
- singlequotes
|
||||||
|
- doublequotes
|
||||||
|
- single
|
||||||
|
- double
|
||||||
|
---
|
||||||
|
|
||||||
![](keywords>bash shell scripting quoting quotes escape backslash marks singlequotes doublequotes single double)
|
# Quotes and escaping
|
||||||
|
|
||||||
Quoting and escaping are important, as they influence the way Bash acts
|
Quoting and escaping are important, as they influence the way Bash acts
|
||||||
upon your input. There are three recognized types:
|
upon your input. There are three recognized types:
|
||||||
|
@ -88,8 +88,8 @@ list of aliases as maintained by the alias builtin. Elements added to
|
|||||||
this array appear in the alias list; unsetting array elements cause
|
this array appear in the alias list; unsetting array elements cause
|
||||||
aliases to be removed from the alias list.
|
aliases to be removed from the alias list.
|
||||||
|
|
||||||
The associative key is the name of the alias as used with the [alias
|
The associative key is the name of the alias as used with the `alias`
|
||||||
builtin command](../commands/builtin/alias.md).
|
builtin command.
|
||||||
|
|
||||||
### BASH_ARGC
|
### BASH_ARGC
|
||||||
|
|
||||||
@ -102,8 +102,8 @@ An array variable whose values are the number of parameters in each
|
|||||||
frame of the current Bash execution call stack.
|
frame of the current Bash execution call stack.
|
||||||
|
|
||||||
The number of parameters to the current subroutine (shell function or
|
The number of parameters to the current subroutine (shell function or
|
||||||
script executed with [`.` or `source` builtin
|
script executed with `.` or `source` builtin
|
||||||
command](../commands/builtin/source.md)) is at the top of the stack. When a
|
command) is at the top of the stack. When a
|
||||||
subroutine is executed, the number of parameters passed is pushed onto
|
subroutine is executed, the number of parameters passed is pushed onto
|
||||||
`BASH_ARGC`.
|
`BASH_ARGC`.
|
||||||
|
|
||||||
@ -144,13 +144,13 @@ subsequently reset.
|
|||||||
Set by Bash: yes Default: n/a
|
Set by Bash: yes Default: n/a
|
||||||
|
|
||||||
An associative array variable whose members correspond to the internal
|
An associative array variable whose members correspond to the internal
|
||||||
hash table of commands as maintained by the [hash builtin
|
hash table of commands as maintained by the `hash` builtin
|
||||||
command](../commands/builtin/hash.md). Elements added to this array appear in
|
command. Elements added to this array appear in
|
||||||
the hash table; unsetting array elements cause commands to be removed
|
the hash table; unsetting array elements cause commands to be removed
|
||||||
from the hash table.
|
from the hash table.
|
||||||
|
|
||||||
The associative key is the name of the command as used with the[hash
|
The associative key is the name of the command as used with the `hash`
|
||||||
builtin command](../commands/builtin/hash.md).
|
builtin command.
|
||||||
|
|
||||||
### BASH_COMMAND
|
### BASH_COMMAND
|
||||||
|
|
||||||
@ -573,8 +573,8 @@ The previous working directory as set by the cd command.
|
|||||||
Type: normal variable Read-only: no
|
Type: normal variable Read-only: no
|
||||||
Set by Bash: yes Default: n/a
|
Set by Bash: yes Default: n/a
|
||||||
|
|
||||||
The value of the last option argument processed by the [getopts builtin
|
The value of the last option argument processed by the `getopts` builtin
|
||||||
command](../commands/builtin/getopts.md).
|
command.
|
||||||
|
|
||||||
### OPTIND
|
### OPTIND
|
||||||
|
|
||||||
@ -583,8 +583,8 @@ command](../commands/builtin/getopts.md).
|
|||||||
Type: integer variable Read-only: no
|
Type: integer variable Read-only: no
|
||||||
Set by Bash: yes Default: n/a
|
Set by Bash: yes Default: n/a
|
||||||
|
|
||||||
The index of the next argument to be processed by the [getopts builtin
|
The index of the next argument to be processed by the `getopts` builtin
|
||||||
command](../commands/builtin/getopts.md).
|
command.
|
||||||
|
|
||||||
### OSTYPE
|
### OSTYPE
|
||||||
|
|
||||||
@ -828,7 +828,7 @@ Similar to `BASH_ENV`: Used when the shell is invoked in POSIX(r) mode.
|
|||||||
Type: normal variable Read-only: no
|
Type: normal variable Read-only: no
|
||||||
Set by Bash: no Default: n/a
|
Set by Bash: no Default: n/a
|
||||||
|
|
||||||
The default editor for the [fc builtin command](../commands/builtin/fc.md).
|
The default editor for the `fc` builtin command.
|
||||||
|
|
||||||
### FIGNORE
|
### FIGNORE
|
||||||
|
|
||||||
@ -1177,7 +1177,7 @@ Example content:
|
|||||||
Set by Bash: yes Default: 1 (set on startup)
|
Set by Bash: yes Default: 1 (set on startup)
|
||||||
|
|
||||||
If set to the value 1, Bash displays error messages generated by the
|
If set to the value 1, Bash displays error messages generated by the
|
||||||
[getopts builtin command](../commands/builtin/getopts.md).
|
`getopts` builtin command.
|
||||||
|
|
||||||
`OPTERR` is initialized to 1 each time the shell is invoked or a shell
|
`OPTERR` is initialized to 1 each time the shell is invoked or a shell
|
||||||
script is executed.
|
script is executed.
|
||||||
@ -1370,7 +1370,7 @@ A trailing newline is added when the format string is displayed.
|
|||||||
If set to a value greater than zero, `TMOUT` is treated as the default
|
If set to a value greater than zero, `TMOUT` is treated as the default
|
||||||
timeout for the [read builtin command](../commands/builtin/read.md).
|
timeout for the [read builtin command](../commands/builtin/read.md).
|
||||||
|
|
||||||
The [select command](../commands/builtin/select.md) terminates if input does
|
The `select` command terminates if input does
|
||||||
not arrive after `TMOUT` seconds when input is coming from a terminal.
|
not arrive after `TMOUT` seconds when input is coming from a terminal.
|
||||||
|
|
||||||
In an interactive shell, the value is interpreted as the number of
|
In an interactive shell, the value is interpreted as the number of
|
||||||
|
@ -1,6 +1,16 @@
|
|||||||
# Words\...
|
---
|
||||||
|
tags:
|
||||||
|
- bash
|
||||||
|
- shell
|
||||||
|
- scripting
|
||||||
|
- token
|
||||||
|
- words
|
||||||
|
- split
|
||||||
|
- splitting
|
||||||
|
- recognition
|
||||||
|
---
|
||||||
|
|
||||||
![](keywords>bash shell scripting token words split splitting recognition)
|
# Words\...
|
||||||
|
|
||||||
FIXME This article needs a review, it covers two topics (command line
|
FIXME This article needs a review, it covers two topics (command line
|
||||||
splitting and word splitting) and mixes both a bit too much. But in
|
splitting and word splitting) and mixes both a bit too much. But in
|
||||||
|
@ -23,12 +23,12 @@ theme:
|
|||||||
repo: fontawesome/brands/github
|
repo: fontawesome/brands/github
|
||||||
|
|
||||||
plugins:
|
plugins:
|
||||||
- tags:
|
|
||||||
tags_file: tags.md
|
|
||||||
- git-revision-date-localized:
|
- git-revision-date-localized:
|
||||||
enable_creation_date: true
|
enable_creation_date: true
|
||||||
- search
|
- search
|
||||||
- awesome-pages
|
- awesome-pages
|
||||||
|
- tags:
|
||||||
|
tags_file: tags.md
|
||||||
- minify:
|
- minify:
|
||||||
minify_html: true
|
minify_html: true
|
||||||
minify_css: true
|
minify_css: true
|
||||||
|
Loading…
Reference in New Issue
Block a user