Add bash/README.org

This commit is contained in:
andy 2024-02-27 10:35:47 -05:00
parent 57a6a5fa90
commit be5bbd84ed

48
bash/README.org Normal file
View file

@ -0,0 +1,48 @@
Here is some code that I test trying to capture =STDIN= from a function and with wrapping a command with a logger
#+begin_src bash
#!/usr/bin/env bash
alu-log-warn () {
echo '{{ Color "192" "0" " warn "}}' "$@" | gum format -t 'template' >&2
}
myfunc () {
local in
if [[ -z "$@" ]]
then
read in
else
in="$@"
fi
echo '{{ Color "86" "0" " info "}}' "$in" | gum format -t 'template' >&2
}
extern-func () {
echo 'I write to stdout'
echo 'I write to stderr' >&2
}
# alu-log-warn "Testing calling the function"
# myfunc 'Testing testing 1 2 3'
# alu-log-warn "Testing piping to the function"
# echo 'Testing testing 1 2 3' | myfunc
alu-log-warn "Smoke test: Calling the function"
extern-func
alu-log-warn "Smoke test: Filtering stdout"
extern-func > /dev/null
alu-log-warn "Smoke test: Filtering stderr"
extern-func 2> /dev/null
alu-log-warn "Catching output"
extern-func 2> >(myfunc)
#+end_src