Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Modifiers, command position, and so forth (Re: Bug#519535: history expansion: modifier completion missing)

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*
schaefer<551> echo !$:a
echo /usr/local/src/zsh/zsh-4.0/Src//b*

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
schaefer<504> /bin/echo(:h) xx
zsh: permission denied: /bin
schaefer<505> /bin/echo(:t) xx
schaefer<506> /bin/echo(:a) 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.)


Messages sorted by: Reverse Date, Date, Thread, Author