Gentoo Archives: gentoo-user

From: David Haller <gentoo@×××××××.de>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] detox'ing files by keeping their time stamp?
Date: Sun, 18 Feb 2018 16:36:57
Message-Id: 20180218163421.adjysrwugjjm7gkh@grusum.endjinn.de
In Reply to: Re: [gentoo-user] detox'ing files by keeping their time stamp? by Floyd Anderson
1 Hello,
2
3 On Sun, 18 Feb 2018, Floyd Anderson wrote:
4 >On Sun, 18 Feb 2018 14:44:24 +0100
5 >tuxic@××××××.de wrote:
6 >> On 02/18 01:55, Floyd Anderson wrote:
7 >> > On Sun, 18 Feb 2018 13:07:33 +0100
8 >> > tuxic@××××××.de wrote:
9 >> > > On 02/18 11:38, Stroller wrote:
10 [..]
11 >> > > > I think:
12 >> > > >
13 >> > > > tmpfile=/tmp/foo-$RANDOM
14 >> > > > touch -r "$file" "$tmpfile"
15 >> > > > detox "$file"
16 >> > > > touch -r "$tmpfile "$file"
17 >> > > > rm "$tmpfile"
18 [..]
19 >> > > I like to wrap detox with a script, which will do you magic trick.
20 >> > > Since I want to get rid of those evil characters (...) in the filename,
21 >> > > which normally intercept shell processing, I want to use detox,
22 >> > > which in turn will be called by a shell script in turn, to do the
23 >> > > time machine magic. To do so, I need detox, to sanitize the
24 >> > > filenames from the evil characters, which normally intercept.....
25 >> > > .....stack overflow....recursion depth failure.....process killed.
26 [..]
27 >So you have to figure out why detox, that I doesn't know and thus never have
28 >been used, does not rename those files. Maybe because the new file (after
29 >file name translation) already exists in directory as mentioned in the BUGS
30 >section of the manual page. So you must ensure that all resulting file names
31 >are unique.
32 [..]
33 >> And the circle starts right from the beginning.
34 >> The problem arises at that moment, where I need to feed the name
35 >> of a single file what program ever, since first there is the shell...
36 >> even when calling other programs.
37 >
38 >Here comes escaping and/or quoting into play but the glob `detox *`, you've
39 >specified, should work. Can you share a sample file name with funny
40 >characters in it?
41
42 Well, at least bash is robust enough if you quote variables correctly.
43
44 $ ls -lb
45 total 4
46 -rw-r--r-- 1 dh dh 0 Feb 18 17:23 a\ "\ b\ '\ c\ #\ d
47 -rw-r--r-- 1 dh dh 0 Feb 18 17:27 a"b\ c
48 -rw-r--r-- 1 dh dh 0 Feb 18 17:26 a'b
49 -rw-r----- 1 dh dh 166 Feb 18 17:26 t.sh
50
51 $ cat t.sh
52 #!/bin/bash
53 TMPF=$(mktemp "/tmp/detox_wrapper.$$.XXXXXXXX")
54 for f in "$@"; do
55 touch -r "$f" "$TMPF"
56 detox "$f"
57 touch -r "$TMPF" "$f"
58 done
59 rm -f "$TMPF"
60
61 $ bash t.sh *
62 $ ls -lb
63 -rw-r--r-- 1 dh dh 0 Feb 18 17:23 a\ "\ b\ '\ c\ #\ d
64 -rw-r--r-- 1 dh dh 0 Feb 18 17:27 a"b\ c
65 -rw-r--r-- 1 dh dh 0 Feb 18 17:26 a'b
66 -rw-r--r-- 1 dh dh 0 Feb 18 17:26 a_b
67 -rw-r--r-- 1 dh dh 0 Feb 18 17:27 a_b_c
68 -rw-r--r-- 1 dh dh 0 Feb 18 17:23 a_b_c_#_d
69 -rw-r----- 1 dh dh 163 Feb 18 17:28 t.sh
70 $ rm *_*
71 $ zsh t.sh *
72 $ ls -lb
73 total 4
74 -rw-r--r-- 1 dh dh 0 Feb 18 17:23 a\ "\ b\ '\ c\ #\ d
75 -rw-r--r-- 1 dh dh 0 Feb 18 17:27 a"b\ c
76 -rw-r--r-- 1 dh dh 0 Feb 18 17:26 a'b
77 -rw-r--r-- 1 dh dh 0 Feb 18 17:26 a_b
78 -rw-r--r-- 1 dh dh 0 Feb 18 17:27 a_b_c
79 -rw-r--r-- 1 dh dh 0 Feb 18 17:23 a_b_c_#_d
80 -rw-r----- 1 dh dh 163 Feb 18 17:28 t.sh
81
82 So, zsh can do it too. And pdksh.
83
84 HTH,
85 -dnh
86
87 --
88 printk("you lose buddy boy...\n");
89 linux-2.6.6/arch/sparc/kernel/traps.c

Replies

Subject Author
Re: [gentoo-user] detox'ing files by keeping their time stamp? Floyd Anderson <f.a@××××.net>