如何在 Windows 上使用斜杠“/”在 git bash 上运行 bash 脚本。
这是我的脚本文件。我可以在 Ubuntu/Linux 上运行良好。
#!/bin/sh
KONG_ADMIN_HOST=localhost
KONG_ADMIN_PORT=8001
registerServiceRoute() {
printf "\nRegister %s service route\n" $1
curl -XPOST ${KONG_ADMIN_HOST}:${KONG_ADMIN_PORT}/services/$1/routes \
--data protocols=grpc \
--data name=$1-grpc \
--data paths=$2 -----> This line '/'is understood wrong in Git Bash Windows
printf "\n"
}
SERVICE_NAME=auth
SERVICE_PATH=/com.bht.saigonparking.api.grpc.auth.AuthService/ ----------> path with '/' here
registerServiceRoute ${SERVICE_NAME} ${SERVICE_PATH}
Run Code Online (Sandbox Code Playgroud)
当我在 Windows 上的 Git Bash 上运行脚本时,控制台告诉路径应该以 / 开头,这意味着它与路径中的 / 混淆。虽然 / 已经是正确的。
这是 git bash Windows 控制台输出:
Register auth service route
% Total …Run Code Online (Sandbox Code Playgroud)