aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiquel Sabaté <msabate@suse.com>2015-08-24 10:58:00 +0200
committerMiquel Sabaté <msabate@suse.com>2015-08-24 10:58:00 +0200
commit9e9bee407b7e44dfecf48c9e0b878f40c68f01a3 (patch)
tree5290a825e01fd383ab392ac0d8f6ac7750256e53
parent21140b4d13d32e62c753d037d42f23fded879fad (diff)
downloadg-9e9bee407b7e44dfecf48c9e0b878f40c68f01a3.tar.gz
g-9e9bee407b7e44dfecf48c9e0b878f40c68f01a3.zip
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.
-rw-r--r--g.sh11
1 files 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)