From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1012a6,f7f68e18cfb8d31b X-Google-Attributes: gid1012a6,public X-Google-Thread: fa528,f7f68e18cfb8d31b X-Google-Attributes: gidfa528,public X-Google-ArrivalTime: 2003-12-11 10:24:35 PST Path: archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!zeus.visi.com!priapus.visi.com!orange.octanews.net!news.octanews.net!news-out.visi.com!petbe.visi.com!newsfeeds-atl2!news.webusenet.com!elnk-atl-nf1!newsfeed.earthlink.net!cyclone.tampabay.rr.com!news-post.tampabay.rr.com!twister.tampabay.rr.com.POSTED!53ab2750!not-for-mail From: Joseph Dionne Reply-To: Joseph User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.unix.shell,comp.unix.tru64 Subject: Re: Unexpected result from grep References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Thu, 11 Dec 2003 18:24:35 GMT NNTP-Posting-Host: 24.73.214.242 X-Complaints-To: abuse@rr.com X-Trace: twister.tampabay.rr.com 1071167075 24.73.214.242 (Thu, 11 Dec 2003 13:24:35 EST) NNTP-Posting-Date: Thu, 11 Dec 2003 13:24:35 EST Organization: RoadRunner - Tampa Bay Xref: archiver1.google.com comp.unix.shell:3330 comp.unix.tru64:11028 I have noticed that the Tru64 version of ksh is not a true Korn shell. Is the source code available. Has anyone else noticed any differences? Stephane CHAZELAS wrote: > 2003-12-11, 08:13(-08), Dan: > [...] > >>typeset -r COMMAND='/sbin/grep' > > > a command is either a simple command that can be represented as > a list of arguments, so with an *array* type variable, or a more > complex one, that needs to be a string to be evaluated though > the "eval" builtin. or a very very simple command that only > consists of one 0th arg, in which case you can use a string, but > you should rather name that variable PROG_PATH or even GREP_PATH > or GREP as it appears that you need a grep-like program. > > >>typeset -r EXPRESSION="${1}" >>typeset -r CHECK_FILE="${2}" >>typeset RESULT='' >> >>RESULT="$(${COMMAND} -E \'${EXPRESSION}\' ${CHECK_FILE} 2>/dev/null)" > > > Once a variable is left unquoted, word splitting and filename > generation is performed, that's not what you want. Moreover, > even if '$EXPRESSION' is a single word that expands to no > filename, that will seach for 'the-expression' (with the single > quotes), not the-expression. > > > set -A EGREP /sbin/grep -E > RESULT=$( > "${EGREP[@]}" -- "$EXPRESSION" "$CHECK_FILE" 2> /dev/null > ) > > or > > COMMAND='/sbin/grep -E -- "$EXPRESSION" "$CHECK_FILE" 2> /dev/null' > RESULT=$(eval "$COMMAND") > > GREP=/sbin/grep > RESULT=$( > "$GREP" -E -- "$EXPRESSION" "$CHECK_FILE" 2> /dev/null > ) > >