gpt4 book ai didi

bash - 特拉维斯 CI : How do I escape my password for `travis encrypt` to work?

转载 作者:行者123 更新时间:2023-11-29 09:18:45 26 4
gpt4 key购买 nike

travis encryption docs提到我必须在加密之前对我的密码进行 bash-escape:

Note on escaping certain symbols

When you use travis encrypt to encrypt sensitive data, it is important to note that it will be processed as a bash statement. This means that secret you are encrypting should not cause errors when bash parses it. Having incomplete data will cause bash to dump the error statement to the log, which contains portions of your sensitive data.

Thus, you need to escape special characters such as braces, parentheses, backslashes, and pipe symbols. For example, when you want to assign the string 6&a(5!1Ab\ to FOO, you need to execute:

travis encrypt "FOO=6\\&a\\(5\\!1Ab\\\\"

bash 的答案似乎围绕着 printf "%q" 展开,但是弄清楚如何将 printftravis cli 连接起来仍然太复杂了。

travis encrypt 执行它应该执行的操作的 bash 语句是什么?

我的意思是,我想粘贴我的变量名及其值,并确保它会被正确加密,而不必担心 bash 转义。我们可以保留上面的示例,假设我想将字符串 6&a(5!1Ab\ 分配给变量 FOO

当我们这样做时,travis env set 对应的一行代码是什么?这将有助于那些与 data too large 错误作斗争的人。

最佳答案

基于 Armali's answer :

read -r && travis encrypt "$(printf %q "$REPLY")"

然后粘贴您的变量及其值:

FOO=6&a(5!1Ab\

关于bash - 特拉维斯 CI : How do I escape my password for `travis encrypt` to work?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54538254/

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