commit f90359b028b139a4cfef3004ab118cb36f385ba0 Author: ptrcnull Date: Fri Aug 5 16:26:04 2022 +0200 feat: initial commit diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..470dc1a --- /dev/null +++ b/LICENSE @@ -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. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..5172d1f --- /dev/null +++ b/README.md @@ -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 +``` diff --git a/eprintln b/eprintln new file mode 100755 index 0000000..661851c --- /dev/null +++ b/eprintln @@ -0,0 +1,6 @@ +#!/bin/execlineb + +foreground { fdmove -c 1 2 importas -ui msg 1 s6-echo $msg } +shift +elgetpositionals +$@ diff --git a/println b/println new file mode 100755 index 0000000..e5eecc7 --- /dev/null +++ b/println @@ -0,0 +1,6 @@ +#!/bin/execlineb + +foreground { importas -ui msg 1 s6-echo $msg } +shift +elgetpositionals +$@ diff --git a/tdefine b/tdefine new file mode 100755 index 0000000..7677f08 --- /dev/null +++ b/tdefine @@ -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