user2225483
user2225483

Reputation: 109

Bash, use export and run export in single script

#!/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.

Upvotes: 0

Views: 262

Answers (2)

Barmar
Barmar

Reputation: 780974

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"

Upvotes: 0

William Pursell
William Pursell

Reputation: 212248

I believe you are just looking for:

bash -c "$foo"

Upvotes: 1

Related Questions