zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@sunsite.dk
Subject: Re: Prepend/append to the members of a list
Date: Mon, 30 Oct 2006 18:54:07 -0800	[thread overview]
Message-ID: <061030185409.ZM9982@torch.brasslantern.com> (raw)
In-Reply-To: =?iso-8859-1?Q?=3C20061030170919=2EGA9507=40alea=2Egnuu=2Ede?= =?iso-8859-1?Q?=3E?= =?iso-8859-1?Q?Comments=3A_In_reply_to_J=F6rg_Sommer_=3Cjoerg=40alea=2Egn?= =?iso-8859-1?Q?uu=2Ede=3E?= =?iso-8859-1?Q?________=22Prepend=2Fappend_to_the_members_of_a_list=22_?= =?iso-8859-1?Q?=28Oct_30=2C__6=3A09pm=29?=

On Oct 30,  6:09pm, Jörg Sommer wrote:
}
} % ls !ls*:(s/^/dir/)
} 
} But it does not work, because the s/// expression doesn't know ^.

Even if history substitution did understand beginning-of-word, that
still wouldn't work.  You'd at the least need :gs and some character
other than slash as the separator.

Usually in this situation I would do something like

% (cd dir; !ls )

Nikolai's suggestion can be tweaked to not require rcexpandparam:

% a=( !ls:* ); ls dir/$^a

Or this:

% ls dir/${^$(echo !{ls:*:q})}

} Or another example:
} 
} % cp dir/*.[1-9](:t:s+^+/usr/share/man/man?/+:s/$/.gz/) .

There you're in a bit of a pickle because you're using history modifiers
on a glob pattern, which is even more limited.  I believe the closest
you'd get without pain [#] is:

% cp /usr/share/man/man?/${^$(echo dir/*.[1-9](:t)}.gz .

which isn't that much uglier than what you constructed.

Of course, if you do this specific thing often you can do

% function mangz { reply=(/usr/share/man/man?/$REPLY:t.gz) }
% cp dir/*.[1-9](+mangz) .

[#] Pain is safely quoting special characters in the file name:

% cp /usr/share/man/man?/${^$(echo dir/*.[1-9](:te.'reply=${(q)REPLY}'.))}.gz .

-- 


  parent reply	other threads:[~2006-10-31  2:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-30 17:09 Jörg Sommer
2006-10-30 18:23 ` Nikolai Weibull
2006-10-31  2:54 ` Bart Schaefer [this message]
2006-10-31 14:52 ` Peter Stephenson
2006-10-31 16:31   ` Bart Schaefer
2006-10-31 16:40     ` Nikolai Weibull
2006-10-31 18:01       ` Nikolai Weibull
2006-10-31 17:08     ` Peter Stephenson
2006-11-01 12:24       ` Peter Stephenson

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=061030185409.ZM9982@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --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).