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

Re: 'r' history parameter documentation fix



A more exact suggestion:

On Mon, 2011-07-25 at 01:34 -0700, Bart Schaefer wrote:
> On Jul 22, 11:37pm, Jesse Weinstein wrote:
> }
> } In the Modifier's section of the docs, defining the 'r' history
> } modifier, "Remove a filename extension of the form `.XXX', leaving the
> } root name." appears to be subtly wrong.
> } 
> } At least in 4.3.10.Debian, (foo=blah.flac; echo ${foo:r}) gives blah, 
> } although it should't, according to the manual, as .flac isn't of the
> } form .XXX .  
> }  
> } I think the doc should be changed to "Remove a filename extension
> } leaving the root name."
> 
> That'd be at least as wrong (except maybe less subtly) because it
> doesn't define "extension" at all.
It would be less wrong, because rather than defining extension wrongly, 
it leaves it up to the expectations of the reader, which in many cases
may be correct.

However, you convinced me to look up how the 'r' modifier is handled in
the code, so we can be strictly correct.  It's implemented by a call to
hist.c:remtext() which simply trims off the last dot in the filename,
and whatever characters follow it, i.e. ${variable%%.[^.]#} (with
EXTENDED_GLOB set).

So we could rephrase the documentation as:

"Remove a filename extension (the rightmost period and everything
following it) leaving the root name."

> I guess the question is whether anyone is really confused by what the
> doc currently says?
Currently, the doc implies behavior that differs from what the shell
does.  This is a (minor) problem whether anyone is "really confused" or
not.

Jesse



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