Afficher un message
Vieux 16/05/2007, 23h56   #1
Farid Hamjavar
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Capturing 'unbound variable' error (fwd)


Hello,

Thanks for the prompt response.

I apologize if my writing was not clear.


Let's try again:



****************************

% ./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




Thanks,
Farid








---------- Forwarded message ----------
Date: Wed, 16 May 2007 20:19:56 GMT
From: Bill Marcum <marcumbill@bellsouth.net>
Newsgroups: comp.unix.shell
Subject: Re: Capturing 'unbound variable' error

On Wed, 16 May 2007 12:26:49 -0600, Farid Hamjavar
<hamjavar@unm.edu> wrote:
>
>
>
> Hello,
>
>
> In bash/sh environment I use 'set -u' to catch
> unset variables.
>
> I have:
>
> envcfg=${EnvRootDir}/instance/env_path.cfg
> . ${envcfg} > ${errmsgs} 2>&1
>
>
>
> Neither checking the value of $? nor redirecting
> the output let me catch the 'unbound variable' error
> produced by sourcing ${envcfg}
>
>
> How do I catch the errors in above scenario?
>

[ -f $envcfg ] || { echo "cfg file not found" >&2; exit ; }

Where will the error messages go if ${errmsgs} is not valid? Perhaps you
should use a default value like
${errmsgs:-$HOME/my_errors}


--
A shortcut is the longest distance between two points.
  Réponse avec citation
 
Page generated in 0,06080 seconds with 9 queries