Deutsch English Français Italiano |
<87h664jyfx.fsf@nosuchdomain.example.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!fu-berlin.de!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Keith Thompson <Keith.S.Thompson+u@gmail.com> Newsgroups: comp.unix.shell Subject: Re: Problem with 'rm -i' in ksh Date: Sat, 11 Jan 2025 23:14:42 -0800 Organization: None to speak of Lines: 35 Message-ID: <87h664jyfx.fsf@nosuchdomain.example.com> References: <vlsqmt$fem4$1@dont-email.me> <slrnvo4udu.a76.naddy@lorvorc.mips.inka.de> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Sun, 12 Jan 2025 08:15:15 +0100 (CET) Injection-Info: dont-email.me; posting-host="e09f1c48d05ea16eba68b16586b9febd"; logging-data="1121884"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+52PlDateDPrs0+Ix+M/gS" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:W3vaIxlU7Yg749oZLXOWX5otjNg= sha1:lQ4JjuNtAeH3XCQnOt5/WM46i0c= Bytes: 2305 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.com void Void(void) { Void(); } /* The recursive call of the void */