Deutsch English Français Italiano |
<vlsqmt$fem4$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Janis Papanagnou <janis_papanagnou+ng@hotmail.com> Newsgroups: comp.unix.shell Subject: Problem with 'rm -i' in ksh Date: Sat, 11 Jan 2025 05:05:48 +0100 Organization: A noiseless patient Spider Lines: 69 Message-ID: <vlsqmt$fem4$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Date: Sat, 11 Jan 2025 05:05:50 +0100 (CET) Injection-Info: dont-email.me; posting-host="084cea3a58bc5f6225d8f47497c4a4fc"; logging-data="506564"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/LmNDuXi7+V2cbL4vV5j1x" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 Cancel-Lock: sha1:RwsEEsWHGfawoDTINonr1p+imck= X-Enigmail-Draft-Status: N1110 X-Mozilla-News-Host: news://news.eternal-september.org:119 Bytes: 3322 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.