:: Re: [DNG] Review of documentation n…
Etusivu
Poista viesti
Vastaa
Lähettäjä: Bob Proulx
Päiväys:  
Vastaanottaja: dng
Aihe: Re: [DNG] Review of documentation needed
g4sra via Dng wrote:
> I opt to live dangerously..(shove an '-r' in there too if you feel like it)
> $ rm -i .* *
> this way you can delete illegitimate entries without hacking the filesystem.


That is definitely dangerous indeed. For example if for whatever
reason one happens to have "-f" as a file name then it will override
the "-i" listed as a command line option and then all files will be
deleted without question.

    $ mkdir /tmp/testdir
    $ cd /tmp/testdir
    $ touch ./-f .foo foo
    $ echo rm -i .* *
    rm -i . .. .foo -f foo
    $ rm -i .* *
    rm: cannot remove '.': Is a directory
    rm: cannot remove '..': Is a directory
    $ ll -a
    -rw-rw-r--  1 rwp  rwp    0 Sep 22 14:57 -f
    drwxrwxr-x  2 rwp  rwp   60 Sep 22 14:57 ./
    drwxrwxrwt 11 root root 760 Sep 22 14:57 ../


Where is .foo? Where is foo? There was no -i prompt. The -f file is
still on disk and not removed? All correct behavior given the
command as given.

When dealing with file globs like "*" it is always better to prefix it
with "./" as in "./*" so as to avoid the first character having any
possibility of matching a dash and being interpreted as an option.
You make your own luck! :-)

[[ I have seen people intentionally leave a -i file in their home
directory so as to intentionally have rm * cause it to be interpreted
as an option. I recommend not relying upon it though. ]]

Bob