Hello,

On Sun, 18 Feb 2018, Floyd Anderson wrote:
>On Sun, 18 Feb 2018 14:44:24 +0100
>tu...@posteo.de wrote:
>> On 02/18 01:55, Floyd Anderson wrote:
>> > On Sun, 18 Feb 2018 13:07:33 +0100
>> > tu...@posteo.de 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"

$ bash t.sh *
$ ls -lb
-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--r-- 1 dh dh   0 Feb 18 17:26 a_b
-rw-r--r-- 1 dh dh   0 Feb 18 17:27 a_b_c
-rw-r--r-- 1 dh dh   0 Feb 18 17:23 a_b_c_#_d
-rw-r----- 1 dh dh 163 Feb 18 17:28 t.sh
$ rm *_*
$ zsh t.sh *
$ 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--r-- 1 dh dh   0 Feb 18 17:26 a_b
-rw-r--r-- 1 dh dh   0 Feb 18 17:27 a_b_c
-rw-r--r-- 1 dh dh   0 Feb 18 17:23 a_b_c_#_d
-rw-r----- 1 dh dh 163 Feb 18 17:28 t.sh

So, zsh can do it too. And pdksh.

HTH,
-dnh

-- 
printk("you lose buddy boy...\n");
        linux-2.6.6/arch/sparc/kernel/traps.c

Reply via email to