1 |
Hi David, |
2 |
|
3 |
On Sun, 18 Feb 2018 17:34:21 +0100 |
4 |
David Haller <gentoo@×××××××.de> wrote: |
5 |
>Hello, |
6 |
> |
7 |
>On Sun, 18 Feb 2018, Floyd Anderson wrote: |
8 |
>>On Sun, 18 Feb 2018 14:44:24 +0100 |
9 |
>>tuxic@××××××.de wrote: |
10 |
>>> On 02/18 01:55, Floyd Anderson wrote: |
11 |
>>> > On Sun, 18 Feb 2018 13:07:33 +0100 |
12 |
>>> > tuxic@××××××.de wrote: |
13 |
>>> > > On 02/18 11:38, Stroller wrote: |
14 |
>[..] |
15 |
>>> > > > I think: |
16 |
>>> > > > |
17 |
>>> > > > tmpfile=/tmp/foo-$RANDOM |
18 |
>>> > > > touch -r "$file" "$tmpfile" |
19 |
>>> > > > detox "$file" |
20 |
>>> > > > touch -r "$tmpfile "$file" |
21 |
>>> > > > rm "$tmpfile" |
22 |
>[..] |
23 |
>>> > > I like to wrap detox with a script, which will do you magic trick. |
24 |
>>> > > Since I want to get rid of those evil characters (...) in the filename, |
25 |
>>> > > which normally intercept shell processing, I want to use detox, |
26 |
>>> > > which in turn will be called by a shell script in turn, to do the |
27 |
>>> > > time machine magic. To do so, I need detox, to sanitize the |
28 |
>>> > > filenames from the evil characters, which normally intercept..... |
29 |
>>> > > .....stack overflow....recursion depth failure.....process killed. |
30 |
>[..] |
31 |
>>So you have to figure out why detox, that I doesn't know and thus never have |
32 |
>>been used, does not rename those files. Maybe because the new file (after |
33 |
>>file name translation) already exists in directory as mentioned in the BUGS |
34 |
>>section of the manual page. So you must ensure that all resulting file names |
35 |
>>are unique. |
36 |
>[..] |
37 |
>>> And the circle starts right from the beginning. |
38 |
>>> The problem arises at that moment, where I need to feed the name |
39 |
>>> of a single file what program ever, since first there is the shell... |
40 |
>>> even when calling other programs. |
41 |
>> |
42 |
>>Here comes escaping and/or quoting into play but the glob `detox *`, you've |
43 |
>>specified, should work. Can you share a sample file name with funny |
44 |
>>characters in it? |
45 |
> |
46 |
>Well, at least bash is robust enough if you quote variables correctly. |
47 |
> |
48 |
>$ ls -lb |
49 |
>total 4 |
50 |
>-rw-r--r-- 1 dh dh 0 Feb 18 17:23 a\ "\ b\ '\ c\ #\ d |
51 |
>-rw-r--r-- 1 dh dh 0 Feb 18 17:27 a"b\ c |
52 |
>-rw-r--r-- 1 dh dh 0 Feb 18 17:26 a'b |
53 |
>-rw-r----- 1 dh dh 166 Feb 18 17:26 t.sh |
54 |
> |
55 |
>$ cat t.sh |
56 |
>#!/bin/bash |
57 |
>TMPF=$(mktemp "/tmp/detox_wrapper.$$.XXXXXXXX") |
58 |
>for f in "$@"; do |
59 |
> touch -r "$f" "$TMPF" |
60 |
> detox "$f" |
61 |
> touch -r "$TMPF" "$f" |
62 |
>done |
63 |
>rm -f "$TMPF" |
64 |
|
65 |
If I’m not totally wrong, the second `touch` cannot work because the |
66 |
file that "$f" holds is renamed now. That’s what I mean earlier with |
67 |
iterating a list or adapt Stroller’s suggestion. |
68 |
|
69 |
I have no idea if: |
70 |
|
71 |
modtime="$(stat -c '%Y' "$f")" |
72 |
newfile="$(detox $"f")" |
73 |
touch -d "@$modtime" "$newfile" |
74 |
|
75 |
is possible instead. |
76 |
|
77 |
|
78 |
-- |
79 |
Regards, |
80 |
floyd |