zsh-users
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@brasslantern.com>
To: zsh-users@math.gatech.edu
Subject: Re: globbing for links in pathnames
Date: Fri, 5 Feb 1999 09:14:28 -0800	[thread overview]
Message-ID: <990205091428.ZM23509@candle.brasslantern.com> (raw)

On Feb 5,  2:24pm, Andrew Gallagher wrote:
} Subject: Re: globbing for links in pathnames
}
} Phil Pennock wrote:
} 
} > Okay, why do neither the second nor third ones here work "as expected"?
} >
} > % print -l ${(A)~x::=pkgs/*(@)}
} > pkgs/bar
} > pkgs/foo
} > % print -l ${(A)^~x::=pkgs/*(@)}/man
} > pkgs/*(@)/man
} > % print -l ${^${(A)~x::=pkgs/*(@)}}/man
} > pkgs/*(@)/man
} > %
} 
}  I can't tell you "why" this happens, but it seems that "how" it happens is
} that the "/man" is being appended to the result of the parameter expansion
} before globbing takes place. Evidently, when the ~ is processed it sets a
} flag which allows globbing to happen further down the line, rather than
} forcing globbing to happen at that point.

Mostly correct.

Normally zsh "tokenizes" the command line as it is parsed.  '*' is changed
into a character represented internally by the constant Star, '(' becomes
Inpar, '$' becomes String, etc.  (If the tokens themselves appear in the
input, they become a magic two-byte sequence.)  Globbing is invoked when
the Star token (among others) is seen when the input is re-scanned after
other expansions; the order in which expansions occur is in the manual.

Also normally, the parameter expansion code DOES NOT tokenize the string
that it returns, so Star et al. don't appear and no globbing happens.
What ~ does is cause the string to be tokenized.  That doesn't affect the
order of expansions, so globbing is now enabled but doesn't happen until
later.

(Maybe that's more than zsh-users want to know ....)

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


             reply	other threads:[~1999-02-05 17:14 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-02-05 17:14 Bart Schaefer [this message]
  -- strict thread matches above, loose matches on Subject: below --
1999-02-05 14:24 Andrew Gallagher
1999-02-05 12:06 Phil Pennock
1999-02-05  5:07 Bart Schaefer
1999-02-05  4:22 Sweth Chandramouli
1999-02-05  4:11 Sweth Chandramouli
1999-02-05  0:56 Bart Schaefer
1999-02-05  0:23 Steve Talley
1999-02-04 23:27 Sweth Chandramouli
1999-02-04 22:36 Steve Talley

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=990205091428.ZM23509@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@math.gatech.edu \
    /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).