When mv tries to overwrite a file with mode 0555 (read-only), it prompts for confirmation even when stdin is not a terminal. GNU mv silently proceeds in this scenario.
This is the mv equivalent of #7326, which was fixed for rm in PR #7492.
Expected behavior (GNU coreutils)
$ touch target && chmod 555 target
$ echo content > source
$ mv source target < /dev/null
$ # No promprt, file is moved
$ cat target
Actual behavior (uutils)
$ touch target && chmod 555 target
$ echo content > source
$ mv source target < /dev/null
mv: replace 'target', overriding mode 0555 (r-xr-xr-x)?
$ # Prompts and waits/fails, file is NOT moved
Reproducing script
#!/usr/bin/env bash
set -e
WORKDIR=$(mktemp -d)
cd "$WORKDIR"
trap "rm -rf $WORKDIR" EXIT
# Create a read-only target file
echo "original" > target
chmod 555 target
# Create source file
echo "replacement" > source
echo "=== Testing mv with stdin redirected from /dev/null ==="
echo "Running: mv source target < /dev/null"
# This should NOT prompt when stdin is not a terminal
if timeout 2 mv source target < /dev/null 2>&1; then
echo "PASS: mv completed without prompting"
echo "target contents: $(cat target)"
else
echo "FAIL: mv prompted or timed out (exit code: $?)"
echo "GNU mv would silently overwrite the file"
fi
When
mvtries to overwrite a file with mode 0555 (read-only), it prompts for confirmation even when stdin is not a terminal. GNUmvsilently proceeds in this scenario.This is the
mvequivalent of #7326, which was fixed forrmin PR #7492.Expected behavior (GNU coreutils)
Actual behavior (uutils)
Reproducing script