feat: initial commit

This commit is contained in:
ptrcnull 2022-08-05 16:26:04 +02:00
commit f90359b028
5 changed files with 78 additions and 0 deletions

22
LICENSE Normal file
View file

@ -0,0 +1,22 @@
Copyright (c) 2022 ptrcnull
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

32
README.md Normal file
View file

@ -0,0 +1,32 @@
# execline-ptrc-extras
> fun execline scripts to try at home
### println
like echo, but chainable
```sh
println "test"
echo test1
```
### eprintln
println but to stderr :)
```sh
eprintln "test"
echo test1
```
### tdefine
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
```

6
eprintln Executable file
View file

@ -0,0 +1,6 @@
#!/bin/execlineb
foreground { fdmove -c 1 2 importas -ui msg 1 s6-echo $msg }
shift
elgetpositionals
$@

6
println Executable file
View file

@ -0,0 +1,6 @@
#!/bin/execlineb
foreground { importas -ui msg 1 s6-echo $msg }
shift
elgetpositionals
$@

12
tdefine Executable file
View file

@ -0,0 +1,12 @@
#!/bin/execlineb
elgetpositionals
backtick result {
ifelse { runblock -n 3 1 } {
echo "$2"
}
echo "$3"
}
runblock -n 3 -r 1
importas -ui "$1" result
unexport result