error message when no root is set

This commit is contained in:
Thomas Levine 2016-02-27 14:50:04 +00:00
parent f9ddefcf54
commit 97faea610c
2 changed files with 20 additions and 10 deletions

View File

@ -0,0 +1,2 @@
#!/bin/sh
../../urchin --root /bin 2>&1 | grep "'/bin/.urchin'"

28
urchin
View File

@ -17,25 +17,33 @@ unset CDPATH
VERSION=0.0.6
urchin_root() {
# Call recursively but remember the original argument.
current="$1"
if test -n "$2"; then
orig="$2"
else
orig="$1"
fi
(
set -e
if ! test -e "$1"; then
echo "$1: No such file or directory">&2
if ! test -e "$current"; then
echo "$current: No such file or directory">&2
exit 1
elif test -f "$1"; then
urchin_root $(dirname "$1")
elif test -d "$1"/.urchin; then
echo "$1"
elif test "$(readlink -f $1)" = /; then
guess=$(readlink -f "$1"|sed s+\(/tests?/\).*+/tests/+)
elif test -f "$current"; then
urchin_root $(dirname "$current") "$orig"
elif test -d "$current"/.urchin; then
echo "$current"
elif test "$(readlink -f $current)" = /; then
guess=$(readlink -f "$orig"|sed s+\(/tests?/\).*+/tests/+)
echo "You need to create the .urchin directory in the root of your tests,
maybe like this:
mkdir '$guess'/.urchin
mkdir '$guess/.urchin'
" >&2
else
urchin_root "$1"/..
urchin_root "$current"/.. "$orig"
fi
)
}