From: Bart Schaefer <schaefer@brasslantern.com>
To: Peter Stephenson <pws@pwstephenson.fsnet.co.uk>, zsh-users@sunsite.dk
Subject: Re: Zsh Guide chapter 5 (substitutions)
Date: Mon, 20 Aug 2001 18:26:38 +0000 [thread overview]
Message-ID: <1010820182638.ZM20357@candle.brasslantern.com> (raw)
In-Reply-To: <20010815230024.3E7F614284@pwstephenson.fsnet.co.uk>
In this example:
% fn() { print "Twice ${1:-0} is $(( 2 * ${1:-0} ))"; }
% fn
Twice 0 is 0
It'd be even more exemplary to write:
fn() { print "Twice ${1:=0} is $(( 2 * $1 ))"; }
Moving on:
the `^' character turns on the option just for that expansion, as `='
does with SH_WORD_SPLIT (can't think of a good mnemonic, sorry).
Think of proofreaders' marks, where a carat means to insert a new word in
between two other words.
In addition to `*' and `?', which are so basic that even DOS had them
(though I never quite worked out exactly what it was doing with them a
lot of the time)
I'm going to guess that you really don't want to know.
... anywhere where history substitution doesn't get it's hands
on the `!' first. ^^^^
Apostrophe abuse!
Note one point mentioned in the FAQ --- probably indicating the reason
that `^' is only available with EXTENDED_GLOB switched on. Some
commands use an initial `^' to indicate a control character
In fact, there's another reason: Some keyboards used not to have a `|'
character, so many older versions of the Bourne shell interpret `^' as
`|', that is, `echo foo^grep f' would run grep and output `foo'.
Slightly less obviously, the `**/*' matches files in the current
directory, while the `*/CVS' never matches a `CVS' in the current
directory, so that could appear. If you want to, you can fix that up
like this:
print **/*~(*/|)CVS(/*|)(/)
Easier is
print ./**/*~*/CVS(/)
but I suppose that doesn't show that slashes can appear in parens on
the right side of the tilde.
A `~' at the beginning is never treated as excluding what follows; as
you already know, it has other uses.
Might be worth pointing out here or elsewhere that (#i)~/foo does NOT
mean ~(#i)/foo, but rather means (#i)(|)~/foo, that is, the presence of
(#i) means that `~' is no longer at the start of the pattern. Or maybe
that's a bug?
In the table of ksh glob equivalences quoted from the FAQ, you've included
the footnote reference [1] but not the footnote itself.
... since no-one would right two *'s in a row for any other reason.
They might, however, write two wrongs.
There are a couple of minor typos in the first few paragraphs about glob
qualifiers: "usual" for "usually" and "t((%b))" for "((%b))". Also,
"whackier" -- on this side of the pond we spell it without the "h", but
maybe this is a "colour programme" sort of thing.
Gotta stop now, back later for sections 5.9.7 and later.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
next prev parent reply other threads:[~2001-08-20 18:27 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-08-15 23:00 Peter Stephenson
2001-08-16 2:31 ` Bart Schaefer
2001-08-17 16:55 ` Bart Schaefer
2001-08-20 18:26 ` Bart Schaefer [this message]
2001-08-20 18:35 ` Phil Pennock
2001-08-21 16:38 ` Bart Schaefer
2001-08-21 14:21 ` Richard Curnow
2001-08-21 15:34 ` Bart Schaefer
2001-08-22 17:10 martin.ebourne
2001-08-23 7:30 ` Borsenkow Andrej
2001-08-23 7:41 ` Borsenkow Andrej
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=1010820182638.ZM20357@candle.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=pws@pwstephenson.fsnet.co.uk \
--cc=zsh-users@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).