From: Joseph Dionne <jdionne@hotmail.com>
Subject: Re: Unexpected result from grep
Date: Thu, 11 Dec 2003 18:24:35 GMT [thread overview]
Message-ID: <DD2Cb.62750$%h4.33767@twister.tampabay.rr.com> (raw)
In-Reply-To: <slrnbth7sr.3v.stephane.chazelas@spam.is.invalid>
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
> )
>
>
next prev parent reply other threads:[~2003-12-11 18:24 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 [this message]
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
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