#!/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
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;;