Problem with 'rm -i' in ksh

Liste des GroupesRevenir à cu shell 
Sujet : Problem with 'rm -i' in ksh
De : janis_papanagnou+ng (at) *nospam* hotmail.com (Janis Papanagnou)
Groupes : comp.unix.shell
Date : 11. Jan 2025, 05:05:48
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vlsqmt$fem4$1@dont-email.me>
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0
I came across an issue whose origin I could not track down, neither
by constructing a test sample from scratch nor by reducing the whole
shell program. So I'm asking here just generally whether the observed
effect triggers some memories of the audience to get any hint or some
ideas what might possibly be a source of the issue. The context is...

I'm populating a set of files in an associative array (defined with
'typeset -A a_set') using
   a_set["${a_file}"]=
finally I want to remove them with 'rm'. So far so good. The program
creates (for example) for these commands the respective output[*]

  printf "rm '%s'\n" "${!a_set[@]}"
 =>
rm 'rmd2'
rm 'rmd4'
rm 'rmd9 2'
rm 'rmd9 3'

  print "${!a_set[@]}"
 =>
rmd2 rmd4 rmd9 2 rmd9 3

  rm "${!a_set[@]}"
 =>
# no output, and correctly removes the four sample files as expected

Since that's what I actually want I could just use that and be fine.

But being paranoid (with removing files) I wanted to use for a period
of time (to obtain confidence) the individual confirmations 'rm -i'

  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'?

The 'rm -i' version is just flushing out the above line on stderr
(and does nothing else)!

(I also tried '/bin/rm -i' to be on the safe side but to no avail.)

If the single shell commands (typeset -A, assignations, rm -i) are
issued interactively the 'mv -i' works as expected; I'm getting asked
for each file whether it shall be removed or not...

(1681)$ typeset -A a_set
(1682)$ a_set["rmd2"]=
(1683)$ a_set["rmd3"]=
(1684)$ a_set["rmd9 2"]=
(1685)$ a_set["rmd9 3"]=
(1686)$ print "${!a_set[@]}"
rmd2 rmd3 rmd9 2 rmd9 3
(1687)$ rm -i "${!a_set[@]}"
rm: remove regular file `rmd2'? n
rm: remove regular file `rmd3'? n
rm: remove regular file `rmd9 2'? n
rm: remove regular file `rmd9 3'? n


Does that effect - interaction of rm -i behavior with non-interactive
ksh, flushing the confirmation messages! - sound familiar to anybody?

(I get the same behavior with 'ksh 93u' and 'ksh 93u+m', BTW.)

Janis

[*] Note: in Kornshell the expression  ${!a_set[@]}  expands to the
list of keys/indexes of the associative array a_set.

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