#!/bin/bash set -e exit=0 rm -rf scenario mkdir scenario mkdir scenario/dir scenario/target-dir touch scenario/target-file scenario/target-dir/file ln -s ../target-file scenario/dir/link-file ln -s ../target-dir scenario/dir/link-dir testone() { rm -rf scenario-gnu scenario-uutils cp -a scenario scenario-gnu cp -a scenario scenario-uutils echo "============================= $@ ============================" env -C scenario-gnu gnu"$@" env -C scenario-uutils coreutils "$@" if ! diff -U0 <(env -C scenario-gnu find | env -C scenario-gnu xargs ls -ldh) <(env -C scenario-uutils find | env -C scenario-uutils xargs ls -ldh); then exit=1 fi } for option in "" -H -L -P --dereference --no-dereference "--dereference -L" "--no-dereference -L" "--no-dereference -P"; do testone chmod $option -R go-rwx dir testone chmod $option -R go-rwx dir/link-dir testone chmod $option -R go-rwx dir/link-file done if [ "$SUDO_USER" ]; then for option in "" -H -L -P "--dereference -H" "--dereference -L" --no-dereference; do testone chown $option -R $SUDO_USER dir testone chown $option -R $SUDO_USER dir/link-dir testone chown $option -R $SUDO_USER dir/link-file done fi if [ "$SUDO_USER" ]; then for option in "" -H -L -P "--dereference -H" "--dereference -L" --no-dereference; do testone chgrp $option -R $SUDO_USER dir testone chgrp $option -R $SUDO_USER dir/link-dir testone chgrp $option -R $SUDO_USER dir/link-file done fi rm -r scenario scenario-gnu scenario-uutils exit $exit