diff options
| -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")" +} |
