Since coreutils 9.3 we had --update={all,older} override -i.
In coreutils 9.5 this was expanded to -u
(to make it consistent with --update=older).
This patch reinstates things so that -i combines with -u instead.
I.e. have -i be protective, rather than selective (like -u).
The -f option of mv is similarly adjusted in this patch,
so now --update does not override any of -f,-i,-n.
* NEWS: Mention the bug fix.
* src/cp.c (main): Don't have -u disable prompting.
* src/mv.c (main): Likewise.
* tests/cp/cp-i.sh: Add a test case for -i.
* tests/mv/update.sh: Likewise.
* tests/mv/i-3.sh. Add a test case for -f.
Fixes https://bugs.gnu.org/70887
rejected as an invalid option.
[bug introduced in coreutils-9.5]
+ cp,mv --update no longer overrides --interactive or --force.
+ [bug introduced in coreutils-9.3]
+
ls and printf fix shell quoted output in the edge case of escaped
first and last characters, and single quotes in the string.
[bug introduced in coreutils-8.26]
break;
case 'i':
- x.interactive = I_ASK_USER;
+ /* -i overrides -n, but not --update={none,none-fail}. */
+ if (no_clobber || x.interactive == I_UNSPECIFIED)
+ x.interactive = I_ASK_USER;
break;
case 'l':
{
/* Default cp operation. */
x.update = false;
- x.interactive = I_UNSPECIFIED;
+ if (x.interactive != I_ASK_USER)
+ x.interactive = I_UNSPECIFIED;
}
else if (update_opt == UPDATE_NONE)
{
else if (update_opt == UPDATE_OLDER)
{
x.update = true;
- x.interactive = I_UNSPECIFIED;
+ if (x.interactive != I_ASK_USER)
+ x.interactive = I_UNSPECIFIED;
}
}
break;
version_control_string = optarg;
break;
case 'f':
- x.interactive = I_ALWAYS_YES;
+ /* -f overrides -n, or -i, but not --update={none,none-fail}. */
+ if (no_clobber
+ || x.interactive == I_ASK_USER
+ || x.interactive == I_UNSPECIFIED)
+ x.interactive = I_ALWAYS_YES;
break;
case 'i':
- x.interactive = I_ASK_USER;
+ /* -i overrides -n, or -f, but not --update={none,none-fail}. */
+ if (no_clobber
+ || x.interactive == I_ALWAYS_YES
+ || x.interactive == I_UNSPECIFIED)
+ x.interactive = I_ASK_USER;
break;
case 'n':
x.interactive = I_ALWAYS_SKIP;
{
/* Default mv operation. */
x.update = false;
- x.interactive = I_UNSPECIFIED;
+ if (x.interactive != I_ASK_USER
+ && x.interactive != I_ALWAYS_YES)
+ x.interactive = I_UNSPECIFIED;
}
else if (update_opt == UPDATE_NONE)
{
else if (update_opt == UPDATE_OLDER)
{
x.update = true;
- x.interactive = I_UNSPECIFIED;
+ if (x.interactive != I_ASK_USER
+ && x.interactive != I_ALWAYS_YES)
+ x.interactive = I_UNSPECIFIED;
}
}
break;
returns_ 1 cp -b --update=none c d 2>/dev/null || fail=1
returns_ 1 cp -b --update=none-fail c d 2>/dev/null || fail=1
+# Verify -i combines with -u,
+echo old > old || framework_failure_
+touch -d yesterday old || framework_failure_
+echo new > new || framework_failure_
+# coreutils 9.3 had --update={all,older} ignore -i
+echo n | returns_ 1 cp -vi --update=older new old 2>/dev/null >out8 || fail=1
+compare /dev/null out8 || fail=1
+echo n | returns_ 1 cp -vi --update=all new old 2>/dev/null >out8 || fail=1
+compare /dev/null out8 || fail=1
+# coreutils 9.5 also had -u ignore -i
+echo n | returns_ 1 cp -vi -u new old 2>/dev/null >out8 || fail=1
+compare /dev/null out8 || fail=1
+# Don't prompt as not updating
+cp -v -i --update=none new old 2>/dev/null >out8 </dev/null || fail=1
+compare /dev/null out8 || fail=1
+# Likewise, but coreutils 9.3 - 9.5 incorrectly ignored the update option
+cp -v --update=none -i new old 2>/dev/null >out8 </dev/null || fail=1
+compare /dev/null out8 || fail=1
+
Exit $fail
uname -s | grep 'BSD$' && skip_ 'known spurious failure on *BSD'
-touch f g h i || framework_failure_
-chmod 0 g i || framework_failure_
+touch f g h i j k || framework_failure_
+chmod 0 g i j k || framework_failure_
ls /dev/stdin >/dev/null 2>&1 \
cleanup_
-mv -f h i > out 2>&1 || fail=1
+# Make sure there was no prompt with -f
+timeout 10 mv -f h i > out 2>&1 || fail=1
test -f i || fail=1
test -f h && fail=1
+case "$(cat out)" in
+ '') ;;
+ *) fail=1 ;;
+esac
-# Make sure there was no prompt.
+# Likewise make sure there was no prompt with -f -u
+# coreutils 9.3-9.5 mistakenly did prompt.
+timeout 10 mv -f --update=all j k > out 2>&1 || fail=1
+test -f k || fail=1
+test -f j && fail=1
case "$(cat out)" in
'') ;;
*) fail=1 ;;
done
done
+# This should prompt. coreutils 9.3-9.5 mistakenly did not
+echo n | returns_ 1 mv -vi -u new old >/dev/null 2>&1 || fail=1
+
# These should accept all options
for update_option in '--update' '--update=older' '--update=all' \
'--update=none' '--update=none-fail'; do