首页 > 解决方案 > 在 UBUNTU 上编码 BASH curl 的 URL

问题描述

我正在通过 gitook 传递以下行

curl -d \"githook[action]=code_commit\" -d \"githook[stats]=$encodestat\"  -d \"githook[project_key]=$Vproject\" -d \"githook[user_email]=$Vemail\" -d \"githook[description]=SM$encodemsg\" http://mydomain/githooks 

如果我回应这条线,我会得到

curl -d "githook[action]=code_commit" -d "githook[stats]=%201%20file%20changed%2C%201%20insertion%28%2B%29%2C%201%20deletion%28-%29" -d "githook[project_key]=divine_frost_994_147_5511" -d "githook[user_email]=steven@domain.uk" -d "githook[description]=SMtest%20git" http://mydomain.uk/githooks

当我复制和粘贴时执行并运行

但是,当在 githook 中以第一种形式触发时,它拒绝执行没有错误

我真的无法再阅读屏幕了:/

如果有人有任何线索,不胜感激,它正在执行,然后我得到一个 Glob 错误,用 -g 尝试过,现在它似乎没有执行,重新启动,没有乐趣

标签: bashcurlencodeurlencode

解决方案


乔丹马上就看到了。

我们正在从初始化程序编写挂钩文件,并且我们不需要转义引号,因为 bash 会注入变量

我今天早上起床时看到了它,拍了拍我的额头,孩子们晚上不要编码。

会考虑删除,因为除了我以外的任何人都无法学习 - 每 12 小时离开屏幕一次?


推荐阅读