Skip to content

Commit

Permalink
do cannonicalize path the right way (tm)
Browse files Browse the repository at this point in the history
  • Loading branch information
crowell committed Aug 13, 2015
1 parent 4b55af7 commit de3facf
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions env.sh
Original file line number Diff line number Diff line change
@@ -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]"
Expand Down

0 comments on commit de3facf

Please sign in to comment.