#!/usr/bin/env bash
-set -e -o pipefail
-
top=$(pwd)
usage()
case "$1" in
'--setup')
(
- cd t/sampledata
- ln -sf a b
- ln -sf b c
- ln -sf /etc .
- )
+ cd t/sampledata || exit $?
+ ln -sf a b || exit $?
+ ln -sf b c || exit $?
+ ln -sf /etc . || exit $?
+ ) || exit $?
;;
'--clean')
(
- cd t/sampledata
- if test -e b; then rm b; fi
- if test -e c; then rm c; fi
- if test -e etc; then rm etc; fi
+ cd t/sampledata || exit $?
+ # test -e is false for dangling symlinks.
+ if test -h b -o -e b; then rm b || exit $?; fi
+ if test -h c -o -e c; then rm c || exit $?; fi
+ if test -h etc -o -e etc; then rm etc || exit $?; fi
)
;;
*)