Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: unshift



On Mon, Apr 1, 2024 at 6:52 AM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> shift
> while [ "$1" ]; do
>     if [ a ]; then b; c; continue fi
>     if [ d ]; then e; f; continue fi
>     if [ g ]; then h; i; continue fi
> ...
> shift
> done
>
> ... because only one 'if' test will be relevant per loop and the remaining 'if' tests might even do some bad stuff.  The problem of course is that if I 'continue', the final 'shift' is missed.

shift
while [ "$1" ]; do
  repeat 1 do
    if [ a ]; then b; c; break; fi
    if [ d ]; then e; f; break; fi
    if [ g ]; then h; i; break; fi
    ...
  done
  shift
done




Messages sorted by: Reverse Date, Date, Thread, Author