execline-ptrc-extras/README.md

58 lines
731 B
Markdown
Raw Permalink Normal View History

2022-08-05 14:26:04 +00:00
# execline-ptrc-extras
> fun execline scripts to try at home
2022-08-05 17:06:16 +00:00
#### println
2022-08-05 14:26:04 +00:00
like echo, but chainable
```sh
println "test"
echo test1
```
2022-08-05 17:06:16 +00:00
#### eprintln
2022-08-05 14:26:04 +00:00
println but to stderr :)
```sh
eprintln "test"
echo test1
```
2022-08-05 17:06:16 +00:00
#### tdefine
2022-08-05 14:26:04 +00:00
ternary define: `$1 = if ($4) { $2 } { $3 } cmd...`
```sh
backtick -E uid { id -u }
tdefine sucmd "doas" "exec" { s6-test $uid != 0 }
$sucmd s6-linux-init-shutdown
```
2022-08-05 17:06:16 +00:00
#### elevate
the same thing from above but just one command (and with sudo fallback)
```sh
elevate s6-linux-init-shutdown
```
#### where
which(1) but in execline
```sh
backtick -E sh { where sh }
echo "shell full path: $sh"
```
#### iscmd
exits with 0 if command exists
```sh
tdefine shell "zsh" "sh" { iscmd zsh }
```