in reply to simulating bash
If I need to, I can pass it through bash. I just don't know how (with the ability to get the values back).
You have sparked a fascinating discussion, making me wonder whether "only bash can parse a bash script"...
Meanwhile, you could get bash to do the work for you, I think, if you try the following steps:
Maybe you want to redirect the output of that to a file. Note that the output will include everything in your current shell environment, along with everything declared by the bash script. If you also run a one-liner like this:perl -e '$env = `your_bash_script.file`; print $env,$/'
and compare that output to the one involving your bash script, you'll be able to "subtract out" the "ambient environment", and isolate the stuff that comes from the script.perl -e '$env = `bash -c env`; print $env,$/'
There might be other ways to do the same thing, but this was the first one I found (and I'll confess it took several iterations to figure it out).
UPDATE: Just putting "env" at the end entails a simplistic assumption that the bash script will execute more or less linearly from top to bottom. But if there are multiple points in the script where processing could end under different conditions (and especially if more than one of these exit points qualifies as "success"), you would need to add the "env" command at every such point. Good luck with that...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: simulating bash
by agaffney (Beadle) on May 15, 2004 at 05:01 UTC | |
by graff (Chancellor) on May 15, 2004 at 06:01 UTC |