ajout de relpathx()
This commit is contained in:
parent
220016a1e9
commit
36460f5364
@ -1239,6 +1239,18 @@ function relpath() {
|
|||||||
echo "${rp%//}"
|
echo "${rp%//}"
|
||||||
fi
|
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() {
|
function withinpath() {
|
||||||
# Tester si le chemin absolu $2 se trouve dans le chemin absolu "$1" (appelée
|
# 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
|
# barrière). Soit un chemin P, on considère que P est dans P. Si ce comportement
|
||||||
|
Loading…
Reference in New Issue
Block a user