From 36460f5364175cf5ccbf654fb9643db46f77da31 Mon Sep 17 00:00:00 2001 From: Jephte CLAIN Date: Mon, 15 Sep 2014 09:51:23 +0400 Subject: [PATCH] ajout de relpathx() --- lib/ulib/base | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/ulib/base b/lib/ulib/base index 5727127..69ec4ad 100644 --- a/lib/ulib/base +++ b/lib/ulib/base @@ -1239,6 +1239,18 @@ function relpath() { echo "${rp%//}" fi } +function relpathx() { +# Comme relpath, mais pour un chemin vers un exécutable qu'il faut lancer: +# s'assurer qu'il y a une spécification de chemin, e.g. ./script + local p="$(relpath "$@")" + if [ -z "$p" ]; then + echo . + elif [ "${p#../}" != "$p" -o "${p#./}" != "$p" ]; then + echo "$p" + else + echo "./$p" + fi +} function withinpath() { # Tester si le chemin absolu $2 se trouve dans le chemin absolu "$1" (appelée # barrière). Soit un chemin P, on considère que P est dans P. Si ce comportement