Mention $_ in 'Elegant bash conditionals' post
This commit is contained in:
parent
09268de46d
commit
c1139f3e9c
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue