Created
October 30, 2011 02:52
-
-
Save HansCz/1325399 to your computer and use it in GitHub Desktop.
Bash - Source a file and find out what variables it set
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
# 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