From 2bd752012c561376c96fd21d4ecd8763e6dcd304 Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Sun, 10 Apr 2016 21:27:04 +0000 Subject: [PATCH] localpath --- urchin | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/urchin b/urchin index b619c83..b4a11e8 100755 --- a/urchin +++ b/urchin @@ -249,14 +249,15 @@ localpath() { child="$(fullpath "${2}" | sed 's/\/*$//')" if test "${parent}" = "${child}"; then - echo . + # Same file + return 1 + elif contains "${child}" "^${parent}"; + # Child is really a child. + echo "${child##"${parent}/"}" + return 0 else - rel="${child##"${parent}/"}" - if test "${rel}" = "${parent}"; then - return 1 - else - echo "${rel}" - fi + # Child is not really a child. + return 2 fi } @@ -275,10 +276,6 @@ is_set() { set | grep "^${1}=" > /dev/null } -remove_trailing_slash() { - echo "$1" | sed s/\\/$// -} - # File where a test's stdout and stderr is saved stdout_file() { tmp_dir="${1}"