From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: <09DB2D65-A18A-493E-9886-2D5D3334F460@corpus-callosum.com> References: <09DB2D65-A18A-493E-9886-2D5D3334F460@corpus-callosum.com> Date: Tue, 10 Aug 2010 10:10:51 -0300 Message-ID: From: "Federico G. Benavento" To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [9fans] regexp metacharacter difficulty inside grap Topicbox-Message-UUID: 469733b0-ead6-11e9-9d60-3106f5b1d025 this is probably related to the fact that grap(1) is an APE program, and sh actually execs sh, not rc... On Tue, Aug 10, 2010 at 2:23 AM, Jeff Sickel wrot= e: > I've been trying to figure out this little one for a while now and figure= I could use a refresher course in regexp. > > There are quite a few files that I'm trying to copy through grap that wou= ld be really easy if I could take a line like: > > =C2=A0 =C2=A0 =C2=A0 =C2=A0# (Yo 4.9534) > > and turn it into a value for x,y graphing. =C2=A0Unfortunately, I'm compl= etely blanking out on how to get that pesky ')' stripped out. =C2=A0I try t= he following: > > =C2=A0 =C2=A0 =C2=A0 =C2=A0if "$2" =3D=3D "(Yo" then { > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0print sprintf("Yo = was %f", yo) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 yo =3D sh { echo = $3 | sed 's/\)#//' } > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 print sprintf("Yo= is %f", yo) > =C2=A0 =C2=A0 =C2=A0 =C2=A0} > > but that just gives me: > > =C2=A0 =C2=A0 =C2=A0 =C2=A0cpu% eval `{doctype t.g} | lp -dstdout > t.ps > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Yo was 8.579000 > =C2=A0 =C2=A0 =C2=A0 =C2=A0rc: line 2: token ')': syntax error > =C2=A0 =C2=A0 =C2=A0 =C2=A0grap: syntax error???: No such file or directo= ry > =C2=A0 =C2=A0 =C2=A0 =C2=A0 near 20100809_pscheck_XX.d:8 > =C2=A0 =C2=A0 =C2=A0 =C2=A0 context is > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0yo =3D sh { echo 4= .9534)# | sed 's/\)#//' } >>> <<< > > > I'm not quite sure why grap converts $3 into "4.9534)#", so I try brute f= orce: > > =C2=A0 =C2=A0 =C2=A0 =C2=A0cpu% echo '4.9534)#' | sed 's/\)#//' > =C2=A0 =C2=A0 =C2=A0 =C2=A04.9534 > > > Does anyone have any hints on what might I be doing wrong in my grap sour= ce? > > -jas > > > --=20 Federico G. Benavento