9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] quouteing(?) problems in rc
@ 2008-01-30 12:18 Bengt Kleberg
  2008-01-30 13:04 ` roger peppe
  0 siblings, 1 reply; 2+ messages in thread
From: Bengt Kleberg @ 2008-01-30 12:18 UTC (permalink / raw)
  To: 9fans

Greetings,

I am using rc from plan9port on Linux and I am trying to construct a grep
command. This is what I have so far:

	file = nibsRouteMib.erl
	func = create_ok
	echo		grep -n -e '''' ^  '^' ^ $func ^ '''' $file /dev/null
	grep -n -e '''' ^  '^' ^ $func ^ '''' $file /dev/null

The echo is only there to test what the command looks like. If I run
the above lines I get:

grep -n -e '^create_ok' nibsRouteMib.erl /dev/null
file: exit 1


If I run the line I got from the echo (grep -n -e '^create_ok'
nibsRouteMib.erl /dev/null) I get:

nibsRouteMib.erl:522: create_ok( Row_index, _Columns ) ->


Since the echo'ed line works fine but not the very similar line below, I
must have made a mistake somewhere and wonder if somebody can spot it and
tell me?


bengt

-- 
Those were the days...
   EPO guidelines 1978: "If the contribution to the known art resides
   solely in a computer program then the subject matter is not
   patentable in whatever manner it may be presented in the claims."


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [9fans] quouteing(?) problems in rc
  2008-01-30 12:18 [9fans] quouteing(?) problems in rc Bengt Kleberg
@ 2008-01-30 13:04 ` roger peppe
  0 siblings, 0 replies; 2+ messages in thread
From: roger peppe @ 2008-01-30 13:04 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

>         grep -n -e '''' ^  '^' ^ $func ^ '''' $file /dev/null

your problem is that you're constructing a list containing quotes
suitable for input to the shell, but you really want to construct
a list containing values suitable for arguments to grep.
i think what you want is:

grep -n -e '^'^$func $file /dev/null

which of course will only work correctly if $func contains no
regexp metacharacters, but i'm sure you know that.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-01-30 13:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-30 12:18 [9fans] quouteing(?) problems in rc Bengt Kleberg
2008-01-30 13:04 ` roger peppe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).