is '!' a metacharacter in regexes? regex(6) doesn't say anything about it.



2014-04-23 9:29 GMT+02:00 Alexander Kapshuk <alexander.kapshuk@gmail.com>:
Turns out, the reason why writing '/[A-Z]+\![a-z0-9]+\![0-9a-z]+' to
/dev/$winid/addr would fail for me is because sending a string
represented by the regular expression in question to /dev/$winid/body
was immediately followed by writing the regexp to addr. Putting a
while loop on the 'echo regexp >addr' followed by sleep, seems to have
been the answer. The script sets the prompt and the name of the window
running win when logged onto a UNIX machine.
Here's the script for those interested.

#!/bin/rc
{
 echo 'echo $SYSNAME!`uname -n`!$USER'
 echo 'PS1='':; '' PS2='' '''
} >/dev/$winid/body
while(! echo -n '/[A-Z]+\![a-z0-9]+\![0-9a-z]+' >/dev/$winid/addr >[2]/dev/null)
 sleep 0.2
sel=`{cat /dev/$winid/xdata}
echo name $sel >/dev/$winid/ctl

On Tue, Apr 22, 2014 at 4:53 PM, Alexander Kapshuk
<alexander.kapshuk@gmail.com> wrote:
> Howdy,
>
> I'm working on a script where I want to get hold of a particular string
> and use it as a new name of a particular window.
>
> What I've tried so far, although not successfully, is writing to
> /dev/$winid/addr with the intention of then being able to read the
> string found from the /dev/$winid/data or /dev/$winid/xdata.
>
> acme(4) says,
> addr        may be written with any textual address (line number,
>                regular expression, etc.), in the format understood by
>                button 3 but without the initial colon, including com-
>                pound addresses, to set the address for text accessed
>                through the data file.
>
> Here's an example of what I tried.
> echo '/[A-Z]+\![a-z0-9]+\![0-9a-z]+' >/dev/$winid/addr
>
> Which results in an 'address out of bounds' message being generated.
>
> How does one write to 'addr'? Clearly, the shortcoming is on my part.
> I'm just not sure what it is that's missing.
>
> Thanks.
>