未验证 提交 dc96f667 编写于 作者: C Chen Mulong 提交者: GitHub

Make greenplum-path.sh compatible with more shells (#11043)

The generated greenplum_path.sh env file contained bash specific syntax
previously, so it errors out if the user's shell is zsh.

zsh doesn't have BASH_SOURCE. "${(%):-%x}" is the similar replacement
for zsh.
Also try to support other shells with some command combinations.
Tested with bash/zsh/dash.
上级 d7bfe6ee
#!/usr/bin/env bash
cat <<"EOF"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
if test -n "$ZSH_VERSION"; then
# zsh
SCRIPT_PATH="${(%):-%x}"
elif test -n "$BASH_VERSION"; then
# bash
SCRIPT_PATH="${BASH_SOURCE[0]}"
else
# Unknown shell, hope below works.
# Tested with dash
result=$(lsof -p $$ -Fn | tail --lines=1 | xargs --max-args=2 | cut --delimiter=' ' --fields=2)
SCRIPT_PATH=${result#n}
fi
if test -z "$SCRIPT_PATH"; then
echo "The shell cannot be identified. \$GPHOME may not be set correctly." >&2
fi
SCRIPT_DIR="$(cd "$(dirname "${SCRIPT_PATH}")" >/dev/null 2>&1 && pwd)"
if [ ! -L "${SCRIPT_DIR}" ]; then
GPDB_DIR=$(basename "${SCRIPT_DIR}")
else
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册