Re: Problem with 'rm -i' in ksh

Liste des GroupesRevenir à cu shell 
Sujet : Re: Problem with 'rm -i' in ksh
De : gazelle (at) *nospam* shell.xmission.com (Kenny McCormack)
Groupes : comp.unix.shell
Date : 11. Jan 2025, 16:16:31
Autres entêtes
Organisation : The official candy of the new Millennium
Message-ID : <vlu20f$2rlri$1@news.xmission.com>
References : 1 2
User-Agent : trn 4.0-test77 (Sep 1, 2010)
In article <slrnvo4udu.a76.naddy@lorvorc.mips.inka.de>,
Christian Weisgerber  <naddy@mips.inka.de> wrote:
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? $

Yeah, that was my first reaction as well.  But it seems so obvious, that it
seems unlikely that this particular poster would have fallen into that trap.

Maybe the script is being executed in some non-normal environment, say in
cron, or in an "init" script, where stdin is redirected to /dev/null.

A couple of other comments:

1) I've found out recently that, under certain, as yet undetermined,
conditions, scripts run from .profile have stdin == /dev/null.

2) I think that "rm" should (*) open up /dev/tty to prompt for yes/no,
rather than rely on standard input.  It should fail/exit with an error
message if /dev/tty can't be opened (which will happen if the process has
no controlling terminal).

(*) "should" in the sense of does not now, but the world would be better if
it did.

--
"Insisting on perfect safety is for people who don't have the balls to live
in the real world."

    - Mary Shafer, NASA Ames Dryden -

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