Last active
January 14, 2019 06:24
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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