|
Home > Archive > Unix Shell > November 2006 > is it possible to source stdout [of some command] in current shell
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
is it possible to source stdout [of some command] in current shell
|
|
|
| I have command that prints shell variable assignments like this:
perl -e 'print "SIZE=......"'. I am sourcing the resulting assignments
like this:
perl -e 'print "SIZE=......" >$tmpfile
. $tmpfile # which sets shell variable SIZE
This works, but I wonder if it's possible to do it without
tempfile ? I believe it's possible to fo with fifos, but
i don't really like fifos because they need later cleanup anyway ...
Thanks
Yakov
| |
| Stephane CHAZELAS 2006-11-21, 7:24 am |
| 2006-11-21, 02:20(-08), Yakov:
> I have command that prints shell variable assignments like this:
> PERL -e 'print "SIZE=......"'. I am sourcing the resulting assignments
> like this:
> PERL -e 'print "SIZE=......" >$tmpfile
> . $tmpfile # which sets shell variable SIZE
> This works, but I wonder if it's possible to do it without
> tempfile ? I believe it's possible to fo with fifos, but
> i don't really like fifos because they need later cleanup anyway ...
[...]
Source stdin:
eval "$(cat)"
source a command output
eval "$(cmd)"
eval "$(
printf '%s="%s"\n' \
SIZE 1 \
foo 2
)"
--
Stéphane
| |
|
| Stephane CHAZELAS wrote:
> 2006-11-21, 02:20(-08), Yakov:
> [...]
>
> Source stdin:
>
> eval "$(cat)"
>
> source a command output
>=20
> eval "$(cmd)"
Thanks St=E9phane, that's perfect.
Yakov
|
|
|
|
|