]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
*** empty log message ***
authorJim Meyering <jim@meyering.net>
Sat, 27 Jun 1998 20:33:22 +0000 (20:33 +0000)
committerJim Meyering <jim@meyering.net>
Sat, 27 Jun 1998 20:33:22 +0000 (20:33 +0000)
tests/cp/same-file

index 981f0768c758292afaf055fc9760d1326b250c7f..e8e303214d8bfd86f0b8a3857b735fa6165c0b32 100755 (executable)
@@ -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;;