Skip to content

Instantly share code, notes, and snippets.

@lbvf50mobile
Last active September 13, 2021 18:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lbvf50mobile/e34e8e7c1fe0e2dab1ddda0d2b8b38b0 to your computer and use it in GitHub Desktop.
Save lbvf50mobile/e34e8e7c1fe0e2dab1ddda0d2b8b38b0 to your computer and use it in GitHub Desktop.
Bash wrapper for @eifgr
#!/usr/bin/env bash
# Help for @eifgr at Sunday September 2021.09.12.
# Usage: echo 'abc def ghi' | xargs -0 ./wrapper.sh > output.txt
# cat input.txt | xargs -0 ./wrapper.sh > output.txt
# Do not forget to set execution right for the script.
# chmod u+x wrapper.sh
HEADER='{{#inline "content" }}'
FOOTER_1='{{/inline}}'
FOOTER_2='{{>partials/basis}}'
NEWLINE='\n'
# https://stackoverflow.com/questions/20536112/how-to-insert-a-new-line-in-linux-shell-script/20538015
# https://stackoverflow.com/questions/54218833/pass-multiline-argument-with-xargs
echo -e "$HEADER${NEWLINE}$1${NEWLINE}$FOOTER_1${NEWLINE}$FOOTER_2"
#!/usr/bin/env bash
# !!!!!!! This code has problems !!!!!!!
# Help for @eifgr at Sunday September 2021.09.12.
# Usage: echo 'abc def ghi' | ./wrapper_stdin.sh > output.txt
# cat input.txt | ./wrapper_stdin.sh > output.txt
# Do not forget to set execution right for the script.
# chmod u+x wrapper.sh
HEADER='{{#inline "content" }}'
FOOTER_1='{{/inline}}'
FOOTER_2='{{>partials/basis}}'
NEWLINE='\n'
echo -e "$HEADER"
# https://stackoverflow.com/a/33234042/8574922
full=""
while read line
do
full="$full$line\n"
done
printf $full
echo -e "$FOOTER_1${NEWLINE}$FOOTER_2"
#!/usr/bin/env bash
# Help for @eifgr at Sunday September 2021.09.12.
# Usage: echo 'abc def ghi' | ./wrapper_stdin.sh > output.txt
# cat input.txt | ./wrapper_stdin.sh > output.txt
# Do not forget to set execution right for the script.
# chmod u+x wrapper.sh
# Code by @Fearan.
cat <<EOF
{{#inline "content" }}
$(cat)
{{/inline}}
{{>partials/basis}}
EOF
#!/usr/bin/env bash
# Help for @eifgr at Sunday September 2021.09.12.
# Usage: echo 'abc def ghi' | ./wrapper_stdin.sh > output.txt
# cat input.txt | ./wrapper_stdin.sh > output.txt
# Do not forget to set execution right for the script.
# chmod u+x wrapper.sh
HEADER='{{#inline "content" }}'
FOOTER_1='{{/inline}}'
FOOTER_2='{{>partials/basis}}'
NEWLINE='\n'
echo -e "$HEADER"
# https://stackoverflow.com/a/33234042/8574922
full=""
while read line
do
echo $line
done
echo -e "$FOOTER_1${NEWLINE}$FOOTER_2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment