From 9e9bee407b7e44dfecf48c9e0b878f40c68f01a3 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Date: Mon, 24 Aug 2015 10:58:00 +0200 Subject: Replaced `realpath` for a custom `__g_realpath` function `realpath` is not a standard command, and it won't work on some systems or even in zsh. --- g.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/g.sh b/g.sh index 8513190..3b9846d 100644 --- a/g.sh +++ b/g.sh @@ -79,9 +79,16 @@ __g_join_path() { local IFS="/"; echo "$*"; } +# Replacement for the non-standard `realpath` command. Implemented taken from +# https://github.com/travis-ci/gimme. +__g_realpath() { + [ -d "$1" ] && echo "$(cd "$1" && pwd)" || echo "$(cd "$(dirname "$1")" + && pwd)/$(basename "$1")" +} + # The main function for this script. g() { - version="0.3.8" + version="0.3.9" cmd="$1" if [ -z "$cmd" ]; then __g_help @@ -121,7 +128,7 @@ g() { return 1 fi __g_get_shortcuts - __g_shortcuts[$2]=$(realpath $path) + __g_shortcuts[$2]=$(__g_realpath $path) __g_save_shortcuts ;; rm) -- cgit v1.2.3