[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: weird problem -- path interpretted/eval'd as numeric expression

From: Greg Wooledge
Subject: Re: weird problem -- path interpretted/eval'd as numeric expression
Date: Wed, 27 Mar 2013 15:52:35 -0400
User-agent: Mutt/

On Wed, Mar 27, 2013 at 12:17:21PM -0700, Linda Walsh wrote:
> dcl -xa _FPATH

Arrays cannot be exported.  The bash manual explicitly says so:

      Array variables may not (yet) be exported.

> } | ( ((!(remove||expire))) && hsort -s || cat)

Use of the && and || operators together as a "shorthand" for if/then/else
is dangerous.  If the hsort command returns failure, the cat command
will ALSO be executed.


Use an if command instead:

... } | if (( !(remove||expire) )); then hsort -s; else cat; fi

Or even better:

... } | if ((remove||expire)); then cat; else hsort -s; fi

Apart from those two things, I didn't really read the code.  It was
quite a bit larger than I expected.  Those two problems were just the
first ones I found.

You may find it helpful to use "set -x" on the section of the code from
which the error message is originating.  Seeing the expanded command that
generates the message may be sufficient to identify the error (assuming
it's your error and not bash's).  If it turns out to be a bug in bash,
then having a smaller piece of code that can reproduce the bug will be

reply via email to

[Prev in Thread] Current Thread [Next in Thread]