mirror of
https://codeberg.org/landley/toybox.git
synced 2026-01-26 14:13:25 +00:00
Peter McConalogue pointed out that cp/mv -i prompt should default N.
Also, the failing mv test was because posix says to prompt when mv-ing over an unwriteable file only when stdin is a tty (but -i prompts either way)
This commit is contained in:
parent
152e32857a
commit
dfd403c8d2
@ -135,32 +135,16 @@ testing "no clobber (dest doesn't exist)" \
|
||||
"yes\n" "" ""
|
||||
rm -f file*
|
||||
|
||||
# If there is stdin, it prompts. If no stdin, it moves anyway and file2 won't
|
||||
# exist.
|
||||
touch file1 file2
|
||||
chmod 400 file1 file2
|
||||
testing "mv over unwritable file: no stdin" \
|
||||
testing "over unwritable file only prompts when stdin is a terminal" \
|
||||
"mv file2 file1 2>/dev/null && [ -e file1 -a ! -e file2 ] && echo yes" \
|
||||
"yes\n" "" ""
|
||||
rm -f file*
|
||||
|
||||
touch file1 file2
|
||||
chmod 400 file1 file2
|
||||
testing "mv over unwritable file: answered YES" \
|
||||
"mv file2 file1 2>/dev/null && [ -e file1 -a ! -e file2 ] && echo yes" \
|
||||
"yes\n" "" "y\n"
|
||||
rm -f file*
|
||||
|
||||
touch file1 file2
|
||||
chmod 400 file1 file2
|
||||
testing "mv over unwritable file: answered NO" \
|
||||
"mv file2 file1 2>/dev/null && [ -e file1 -a -e file2 ] && echo yes" \
|
||||
"yes\n" "" "n\n"
|
||||
rm -f file*
|
||||
|
||||
touch file1 file2
|
||||
testing "interactive: no stdin" \
|
||||
"mv -i file2 file1 2>/dev/null && [ -e file1 -a ! -e file2 ] && echo yes" \
|
||||
"mv -i file2 file1 2>/dev/null && [ -e file1 -a -e file2 ] && echo yes" \
|
||||
"yes\n" "" ""
|
||||
rm -f file*
|
||||
|
||||
|
||||
@ -166,7 +166,7 @@ static int cp_node(struct dirtree *try)
|
||||
fprintf(stderr, "%s: overwrite '%s'", toys.which->name,
|
||||
s = dirtree_path(try, 0));
|
||||
free(s);
|
||||
if (!yesno(1)) return 0;
|
||||
if (!yesno(0)) return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -434,7 +434,7 @@ void cp_main(void)
|
||||
// _else_) but I don't care.
|
||||
if (exists && (FLAG(i) || !(st.st_mode & 0222))) {
|
||||
fprintf(stderr, "%s: overwrite '%s'", toys.which->name, TT.destname);
|
||||
if (!yesno(1)) rc = 0;
|
||||
if (!yesno(0)) rc = 0;
|
||||
else unlink(TT.destname);
|
||||
}
|
||||
// if -n and dest exists, don't try to rename() or copy
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user