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

Simpler for statements



Hi,

I look for a way to ease writing of for loops. I often have commands like
for i in other_files.*; do cmp file $i; done

On Dec 06, Stephane Chazelas posted a mail in the thread “avoid
interpretation of special characters” that gave me an idea:
accept-line()
{
    case "$BUFFER" in
      *"++"*)
        local repl
        repl=${${BUFFER#*++}%%++*}
        BUFFER="for i in $repl; do ${BUFFER/++$repl++/\$i}; done"
    esac
    zle .accept-line
}
zle -N accept-line

With this I can write “cmp file ++other_files.*++” and all is done. Or
“(cd ++*++; cvs up)” to update all cvs repositories.

Is there a better way to do this? Can I somehow improve my little
function?

Bye and thanks for the best shell on earth, Jörg.
-- 
Nicht was du bist, ist es was dich ehrt, wie du bist bestimmt den Wert.
Wünsche hat man oft und viel, nur wer lernt erreicht sein Ziel.



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