diff options
author | root | 2013-02-25 14:39:26 +0100 |
---|---|---|
committer | root | 2013-02-25 14:39:26 +0100 |
commit | 2598a2f4ec750b00610e1bac78fa3963231ab610 (patch) | |
tree | a0ebe96e859adac1c662297f45b4c46ac8858a78 /helper/string.inc | |
parent | Merge branch 'master' of git.openslx.org:openslx-ng/tm-scripts (diff) | |
download | tm-scripts-2598a2f4ec750b00610e1bac78fa3963231ab610.tar.gz tm-scripts-2598a2f4ec750b00610e1bac78fa3963231ab610.tar.xz tm-scripts-2598a2f4ec750b00610e1bac78fa3963231ab610.zip |
canonicalize function for paths
Diffstat (limited to 'helper/string.inc')
-rw-r--r-- | helper/string.inc | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/helper/string.inc b/helper/string.inc index 1d15b26e..0a166708 100644 --- a/helper/string.inc +++ b/helper/string.inc @@ -7,3 +7,8 @@ trim() { echo -n "$var" } +# usage: CANONICALIZED_STRING=$(canonalize <path>) +# usage with relative path requires you to be in the correct directory. +canonicalize() { + cd -P -- "$(dirname -- "$1")" && printf '%s\n' "$(pwd -P)/$(basename -- "$1")" +} |