urchin root

This commit is contained in:
Thomas Levine 2016-02-27 16:53:27 +00:00
parent e5ba45ae96
commit fdc7129921

45
urchin
View File

@ -26,31 +26,28 @@ urchin_root() {
orig="$1" orig="$1"
fi fi
( if ! test -e "$current"; then
set -e echo "$current: No such file or directory">&2
exit 1
if ! test -e "$current"; then elif test -f "$current"; then
echo "$current: No such file or directory">&2 urchin_root "$(dirname "$current")" "$orig"
exit 1 elif test -d "$current"/.urchin; then
elif test -f "$current"; then echo "$current"
urchin_root "$(dirname "$current")" "$orig" elif test "$(readlink -f "$current")" = /; then
elif test -d "$current"/.urchin; then if test -d "$orig"; then
echo "$current" origdir="$orig"
elif test "$(readlink -f "$current")" = /; then else
if test -d "$orig"; then origdir=$(dirname "$orig")
origdir="$orig" fi
else echo "You need to create the .urchin directory in the root of your tests,
origdir=$(dirname "$orig")
fi
echo "You need to create the .urchin directory in the root of your tests,
maybe like this: maybe like this:
mkdir '$origdir/.urchin' mkdir '$(echo "$origdir" | sed s/\\/$//)/.urchin'
" >&2 " >&2
else return 1
urchin_root "$current"/.. "$orig" else
fi urchin_root "$current"/.. "$orig"
) fi
} }
indent() { indent() {
@ -359,7 +356,9 @@ if [ "$#" != '1' ] || [ ! -d "$1" ]
fi fi
# Run or present the Molly guard. # Run or present the Molly guard.
if dirname "$(readlink -f "$(urchin_root "$1")")" | if ! urchin_root "$1" > /dev/null; then
exit 1
elif basename "$(readlink -f "$(urchin_root "$1")")" |
grep -Fi 'test' > /dev/null || $force; then grep -Fi 'test' > /dev/null || $force; then
logfile="$(readlink -f "$(urchin_root "$1")/.urchin/.log")" logfile="$(readlink -f "$(urchin_root "$1")/.urchin/.log")"
echo > "$logfile" echo > "$logfile"