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 <quans...@quanstro.net>:

> by doing it in the grammar, the redirection issue is avoided.
>
> - erik
>
>
> On May 16, 2017 2:24 AM, Charles Forsyth <charles.fors...@gmail.com>
> wrote:
>
>
> On 15 May 2017 at 17:44, trebol <trebol55...@yandex.ru> 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...
>
>
>

Reply via email to