diff options
Diffstat (limited to 'tests/cp')
-rwxr-xr-x | tests/cp/same-file | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/tests/cp/same-file b/tests/cp/same-file index 981f0768c..e8e303214 100755 --- a/tests/cp/same-file +++ b/tests/cp/same-file @@ -1,4 +1,8 @@ #!/bin/sh +# Test some of cp's options and how cp handles situations in +# which a naive implementation might overwrite the source file. + +: ${CP=cp} LANGUAGE=C; export LANGUAGE LANG=C; export LANG @@ -26,14 +30,18 @@ for args in 'foo symlink' 'symlink foo' 'foo foo' 'sl1 sl2'; do case "$args" in *sl2*) ln -s foo sl2;; esac ( ( - cp $options $args 2>.err + $CP $options $args 2>.err echo $? - test -s .err && echo "[`cat .err`]" + + # Normalize the program name in the error output, + # and put brackets around the output. + test -s .err && echo "[`sed 's/^[^:][^:]*:/cp:/' .err`]" # Strip off all but the file names. ls -lG * | sed 's/^..............................................//' + # Make sure the original is unchanged and that + # the destination is a copy. for f in $args; do if test -f $f; then - # make sure the file was copied. case "`cat $f`" in "$contents") ;; *) echo cp FAILED;; |