我们如何转换下面的shell脚本,以便在Mac OS X上实现相同的结果?为Mac OS X转换Linux shell脚本
# To generate secure SSH deploy key for a github repo to be used from Travis
# https://gist.github.com/floydpink/4631240
base64 --wrap=0 ~/.ssh/id_rsa_deploy > ~/.ssh/id_rsa_deploy_base64
ENCRYPTION_FILTER="echo \$(echo \"- secure: \")\$(travis encrypt \"\$FILE='\`cat $FILE\`'\" -r floydpink/harimenon.com)"
split --bytes=100 --numeric-suffixes --suffix-length=2 --filter="$ENCRYPTION_FILTER" ~/.ssh/id_rsa_deploy_base64 id_rsa_
# To reconstitute the private SSH key once running inside Travis (typically from 'before_script')
echo -n $id_rsa_{00..30} >> ~/.ssh/id_rsa_base64
base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
我能想出相当于base64
命令是:
base64 --break=0 id_rsa_deploy > id_rsa_deploy_base64
但它看起来像split command on Mac OS X是在Linux/Unix的有点不同,不具有--filter
选项。
编辑:这是我a gist从this blog entry,详细说明如何将自动部署使用Travis CI的Octopress博客到GitHub上跌跌撞撞就到了。
我已经在Ubuntu Linux和had blogged about it上成功完成了这个任务,但是无法在Mac上重复。
的“好”的'分裂--filter示例输出..在你的问题中包括**将会帮助人们思考备用解决方案。现在,我/我们必须猜测。你可以使用类似'awk'{长度($ 0)> 100){printf(“%100s \ n”,$ 0); sub(/。{100} /,“”,$ 0)#或somesuch; } printf(“%s \ n”$ 0)}''替代'split --bytes = 100'?祝你好运。 – shellter
谢谢你的建议@shellter。这个脚本是我发现的[https://gist.github.com/lukewpatterson/4242707],它有助于为[Travis CI]创建安全的GitHub部署密钥(https://travis-ci.org /)。我对shell脚本和bash命令的n00b-ness是这个问题同样糟糕的原因。我将尝试'awk'方法并在这里更新。再次感谢...... :) –