Mention $_ in 'Elegant bash conditionals' post

This commit is contained in:
timvisee 2021-03-02 13:56:38 +01:00
parent 09268de46d
commit c1139f3e9c
No known key found for this signature in database
GPG Key ID: B8DB720BC383E172
1 changed files with 6 additions and 0 deletions

View File

@ -158,6 +158,12 @@ it is empty, so you won't even need conditionals.
Most other shells support similar operators. [fish][fish] uses `; and` and `;
or`, but now [supports][fish-and-and] `&&` and `||` as well in modern versions.
`$_` (or `Alt+.`) is your last used argument (thanks [@Diti](https://lobste.rs/u/Diti)). For example:
```bash
test -f FILE && source $_ || echo "FILE does not exist" >&2
```
## Closing thoughts
These command sequences with control operators are an elegant alternative for
simple if-statements. I think they look much better and are more expressive