When will os.remove fail?

Jon Ribbens jon+usenet at unequivocal.eu
Tue Mar 14 10:30:16 EDT 2017

On 2017-03-14, Chris Angelico <rosuav at gmail.com> wrote:
> On Wed, Mar 15, 2017 at 12:30 AM, Jon Ribbens <jon+usenet at unequivocal.eu> wrote:
>> rm does not ask before deleting. However some Linux distributions
>> take it upon themselves to put "alias rm='rm -i'" in /etc/profile.
> I have no such alias, but it still prompts.

I'm think you must be mistaken. What do you see if you type
'alias rm' and 'which rm'? Are you perhaps trying to delete
files to which you do not have write permission?

> 'man rm':
>        If the -I or --interactive=once option is given,  and  there  are  more
>        than  three  files  or  the  -r,  -R, or --recursive are given, then rm
>        prompts the user for whether to proceed with the entire operation.   If
>        the response is not affirmative, the entire command is aborted.
>        Otherwise,  if  a file is unwritable, standard input is a terminal, and
>        the -f or --force  option  is  not  given,  or  the  -i  or  --interac‐
>        tive=always  option is given, rm prompts the user for whether to remove
>        the file.  If the response is not affirmative, the file is skipped.

Yes, this describes the behaviour if you specify -I or -i,
as I mentioned - not if you don't specify either of those options.

> This is the GNU coreutils rm command.

I am talking about the GNU coreutils rm command (and POSIX for that
matter, since the behaviour of GNU rm appears to be POSIX compliant
as far as what we are talking about goes).

More information about the Python-list mailing list