zsh-workers
 help / color / mirror / code / Atom feed
* Simpler for statements
@ 2007-12-08 17:08 Jörg Sommer
  2007-12-09  3:46 ` Mikael Magnusson
  0 siblings, 1 reply; 2+ messages in thread
From: Jörg Sommer @ 2007-12-08 17:08 UTC (permalink / raw)
  To: zsh-workers

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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-12-09  3:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-12-08 17:08 Simpler for statements Jörg Sommer
2007-12-09  3:46 ` Mikael Magnusson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).