Skip to content

Instantly share code, notes, and snippets.

@RichardBronosky
Last active January 14, 2019 06:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RichardBronosky/d5d66bfe73cbecbfd73528a61b9728e3 to your computer and use it in GitHub Desktop.
Save RichardBronosky/d5d66bfe73cbecbfd73528a61b9728e3 to your computer and use it in GitHub Desktop.
This is a stand in script for any command that might take stdin or arguments and logs everything.
#!/bin/bash
(
echo -e "\n\n #### $(date) ####"
echo -e "\n## Exported Variables"
printenv
echo -e "\n## Local Variables"
( set -o posix ; set) | grep -vf <(printenv | sed 's/^/^/;s/=.*/=/')
echo -e "\n## Arguments"
echo "$@"
if [[ -p /dev/stdin ]]; then # stdin is a pipe
echo -e "\n## Std In"
while read; do
echo "$REPLY"
done
fi
) >> $(basename ${BASH_SOURCE[0]}).out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment