emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[debbugs-tracker] bug#21065: closed (Small bug in touch)


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#21065: closed (Small bug in touch)
Date: Wed, 15 Jul 2015 16:37:02 +0000

Your message dated Wed, 15 Jul 2015 09:40:08 -0600
with message-id <address@hidden>
and subject line Re: bug#21065: Small bug in touch
has caused the debbugs.gnu.org bug report #21065,
regarding Small bug in touch
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
21065: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=21065
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: Small bug in touch Date: Wed, 15 Jul 2015 15:25:02 +0200
touch version 8.23

Command:
$ touch -- '-'
Happens:
Returns successfully, but no file is created (if file exists, timestamp is not updated)

Rickard

--- End Message ---
--- Begin Message --- Subject: Re: bug#21065: Small bug in touch Date: Wed, 15 Jul 2015 09:40:08 -0600 User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.0.1
On 07/15/2015 09:31 AM, Eric Blake wrote:
> tag 21065 notabug
> thanks
> 
> On 07/15/2015 07:25 AM, Rickard Norlander wrote:
>> touch version 8.23
>>
>> Command:
>> $ touch -- '-'
>> Happens:
>> Returns successfully, but no file is created (if file exists, timestamp is
>> not updated)
> 
> Like many other tools, '-' is special-cased in touch to mean operation
> on stdin:

Looks like I'm not careful in what I wrote; most utilities treat '-' as
stdin, but touch documented...

> 
> $ touch --help | grep -A1 ' - '
> A FILE argument string of - is handled specially and causes touch to
> change the times of the file associated with standard output.

...that it was affecting stdout.

> 
> So you successfully touched stdin (in your case, /dev/tty).

Either way, in your example, since you were using an interactive shell,
/dev/tty was still touched,

>  If you want
> to create a file named '-', use 'touch ./-'.

and this advice still holds.

On a related note, the just-released 8.24 fixed 'tee -' to NOT treat '-'
as meaning stdout (which was a violation of POSIX) and to instead treat
it as a literal file.

Here's what POSIX says:

http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html

Guideline 13:
    For utilities that use operands to represent files to be opened for
either reading or writing, the '-' operand should be used to mean only
standard input (or standard output when it is clear from context that an
output file is being specified) or a file named -.

It's not obvious whether 'touch' is opening a file for reading or
writing (it doesn't always have to open a file, after all, but if it
creates the file it IS opening it even if it doesn't read or write to
the file).

We changed 'touch -' way back in 5.90, in 2005, when making a bunch of
POSIX cleanups, so I guess the argument at the time probably still holds
that we are not in violation of that guideline by treating '-' as
stdout, even though POSIX does not explicitly describe that behavior in:

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/touch.html

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]