zsh-workers
 help / color / mirror / code / Atom feed
From: "Jörg Sommer" <joerg@alea.gnuu.de>
To: zsh-workers@sunsite.dk
Subject: Simpler for statements
Date: Sat, 8 Dec 2007 17:08:27 +0000 (UTC)	[thread overview]
Message-ID: <slrnflljsb.43b.joerg@alea.gnuu.de> (raw)

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.


             reply	other threads:[~2007-12-09  3:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-08 17:08 Jörg Sommer [this message]
2007-12-09  3:46 ` Mikael Magnusson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=slrnflljsb.43b.joerg@alea.gnuu.de \
    --to=joerg@alea.gnuu.de \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).