Sujet : Re: Problem with 'rm -i' in ksh
De : Keith.S.Thompson+u (at) *nospam* gmail.com (Keith Thompson)
Groupes : comp.unix.shellDate : 12. Jan 2025, 08:14:42
Autres entêtes
Organisation : None to speak of
Message-ID : <87h664jyfx.fsf@nosuchdomain.example.com>
References : 1 2
User-Agent : Gnus/5.13 (Gnus v5.13)
Christian Weisgerber <
naddy@mips.inka.de> writes:
On 2025-01-11, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
rm -i "${!a_set[@]}"
=>
rm: remove regular file `rmd2'? rm: remove regular file `rmd4'? rm:
remove regular file `rmd9 2'? rm: remove regular file `rmd9 3'?
>
Well, that's what you get when you redirect stdin to null:
>
$ rm -i *
remove a? n
remove b? n
remove c? n
$ rm -i * </dev/null
remove a? remove b? remove c? $
Which raises the question of what rm -i *should* do if stdin isn't
a tty.
POSIX specifically says that "rm shall write a prompt to standard
error and read a line from the standard input".
Changing the current behavior would (a) violate POSIX, and (b) break
usages like "yes | some_script", where "some_script" invokes rm -i.
The current behavior is well defined, even if it may not be ideal.
I can see the usefulness of, for example, bailing out with an error
message if stdin is not a tty or repeating the prompt if the input is
neither 'y' nor 'n' (or whatever the locale-specific equivalents are),
but if you want that you can program it yourself (or add it as a
non-standard option to rm).
-- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.comvoid Void(void) { Void(); } /* The recursive call of the void */