0

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
2
  • 1
    this is not possible as you have described it. you could export the variable, but it would likely require modifying your script. Commented Nov 16, 2013 at 20:06
  • is the importing script python or bash? Commented Nov 16, 2013 at 20:23

1 Answer 1

3

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.