From de3facf3a96e85672442db943a09db2c40ba7e38 Mon Sep 17 00:00:00 2001 From: Jeffrey Crowell Date: Thu, 13 Aug 2015 14:44:12 -0400 Subject: [PATCH] do cannonicalize path the right way (tm) --- env.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/env.sh b/env.sh index 97e6424a965e4..5080b00650f7b 100755 --- a/env.sh +++ b/env.sh @@ -1,11 +1,11 @@ #!/bin/sh +function getabsolutepath(){ + [ -d "$1" ] && { cd "$1"; echo "$(pwd -P)"; } || + { cd "$(dirname "$1")"; echo "$(pwd -P)/$(basename "$1")"; } +} -case "$1" in -"~"*) pfx="$HOME/`cut -c 2- $1`" ; ;; -"/"*) pfx="$1" ; ;; -*) pfx="$PWD/$1" ; ;; -esac +pfx=$(getabsolutepath "$1") if [ -z "$pfx" ]; then echo "Usage: ./env.sh [destdir|prefix] [program]"