Gentoo Archives: gentoo-user

From: Floyd Anderson <f.a@××××.net>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] detox'ing files by keeping their time stamp?
Date: Sun, 18 Feb 2018 12:55:25
Message-Id: 20180218125511.2dgsxufatvsnkeuh@31c0.net
In Reply to: Re: [gentoo-user] detox'ing files by keeping their time stamp? by tuxic@posteo.de
1 On Sun, 18 Feb 2018 13:07:33 +0100
2 tuxic@××××××.de wrote:
3 >On 02/18 11:38, Stroller wrote:
4 >>
5 >> > On 18 Feb 2018, at 08:21, tuxic@××××××.de wrote:
6 >> >
7 >> > when downloading files from non-UNIX sites, they often contain
8 >> > "poisonoys" characters like '#', ' ', ''' or that alike.
9 >> >
10 >> > With the tool 'detox' those filenames could be fixed.
11 >> >
12 >> > But detox changes the time stamp of the files, which
13 >> > filenames are altered (not all files, which are examined).
14 >> >
15 >> > Is there a way to either get detox not to alter the time stamp
16 >>
17 >> I think:
18 >>
19 >> tmpfile=/tmp/foo-$RANDOM
20 >> touch -r "$file" "$tmpfile"
21 >> detox "$file"
22 >> touch -r "$tmpfile "$file"
23 >> rm "$tmpfile"
24 >>
25 >> It should be trivial to patch detox to do this itself.
26 >>
27 >> Stroller
28 >>
29 >>
30 >>
31 >
32 >Hi Stroller,
33 >
34 >this seems to be an egg<->chicken problem.
35 >
36 >I like to wrap detox with a script, which will do you magic trick.
37 >Since I want to get rid of those evil characters (...) in the filename,
38 >which normally intercept shell processing, I want to use detox,
39 >which in turn will be called by a shell script in turn, to do the
40 >time machine magic. To do so, I need detox, to sanitize the
41 >filenames from the evil characters, which normally intercept.....
42 >.....stack overflow....recursion depth failure.....process killed.
43 >
44 >You know....
45 >
46 >I am using zsh...
47 >
48 >Any idea to get a chicken OR an egg instead of an scrambled egg with
49 >feathers??? ;)
50
51 Go back one step and reread the manual page. It seems to be there is an
52 option ‘--dry-run’ (implies ‘--verbose’) that can probably be used to
53 store a list of the final new file names. Afterwards you can traverse
54 this list with Stroller’s suggestion (slightly adopted of course).
55
56 Or you can try other tools which doesn’t use function rename() [1], e.g.
57 perl-rename, and therefore don’t change the last modification time.
58
59 Or you can go two steps back and save the file(s) to your like when you
60 download it, e.g. with curl (maybe your’re also interested in its
61 ‘--remote-time’ option).
62
63
64 References:
65 - [1] <http://pubs.opengroup.org/onlinepubs/9699919799/functions/rename.html>
66
67
68 --
69 Regards,
70 floyd

Replies