bug-fileutils
[Top][All Lists]
Advanced

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

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


From: Paul Eggert
Subject: Re: mv exit status: `echo n |mv -i a b'
Date: Sun, 5 Aug 2001 09:50:28 -0700 (PDT)

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


> This is the ambiguous part of the POSIX spec:
> 
>   EXIT STATUS
>     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
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]