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

Re: unshift





On 2024-04-01 09:03, Bart Schaefer wrote:
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

Ah!  So a 'break' quits the inner loop then hits the 'shift' which has the same effect as putting the shift at the top of the outer loop.  That's very clever.  Never seen 'repeat' used in a real life way.  There are tools which aren't used often, but still very useful when needed.


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