From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII X-Google-Thread: fa528,f7f68e18cfb8d31b X-Google-Attributes: gidfa528,public X-Google-Thread: 1012a6,f7f68e18cfb8d31b X-Google-Attributes: gid1012a6,public X-Google-ArrivalTime: 2003-12-24 08:42:37 PST Path: archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!news-out.visi.com!petbe.visi.com!proxad.net!proxad.net!feeder2-1.proxad.net!news4-1.free.fr!not-for-mail Newsgroups: comp.unix.shell,comp.unix.tru64 From: Stephane CHAZELAS Subject: Re: Unexpected result from grep References: Mail-Copies-To: nobody Date: Wed, 24 Dec 2003 17:41:54 +0100 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 8bit User-Agent: slrn/0.9.8.0 (Linux) Organization: Guest of ProXad - France NNTP-Posting-Date: 24 Dec 2003 17:42:36 MET NNTP-Posting-Host: 62.147.74.73 X-Trace: 1072284156 news4-1.free.fr 29076 62.147.74.73:1119 X-Complaints-To: abuse@proxad.net Xref: archiver1.google.com comp.unix.shell:3825 comp.unix.tru64:11060 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"]