[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: mv exit status: `echo n |mv -i a b'

From: Jim Meyering
Subject: Re: mv exit status: `echo n |mv -i a b'
Date: Sun, 05 Aug 2001 23:40:28 +0200
User-agent: Gnus/5.090004 (Oort Gnus v0.04) Emacs/21.0.105

Paul Eggert <address@hidden> wrote:

>> From: Jim Meyering <address@hidden>
>> Date: Sun, 05 Aug 2001 12:34:09 +0200
>> With the proposed change:
>>   $ touch a b;echo n|./mv -i a b; echo $?; echo
>>   ./mv: overwrite `b', overriding mode 0444? 0
> That sounds like a good change,


> but doesn't the same issue arise even
> without the -i option?  For example, here is my reading of how 'mv'

Yes.  Vin Shelton reported that a week or so ago and
looking at the releated code is what prompted my question.

> should behave without -i:
>    $ rm -f a b; touch a b; chmod 0 a b; mv a b; echo $?
>    mv: b: override protection 0 (yes/no)? n
>    0
> and yet GNU mv mishandles this: it renames a to b without asking the
> user any questions.

I have a fix for that.

>> This is the ambiguous part of the POSIX spec:
>>     The following exit values shall be returned:
>>       0 All input files were moved successfully.
>>       >0 An error occurred.
>> The exit status seems to be over-specified, because with -i and a
>> negative response, there is neither an error, nor have all files been moved.
> My reading is that the POSIX spec (1003.1-200x d7) tries to
> distinguish between the "source files" (the files specified on the
> command line) and the "input files" (the files that are actually

Ahh... that makes more sense.
Thanks for clarifying.

> attempted to be moved, after -i and/or permissions checking is done).
> If my reading is correct, the exit status is not over-specified
> because all "input files" must be moved successfully for exit status
> 0; also, the traditional mv behavior conforms but GNU mv does not
> conform yet.  However, I agree that the standard could be worded more
> clearly.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]