Last active
August 15, 2016 11:52
-
-
Save kanonji/f8debe058a74304de17880940df8bcc6 to your computer and use it in GitHub Desktop.
Test to share variables within two script.
This file contains hidden or 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/sh | |
echo " #${0} begin" | |
echo " echo \$WORKING_DIR" | |
echo " ${WORKING_DIR}" | |
echo " #${0} end" |
This file contains hidden or 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/sh | |
echo "#${0} begin" | |
echo "WORKING_DIR=\$(cd \$(dirname "\${0}"); pwd)" | |
WORKING_DIR=$(cd $(dirname "${0}"); pwd) | |
echo "./callee.sh" | |
./callee.sh # Run in subshell. The variable not shared. | |
echo "source callee.sh" | |
source callee.sh # The variable shared. | |
# . callee.sh # Same as source | |
echo "#${0} end" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment