Re: Problem with 'rm -i' in ksh

Liste des GroupesRevenir à cu shell 
Sujet : Re: Problem with 'rm -i' in ksh
De : Keith.S.Thompson+u (at) *nospam* gmail.com (Keith Thompson)
Groupes : comp.unix.shell
Date : 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.com
void Void(void) { Void(); } /* The recursive call of the void */

Date Sujet#  Auteur
11 Jan 25 * Problem with 'rm -i' in ksh21Janis Papanagnou
11 Jan 25 +* Re: Problem with 'rm -i' in ksh15Lem Novantotto
11 Jan 25 i`* Re: Problem with 'rm -i' in ksh14Janis Papanagnou
12 Jan 25 i `* Re: Problem with 'rm -i' in ksh13Lem Novantotto
12 Jan 25 i  `* Re: Problem with 'rm -i' in ksh12Janis Papanagnou
12 Jan 25 i   `* Re: Problem with 'rm -i' in ksh11Kenny McCormack
12 Jan 25 i    `* Re: Problem with 'rm -i' in ksh10Janis Papanagnou
12 Jan 25 i     +* Re: Problem with 'rm -i' in ksh2Janis Papanagnou
12 Jan 25 i     i`- Re: Problem with 'rm -i' in ksh1Lem Novantotto
13 Jan 25 i     `* Iterating over a set in bash (Was: Problem with 'rm -i' in ksh)7Kenny McCormack
13 Jan 25 i      +- Re: Iterating over a set in bash (Was: Problem with 'rm -i' in ksh)1Janis Papanagnou
13 Jan 25 i      `* Re: Iterating over a set in bash (Was: Problem with 'rm -i' in ksh)5Lem Novantotto
13 Jan 25 i       +- Re: Iterating over a set in bash (Was: Problem with 'rm -i' in ksh)1Lem Novantotto
14 Jan 25 i       `* Re: Iterating over a set in bash3Keith Thompson
14 Jan 25 i        `* Re: Iterating over a set in bash2Lem Novantotto
14 Jan 25 i         `- Re: Iterating over a set in bash1Janis Papanagnou
11 Jan 25 `* Re: Problem with 'rm -i' in ksh5Christian Weisgerber
11 Jan 25  +* Re: Problem with 'rm -i' in ksh2Kenny McCormack
12 Jan 25  i`- Re: Problem with 'rm -i' in ksh1Janis Papanagnou
12 Jan 25  +- Re: Problem with 'rm -i' in ksh1Janis Papanagnou
12 Jan 25  `- Re: Problem with 'rm -i' in ksh1Keith Thompson

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal