0
#!/bin/bash
export foo='script...'

bash --program=foo

how do you run the exported "foo"
i've been working with gtkdialog and it is written

#!/bin/bash
export MAIN_DIALOG='...xml code...'

gtkdialog --program=MAIN_DIALOG

the same should be possible with a simple bash script?
i would like this to reduce the number of files i must include
currently each set of bash scripts i write for one program are saved in separate files then executed by the main script.

2
  • If the program is in the current working directory then it's judt ./$foo Commented Mar 29, 2013 at 19:24
  • gtkdialog --program="${MAIN_DIALOG}" ought to do it. Commented Mar 29, 2013 at 19:27

2 Answers 2

1

I believe you are just looking for:

bash -c "$foo"
Sign up to request clarification or add additional context in comments.

Comments

0

To reduce the number of files, you can change the commands from separate scripts to functions in the main script:

cmd() {
  # actions for foo command
}

Then, instead of using bash -c to run them, you can use eval:

foo='cmd ...'

eval "$foo"

Comments

Your Answer

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.