avoid using realpath in scripts

scripts/run uses realpath when COMPOSE_FILE is set. realpath is not available in
some systems (e.g. macOS), and readlink -f isn't either. Replaced with a more
portable approach.

Signed-off-by: Santiago M. Mola <santi@mola.io>
This commit is contained in:
Santiago M. Mola 2020-07-15 18:37:19 +02:00
parent 789bfb0e8b
commit 6311511117
1 changed files with 4 additions and 1 deletions

View File

@ -36,7 +36,10 @@ if [ "$(pwd)" != '/' ]; then
fi fi
if [ -n "$COMPOSE_FILE" ]; then if [ -n "$COMPOSE_FILE" ]; then
COMPOSE_OPTIONS="$COMPOSE_OPTIONS -e COMPOSE_FILE=$COMPOSE_FILE" COMPOSE_OPTIONS="$COMPOSE_OPTIONS -e COMPOSE_FILE=$COMPOSE_FILE"
compose_dir=$(realpath "$(dirname "$COMPOSE_FILE")") compose_dir="$(dirname "$COMPOSE_FILE")"
# canonicalize dir, do not use realpath or readlink -f
# since they are not available in some systems (e.g. macOS).
compose_dir="$(cd "$compose_dir" && pwd)"
fi fi
if [ -n "$COMPOSE_PROJECT_NAME" ]; then if [ -n "$COMPOSE_PROJECT_NAME" ]; then
COMPOSE_OPTIONS="-e COMPOSE_PROJECT_NAME $COMPOSE_OPTIONS" COMPOSE_OPTIONS="-e COMPOSE_PROJECT_NAME $COMPOSE_OPTIONS"