On Wednesday, October 13, 2010 03:08:24 Vaeth wrote:
> Mike Frysinger wrote:
> > > for foo in ${ROOT}/etc/openvpn/*/local.conf; do
> > > 
> > >   [ -e ${foo} ] && bar ${foo}
> > > 
> > > done
> > 
> > i'd say doing a loop is worse than a `ls` hack.
> 
> Why do you think so? No external program on which you must rely,
> and if you put a "break" in there, the loop is just syntactical.
> Here is another possibility if you do not need positional
> parameters anymore:
> 
> set -- "${ROOT}"/etc/openvpn/*/local.conf
> if test -e "${1}"
> then ...
> fi
> 
> And if you do need, you can write a function:
> 
> Test2() {
>       test "${1}" "${2}"
> }
> 
> if Test2 -e "${ROOT}"/etc/openvpn/*/local.conf
> then ...
> fi

relying on an external program to get a single line of readable code is better 
than multiple lines of code that attempt to do the same thing.  your further 
examples here are even worse on many levels.
-mike

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to