Compare commits
1 commit
Author | SHA1 | Date | |
---|---|---|---|
55b9261cfd |
4 changed files with 54 additions and 3 deletions
31
README.md
31
README.md
|
@ -2,7 +2,7 @@
|
|||
|
||||
> fun execline scripts to try at home
|
||||
|
||||
### println
|
||||
#### println
|
||||
|
||||
like echo, but chainable
|
||||
|
||||
|
@ -11,7 +11,7 @@ println "test"
|
|||
echo test1
|
||||
```
|
||||
|
||||
### eprintln
|
||||
#### eprintln
|
||||
|
||||
println but to stderr :)
|
||||
|
||||
|
@ -20,7 +20,7 @@ eprintln "test"
|
|||
echo test1
|
||||
```
|
||||
|
||||
### tdefine
|
||||
#### tdefine
|
||||
|
||||
ternary define: `$1 = if ($4) { $2 } { $3 } cmd...`
|
||||
|
||||
|
@ -30,3 +30,28 @@ tdefine sucmd "doas" "exec" { s6-test $uid != 0 }
|
|||
|
||||
$sucmd s6-linux-init-shutdown
|
||||
```
|
||||
|
||||
#### 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 }
|
||||
```
|
||||
|
|
8
elevate
Executable file
8
elevate
Executable file
|
@ -0,0 +1,8 @@
|
|||
#!/bin/execlineb
|
||||
|
||||
backtick -E uid { id -u }
|
||||
tdefine lift "doas" "sudo" { iscmd doas }
|
||||
tdefine sucmd "$lift" "exec" { s6-test $uid != 0 }
|
||||
elgetpositionals
|
||||
$sucmd
|
||||
$@
|
5
iscmd
Executable file
5
iscmd
Executable file
|
@ -0,0 +1,5 @@
|
|||
#!/bin/execlineb
|
||||
|
||||
elgetpositionals
|
||||
redirfd -w 1 /dev/null
|
||||
where $1
|
13
where
Executable file
13
where
Executable file
|
@ -0,0 +1,13 @@
|
|||
#!/bin/execlineb
|
||||
|
||||
elgetpositionals
|
||||
importas -isd ":" path PATH
|
||||
|
||||
backtick -E result {
|
||||
forx -E -x 0 dir { $path }
|
||||
if { s6-test -x ${dir}/$1 }
|
||||
echo ${dir}/$1
|
||||
}
|
||||
|
||||
if { s6-test -n "$result" }
|
||||
echo "$result"
|
Loading…
Reference in a new issue