From debbugs-submit-bounces@debbugs.gnu.org Sat Feb 09 14:50:30 2013 Received: (at submit) by debbugs.gnu.org; 9 Feb 2013 19:50:30 +0000 Received: from localhost ([127.0.0.1]:47126 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1U4GRR-0006zH-4Q for submit@debbugs.gnu.org; Sat, 09 Feb 2013 14:50:30 -0500 Received: from eggs.gnu.org ([208.118.235.92]:55877) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1U4Flz-0005us-DF for submit@debbugs.gnu.org; Sat, 09 Feb 2013 14:07:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U4Flm-0003Bi-OE for submit@debbugs.gnu.org; Sat, 09 Feb 2013 14:07:29 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-102.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, T_DKIM_INVALID, USER_IN_WHITELIST autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:43666) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U4Flm-0003Bd-LB for submit@debbugs.gnu.org; Sat, 09 Feb 2013 14:07:26 -0500 Received: from eggs.gnu.org ([208.118.235.92]:38929) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U4Fll-0002yB-78 for bug-coreutils@gnu.org; Sat, 09 Feb 2013 14:07:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U4FlN-00036p-4S for bug-coreutils@gnu.org; Sat, 09 Feb 2013 14:07:02 -0500 Received: from mail-lb0-f174.google.com ([209.85.217.174]:60330) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U4FlM-00036N-Ry for bug-coreutils@gnu.org; Sat, 09 Feb 2013 14:07:01 -0500 Received: by mail-lb0-f174.google.com with SMTP id l12so3782915lbo.19 for ; Sat, 09 Feb 2013 11:06:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=58akXUQ8PD2hmiHht5a6lWDoc/1BVuOfhcecjj1FgSQ=; b=bZklUInSWDjZlk7xL2MI9+P6zGpeYLofM2pUCuKaC4MWG+7MV2iuFpq7/Qt2Uvggzz BMZ2FkL7KHZcWFz+21uTrKRY764XuT1EU/Dum2OT9bRjZaB6yKL7+W1eQ59O520SMz7+ tK0jFw4TLpyRAikd1HU3nB/SSDvIUAm25UDZPdLLmzrEBstMZB/iVtzuL42RhS70bhZP 5q3qjO5kAuEFFdbCShhFJ+K20dwVj2l++EgvsjplrWRZtAxS0KxaBSDNvo+Vf8myqjqU pHmmQs0ED6W54TvXzY/0ieBFieI7teEYhI8kutQjsANRvCQDXEdGaaO/Xd2CCNQ+WJ4c q4BQ== MIME-Version: 1.0 X-Received: by 10.112.54.1 with SMTP id f1mr3794675lbp.85.1360436818488; Sat, 09 Feb 2013 11:06:58 -0800 (PST) Received: by 10.112.57.33 with HTTP; Sat, 9 Feb 2013 11:06:58 -0800 (PST) Date: Sat, 9 Feb 2013 11:06:58 -0800 Message-ID: Subject: Touch: Cannot use a symbolic link as a reference time From: Michael_google gmail_Gersten To: bug-coreutils@gnu.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 208.118.235.17 X-Spam-Score: -3.4 (---) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Sat, 09 Feb 2013 14:50:27 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.2 (----) I can set the timestamp of a symbolic link with "-h". But I cannot use "-r -h" to use the timestamp on a symbolic link as the reference time. keybounceMBP:QuickTime Player michael$ ls -l capture.mov 4 lrwxr-xr-x 1 michael staff 57 Aug 24 04:54 capture.mov -> ../../iMovie Events.localized/Season 2 header/capture.mov keybounceMBP:QuickTime Player michael$ ls -lL capture.mov 365800 -rw-r--r-- 1 michael staff 374572867 Feb 8 23:50 capture.mov keybounceMBP:QuickTime Player michael$ touch -r -h capture.mov capture.mov touch: failed to get attributes of =E2=80=98-h=E2=80=99: No such file or di= rectory (Yes, the fault is iMovie for arbitrarily touching the timestamps of the movies in it's library. I'm trying to fix it.) --=20 Political and economic blog of a strict constitutionalist http://StrictConstitution.BlogSpot.com This message may have been spell checked by a laptop kitten. From debbugs-submit-bounces@debbugs.gnu.org Wed Feb 13 03:21:39 2013 Received: (at 13666-done) by debbugs.gnu.org; 13 Feb 2013 08:21:39 +0000 Received: from localhost ([127.0.0.1]:53172 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1U5Xb0-0006f9-Sk for submit@debbugs.gnu.org; Wed, 13 Feb 2013 03:21:39 -0500 Received: from moutng.kundenserver.de ([212.227.17.10]:55304) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1U5Xax-0006ez-0c for 13666-done@debbugs.gnu.org; Wed, 13 Feb 2013 03:21:36 -0500 Received: from [192.168.1.11] (p5083F782.dip.t-dialin.net [80.131.247.130]) by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis) id 0LuLO3-1V5VrE2j15-011TjI; Wed, 13 Feb 2013 09:21:03 +0100 Message-ID: <511B4CEE.4020204@bernhard-voelker.de> Date: Wed, 13 Feb 2013 09:21:02 +0100 From: Bernhard Voelker User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130105 Thunderbird/17.0.2 MIME-Version: 1.0 To: Michael_google gmail_Gersten Subject: Re: bug#13666: Touch: Cannot use a symbolic link as a reference time References: In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Provags-ID: V02:K0:pChqjwxKbrQEE/KMoH2BUzvgP27bNfI4iaUTjUE7xPG 3zrsPuprcqBiksZFBF19tlWnznjbU73Mzb/bmm/LnOSbx10GDM mWV+JAxNyUX3vq1G+PqL+LURppYemJWw0SroBDmOlFW5AKS6SX rz7oktgySUb5h4eDN9Qg9tEis9C/l00nLMfhF71pQSGRQeQR4V NFN84Dixu9NJgs1T7oNnejb1OYmFhfNXL1LCfKvm/T69qmTQAt zxoH96/fVNrFV5IyxRXX8oy2fTn452umt9bMc7e6pRJYCWfyJu Ea7FSgL8V+gKNQrHa7yj11fHBkP9qasuD+/vcuiX32cMnzHuRW fyaqBPmmRZhlw0iVF/ZtFToie5g5Bwd81RF4OU6F1 X-Spam-Score: 0.8 (/) X-Debbugs-Envelope-To: 13666-done Cc: 13666-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -0.0 (/) tag 13666 notabug thanks On 02/09/2013 08:06 PM, Michael_google gmail_Gersten wrote: > I can set the timestamp of a symbolic link with "-h". > > But I cannot use "-r -h" to use the timestamp on a symbolic link as > the reference time. Hello Michael, thanks for the bug report, however I doubt there is a bug. > keybounceMBP:QuickTime Player michael$ ls -l capture.mov > 4 lrwxr-xr-x 1 michael staff 57 Aug 24 04:54 capture.mov -> > ../../iMovie Events.localized/Season 2 header/capture.mov > keybounceMBP:QuickTime Player michael$ ls -lL capture.mov > 365800 -rw-r--r-- 1 michael staff 374572867 Feb 8 23:50 capture.mov > keybounceMBP:QuickTime Player michael$ touch -r -h capture.mov capture.mov > touch: failed to get attributes of ‘-h’: No such file or directory As the -r option requires an argument - the reference file - you can not use the -h option directly after it. Touch tried to use "-h" as the file name which obviously didn't work, and therefore reported that error. Instead, you can switch the 2 options: touch -h -r REFERENCE TARGET And this _does_ work with symlinks: $ touch target $ ln -vs target symlink ‘symlink’ -> ‘target’ $ touch -d yesterday -h symlink $ ls -ldog symlink target lrwxrwxrwx 1 6 Feb 12 08:53 symlink -> target -rw-r--r-- 1 0 Feb 13 08:52 target $ touch -hr symlink target $ ls -ldog symlink target lrwxrwxrwx 1 6 Feb 12 08:53 symlink -> target -rw-r--r-- 1 0 Feb 12 08:53 target However, in your case, this will not work, because the -h option works on both the reference file and the target, i.e. nothing will effectively happen if you use the symlink both as reference file and the target: $ touch -hr symlink symlink This has set the time on the symlink - see strace output: lstat("symlink", {st_mode=S_IFLNK|0777, st_size=6, ...}) = 0 utimensat(AT_FDCWD, "symlink", ..., AT_SYMLINK_NOFOLLOW) = 0 As the -h option is used on both the reference file and the target, you have to resolve the symlink yourself, either as like I did above, or by using the readlink utility: $ touch -hr symlink $(readlink symlink) This is all documented in the TEXINFO manual: `-h' `--no-dereference' Attempt to change the timestamps of a symbolic link, rather than what the link refers to. When using this option, empty files are not created, but option `-c' must also be used to avoid warning about files that do not exist. Not all systems support changing the timestamps of symlinks, since underlying system support for this action was not required until POSIX 2008. Also, on some systems, the mere act of examining a symbolic link changes the access time, such that only changes to the modification time will persist long enough to be observable. When coupled with option `-r', a reference timestamp is taken from a symbolic link rather than the file it refers to. `-r FILE' `--reference=FILE' Use the times of the reference FILE instead of the current time. If this option is combined with the `--date=TIME' (`-d TIME') option, the reference FILE's time is the origin for any relative TIMEs given, but is otherwise ignored. For example, `-r foo -d '-5 seconds'' specifies a time stamp equal to five seconds before the corresponding time stamp for `foo'. If FILE is a symbolic link, the reference timestamp is taken from the target of the symlink, unless `-h' was also in effect. There is no option to make touch use no-dereferencing on the reference file and use dereferencing on the target at the same time, and I doubt there are enough use cases which would make it worthwhile to add one. Finally, the situation is complicated enough - and some systems or file systems do not even support timestamps on symlinks. As such, I'm closing this bug report, although you may feel free to add further comments or questions. Have a nice day, Berny From unknown Thu Aug 21 12:12:12 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 13 Mar 2013 11:24:06 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator