zsh-workers
 help / color / mirror / code / Atom feed
From: "Johan Sundström" <johsu650@student.liu.se>
To: zsh-workers@sunsite.auc.dk
Subject: Re: <n> == <n->?
Date: Tue, 4 Apr 2000 19:00:42 +0200 (MET DST)	[thread overview]
Message-ID: <Pine.GSO.4.02.10004041813220.28633-100000@astmatix.ida.liu.se> (raw)
In-Reply-To: <E12cHx7-0006VR-00@crucigera.fysh.org>

On Tue, 4 Apr 2000, Zefram wrote:

> I thought we'd decided, quite some time ago, that the numeric glob syntax
> was going to require a "-", to minimise ambiguity with redirection.

Sounds reasonable. After some digging through zshmisc(1), I'd guess the
situation we're trying to protect from a possible ambiguity is "< word" --
am I right? I may be at a loss here, but I don't quite see where the
problem might arise. Could someone depict an example or two and how to
trigger the problem?

I guess some situation with a directory having files named '1>', '1', '01'
and/or similar, and trying some command with an argument of <1> might be
what yo're getting at, but I haven't been able to figure out how or why.

> Actually, lex.c is more lenient than that.  Anything matching
> /\<[-0-9]+\>/ is initially lexed as a string rather than as operators.
> However, gettokstr() has some nasties here.  Although the above grammar
> applies at the beginning of a word, gettokstr() makes no such check
> in the middle of a word.  As far as it's concerned, anything matching
> /\<[-0-9]/ is the start of a glob operator, and it'll keep adding to
> the string (past whitespace and so on) until it finds the closing ">".
> Try typing "echo a<1" (and compare against "echo <1").

I noticed them being different (which showed better using cat than echo),
but I failed to understand how the first case tried to operate; to me, it
seemed like a broken effort at <<- or <<<, but then I guess I just didn't
understand what happened, so my guess isn't worth a lot. :-]

Either way, I'm not sure I see the impact of this on the case where the
word continues with a > and possibly more pattern matching. After all,
when I want redirection, I don't try my luck at inserting a < or > in
the middle of the current word I'm typing, and I haven't found anything in
the man pages supporting that behaviour either.

> "0#n" will do that (# = zero or more of the previous character).

As stated, I've been quite fond of <n>. Among other reasons, because
editing a past commandline from <n> to <-n> or <n-> was such a breeze. I'm 
familiar with #, but lazy as I am, I found the deprecated <n> syntax more 
typing friendly.

Another thing I forgot at first when on the subject: for quite some time
now, <x-y> has been ungreedy about its matches, to my disappointment. This
means that <1-2>* will match 1, 2, 10 through 29, and so on, instead of a
single, closed range, as at leas I would hope when constructing such a
pattern. The <x-y> syntax is of course still useful, but it takes a whole
lot more work and narrowing-down to make the pattern as tight as wanted.
Any chance of getting back the greedy version as seen in, for example,
3.0.0? (I'm starting to sound like an old fart, here... ;-) Some
pattern-matching token for stating the level of greediness would of course
be a welcome addition as well, but that sounds like a whole lot more work.

Oh, and don't get me wrong about all this; I'm not complaining about how
zsh works or doesn't work, I'm just trying to make the best I can of the
situation. Zsh isn't my all-time favourite shell without reason; I'm very
fond of zsh's trend of always trying to make things as handy as they can
be, and whenever I can help, I do my best.

/Johan Sundström, fond of globbing and pattern matching


  reply	other threads:[~2000-04-04 17:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-04-03 23:09 Johan Sundström
2000-04-04  1:16 ` Zefram
2000-04-04 17:00   ` Johan Sundström [this message]
2000-04-04 19:32     ` Peter Stephenson
2000-04-04 21:01     ` Zefram

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=Pine.GSO.4.02.10004041813220.28633-100000@astmatix.ida.liu.se \
    --to=johsu650@student.liu.se \
    --cc=zsh-workers@sunsite.auc.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).