touch /no/such-dir >> out 2>&1 && fail=1
-cat > exp <<\EOF
-touch: setting times of `/': Permission denied
-touch: creating `/no/such-dir': No such file or directory
+# On SunOS4, EPERM is `Not owner'.
+# On some *BSD systems it's `Operation not permitted'.
+for msg in 'Not owner' 'Operation not permitted' 'Permission denied'; do
+ cat > exp <<EOF
+ touch: setting times of \`/': $msg
+ touch: creating \`/no/such-dir': No such file or directory
EOF
-cmp out exp || {
- # On SunOS4, EPERM is `Not owner'
- cat > exp2 <<\EOF
-touch: setting times of `/': Not owner
-touch: creating `/no/such-dir': No such file or directory
-EOF
- cmp out exp2 || fail=1
-}
+ cmp out exp > /dev/null 2>&1 && break
+
+done
test $fail = 1 && diff out exp 2> /dev/null