14
5
Kind of a tricky one to name this...
Basically I have a program which when run prints on STDOUT a set of shell variables:
$ ./settings
SETTING_ONE="this is setting one"
SETTING_TWO="This is the second setting"
ANOTHER_SETTING="This is another setting".
I want to run this from within a shell script as if the STDOUT were being evaluated with source
.
I'd like to do something like ...
source `./settings`
... but of course that doesn't work.
I know I could do:
./settings >/tmp/file
source /tmp/file
but I really don't want to do that.
Any clues?
$( )
doesn't work in heirloom shell (which predates POSIX). – Rufflewind – 2015-08-14T23:31:09.443Sorry, should have mentioned, it's /bin/sh not bash. $() doesn't work. I have updated the question. – Majenko – 2011-04-18T20:19:53.293
@Matt: Well, sh is bash on most systems. Unless of course you meant recent Ubuntu versions, where it has been replaced with dash. – Hello71 – 2011-04-18T20:24:09.863
@Matt: In that case, backticks should work. But you should add the exact version of
sh
too - it could be a symlink to dash, ash, busybox... I have not seen a copy of "the real 'sh'" live. – user1686 – 2011-04-18T20:29:45.8631
@Matt: So you've got an ... interesting system there. Especially since almost all "sh" variations support
– user1686 – 2011-04-18T20:31:35.970$( )
-- starting with Almquist's shell in 4.3BSD -- and it's POSIX too. (Note: not arguing, just curious.)$() exists, it just doesn't work like that in this circumstance. FreeBSD 8.2's /bin/sh – Majenko – 2011-04-18T20:32:56.873
Well, it didn't when I tried it just now - now it does. Strange - must be having a 'moment'... – Majenko – 2011-04-18T20:34:16.563