Merge pull request #2028 from BlitzKraft/2027-use-command-v

Addressing #2027 gradually - use command -v
This commit is contained in:
BK 2019-10-11 21:25:56 +00:00 committed by GitHub
commit f4dfe39112
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 58 additions and 58 deletions

View File

@ -10,7 +10,7 @@ if test -n "$OSTYPE" ; then
elif test "${OSTYPE#darwin}" ; then
darwin=1
fi
elif which uname >/dev/null ; then
elif command -v uname >/dev/null ; then
if uname -o | grep -iqF linux ; then
use_filesystem=
elif uname -o | grep -iqF darwin ; then

View File

@ -1,5 +1,5 @@
_powerline_columns_fallback() {
if which stty &>/dev/null ; then
if command -v stty &>/dev/null ; then
local cols="$(stty size 2>/dev/null)"
if ! test -z "$cols" ; then
echo "${cols#* }"
@ -138,7 +138,7 @@ _powerline_setup_prompt() {
}
if test -z "${POWERLINE_CONFIG_COMMAND}" ; then
if which powerline-config >/dev/null ; then
if command -v powerline-config >/dev/null ; then
POWERLINE_CONFIG_COMMAND=powerline-config
else
POWERLINE_CONFIG_COMMAND="$(dirname "$BASH_SOURCE")/../../../scripts/powerline-config"

View File

@ -1,6 +1,6 @@
_POWERLINE_SOURCED="$_"
_powerline_columns_fallback() {
if which stty >/dev/null ; then
if command -v stty >/dev/null ; then
# Ksh does not have “local” built-in
_powerline_cols="$(stty size 2>/dev/null)"
if ! test -z "$_powerline_cols" ; then
@ -220,7 +220,7 @@ _powerline_init_tmux_support() {
}
if test -z "${POWERLINE_CONFIG_COMMAND}" ; then
if which powerline-config >/dev/null ; then
if command -v powerline-config >/dev/null ; then
POWERLINE_CONFIG_COMMAND=powerline-config
else
POWERLINE_CONFIG_COMMAND="$(dirname "$_POWERLINE_SOURCED")/../../../scripts/powerline-config"

View File

@ -143,7 +143,7 @@ rm_test_root() {
fi
}
if ! which realpath ; then
if ! command -v realpath ; then
realpath() {
$PYTHON -c 'import os, sys; print(os.path.realpath(sys.argv[1]))' "$1"
}

View File

@ -6,8 +6,8 @@ vterm_setup() {
mkdir "$TEST_ROOT/path"
ln -s "$(which "${PYTHON}")" "$TEST_ROOT/path/python"
ln -s "$(which bash)" "$TEST_ROOT/path"
ln -s "$(command -v "${PYTHON}")" "$TEST_ROOT/path/python"
ln -s "$(command -v bash)" "$TEST_ROOT/path"
cp -r "$ROOT/tests/terminfo" "$TEST_ROOT"
}

View File

@ -18,7 +18,7 @@ if test "$TRAVIS" = true ; then
workon cpython-ucs2-$UCS2_PYTHON_VARIANT
set -e
else
LIBRARY_PATH="$(ldd "$(which python)" | grep libpython | sed 's/^.* => //;s/ .*$//')"
LIBRARY_PATH="$(ldd "$(command -v python)" | grep libpython | sed 's/^.* => //;s/ .*$//')"
LIBRARY_DIR="$(dirname "${LIBRARY_PATH}")"
export LD_LIBRARY_PATH="$LIBRARY_DIR${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH"
fi

View File

@ -13,20 +13,20 @@ cp -r "$TEST_STATIC_ROOT/powerline" "$TEST_ROOT"
export PYTHONPATH="$ROOT${PYTHONPATH:+:}$PYTHONPATH"
ln -s "$(which "${PYTHON}")" "$TEST_PATH"/python
ln -s "$(which cat)" "$TEST_PATH"
ln -s "$(which sh)" "$TEST_PATH"
ln -s "$(which env)" "$TEST_PATH"
if which socat ; then
ln -s "$(which socat)" "$TEST_PATH"
ln -s "$(command -v "${PYTHON}")" "$TEST_PATH"/python
ln -s "$(command -v cat)" "$TEST_PATH"
ln -s "$(command -v sh)" "$TEST_PATH"
ln -s "$(command -v env)" "$TEST_PATH"
if command -v socat ; then
ln -s "$(command -v socat)" "$TEST_PATH"
fi
for pexe in powerline powerline.sh powerline.py ; do
if test -e scripts/$pexe ; then
ln -s "$PWD/scripts/$pexe" $TEST_ROOT/path
elif test -e client/$pexe ; then
ln -s "$PWD/client/$pexe" $TEST_ROOT/path
elif which $pexe ; then
ln -s "$(which $pexe)" $TEST_ROOT/path
elif command -v $pexe ; then
ln -s "$(command -v $pexe)" $TEST_ROOT/path
else
continue
fi

View File

@ -12,11 +12,11 @@ cp -r "$TEST_STATIC_ROOT/powerline" "$TEST_ROOT"
export PYTHONPATH="$ROOT${PYTHONPATH:+:}$PYTHONPATH"
ln -s "$(which "${PYTHON}")" "$TEST_PATH"/python
ln -s "$(which sed)" "$TEST_PATH"
ln -s "$(which cat)" "$TEST_PATH"
ln -s "$(which mkdir)" "$TEST_PATH"
ln -s "$(which basename)" "$TEST_PATH"
ln -s "$(command -v "${PYTHON}")" "$TEST_PATH"/python
ln -s "$(command -v sed)" "$TEST_PATH"
ln -s "$(command -v cat)" "$TEST_PATH"
ln -s "$(command -v mkdir)" "$TEST_PATH"
ln -s "$(command -v basename)" "$TEST_PATH"
ln -s "$TEST_PATH/lemonbar" "$TEST_PATH/bar-aint-recursive"
DEPRECATED_SCRIPT="$ROOT/powerline/bindings/bar/powerline-bar.py"

View File

@ -27,30 +27,30 @@ mkdir "$TEST_ROOT/fish_home/fish"
mkdir "$TEST_ROOT/fish_home/fish/generated_completions"
cp -r "$ROOT/tests/test_shells/ipython_home" "$TEST_ROOT"
ln -s "$(which env)" "$TEST_ROOT/path"
ln -s "$(which git)" "$TEST_ROOT/path"
ln -s "$(which sleep)" "$TEST_ROOT/path"
ln -s "$(which cat)" "$TEST_ROOT/path"
ln -s "$(which false)" "$TEST_ROOT/path"
ln -s "$(which true)" "$TEST_ROOT/path"
ln -s "$(which kill)" "$TEST_ROOT/path"
ln -s "$(which echo)" "$TEST_ROOT/path"
ln -s "$(which which)" "$TEST_ROOT/path"
ln -s "$(which dirname)" "$TEST_ROOT/path"
ln -s "$(which wc)" "$TEST_ROOT/path"
ln -s "$(which stty)" "$TEST_ROOT/path"
ln -s "$(which cut)" "$TEST_ROOT/path"
ln -s "$(which bc)" "$TEST_ROOT/path"
ln -s "$(which expr)" "$TEST_ROOT/path"
ln -s "$(which mktemp)" "$TEST_ROOT/path"
ln -s "$(which grep)" "$TEST_ROOT/path"
ln -s "$(which sed)" "$TEST_ROOT/path"
ln -s "$(which rm)" "$TEST_ROOT/path"
ln -s "$(which tr)" "$TEST_ROOT/path"
ln -s "$(which uname)" "$TEST_ROOT/path"
ln -s "$(which test)" "$TEST_ROOT/path"
ln -s "$(which pwd)" "$TEST_ROOT/path"
ln -s "$(which hostname)" "$TEST_ROOT/path"
ln -s "$(command -v env)" "$TEST_ROOT/path"
ln -s "$(command -v git)" "$TEST_ROOT/path"
ln -s "$(command -v sleep)" "$TEST_ROOT/path"
ln -s "$(command -v cat)" "$TEST_ROOT/path"
ln -s "$(command -v false)" "$TEST_ROOT/path"
ln -s "$(command -v true)" "$TEST_ROOT/path"
ln -s "$(command -v kill)" "$TEST_ROOT/path"
ln -s "$(command -v echo)" "$TEST_ROOT/path"
ln -s "$(command -v which)" "$TEST_ROOT/path"
ln -s "$(command -v dirname)" "$TEST_ROOT/path"
ln -s "$(command -v wc)" "$TEST_ROOT/path"
ln -s "$(command -v stty)" "$TEST_ROOT/path"
ln -s "$(command -v cut)" "$TEST_ROOT/path"
ln -s "$(command -v bc)" "$TEST_ROOT/path"
ln -s "$(command -v expr)" "$TEST_ROOT/path"
ln -s "$(command -v mktemp)" "$TEST_ROOT/path"
ln -s "$(command -v grep)" "$TEST_ROOT/path"
ln -s "$(command -v sed)" "$TEST_ROOT/path"
ln -s "$(command -v rm)" "$TEST_ROOT/path"
ln -s "$(command -v tr)" "$TEST_ROOT/path"
ln -s "$(command -v uname)" "$TEST_ROOT/path"
ln -s "$(command -v test)" "$TEST_ROOT/path"
ln -s "$(command -v pwd)" "$TEST_ROOT/path"
ln -s "$(command -v hostname)" "$TEST_ROOT/path"
ln -s "$ROOT/tests/test_shells/bgscript.sh" "$TEST_ROOT/path"
ln -s "$ROOT/tests/test_shells/waitpid.sh" "$TEST_ROOT/path"
@ -62,8 +62,8 @@ if test -e "$ROOT/scripts/powerline" ; then
ln -s "$ROOT/scripts/powerline" "$TEST_ROOT/path"
elif test -e client/powerline ; then
ln -s "$ROOT/client/powerline" "$TEST_ROOT/path"
elif which powerline ; then
ln -s "$(which powerline)" "$TEST_ROOT/path"
elif command -v powerline ; then
ln -s "$(command -v powerline)" "$TEST_ROOT/path"
else
echo "Executable powerline was not found"
exit 1
@ -75,9 +75,9 @@ if test "$(
HAS_C_CLIENT=1
fi
if which socat ; then
if command -v socat ; then
HAS_SOCAT=1
ln -s "$(which socat)" "$TEST_ROOT/path"
ln -s "$(command -v socat)" "$TEST_ROOT/path"
ln -s "$ROOT/client/powerline.sh" "$TEST_ROOT/path"
fi
@ -97,8 +97,8 @@ test_shell() {
echo "Skipping test, C client not available"
return
fi
if which "$test_binding" ; then
ln -s "$(which "$test_binding")" "$TEST_ROOT/path"
if command -v "$test_binding" ; then
ln -s "$(command -v "$test_binding")" "$TEST_ROOT/path"
fi
if ! "${PYTHON}" "$ROOT/tests/test_in_vterm/test_shells.py" \

View File

@ -6,8 +6,8 @@ enter_suite tmux final
vterm_setup
ln -s "$(which env)" "$TEST_ROOT/path"
ln -s "$(which cut)" "$TEST_ROOT/path"
ln -s "$(command -v env)" "$TEST_ROOT/path"
ln -s "$(command -v cut)" "$TEST_ROOT/path"
ln -s "$ROOT/scripts/powerline-render" "$TEST_ROOT/path"
ln -s "$ROOT/scripts/powerline-config" "$TEST_ROOT/path"
@ -17,10 +17,10 @@ test_tmux() {
# occasionally.
return 0
fi
if ! which "${POWERLINE_TMUX_EXE}" ; then
if ! command -v "${POWERLINE_TMUX_EXE}" ; then
return 0
fi
ln -sf "$(which "${POWERLINE_TMUX_EXE}")" "$TEST_ROOT/path/tmux"
ln -sf "$(command -v "${POWERLINE_TMUX_EXE}")" "$TEST_ROOT/path/tmux"
f="$ROOT/tests/test_in_vterm/test_tmux.py"
if ! "${PYTHON}" "$f" ; then
local test_name="$("$POWERLINE_TMUX_EXE" -V 2>&1 | cut -d' ' -f2)"

View File

@ -12,10 +12,10 @@ test_vim() {
# Can only link with cpython
return 0
fi
if ! which "$POWERLINE_VIM_EXE" ; then
if ! command -v "$POWERLINE_VIM_EXE" ; then
return 0
fi
ln -sf "$(which "${POWERLINE_VIM_EXE}")" "$TEST_ROOT/path/vim"
ln -sf "$(command -v "${POWERLINE_VIM_EXE}")" "$TEST_ROOT/path/vim"
f="$ROOT/tests/test_in_vterm/test_vim.py"
if ! "${PYTHON}" "$f" ; then
local test_name="$(LANG=C "$POWERLINE_VIM_EXE" --cmd 'echo version' --cmd qa 2>&1 | tail -n2)"