GNU bug report logs -
#23422
stat -c %N returns strange results for file names including <TAB>
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 23422 in the body.
You can then email your comments to 23422 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-coreutils <at> gnu.org
:
bug#23422
; Package
coreutils
.
(Mon, 02 May 2016 09:29:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Michael Albinus <michael.albinus <at> gmx.de>
:
New bug report received and forwarded. Copy sent to
bug-coreutils <at> gnu.org
.
(Mon, 02 May 2016 09:29:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hi,
I have a file called "foo<TAB>bar". Yes, it includes the <TAB> char in
its name. When I call "stat -c %N", I get 'foo'$'\t''bar' .
This looks pretty strange. It is with "stat (GNU coreutils) 8.25". Earlier
stat versions, say "stat (GNU coreutils) 6.12" on a very old machine I
have access too, used to return `foo\tbar' .
Best regards, Michael.
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#23422
; Package
coreutils
.
(Mon, 02 May 2016 14:01:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 23422 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 05/02/2016 03:27 AM, Michael Albinus wrote:
> Hi,
>
> I have a file called "foo<TAB>bar". Yes, it includes the <TAB> char in
> its name. When I call "stat -c %N", I get 'foo'$'\t''bar' .
That is intentional; in the same vein as the way 'ls' changed its
default output for files with awkward characters. The defaults are to
quote in a way that is reusable by shells that understand $'' quoting
(since POSIX will be adding support for it). And you can always select
other quoting methods, via the QUOTING_STYLE environment variable.
Hmm, maybe 'stat' should gain a --quoting-style command line option to
override the env-var, the same way as is done in ls. So on that
grounds, I'll leave this bug report open.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[signature.asc (application/pgp-signature, attachment)]
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#23422
; Package
coreutils
.
(Mon, 02 May 2016 14:28:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 23422 <at> debbugs.gnu.org (full text, mbox):
Eric Blake <eblake <at> redhat.com> writes:
Hi Eric,
>> I have a file called "foo<TAB>bar". Yes, it includes the <TAB> char in
>> its name. When I call "stat -c %N", I get 'foo'$'\t''bar' .
>
> That is intentional; in the same vein as the way 'ls' changed its
> default output for files with awkward characters. The defaults are to
> quote in a way that is reusable by shells that understand $'' quoting
> (since POSIX will be adding support for it). And you can always select
> other quoting methods, via the QUOTING_STYLE environment variable.
Thanks for the hint with QUOTING_STYLE. However, it doesn't work for me:
# env QUOTING_STYLE=escape /usr/bin/stat -c %N /tmp/foo*
'/tmp/foo'$'\t''bar'
Best regards, Michael.
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#23422
; Package
coreutils
.
(Mon, 02 May 2016 15:43:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 23422 <at> debbugs.gnu.org (full text, mbox):
On 02/05/16 10:27, Michael Albinus wrote:
> Hi,
>
> I have a file called "foo<TAB>bar". Yes, it includes the <TAB> char in
> its name. When I call "stat -c %N", I get 'foo'$'\t''bar' .
> This looks pretty strange. It is with "stat (GNU coreutils) 8.25". Earlier
> stat versions, say "stat (GNU coreutils) 6.12" on a very old machine I
> have access too, used to return `foo\tbar' .
We were thinking that since %N returns the quoted file name,
that it would be more generally useful to return the shell quoted format,
as that can be copied and pasted back to a shell command.
For example it allows one to always paste back the file name from
`stat *` which includes %N in the default output.
thanks,
Pádraig
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#23422
; Package
coreutils
.
(Mon, 02 May 2016 15:45:01 GMT)
Full text and
rfc822 format available.
Message #17 received at 23422 <at> debbugs.gnu.org (full text, mbox):
On 02/05/16 15:27, Michael Albinus wrote:
> Eric Blake <eblake <at> redhat.com> writes:
>
> Hi Eric,
>
>>> I have a file called "foo<TAB>bar". Yes, it includes the <TAB> char in
>>> its name. When I call "stat -c %N", I get 'foo'$'\t''bar' .
>>
>> That is intentional; in the same vein as the way 'ls' changed its
>> default output for files with awkward characters. The defaults are to
>> quote in a way that is reusable by shells that understand $'' quoting
>> (since POSIX will be adding support for it). And you can always select
>> other quoting methods, via the QUOTING_STYLE environment variable.
>
> Thanks for the hint with QUOTING_STYLE. However, it doesn't work for me:
>
> # env QUOTING_STYLE=escape /usr/bin/stat -c %N /tmp/foo*
> '/tmp/foo'$'\t''bar'
Right, stat currently hard codes the "shell" style.
It probably makes sense to have this configurable.
I'll do that for the next release.
thanks,
Pádraig.
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#23422
; Package
coreutils
.
(Mon, 02 May 2016 16:23:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 23422 <at> debbugs.gnu.org (full text, mbox):
Pádraig Brady <P <at> draigBrady.com> writes:
Hi,
>> I have a file called "foo<TAB>bar". Yes, it includes the <TAB> char in
>> its name. When I call "stat -c %N", I get 'foo'$'\t''bar' .
>
>> This looks pretty strange. It is with "stat (GNU coreutils) 8.25". Earlier
>> stat versions, say "stat (GNU coreutils) 6.12" on a very old machine I
>> have access too, used to return `foo\tbar' .
>
> We were thinking that since %N returns the quoted file name,
> that it would be more generally useful to return the shell quoted format,
> as that can be copied and pasted back to a shell command.
> For example it allows one to always paste back the file name from
> `stat *` which includes %N in the default output.
I'm using stat in Emacs/Tramp in order to retrieve information about
files on remote hosts. The returned string is parsed then inside Emacs.
This is broken now, and I'm really undecided whether I shall start to
parse a shell quoted output. Likely not, if you bring this functionality
back, somehow. For the time being, I'll disable use of stat in Tramp
(unfortunately too late for the upcoming Emacs 25.1).
Btw, neither in the stat man page nor in the NEWS file of coreutils I
found a hint about the changed behaviour. It would be nice to announce
such incompatible changes, somehow.
> thanks,
> Pádraig
Best regards, Michael.
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#23422
; Package
coreutils
.
(Mon, 02 May 2016 16:28:01 GMT)
Full text and
rfc822 format available.
Message #23 received at 23422 <at> debbugs.gnu.org (full text, mbox):
Pádraig Brady <P <at> draigBrady.com> writes:
>> Thanks for the hint with QUOTING_STYLE. However, it doesn't work for me:
>>
>> # env QUOTING_STYLE=escape /usr/bin/stat -c %N /tmp/foo*
>> '/tmp/foo'$'\t''bar'
>
> Right, stat currently hard codes the "shell" style.
> It probably makes sense to have this configurable.
> I'll do that for the next release.
Thanks! In general I don't care whether you implement it via environment
variable or command parameter. The environment variable has the
advantage, that the call of stat would be backwards compatible.
> thanks,
> Pádraig.
Best regards, Michael.
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#23422
; Package
coreutils
.
(Mon, 02 May 2016 22:20:01 GMT)
Full text and
rfc822 format available.
Message #26 received at 23422 <at> debbugs.gnu.org (full text, mbox):
On Monday 02 May 2016, Michael Albinus wrote:
> Pádraig Brady <P <at> draigBrady.com> writes:
>
> Hi,
>
> >> I have a file called "foo<TAB>bar". Yes, it includes the <TAB>
> >> char in its name. When I call "stat -c %N", I get 'foo'$'\t''bar'
> >> .
> >>
> >> This looks pretty strange. It is with "stat (GNU coreutils) 8.25".
> >> Earlier stat versions, say "stat (GNU coreutils) 6.12" on a very
> >> old machine I have access too, used to return `foo\tbar' .
> >
> > We were thinking that since %N returns the quoted file name,
> > that it would be more generally useful to return the shell quoted
> > format, as that can be copied and pasted back to a shell command.
> > For example it allows one to always paste back the file name from
> > `stat *` which includes %N in the default output.
>
> I'm using stat in Emacs/Tramp in order to retrieve information about
> files on remote hosts. The returned string is parsed then inside
> Emacs.
>
> This is broken now, and I'm really undecided whether I shall start to
> parse a shell quoted output. Likely not, if you bring this
> functionality back, somehow. For the time being, I'll disable use of
> stat in Tramp (unfortunately too late for the upcoming Emacs 25.1).
>
> Btw, neither in the stat man page nor in the NEWS file of coreutils I
> found a hint about the changed behaviour. It would be nice to
> announce such incompatible changes, somehow.
Actually it would be nice to simply _avoid_ such incompatible changes.
This new quoting style default is just ugly, unreadable and annoying.
Please revert.
cu,
Rudi
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#23422
; Package
coreutils
.
(Mon, 02 May 2016 22:37:02 GMT)
Full text and
rfc822 format available.
Message #29 received at 23422 <at> debbugs.gnu.org (full text, mbox):
On 05/02/2016 03:19 PM, Ruediger Meier wrote:
> This new quoting style default is just ugly, unreadable and annoying.
If you can think of an unambiguous output style that is beautiful,
readable, and pleasant, please let us know.
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#23422
; Package
coreutils
.
(Wed, 04 May 2016 08:29:01 GMT)
Full text and
rfc822 format available.
Message #32 received at 23422 <at> debbugs.gnu.org (full text, mbox):
On Tuesday 03 May 2016, Paul Eggert wrote:
> On 05/02/2016 03:19 PM, Ruediger Meier wrote:
> > This new quoting style default is just ugly, unreadable and
> > annoying.
>
> If you can think of an unambiguous output style that is beautiful,
> readable, and pleasant, please let us know.
Looking again at the OP's example
'foo'$'\t''bar'
it's not so difficult to imagine a better quoting style. It would be
more difficult to make it more ugly ... Nobody would ever type this
string like this, mixing and changing the quotes a few times within one
string. Moreover it's unusable for most use cases (except shell
copy/paste).
The old behavior 'foo\tbar' seems like C style which was already nice to
read and also unambiguous I guess. Adding a $ in front of that C string
should work in shell too, or not?
Anyways the incompatible change is IMO not acceptable. %N is probably
most likely used in scripts which rely on the known style. One argument
to defend the ugly quoting style change in ls(1) was that it's usually
only used interactively. This is not the case for stat -c.
cu,
Rudi
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#23422
; Package
coreutils
.
(Wed, 04 May 2016 16:30:02 GMT)
Full text and
rfc822 format available.
Message #35 received at 23422 <at> debbugs.gnu.org (full text, mbox):
Ruediger Meier <sweet_f_a <at> gmx.de> writes:
> Anyways the incompatible change is IMO not acceptable. %N is probably
> most likely used in scripts which rely on the known style.
The style was never documented (and still isn't).
Andreas.
--
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#23422
; Package
coreutils
.
(Wed, 04 May 2016 16:59:01 GMT)
Full text and
rfc822 format available.
Message #38 received at 23422 <at> debbugs.gnu.org (full text, mbox):
On Wednesday 04 May 2016, Andreas Schwab wrote:
> Ruediger Meier <sweet_f_a <at> gmx.de> writes:
> > Anyways the incompatible change is IMO not acceptable. %N is
> > probably most likely used in scripts which rely on the known style.
>
> The style was never documented (and still isn't).
What does this mean? Using %N wasn't and still isn't recommended because
behavior is undefined? Come on ...
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#23422
; Package
coreutils
.
(Wed, 04 May 2016 22:00:02 GMT)
Full text and
rfc822 format available.
Message #41 received at 23422 <at> debbugs.gnu.org (full text, mbox):
Ruediger Meier <sweet_f_a <at> gmx.de> writes:
> On Wednesday 04 May 2016, Andreas Schwab wrote:
>> Ruediger Meier <sweet_f_a <at> gmx.de> writes:
>> > Anyways the incompatible change is IMO not acceptable. %N is
>> > probably most likely used in scripts which rely on the known style.
^^^^^^^^^^^
>>
>> The style was never documented (and still isn't).
>
> What does this mean? Using %N wasn't and still isn't recommended because
> behavior is undefined? Come on ...
See above.
Andreas.
--
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#23422
; Package
coreutils
.
(Thu, 05 May 2016 08:24:01 GMT)
Full text and
rfc822 format available.
Message #44 received at 23422 <at> debbugs.gnu.org (full text, mbox):
On 04/05/16 22:59, Andreas Schwab wrote:
> Ruediger Meier <sweet_f_a <at> gmx.de> writes:
>
>> On Wednesday 04 May 2016, Andreas Schwab wrote:
>>> Ruediger Meier <sweet_f_a <at> gmx.de> writes:
>>>> Anyways the incompatible change is IMO not acceptable. %N is
>>>> probably most likely used in scripts which rely on the known style.
> ^^^^^^^^^^^
>>>
>>> The style was never documented (and still isn't).
>>
>> What does this mean? Using %N wasn't and still isn't recommended because
>> behavior is undefined? Come on ...
Both points are valid.
%N had a defacto style on Linux until now, but it was not documented.
%N is not a standard style as it produces unquoted output on BSD for example.
For the next version of coreutils we'll document the default format
and allow selection of the quoting style used.
thanks,
Pádraig.
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#23422
; Package
coreutils
.
(Thu, 03 Nov 2016 16:05:01 GMT)
Full text and
rfc822 format available.
Message #47 received at 23422 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
unarchive 23422
stop
On 05/05/16 09:23, Pádraig Brady wrote:
> Both points are valid.
> %N had a defacto style on Linux until now, but it was not documented.
> %N is not a standard style as it produces unquoted output on BSD for example.
>
> For the next version of coreutils we'll document the default format
> and allow selection of the quoting style used.
Patch to do the above is attached.
thanks,
Pádraig
[stat-N-QUOTING_STYLE.patch (text/x-patch, attachment)]
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#23422
; Package
coreutils
.
(Thu, 03 Nov 2016 22:30:03 GMT)
Full text and
rfc822 format available.
Message #50 received at 23422 <at> debbugs.gnu.org (full text, mbox):
On 11/03/2016 05:04 PM, Pádraig Brady wrote:
> Subject: [PATCH] stat: make --format=%N honor the QUOTING_STYLE env var
>
> * doc/coreutils.texi (stat invocation): Describe the
> QUOTING_STYLE values now supported.
> * src/stat.c (getenv_quoting_style): A new function called
> from main, that sets the default quoting style for quotearg.
> (main): Call getenv_quoting_style() when %N specified.
> * tests/misc/stat-fmt.sh: Add a test case.
> * NEWS: Mention the improvement.
> Fixes http://bugs.gnu.org/23422
The patch looks good to me, but the above URL seems to have
temporary redirection problems:
$ wget -S -O - http://bugs.gnu.org/23422 2>&1 | sed -n '/Location/{p;q}'
Location: http://debbugs.gnu.org23422
Have a nice day,
Berny
bug closed, send any further explanations to
23422 <at> debbugs.gnu.org and Michael Albinus <michael.albinus <at> gmx.de>
Request was from
Pádraig Brady <P <at> draigBrady.com>
to
control <at> debbugs.gnu.org
.
(Sat, 05 Nov 2016 00:51:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sat, 03 Dec 2016 12:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 7 years and 352 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.