Unix Shell - Re: Capturing 'unbound variable' error (fwd)

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > May 2007 > Re: Capturing 'unbound variable' error (fwd)





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 Re: Capturing 'unbound variable' error (fwd)
Stephane CHAZELAS

2007-05-18, 1:23 pm

2007-05-16, 15:56(-06), Farid Hamjavar:
[...]
> % ./driver.sh
> ./instance/env_path.cfg: line 58: EnvGGGZIP: unbound variable
>
> ****************************
>
>
> Such 'unbound variable' errors, like the one
> above, viewable ONLY on interactive shell session.
>
>
> I like to detect that inside a script (e.g. driver.sh)
>
>
> Inside driver.sh I have a line:
>
> . env_path.cfg

[...]

There's not much you can do. "." causes the code in the
corresponding shell to be executed by the current shell process.
If there's something that causes an exit there, then that exits
the whole shell.

You could do things like:

if code=$(
. env_path.cfg
set
export
) && eval "$code"; then
echo went fine
else
echo did not go fine
fi

(untested)


--
Stéphane
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com