Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Exporting variable from within a variable



Hi,

Apologies for the somewhat ambiguous title, but this is quite hard to succinctly describe. Let's say that I have a variable that contains the string
  export FOO=foo
How do I get that to actually export the variable?

In other words, why does the following script, when run, not set the environment variable?

  % cat ./test
  #!/usr/bin/env

  FOO="export BAR=bar"
  `${FOO}`
  % ./test
  ./test:1: command not found: export BAR=bar

I have a suspicion that this has got something to do with forking and the environment within which the command is run.

Thanks in advance for any pointers.

Regards,
Andrew Ho

Attachment: pgpvYyEG8yhda.pgp
Description: PGP signature



Messages sorted by: Reverse Date, Date, Thread, Author