From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by archone.tamu.edu id <18888>; Sat, 1 Feb 1992 11:49:11 -0600 From: Byron Rakitzis To: rc Subject: Re: Match operator puzzlement Message-Id: <92Feb1.114911cst.18888@archone.tamu.edu> Date: Sat, 1 Feb 1992 11:49:02 -0600 Hm. I think I can do a little better than John here. The two following sed substitutions should be ok to quote all characters in a word except the metacharacters *, ? and [. The sed scripts will FAIL if there are single quotes in the input, but I'm sure there's a way around that problem too, I just haven't thought of a good way yet. Anyway: First you turn all single non-meta characters into quoted characters: sed 's/\([^[*?]\)/''\1''/g' # using rc's quoting rules, of course. e.g., "Hello?" goes to "'H''e''l''l''o'?" Now you need to remove all '' sequences: sed 's/''''//g' Now "Hello?" becomes "'Hello'?", which is exactly what we want. Not bad. (BTW, I think I can prove by induction that this method works for all strings which do not contain a ', but I do not have enough room to write the proof here :-) So the ~ example becomes something like: eval ~ 'subject' `{echo $funky_pattern | sed garbage}