I'd like to do something like this:
from ./script.sh import VARIABLE # <-- python style
(without changing script.sh)
asked Nov 16, 2013 at 20:04
Alexander Aleksandrovič Klimov
7466 silver badges18 bronze badges
-
1this is not possible as you have described it. you could export the variable, but it would likely require modifying your script.doublesharp– doublesharp2013年11月16日 20:06:22 +00:00Commented Nov 16, 2013 at 20:06
-
is the importing script python or bash?shx2– shx22013年11月16日 20:23:57 +00:00Commented Nov 16, 2013 at 20:23
1 Answer 1
Not exactly the same thing, but this works:
source ./script.sh
echo "VARIABLE=${VARIABLE}."
Shorter form:
. ./script.sh
echo "VARIABLE=${VARIABLE}."
This might not be desired as this will execute any code that is not in functions inside script.sh.
answered Nov 16, 2013 at 20:11
cforbish
8,8993 gold badges32 silver badges32 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
default