From: Stephane CHAZELAS <this.address@is.invalid>
Subject: Re: Unexpected result from grep
Date: Wed, 24 Dec 2003 17:41:54 +0100 [thread overview]
Message-ID: <slrnbujgei.ab.stephane.chazelas@spam.is.invalid> (raw)
In-Reply-To: brvm26$ef0$1@jeeves.eng.abbnm.com
2003-12-19, 20:11(+00), Peter da Silva:
[...]
> COMMAND=/sbin/grep
>
> RESULT="`"$COMMAND" -E "$1" "$2" 2>/dev/null`"
>
> And it would work in any bourne-based shell
No, not with the Bourne shell or ksh (except pdksh) to start
with, where you need:
RESULT="`\"$COMMAND\" -E \"$1\" \"$2\" 2>/dev/null`"
(which, according to the autoconf documentation wouldn't work
with some shells, but I don't know which ones they are refering
to << info -f autoconf -n 'Shell Substitutions' >>, "There is
just no portable way to use double-quoted strings inside
double-quoted back-quoted expressions").
or simply:
RESULT=`"$COMMAND" -E "$1" "$2" 2>/dev/null`
The outer quotes are not necessary here.
The `...` command substitution is a portability nightmare, use
$(...) instead if you only need POSIX portability (actually, if
you don't need compatibility to the Bourne shell, as every
other Bourne-like shell (including ash) supports it).
[...about shell portability...]
> It's not that hard, and it does pay off.
See info -f autoconf -n 'Portable Shell'
That's not that easy.
--
Stᅵphane ["Stephane.Chazelas" at "free.fr"]
next prev parent reply other threads:[~2003-12-24 16:41 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-12-11 16:13 Unexpected result from grep Dan
2003-12-11 16:32 ` Jens Schweikhardt
2003-12-11 16:37 ` Chris F.A. Johnson
2003-12-11 16:47 ` Stephane CHAZELAS
2003-12-11 18:24 ` Joseph Dionne
2003-12-12 13:19 ` Dan
2003-12-19 20:11 ` Peter da Silva
2003-12-20 16:13 ` Dan Mercer
2003-12-22 21:14 ` Peter da Silva
2003-12-23 16:01 ` Dan Mercer
2003-12-23 21:01 ` Peter da Silva
2003-12-23 22:15 ` Dan Mercer
2003-12-25 22:29 ` Peter da Silva
2003-12-24 16:41 ` Stephane CHAZELAS [this message]
2003-12-25 22:15 ` Peter da Silva
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox