bug-bash
[Top][All Lists]
Advanced

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

Re: OT: shell bug?


From: Paul Jarc
Subject: Re: OT: shell bug?
Date: Thu, 06 Mar 2003 17:40:33 -0500
User-agent: Gnus/5.090015 (Oort Gnus v0.15) Emacs/21.2 (i686-pc-linux-gnu)

"Robert Anderson" <address@hidden> wrote:
> prune_dirs="{arch}"
> prune=
> for dir in $prune_dirs; do
>     prune="$prune -path *${dir}* -prune -o"
> done
> files=`find "$arch_src" $prune -name \*.sh -print &> /dev/null`

man bash, EXPANSION:
       The  order of expansions is: brace expansion, tilde expan­
       sion, parameter, variable  and  arithmetic  expansion  and
       command  substitution  (done  in a left-to-right fashion),
       word splitting, and pathname expansion.

So $prune is substituted in the find command, and then the resulting
*{arch}* wildcard is expanded, instead of being passed verbatim to
find.  Try this instead:

shift "$#"   # or, if you want to be more portable: set -- x; shift
prune_dirs='{arch}'
for dir in $prune_dirs; do
  set -- ${1+"$@"} -path "*$dir*" -prune -o
done
files=`find "$arch_src" ${1+"$@"} -name \*.sh -print`

Side note: I think you actually want "*/$dir" instead of "*$dir*".


paul




reply via email to

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