Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Commit

Permalink
create function to get aboslute path
Browse files Browse the repository at this point in the history
The parameter "-e" for readlink is not available on OS X.

Signed-off-by: Markus Rathgeb <maggu2810@gmail.com>
  • Loading branch information
maggu2810 committed Dec 21, 2015
1 parent a31c61f commit 01ec6e7
Showing 1 changed file with 36 additions and 7 deletions.
43 changes: 36 additions & 7 deletions tools/ref-tag/create.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
#!/bin/bash

MY_CMD="${0}"
MY_CMD_ABS="$(readlink -e "${MY_CMD}")"
MY_DIRNAME_ABS="$(dirname "${MY_CMD_ABS}")"

REMOTE=origin
unset COMMIT_ID_WC
#
# Define some functions first
#

log() {
echo "${@}"
Expand All @@ -30,6 +27,38 @@ die() {
exit 1
}

get_abs() {
local ARG_PATH="${1}"; shift

if [ ! -e "${ARG_PATH}" ]; then
log_err "Cannot resolve path (${ARG_PATH})"
return 1
fi

if [ -d "${ARG_PATH}" ]; then
cd "${ARG_PATH}"
echo "${PWD}"
cd "${OLDPWD}"
else
local DIRNAME="$(dirname "${ARG_PATH}")"
local BASENAME="$(basename "${ARG_PATH}")"
cd "${DIRNAME}"
echo "${PWD}/${BASENAME}"
cd "${OLDPWD}"
fi
}

#
# Begin
#

MY_CMD="${0}"
MY_CMD_ABS="$(get_abs "${MY_CMD}")" || die "Cannot resolve path"
MY_DIRNAME_ABS="$(dirname "${MY_CMD_ABS}")"

REMOTE=origin
unset COMMIT_ID_WC

#
# Parse command line arguments
#
Expand All @@ -49,7 +78,7 @@ fi
#

log "version postfix: ${VERSION_POSTFIX}"
log "commid id: ${COMMIT_ID}"
log "commit id: ${COMMIT_ID}"

log "Enter 'Y' to proceed"
read PROCEED
Expand Down

0 comments on commit 01ec6e7

Please sign in to comment.