From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: <0d3820e90fedfa15c374652fe64f06b4@ladd.quanstro.net> References: <0d3820e90fedfa15c374652fe64f06b4@ladd.quanstro.net> Date: Mon, 14 Dec 2009 17:15:40 +0200 Message-ID: <8e04b5820912140715g20e56d31m57bd7e567843d0e4@mail.gmail.com> From: "Ciprian Dorin, Craciun" 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] rc shell UNIX port repository Topicbox-Message-UUID: b00cd602-ead5-11e9-9d60-3106f5b1d025 On Mon, Dec 14, 2009 at 4:08 PM, erik quanstrom wro= te: >> =C2=A0 =C2=A0 Unfortunately after playing a little bit more with rc, and= trying >> it's syntax and semantics to the limit, I've also found other nasty >> bugs (some of which I've fixed, other I was not able to do so)... > > what nasty bugs? =C2=A0could you give some specifics. One for example (I think it is a bug, but maybe in the semantics you've described it's not): * again if we're using `-e`, and inside a function we write `fn dosomething { echo 1 ; false ; echo 2 ; return 0 ; }` * if we run `dosomething` it shall output only `1`, as the false breaks the execution; * but if we run `dosomething || echo 3`, we see `1 2` outputed, because the false is not exiting the shell as the invocation of the function is part of a `||` statement; But undoubtedly, the following is a bug (I have an array and want to display all the elements on a single line, wrapped inside quotes, and everything with a prefix and a suffix): ~~~~ application__erl_files__short=3D( a.erl b.erl c.erl ) application__erl_files__long=3D( /home/ciprian/workbench/vel/a.erl /home/ciprian/workbench/vel/b.erl /home/ciprian/workbench/vel/c.erl ) ifs=3D'\n' echo ' erl files =3D ('^`{ echo -n '`'^$application__erl_files__short^'`' }^')' ifs=3D'\n' echo ' erl files =3D ('^`{ echo -n '`'^$application__erl_files__long^'`' }^')' ~~~~ it displays: ~~~~ erl files =3D (`a.erl` `b.erl` `c.erl`) erl files =3D (`/home/cipria) erl files =3D (/workbe) erl files =3D (ch/vel/a.erl` `/home/cipria) erl files =3D (/workbe) erl files =3D (ch/vel/b.erl` `/home/cipria) erl files =3D (/workbe) erl files =3D (ch/vel/c.erl`) ~~~~ See the second line of the output. It's wrong. I think there is a buffer overrun problem... >> =C2=A0 =C2=A0 By the way, what is the expected outcome of the following = snippet >> of code when the `-e` (exit on non-0 exit code) is on: >> >> { echo 1 ; false ; echo 2 } || echo 3 >> >> =C2=A0 =C2=A0 Case a) it should print `1` and exit because the false in = the >> middle of the block just failed; >> =C2=A0 =C2=A0 Case b) it should print `1`, and then `2`, because `false`= is >> inside a block that is part of a `||` command; >> =C2=A0 =C2=A0 Case c) it should print `1`, and then `3`, because `false`= has >> stopped the evaluation of the block, and made the entire block exit >> code be `1`. > > that's not a bug. =C2=A0-e is only evaluated at the end of a full rc > production. =C2=A0in yiour case, there is only one production and > it $status is '' (true) at the end of it. =C2=A0since echo 3 sets status > to true. > > - erik Even though I understand your reasoning, I see `-e` more as a "accept no errors from commands, and treat any non-0-exit code as an unhandled exception, except :) if its part of an if, &&, or || construct". (I see it as an equivalent for try-throw-except...) Ciprian.