Skip to content

Instantly share code, notes, and snippets.

@RichardBronosky
Last active July 19, 2024 02:40
Show Gist options
  • Select an option

  • Save RichardBronosky/d5d66bfe73cbecbfd73528a61b9728e3 to your computer and use it in GitHub Desktop.

Select an option

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