【发布时间】:2020-09-06 12:26:17
【问题描述】:
如何在 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}
只要我在 Windows 上的 Git Bash 上运行脚本, 控制台告诉路径应该以 / 开头, 这意味着它与路径中的 / 混淆。虽然 / 已经是正确的了。
这是 git bash Windows 控制台输出:
Register auth service route
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 248 100 143 100 105 674 495 --:--:-- --:--:-- --:--:-- 1169{"message":"schema violation (paths.1: should start with: \/)","name":"schema violation","fields":{"paths":["should start with: \/"]},"code":2}
如何在 Git Bash Windows 上执行带有“/”命令的脚本?
我期待着大家的回音!非常感谢!
【问题讨论】:
标签: windows bash shell git-bash slash