[LEDE-DEV] [patch master 01/15] Double quote to prevent globbing and word splitting

Lars Kruse lists at sumpfralle.de
Sun Oct 2 05:19:29 PDT 2016


Hello Oswald,


Am Sat, 1 Oct 2016 09:35:47 +0200
schrieb Oswald Buddenhagen <oswald.buddenhagen at gmx.de>:

> On Fri, Sep 30, 2016 at 11:50:09PM +0200, Lars Kruse wrote:
> > Am Fri, 30 Sep 2016 22:02:15 +0200 schrieb Jan-Tarek Butt <tarek at ring0.de>:  
>  [...]  
> > 
> > Just out of curiosity: do you know, what could be the purpose of the "eval"
> > construct above?
> > I would assume that:
> >  for pattern in $spec; do
> > behaves exactly like:
> >  for pattern in $(eval echo $spec); do
> >   
> nope. $spec may contain brace expansions, which would not be processed
> without the eval. (note that regular file globs *are* processed even
> without it).

Good to know - I missed this, since I never used eval in my code. Thanks!
Given the broad effects that "eval" could expose (e.g. command substition), I
will probably stick to not using it myself :)


> fwiw, i also used $(eval echo $foo) for whitespace normalization before.
> ugly, but short and effective.

"ugly", I agree :)
Probably "${foo//  / }" would be easier to understand and clearer in its scope.
But having a commented usage of "eval" obviously qualifies as "readable", as
well ...

Cheers,
Lars



More information about the Lede-dev mailing list