1

We have code to check for a node install:

which="type -p"
if [ $SHELL = "/bin/zsh" ]; then
    which="whence"
fi
# make sure that node exists
node=`$which node 2>&1`
ret=$?
if [ $ret -ne 0 ] || ! [ -x "$node" ]; then
<"This error code is returned">

But when I run this with ZSH (OhMyZsh) it returns a 127 (does not exist). Commenting out the which="whence" lets it run fine.

Without removing the whole aliasing bit is there any way to have ZSH play along with this? Ideally I'd like to make a change on my end to make this work rather than modifying this code at all.

4

1 に答える 1

1

つまり、実行すると、存在しない$node名前のコマンドを実行しようとしたように見えますか?node --alias-args

これが true の場合、3 行目を use に変更します。出力は bashwhence -pと同じです。type -pそうでない場合は、このコードがいつ返されるかを説明してください。

更新: ohmyzsh で何が行われたかはわかりません (ただし、組み込み関数が見つからないようにする方法はまったくわかりません)。この方法でコードを書き直してみてください。

# At the very top
if [ -n $ZSH_VERSION ] ; then
    emulate -L zsh
endif
<...>
which="type -p"
if [ -n $ZSH_VERSION ] ; then
    which=( whence -p ) # Changes variable type as well
endif
node=`$which node 2>&1`
if (( ? )) || ! test -x $node ; then
<...>
于 2012-07-21T08:49:37.173 に答える