Re: [9fans] equality sign in Rc
Il 16 Maggio 2017 19:11:33 CEST, Kurt H Maierha scritto: >On Mon, May 15, 2017 at 03:32:09PM -0400, s...@9front.org wrote: >> Honestly, the equality sign is never a problem for me. >> What is the purpose again of making this change? >> >> sl > >Why won't anyone answer this question? Rc run commands ;-) Giacomo
Re: [9fans] equality sign in Rc
imo instead of changing = behavior * and ? should give errors like following if unmatched. rc: #d/0: token '*': syntax error rc: #d/0: token '?': syntax error
Re: [9fans] equality sign in Rc
On Mon, May 15, 2017 at 03:32:09PM -0400, s...@9front.org wrote: > Honestly, the equality sign is never a problem for me. > What is the purpose again of making this change? > > sl Why won't anyone answer this question? Is bikeshedding a minor inconvenience worth this kind of complexity? khm
Re: [9fans] equality sign in Rc
Tonight I've tried this little hack, but I do not have a comprehensive test suite (does any exists?) https://github.com/JehanneOS/jehanne/commit/003141901af25f0bb3556be40b7ff963f57ced32 I thought that there's no reason to mimic sh for this since if you need sh to run a script rc won't work anyway. So this is just a little syntactic sugar, that for the joy of sl is not compatible with sh, but imho it can also increases the readability of scripts. Indeed I agree with sl that expliitness is an advantage of the current quotation rules. The idea is to use a single $ to mark the end of variable declarations, so that what's left can't do assignments, and equality is always quoted. Here some examples: % a=1 echo b=$a rc: #d/0: token '=': syntax error % a=1 $ echo b=$a b=1 % $ eval prefix=$home/foo && echo $prefix /usr/glenda/foo % $ eval prefix=$home/foo; echo ./configure --prefix=$prefix rc: #d/0: token '=': syntax error % $ eval prefix=$home/foo; $ echo ./configure --prefix=$prefix ./configure --prefix=/usr/glenda/foo % inf=/dev/random out=/dev/null $ echo dd if=$inf of=$out dd if=/dev/random of=/dev/null The mini-syntax should extend till the end of a single command: ; & && and || should stop it. Note that it's the first time I use yacc, so probably there is a better way to code this and there are probably bugs. For example I was unable to make this works: % $ echo ./configure --prefix=`{cat /env/prefix} Giacomo 2017-05-16 17:59 GMT+02:00 Erik Quanstrom: > by doing it in the grammar, the redirection issue is avoided. > > - erik > > > On May 16, 2017 2:24 AM, Charles Forsyth > wrote: > > > On 15 May 2017 at 17:44, trebol wrote: > > > = is part of rc syntax, like {} and (), and it interprets it, not the > > > i'd forgotten about the = in >[2=1], so you'd need another exception ... > rc would interpret that, but then in [a-b=] it presumably wouldn't again... > > >
Re: [9fans] equality sign in Rc
by doing it in the grammar, the redirection issue is avoided.- erikOn May 16, 2017 2:24 AM, Charles Forsythwrote:On 15 May 2017 at 17:44, trebol wrote:> = is part of rc syntax, like {} and (), and it interprets it, not thei'd forgotten about the = in >[2=1], so you'd need another exception ...rc would interpret that, but then in [a-b=] it presumably wouldn't again...
Re: [9fans] equality sign in Rc
On 15 May 2017 at 17:44, trebolwrote: > > = is part of rc syntax, like {} and (), and it interprets it, not the i'd forgotten about the = in >[2=1], so you'd need another exception ... rc would interpret that, but then in [a-b=] it presumably wouldn't again...
Re: [9fans] equality sign in Rc
So putting control characters aside, and space wich is not part of an unquoted word, they are just one of "!\"#$%&'()+,-./:;<=>?@[\\]^`{|}~", I'm looking in the wrong file, lex.c? If not, may be that explicit list would be nice in rio(1). I'm going to study the code and shut up my mouth. >> characters of the same type (c>' ' && >> !strchr("!\"#$%&'()+,-./:;<=>?@[\\]^`{|}~", c)) should be skipped too, > > I'm making a mess again... > > the type I'm talking about is chars that don't match that expression, I > suppose that not matching > that expression is what is used for > > "character other than an alphanumeric, underscore, or *". > > trebol.
Re: [9fans] equality sign in Rc
> characters of the same type (c>' ' && > !strchr("!\"#$%&'()+,-./:;<=>?@[\\]^`{|}~", c)) should be skipped too, I'm making a mess again... the type I'm talking about is chars that don't match that expression, I suppose that not matching that expression is what is used for "character other than an alphanumeric, underscore, or *". trebol.
Re: [9fans] equality sign in Rc
> $^x is a syntax error, and not $x. > $^x would be "whatever $ is" concatenated with literal "x" > but "$" by itself is a syntax error That's my point! $-fu should be a syntax error, because is (our should be) equivalent to $^-fu, an incorrect expression. >From rc(1) [...] If an unquoted word immediately follows a $ and contains a character other than an alphanumeric, underscore, or *, a ^ is inserted before the first such character. [...] But rc, I suppose, skip the first char next to $ in the search of a not alphanumeric, not * ... character. If this is not a bug, but a feature, then it must be explained in rc(1), and for me, all the contiguous characters of the same type (c>' ' && !strchr("!\"#$%&'()+,-./:;<=>?@[\\]^`{|}~", c)) should be skipped too, so $--fu would be also correct. For me the best is making $-fu a syntax error, and let the programmer decide if such an awkward name is worthy of typing quotes everywhere. trebol
Re: [9fans] equality sign in Rc
On 15 May 2017 at 19:33, trebolwrote: > $-fu must be equivalent to $^-fu, $^x is a syntax error, and not $x. $^x would be "whatever $ is" concatenated with literal "x" but "$" by itself is a syntax error
Re: [9fans] equality sign in Rc
On 15 May 2017 at 17:44, trebolwrote: > I suppose this is the perfect answer to my silly question: why not permit = > after the start of a command? > do that, but make it behave like = before the start of the command. rc provides the outer syntax for all commands, as it does for file matching and redirection. the commands receive argv[], and (in Plan 9) /env as before. rc puts positional word arguments in argv, which are identified by position, and assignments in /env, which is what it currently does for x=y before a command (or before no command).
Re: [9fans] equality sign in Rc
my purpose was to answer the question posed in the list. iirc, rsc proposed this solution as well. I have to mention that this is no funkier than allowing "echo if", which rc does. I also have to mention that I'm not yet convinced of this change. but it sure is no fun to quote every arg to certain programs.- erik
Re: [9fans] equality sign in Rc
Honestly, the equality sign is never a problem for me. What is the purpose again of making this change? sl
Re: [9fans] equality sign in Rc
> This is not sh, use $'--fu'. > Any way, is this a bug? I mean, following the man page, $-fu must be equivalent to $^-fu, and give a syntax error. The first of those characters (not alphanumeric, or * ...) is skiping the trap! Anyway, I'm out of this conversation: I haven't study the code, so I'm talking rubbish. trebol.
Re: [9fans] equality sign in Rc
Ok, sorry... :-) However what about disallowing '-' as variable's name starting character? It would be a breaking change, but probably more in theory than in practice. However options like -Da=1 and --foo=bar could then work unquoted. To my untrained eye, the gain seems larger than the loss. Am I missing an obvious use case? Or maybe the changes to rc's code would be too complex? Giacomo Il 15/Mag/2017 18:39, "Charles Forsyth"ha scritto: > > On 15 May 2017 at 17:30, Giacomo Tesio wrote: > >> % echo "$--fu" >> rc: null list in concatenation >> > > wrong quotes. try echo $'--fu' > > h% --x=hello > h% echo $'--x' > hello > >
Re: [9fans] equality sign in Rc
On Mon, 15 May 2017 16:59:45 +0100 Charles Forsythwrote: > It would be better then to leave things as they are. > = is part of rc syntax, like {} and (), and it interprets it, not the > commands, unless quoted. I suppose this is the perfect answer to my silly question: why not permit = after the start of a command? As I said, = in command arguments should be prohibited! trebol.
Re: [9fans] equality sign in Rc
> Actually a --fu variable is not that useful in Plan 9: > > % --fu=bar > % echo $--fu > rc: null list in concatenation > % echo "$--fu" > rc: null list in concatenation > % ls /env > '/env/*' > /env/--fu > ... > > So rc can create a variable starting with more than one '-', but can't use it. This is not sh, use $'--fu'. Any way, is this a bug?
Re: [9fans] equality sign in Rc
On 15 May 2017 at 17:30, Giacomo Tesiowrote: > % echo "$--fu" > rc: null list in concatenation > wrong quotes. try echo $'--fu' h% --x=hello h% echo $'--x' hello
Re: [9fans] equality sign in Rc
Actually a --fu variable is not that useful in Plan 9: % --fu=bar % echo $--fu rc: null list in concatenation % echo "$--fu" rc: null list in concatenation % ls /env '/env/*' /env/--fu ... So rc can create a variable starting with more than one '-', but can't use it. So I wonder if there is a definition of "the right thing" that can fix this incongruence and also allow the UNIX usage. Giacomoec 2017-05-15 17:59 GMT+02:00 Charles Forsyth: > > On 15 May 2017 at 16:54, Erik Quanstrom wrote: > >> if we implement the right thing, then arguments like --fu=bar will be >> 'eaten silently' from the perspective of the (human) operator. sure gigo, >> but this seems extra hard o get right in a Unix environment. > > > It would be better then to leave things as they are. > = is part of rc syntax, like {} and (), and it interprets it, not the > commands, unless quoted. >
Re: [9fans] equality sign in Rc
On 15 May 2017 at 16:54, Erik Quanstromwrote: > if we implement the right thing, then arguments like --fu=bar will be > 'eaten silently' from the perspective of the (human) operator. sure gigo, > but this seems extra hard o get right in a Unix environment. It would be better then to leave things as they are. = is part of rc syntax, like {} and (), and it interprets it, not the commands, unless quoted.
Re: [9fans] equality sign in Rc
there is no winning.if we implement the right thing, then arguments like --fu=bar will be 'eaten silently' from the perspective of the (human) operator. sure gigo, but this seems extra hard o get right in a Unix environment.- erikOn May 15, 2017 08:42, Charles Forsythwrote:On 15 May 2017 at 16:37, Erik Quanstrom wrote:I implemented the Unix mistake as this hack is for p9p. I'm not sure I like it. it's interesting to note that = is still not allowed in a list.Great. So now there are two different rc conventions.perhaps {} should be treated specially after the first word so find can be used.
Re: [9fans] equality sign in Rc
On 15 May 2017 at 16:37, Erik Quanstromwrote: > I implemented the Unix mistake as this hack is for p9p. I'm not sure I > like it. it's interesting to note that = is still not allowed in a list. Great. So now there are two different rc conventions. perhaps {} should be treated specially after the first word so find can be used.
Re: [9fans] equality sign in Rc
yes. nothing can break.I implemented the Unix mistake as this hack is for p9p. I'm not sure I like it. it's interesting to note that = is still not allowed in a list.- erikOn May 15, 2017 04:56, Charles Forsythwrote:On 15 May 2017 at 12:54, Charles Forsyth wrote:and = would be handled by rc uniformly.It also wouldn't break anything, because nothing currently can use unquoted =,and things that used quoted = would work just as before.
Re: [9fans] equality sign in Rc
On 15 May 2017 at 12:54, Charles Forsythwrote: > and = would be handled by rc uniformly. It also wouldn't break anything, because nothing currently can use unquoted =, and things that used quoted = would work just as before.
Re: [9fans] equality sign in Rc
On 15 May 2017 at 12:54, Charles Forsythwrote: > = would be handled by rc uniformly. Just as file name patterns are handled by the shell for all commands.
Re: [9fans] equality sign in Rc
The original aim was to implement named parameters that the shell would parse and pass to the command. That was frustrated in UNIX because there was one command (dd) that used = in its syntax. There are no such commands in Plan 9, except mk, but mk is interesting because mk treats those as entries into the environment, so the thing you originally complained about would work without quoting, and = would be handled by rc uniformly. On 15 May 2017 at 12:48, trebolwrote: > Why? the assignment is after the start of the command, so is not an > assignment, > and with the correction of Erik, now rc admit the use of = after the first > word > (in the first would be an assignment), so two=2 is just an argument to > echo, > exactly 'two='2. > > I like this behavior. > > trebol > > > Given > > > >> broken! one=1 two=2 echo $one $two > >> > >> 1 2 > > > > What should the following do? > > > > one=1 echo two=2 $one $two > > > > Disregarding a UNIX historical mistake, I'd expect > > 1 2 > >
Re: [9fans] equality sign in Rc
Why? the assignment is after the start of the command, so is not an assignment, and with the correction of Erik, now rc admit the use of = after the first word (in the first would be an assignment), so two=2 is just an argument to echo, exactly 'two='2. I like this behavior. trebol > Given > >> broken! one=1 two=2 echo $one $two >> >> 1 2 > > What should the following do? > > one=1 echo two=2 $one $two > > Disregarding a UNIX historical mistake, I'd expect > 1 2
Re: [9fans] equality sign in Rc
"c is a counter example" I think he means the opposite.
Re: [9fans] equality sign in Rc
> i've heard the argument that one can't make language progress without > breaking things. > c is a counter example. what has been changed in c that you are referring to?
Re: [9fans] equality sign in Rc
Given > broken! one=1 two=2 echo $one $two > 1 2 > What should the following do? one=1 echo two=2 $one $two Disregarding a UNIX historical mistake, I'd expect 1 2 > broken! echo one=1 > one=1 >
Re: [9fans] equality sign in Rc
> You can force rc to setting a variable only if = is surrounded by spaces, > like in sh, but then you'll have a lot of problems in plan9/p9p. nack. disregarding the confusion about spaces, incompatible changes aren't ok. i've heard the argument that one can't make language progress without breaking things. c is a counter example. so far, rc has been as well. - erik
Re: [9fans] equality sign in Rc
On Sun May 14 08:32:47 PDT 2017, trebol55...@yandex.ru wrote: > > That isn't sh's rule. x=y is fine as an assignment without spaces. > > Yes, sorry, in fact I was thinking on the contrary I wrote: don't set a > variable like in sh. > > I like the use of spaces permitted in rc, as I said. i was about to make this correction myself. in any event, this is a sloppy but effective pure extension to the grammar that allows everything but the first word to contain an '='. since this is done at the grammar level, and not as one would expect at the lexer level, there are some surprises like a function with "echo x=1" will deparse as echo 'x='^1. not perfect, but workable here's the code change ../rc/syn.y:24,35 - syn.y:24,47 return !i; } + tree* + treeeq(int type, tree *c0, tree *c1) + { + char *old; + + old = c0->str; + c0->str = smprint("%s=", c0->str); + c0->quoted = 1; + free(old); + return tree2(type, c0, c1); + } + %} %union{ struct tree *tree; }; %type line paren brace body cmdsa cmdsan assign epilog redir - %type cmd simple first word nkword comword keyword nkwords words wordsnl + %type cmd simple first nexteq word nkword comword keyword nkwords words wordsnl %type NOT FOR IN WHILE IF TWIDDLE BANG SUBSHELL SWITCH FN BREAK %type WORD REDIR DUP PIPE %% ../rc.me5/syn.y:84,89 - syn.y:96,102 | FN nkwords brace{$$=tree2(FN, $2, $3);} | FN nkwords {$$=tree1(FN, $2);} simple: first + | simple nexteq {$$=tree2(ARGLIST, $1, $2);} | simple word {$$=tree2(ARGLIST, $1, $2);} | simple redir{$$=tree2(ARGLIST, $1, $2);} first:comword ../rc.me5/syn.y:111,113 - syn.y:124,127 | words word {$$=tree2(WORDS, $1, $2);} nkwords: {$$=(struct tree*)0;} | nkwords nkword {$$=tree2(WORDS, $1, $2);} + nexteq: word '=' word {$$=treeeq('^', $1, $3);} here are some test cases ; ./o.rc broken! x=1 echo $x 1 broken! whatis zot zot: not found broken! zot=1 echo $zot 1 broken! whatis one one: not found broken! one=1 two=2 echo $one $two 1 2 broken! echo one=1 one=1 broken! echo if=1 if=1 broken! fn eq {echo one=1 two=2} broken! eq one=1 two=2 - erik
Re: [9fans] equality sign in Rc
> I see. It seems that you know the code very well. If the variable assignments > are only before a command, why not permit = > after the command? Do you know if is there a thought reason for that? More precisely, "after the start of the command".
Re: [9fans] equality sign in Rc
> That isn't sh's rule. x=y is fine as an assignment without spaces. Yes, sorry, in fact I was thinking on the contrary I wrote: don't set a variable like in sh. I like the use of spaces permitted in rc, as I said. > [...] Shell/environment variable assignments appear only before a command, as > in rc, > and otherwise the text gets passed to the command.[...] > In rc, the unquoted = causes a syntax error because nothing in syn.y allows > '=' after the start of I see. It seems that you know the code very well. If the variable assignments are only before a command, why not permit = after the command? Do you know if is there a thought reason for that? > Perhaps instead of passing it to the command as in Unix, rc could do what sh > originally intended, and lift named parameters > into the environment wherever they appear in a command. I think that the cleanest approach is to work with whatever you want to pass to a command, and then pass the result in a not confusing way. Variables are just fine, and with rc's lists of strings there is not need for more. The use of = in command arguments should be prohibited (by law!). By the way, do you know how this was designed in the original rc for v10 research unix? I looked some time ago in http://www.tuhs.org/Archive/Distributions/Research/ but there is no source of rc, only documentation. trebol.
Re: [9fans] equality sign in Rc
On 13 May 2017 at 13:36, trebolwrote: > You can force rc to setting a variable only if = is surrounded by spaces, > like in sh, but then you'll have a lot of problems in plan9/p9p. That isn't sh's rule. x=y is fine as an assignment without spaces. Shell/environment variable assignments appear only before a command, as in rc, and otherwise the text gets passed to the command. As I understood Bourne's talk about sh, originally it was intended to support named parameters, as in another command interpreter he'd used, and in cmd x=y b=x, the shell not the command would parse the x=y and b=x and pass the result to the command separately from the positional parameters of argv. That was modified to be allowed only at the start, because of an existing command 'dd', which unusually used x=y instead of the usual -x y, partly as humour, since IBM JCL then and now had a DD statement with name=value syntax (//STEP5.INPUT DD DSNAME=FRUITBAT,DISP=SHR) ``The maximum number of DD statements per job step is 3273''. Plan 9's dd's syntax changed to the -x y style. In rc, the unquoted = causes a syntax error because nothing in syn.y allows '=' after the start of . Perhaps instead of passing it to the command as in Unix, rc could do what sh originally intended, and lift named parameters into the environment wherever they appear in a command.
Re: [9fans] equality sign in Rc
Well fix it! Can't be too hard. brucee On 14 May 2017 at 02:53, Charles Forsythwrote: > > On 13 May 2017 at 15:21, trebol wrote: > >> No with hyphenation, my friend! > > > ahh! that's a little more specific. I usually switch it off so I wouldn't > have noticed. >
Re: [9fans] equality sign in Rc
On 13 May 2017 at 15:21, trebolwrote: > No with hyphenation, my friend! ahh! that's a little more specific. I usually switch it off so I wouldn't have noticed.
Re: [9fans] equality sign in Rc
No with hyphenation, my friend!
Re: [9fans] equality sign in Rc
On 13 May 2017 at 13:36, trebolwrote: > Then I used troff to write a paper, and surprise!, there is no utf8 > support. I'm fairly sure there is in troff.
[9fans] equality sign in Rc
> does anybody have a version of Rc that allows unquoted equality sign? > > having to quote the character get a bit annoying on POSIX systems (plan9port) You can change the code, I suppose the key file is rc/lex.c You can force rc to setting a variable only if = is surrounded by spaces, like in sh, but then you'll have a lot of problems in plan9/p9p. I know what you are talking about. I like the use of = in rc, but there is too much unix in plan9, and a lot of programs are straightforwardly ported. An example is gs, making tests with options in rc is a nightmare. People say that the problem of Plan9's popularity is the differences with unix, but for me is the opposite. It try to be different being too much similar. I remember when I discovered it 4 or 5 years ago. I was so happy with the use of utf8 as the system own character coding, I was learning C and I was sick with wchars, multibyte, locales and so on in unix. Then I used troff to write a paper, and surprise!, there is no utf8 support. And the same with spell and other utilities. They were pieces of unix, sewed to the corpse... instead of "Plan 9 from Outer Space", some times It feels more like "Frankenstein". trebol.
Re: [9fans] equality sign in Rc
why do that when you can just run 'mk' On May 6, 2017 12:47 AM, "Sean Callanan"wrote: > I can't speak for dexen, but I would love to be able to run > > cc -DFOO=bar file.c > > or similar commands with button 2 in Acme. What I get instead is > > rc: line 2: token '=': syntax error > > Sean > > iPadから送信 > > 2017/05/05 18:53、t...@teknik.io のメッセージ: > > > May 1, 2017 2:30 PM, "dexen deVries" wrote: > > > >> does anybody have a version of Rc that allows unquoted equality sign? > >> > >> having to quote the character get a bit annoying on POSIX systems > (plan9port) > > > > I don't, but can you explain in detail what you are doing that causes an > issue? > > > > > >
Re: [9fans] equality sign in Rc
Sure, and that's the 'quoted equality sign' dexen was complaining about in the first place. When you're hand-writing a command it probably becomes muscle memory pretty quickly, but for people who often copy-paste commands or run them straight out of files, I'm sure they've been aggravated by this far more often than they've used rc's = syntax for its intended purpose. Sean On Sat, May 6, 2017 at 6:22 AM Steve Simonwrote: > > i would have expected this to work: > > cc '-DFOO=bar' file.c > > -Steve > > > On 6 May 2017, at 08:43, Sean Callanan wrote: > > > > I can't speak for dexen, but I would love to be able to run > > > > cc -DFOO=bar file.c > > > > or similar commands with button 2 in Acme. What I get instead is > > > > rc: line 2: token '=': syntax error > > > > Sean > > > > iPadから送信 > > > > 2017/05/05 18:53、t...@teknik.io のメッセージ: > > > >> May 1, 2017 2:30 PM, "dexen deVries" wrote: > >> > >>> does anybody have a version of Rc that allows unquoted equality sign? > >>> > >>> having to quote the character get a bit annoying on POSIX systems > (plan9port) > >> > >> I don't, but can you explain in detail what you are doing that causes > an issue? > >> > >> > > >
Re: [9fans] equality sign in Rc
i would have expected this to work: cc '-DFOO=bar' file.c -Steve > On 6 May 2017, at 08:43, Sean Callananwrote: > > I can't speak for dexen, but I would love to be able to run > > cc -DFOO=bar file.c > > or similar commands with button 2 in Acme. What I get instead is > > rc: line 2: token '=': syntax error > > Sean > > iPadから送信 > > 2017/05/05 18:53、t...@teknik.io のメッセージ: > >> May 1, 2017 2:30 PM, "dexen deVries" wrote: >> >>> does anybody have a version of Rc that allows unquoted equality sign? >>> >>> having to quote the character get a bit annoying on POSIX systems >>> (plan9port) >> >> I don't, but can you explain in detail what you are doing that causes an >> issue? >> >>
Re: [9fans] equality sign in Rc
I can't speak for dexen, but I would love to be able to run cc -DFOO=bar file.c or similar commands with button 2 in Acme. What I get instead is rc: line 2: token '=': syntax error Sean iPadから送信 2017/05/05 18:53、t...@teknik.io のメッセージ: > May 1, 2017 2:30 PM, "dexen deVries"wrote: > >> does anybody have a version of Rc that allows unquoted equality sign? >> >> having to quote the character get a bit annoying on POSIX systems (plan9port) > > I don't, but can you explain in detail what you are doing that causes an > issue? > >
Re: [9fans] equality sign in Rc
May 1, 2017 2:30 PM, "dexen deVries"wrote: > does anybody have a version of Rc that allows unquoted equality sign? > > having to quote the character get a bit annoying on POSIX systems (plan9port) I don't, but can you explain in detail what you are doing that causes an issue?
[9fans] equality sign in Rc
does anybody have a version of Rc that allows unquoted equality sign? having to quote the character get a bit annoying on POSIX systems (plan9port)