Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 33828 - mv --reply not working properly
Summary: mv --reply not working properly
Status: RESOLVED UPSTREAM
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Martin Schlemmer (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-11-19 07:38 UTC by Voltron Rex
Modified: 2003-12-19 03:14 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Voltron Rex 2003-11-19 07:38:24 UTC
The command 'mv --reply=no' does not work as expected. mv --help gives this
information: 
"      --reply={yes,no,query}   specify how to handle the prompt about an
                                 existing destination file
"

I expect that this means when mv would overwrite a file it shouldn't. However,
whether I use --reply=yes or --reply=no the file is always overwritten.


Reproducible: Always
Steps to Reproduce:
1. echo a>a; echo b>b
2. mv  --reply=no a b
3. cat b

Actual Results:  
cat b ==> 'a'

Expected Results:  
Unless I totally misunderstand how --reply works, cat b should result in 'b'

This behavior has also been confirmed on Debian unstable.
Comment 1 Marius Mauch (RETIRED) gentoo-dev 2003-11-19 10:12:51 UTC
Here is the relevant sourcecode snippet (edited for readybility):

/* cp and mv treat -i and -f differently.  */
if (x->move_mode) {
    if ((x->interactive == I_ALWAYS_NO
	    && UNWRITABLE (dst_path, dst_sb.st_mode))
	|| ((x->interactive == I_ASK_USER
	        || (x->interactive == I_UNSPECIFIED
		    && x->stdin_tty
		    && UNWRITABLE (dst_path, dst_sb.st_mode)))
             && (overwrite_prompt (dst_path, &dst_sb), 1)
             && ! yesno ())) {
        /* Pretend the rename succeeded, so the caller (mv)
	doesn't end up removing the source file.  */
	if (rename_succeeded)
	    *rename_succeeded = 1;
	return 0;
    }
}

The condition (x->interactive == I_ALWAYS_NO && UNWRITABLE (dst_path, dst_sb.st_mode)) is the part affected by --reply=no, but only if the destination is not writable. Skipping the UNWRITABLE() test brings the desired behavior, so the question is if that's a bug or a feature (the man/info pages aren't clear on this).
Comment 2 Seemant Kulleen (RETIRED) gentoo-dev 2003-12-19 03:14:00 UTC
closing this, as there's nothing we can really do about it