tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Coming changes to /bin/sh



In article <20741.1493805377%andromeda.noi.kre.to@localhost>,
Robert Elz  <kre%munnari.OZ.AU@localhost> wrote:
>I have two changes ready to commit that I thought I would let
>people know about, and solicit a few opinions as to a couple of
>open issues...
>
>The first is to implement the ";&" alternative to ";;" in case
>statements - ";&" is "fallthrough", and exists in many other
>shells ... actions that are connected to the following pattern
>(if any) are executed after the actions for the current one (without
>evaluating the pattern, or attempting to match it).
>
>This was approved for the next (major) version of POSIX (issue 8)
>back in 2011, and is (and was) implemented in most other shells
>(just not ours.)   (No, I have no idea when issue8 will actually appear.)
>
>As an exmaple of its use, the canonical example (from the forthcoming
>POSIX text) is ...
>
>x=0 y=1
>case 1 in
>  $((y=0)) ) ;;
>  $((x=1)) ) ;&
>  $((x=2)) ) echo $x.$y ;;
>esac
>
>which is required to emit "1.0" (and does with the changes I have planned,
>but not yet committed).
>
>The question here, is that bash (at least) also has a third form of
>terminator to use instead of ";;" - ";;&".   That one causes fall
>through to the next pattern which matches, that is, after the commands
>associated with a pattern are executed, if those commands were terminated
>with ";;&" then the shell will go on to look at the next pattern, evaluate
>it, see if it matches, and if so, execute its commands (and repeat if it
>also ends with ";;&") - if that pattern does not match, continue looking for
>one that does (ie: after executing the ";;&" commands, everything continues
>more or less as if the pattern which matched had not matched after all.)

Go for it (;& and LINENO) and not bother to add the bash extension for now!

christos



Home | Main Index | Thread Index | Old Index