Hi David,
On Sun, 18 Feb 2018 17:34:21 +0100
David Haller <[email protected]> wrote:
Hello,
On Sun, 18 Feb 2018, Floyd Anderson wrote:
On Sun, 18 Feb 2018 14:44:24 +0100
[email protected] wrote:
On 02/18 01:55, Floyd Anderson wrote:
> On Sun, 18 Feb 2018 13:07:33 +0100
> [email protected] wrote:
> > On 02/18 11:38, Stroller wrote:
[..]
> > > I think:
> > >
> > > tmpfile=/tmp/foo-$RANDOM
> > > touch -r "$file" "$tmpfile"
> > > detox "$file"
> > > touch -r "$tmpfile "$file"
> > > rm "$tmpfile"
[..]
> > I like to wrap detox with a script, which will do you magic trick.
> > Since I want to get rid of those evil characters (...) in the filename,
> > which normally intercept shell processing, I want to use detox,
> > which in turn will be called by a shell script in turn, to do the
> > time machine magic. To do so, I need detox, to sanitize the
> > filenames from the evil characters, which normally intercept.....
> > .....stack overflow....recursion depth failure.....process killed.
[..]
So you have to figure out why detox, that I doesn't know and thus never have
been used, does not rename those files. Maybe because the new file (after
file name translation) already exists in directory as mentioned in the BUGS
section of the manual page. So you must ensure that all resulting file names
are unique.
[..]
And the circle starts right from the beginning.
The problem arises at that moment, where I need to feed the name
of a single file what program ever, since first there is the shell...
even when calling other programs.
Here comes escaping and/or quoting into play but the glob `detox *`, you've
specified, should work. Can you share a sample file name with funny
characters in it?
Well, at least bash is robust enough if you quote variables correctly.
$ ls -lb
total 4
-rw-r--r-- 1 dh dh 0 Feb 18 17:23 a\ "\ b\ '\ c\ #\ d
-rw-r--r-- 1 dh dh 0 Feb 18 17:27 a"b\ c
-rw-r--r-- 1 dh dh 0 Feb 18 17:26 a'b
-rw-r----- 1 dh dh 166 Feb 18 17:26 t.sh
$ cat t.sh
#!/bin/bash
TMPF=$(mktemp "/tmp/detox_wrapper.$$.XXXXXXXX")
for f in "$@"; do
touch -r "$f" "$TMPF"
detox "$f"
touch -r "$TMPF" "$f"
done
rm -f "$TMPF"
If I’m not totally wrong, the second `touch` cannot work because the
file that "$f" holds is renamed now. That’s what I mean earlier with
iterating a list or adapt Stroller’s suggestion.
I have no idea if:
modtime="$(stat -c '%Y' "$f")"
newfile="$(detox $"f")"
touch -d "@$modtime" "$newfile"
is possible instead.
--
Regards,
floyd