gpt4 book ai didi

cmd - wp-cli 适用于 windows cmd,但不适用于 Gitbash

转载 作者:行者123 更新时间:2023-12-05 00:15:07 30 4
gpt4 key购买 nike

我已经使用 Git-bash 安装了 wp-cli,并创建了相关的 PATH 变量。

我现在可以在 Windows CMD 中输入“wp”并且它可以工作,但是 Git-bash 无法识别该命令。

我必须怎么做才能使用 Git-bash,为什么它不能开箱即用?

最佳答案

我遇到了同样的问题。例如,命令“wp cli version”在 cmd 中有效,但在 cygwin 中无效。

检查以下教程:https://deluxeblogtips.com/install-wp-cli-windows/

如果您使用的是 cygwin,则需要创建另一个 wp 文件(不带 .bat)扩展名。只需使用以下内容将其命名为 wp:

#!/usr/bin/env sh

dir=$(d=${0%[/\\]*}; cd "$d"; pwd)

# See if we are running in Cygwin by checking for cygpath program
if command -v 'cygpath' >/dev/null 2>&1; then
# Cygwin paths start with /cygdrive/ which will break windows PHP,
# so we need to translate the dir path to windows format. However
# we could be using cygwin PHP which does not require this, so we
# test if the path to PHP starts with /cygdrive/ rather than /usr/bin
if [[ $(which php) == /cygdrive/* ]]; then
dir=$(cygpath -m $dir);
fi
fi

dir=$(echo $dir | sed 's/ /\ /g')
"${dir}/wp-cli.phar" "$@"

关于cmd - wp-cli 适用于 windows cmd,但不适用于 Gitbash,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45324745/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com