This is for Dash, Bash, and Zsh. For DOS, see Batch file programming.
See:
Table of Contents [hide]
Getting variables from another script in dash (not bash) ∞
dash 0.5.7-4+b1
The commandline:
a= echo "commandline is un-set (1): $a"
Contents of script_one.sh
#!/usr/bin/env sh echo "script_one.sh is un-set: $a" a="VARIABLE HAS CONTENT" echo "script_one.sh is now set to: $a"
Contents of script_two.sh
#!/usr/bin/env sh echo "script_two.sh is un-set: $a" . ./script_one.sh echo "script_two.sh is set: $a"
The commandline:
a= echo "commandline is un-set (2): $a" . ./script_two.sh echo "commandline is set (3): $a"
Last updated 2019-11-21 at 05:08:59
removed things which are hosted on github.