* [9fans] p9p mk(1) syntax
@ 2013-09-06 14:37 dexen deVries
0 siblings, 0 replies; 9+ messages in thread
From: dexen deVries @ 2013-09-06 14:37 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
in p9p mk, this works as expected:
foo = `{echo bar}
but the following does not -- rc(1) indicates syntax error:
foo = `{echo `{echo bar}}
strace indicates that mk(1) passes input to rc(1) with no closing braces at
all.
i'm using MKSHELL = rc.
--
dexen deVries
[[[↓][→]]]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [9fans] p9p mk(1) syntax
2013-09-09 4:30 ` arisawa
@ 2013-09-09 12:37 ` erik quanstrom
0 siblings, 0 replies; 9+ messages in thread
From: erik quanstrom @ 2013-09-09 12:37 UTC (permalink / raw)
To: 9fans
> single quotes are escaped?
yes.
- erik
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [9fans] p9p mk(1) syntax
2013-09-07 16:21 ` erik quanstrom
@ 2013-09-09 4:30 ` arisawa
2013-09-09 12:37 ` erik quanstrom
0 siblings, 1 reply; 9+ messages in thread
From: arisawa @ 2013-09-09 4:30 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
single quotes are escaped?
On 2013/09/08, at 1:21, erik quanstrom <quanstro@quanstro.net> wrote:
> On Sat Sep 7 11:07:06 EDT 2013, cinap_lenrek@gmx.de wrote:
>> why not this?
>>
>> + if(term == '}' && c == '{')
>> + depth++;
>
> this is a better idea, since it would properly deal with
> z=`{x=y {echo $x}}
>
> - erik
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [9fans] p9p mk(1) syntax
2013-09-07 15:05 ` cinap_lenrek
2013-09-07 16:18 ` dexen deVries
@ 2013-09-07 16:21 ` erik quanstrom
2013-09-09 4:30 ` arisawa
1 sibling, 1 reply; 9+ messages in thread
From: erik quanstrom @ 2013-09-07 16:21 UTC (permalink / raw)
To: 9fans
On Sat Sep 7 11:07:06 EDT 2013, cinap_lenrek@gmx.de wrote:
> why not this?
>
> + if(term == '}' && c == '{')
> + depth++;
this is a better idea, since it would properly deal with
z=`{x=y {echo $x}}
- erik
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [9fans] p9p mk(1) syntax
2013-09-07 15:05 ` cinap_lenrek
@ 2013-09-07 16:18 ` dexen deVries
2013-09-07 16:21 ` erik quanstrom
1 sibling, 0 replies; 9+ messages in thread
From: dexen deVries @ 2013-09-07 16:18 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
thanks to you both.
http://github.com/dexen/plan9port-custom/commit/6a67d4d8c97bc682737ae1cf59544fb4c969a105.patch
cinap's version also supports rc block statements; tested with:
MKSHELL = rc
foo = `{ echo aaa; { date; }; pwd; }
bar = `{ echo zzz `{ date } zzz }
test:VQ:
echo foo $foo
echo bar $bar
On Sat, Sep 7, 2013 at 5:05 PM, <cinap_lenrek@gmx.de> wrote:
> why not this?
>
> + if(term == '}' && c == '{')
> + depth++;
>
> --
> cinap
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [9fans] p9p mk(1) syntax
2013-09-07 13:52 ` erik quanstrom
@ 2013-09-07 15:05 ` cinap_lenrek
2013-09-07 16:18 ` dexen deVries
2013-09-07 16:21 ` erik quanstrom
0 siblings, 2 replies; 9+ messages in thread
From: cinap_lenrek @ 2013-09-07 15:05 UTC (permalink / raw)
To: 9fans
why not this?
+ if(term == '}' && c == '{')
+ depth++;
--
cinap
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [9fans] p9p mk(1) syntax
2013-09-07 8:22 ` Friedrich Psiorz
@ 2013-09-07 13:52 ` erik quanstrom
2013-09-07 15:05 ` cinap_lenrek
0 siblings, 1 reply; 9+ messages in thread
From: erik quanstrom @ 2013-09-07 13:52 UTC (permalink / raw)
To: 9fans
On Sat Sep 7 04:23:05 EDT 2013, f.psiorz@gmx.de wrote:
> I don't think that the behavior is really unexpected ... the `{...} part
> is interpreted by mk, but not the text between the braces. You probably
> need to quote it if it contains braces itself.
>
after looking at the code, it appears to me that this is an oversight,
that does not effect bourne-shell compatabiles. we simply need to
count the `{s and subtract the }s, and when the count reachs 0
we're done.
(it appears that ' quoting is incorrect for bourne shell compatables,
and the interpretation of \ is incorrect for rc.)
- erik
; diffy -c lex.c
/n/dump/2013/0907/sys/src/cmd/mk/lex.c:67,73 - lex.c:67,73
static int
bquote(Biobuf *bp, Bufblock *buf)
{
- int c, line, term;
+ int c, line, term, depth;
int start;
line = mkinline;
/n/dump/2013/0907/sys/src/cmd/mk/lex.c:79,88 - lex.c:79,91
;
} else
term = '`'; /* sh style */
+ depth = 1;
start = buf->current-buf->start;
for(;c > 0; c = nextrune(bp, 0)){
- if(c == term){
+ if(term == '}' && c == '`')
+ depth++;
+ if(c == term && --depth == 0){
insert(buf, '\n');
insert(buf,0);
buf->current = buf->start+start;
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [9fans] p9p mk(1) syntax
2013-09-06 11:03 dexen deVries
@ 2013-09-07 8:22 ` Friedrich Psiorz
2013-09-07 13:52 ` erik quanstrom
0 siblings, 1 reply; 9+ messages in thread
From: Friedrich Psiorz @ 2013-09-07 8:22 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
I don't think that the behavior is really unexpected ... the `{...} part
is interpreted by mk, but not the text between the braces. You probably
need to quote it if it contains braces itself.
Am 06.09.2013 13:03, schrieb dexen deVries:
> in p9p mk, this works as expected:
> foo = `{echo bar}
>
> but the following does not -- rc(1) indicates syntax error:
> foo = `{echo `{echo bar}}
>
>
> strace indicates that mk(1) passes input to rc(1) with no closing braces at
> all.
>
>
> i'm using MKSHELL = rc.
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [9fans] p9p mk(1) syntax
@ 2013-09-06 11:03 dexen deVries
2013-09-07 8:22 ` Friedrich Psiorz
0 siblings, 1 reply; 9+ messages in thread
From: dexen deVries @ 2013-09-06 11:03 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
in p9p mk, this works as expected:
foo = `{echo bar}
but the following does not -- rc(1) indicates syntax error:
foo = `{echo `{echo bar}}
strace indicates that mk(1) passes input to rc(1) with no closing braces at
all.
i'm using MKSHELL = rc.
--
dexen deVries
[[[↓][→]]]
Take care of the luxuries and the necessities will take care of themselves.
-- L. Long
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2013-09-09 12:37 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-06 14:37 [9fans] p9p mk(1) syntax dexen deVries
-- strict thread matches above, loose matches on Subject: below --
2013-09-06 11:03 dexen deVries
2013-09-07 8:22 ` Friedrich Psiorz
2013-09-07 13:52 ` erik quanstrom
2013-09-07 15:05 ` cinap_lenrek
2013-09-07 16:18 ` dexen deVries
2013-09-07 16:21 ` erik quanstrom
2013-09-09 4:30 ` arisawa
2013-09-09 12:37 ` erik quanstrom
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).