zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@sunsite.dk
Subject: Modifiers, command position, and so forth (Re: Bug#519535: history expansion: modifier completion missing)
Date: Tue, 17 Mar 2009 11:46:05 -0700	[thread overview]
Message-ID: <090317114606.ZM17772@torch.brasslantern.com> (raw)
In-Reply-To: <20090317095717.02bedf7e@news01>

On Mar 17,  9:57am, Peter Stephenson wrote:
}
} > torch% echo foo
} > torch% !!:a
} > /usr/local/src/zsh/zsh-build/echo foo
} > zsh: no such file or directory: /usr/local/src/zsh/zsh-build/echo
} > 
} > That's almost certainly not the intended behavior ... is it?
} 
} It depends what you mean by "intended": Michael did say the operation
} didn't take account of whether the file existed (but I didn't document
} this), and there was never any special behaviour for command words.

I guess I'm a little skeptical of the utility of this new option in
general.  All the other modifiers do something "inside" the history
string, which would otherwise be difficult to do -- change case,
truncate, substitute, etc.  This one is just prepending something in
a way that can already easily be done with $PWD/!$ (for example).

So if it's not going to be intelligent about what it does, what's the
point?  On the other hand I agree with your conclusion later in this
thread that having :a behave like `whence` depending on whether it
is used on the command word, is also confusing.  Consequently I can't
decide what intelligence is appropriate.  It'd be a lot more useful
if :w worked on history; !*:w:a to make all the arguments into paths
would be handy.

It'd be REALLY handy if :a figured out what the current directory was
at the time the historical command was originally executed and pasted
THAT directory onto the front of the command word, rather than always
using the value of $PWD.  Sort of an uber-$OLDPWD for all history.

Here's another case where some intelligence could be applied:

schaefer<549> cd Src/Zle
schaefer<550> echo ../b*
../builtin.c
schaefer<551> echo !$:a
echo /usr/local/src/zsh/zsh-4.0/Src//b*
/usr/local/src/zsh/zsh-4.0/Src//builtin.c

Double slash?

Incidentally, it's not just (:c) that doesn't work if there's no file
matching the name.  Any other modifier-as-qualifier will fail, too.
This apparently leads to yet other oddities for "command position".

schaefer<503> /bin/echo xxx
xxx
schaefer<504> /bin/echo(:h) xx
zsh: permission denied: /bin
schaefer<505> /bin/echo(:t) xx
xx
schaefer<506> /bin/echo(:a) xx
xx

All as expected.  But now it gets weird:

schaefer<508> echo(:t) xx
zsh: command not found: xx
schaefer<509> echo echo(:t) xx
zsh: no match
schaefer<510> echo(:a) xx 
zsh: command not found: xx

The command disappears entirely when the qualifier fails.  This turns
out to be some strange side-effect of cshnullglob:

schaefer<514> unsetopt cshnullglob 
schaefer<515> echo(:a) xx         
zsh: no matches found: echo(:a)

(Hrm, different error message, too.)

-- 


  parent reply	other threads:[~2009-03-17 18:47 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20090313105555.GA19025@piper.oerlikon.madduck.net>
2009-03-15  6:22 ` Bug#519535: history expansion: modifier completion missing Clint Adams
2009-03-16 18:18   ` Peter Stephenson
2009-03-17  2:44     ` Bart Schaefer
2009-03-17  9:57       ` Peter Stephenson
2009-03-17 11:00         ` Peter Stephenson
2009-03-17 12:09           ` Peter Stephenson
2009-03-17 17:36         ` Bart Schaefer
2009-03-17 18:46         ` Bart Schaefer [this message]
2009-03-18 19:36           ` Modifiers, command position, and so forth (Re: Bug#519535: history expansion: modifier completion missing) Peter Stephenson
2009-03-19  0:34             ` Bart Schaefer
2009-03-19 14:34             ` Peter Stephenson
2009-03-19 15:28     ` Bug#519535: history expansion: modifier completion missing Mikael Magnusson
2009-03-19 16:09       ` Peter Stephenson
2009-03-19 16:18         ` Mikael Magnusson
2009-03-19 16:18       ` Bart Schaefer

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=090317114606.ZM17772@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).