Skip to content

Instantly share code, notes, and snippets.

@HansCz
Created October 30, 2011 02:52
Show Gist options
  • Save HansCz/1325399 to your computer and use it in GitHub Desktop.
Save HansCz/1325399 to your computer and use it in GitHub Desktop.
Bash - Source a file and find out what variables it set
# found here:
# http://stackoverflow.com/questions/1305237/how-to-list-variables-declared-in-script-in-bash/1305273#1305273
# # Todo
# - instead of echoing all vars out on one line separated by spaces, find a way to separate them, so they are one line each
# can be run in command line
( VARS="`set -o posix ; set`"; source repos/backup/test/conf/sync.conf; SCRIPT_VARS="`grep -vFe "$VARS" <<<"$(set -o posix ; set)" | grep -v ^VARS=`"; unset VARS; echo $SCRIPT_VARS; unset SCRIPT_VARS )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment