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

Re: unshift





On 2024-04-02 12:59, Roman Perepelitsa wrote:
On Tue, Apr 2, 2024 at 4:03 PM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
while [ "$2" ]; do
     shift
     if [ a ]; then b; c; continue fi
     if [ d ]; then e; f; continue fi
     code-applies-to-all-below; more(of-the-same)
     if [ g ]; then h; i; continue fi
     if [ j ]; then k; l; continue fi
done

... so elif won't work.
It'll work with one `else` in the mix.

Roman.
I'm happy with it as it is now, it seems clean.  I've always tended to be a good Protestant and do:

...
shift
...
...
while [ $1 ]
...

... get the shifting done ASAP, but the more I think about it the more I like:
...
while [ $2 ]
    shift
...
... more Catholic ... do it when you need to do it.   The function is quite a bit simpler that way.  Cross bridges when I get to them.





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