[clug] Amusing little /bin/sh question..

Peter Barker pbarker at barker.dropbear.id.au
Wed May 23 07:22:14 GMT 2007


On Wed, 23 May 2007, Andrew Janke wrote:

> Thanks for the quick replies...
>
> I forgot one (rather) crucial bit...  I want to find out what somevar
> is but I dont want to run the script itself (thus the set -n
> fiddling).

Well... in that case, I think you'll need to decide on what assumptions 
you can make about a.sh's behaviour - otherwise you're going to hit 
computability issues.

IF you are willing to assume that the variable is simply set with
somevar="foo", running a regex over the file to get the value is an 
easy-enough way to get the value.

Is it possible to rearrange the files in question? In that case you can 
split off something akin to a "config file".  Put the assignment in the 
config file, source the config file from both a.sh and b.sh.

> a

Yours,
-- 
Peter Barker                          |   N    _--_|\ /---- Barham, Vic
Programmer,Sysadmin,Geek              | W + E /     /\
pbarker at barker.dropbear.id.au         |   S   \_,--?_*<-- Canberra
You need a bigger hammer.             |             v    [35S, 149E]
"Peter is apathetic, and I'm vaguely apathetic" -- Rachel, thinking of organising a movie trip


More information about the linux mailing list