【问题标题】:Can I use Bash features in an RPM spec file?我可以在 RPM 规范文件中使用 Bash 功能吗?
【发布时间】:2011-08-30 22:05:11
【问题描述】:

搜索open source projects,向我展示了野外的规范文件确实使用了bash结构,例如cat info|while read

但它真的安全吗? rpm 文档是否告诉我我可以依靠Bash 运行的%build 部分?

【问题讨论】:

    标签: bash rpm rpmbuild


    【解决方案1】:

    为每个规范节调用的默认 shell 由 %_buildshell 给出。默认为/bin/sh,但可以全局或逐节覆盖。

    【讨论】:

    • 如果我指向 /bin/bash 但它不存在,它会优雅地失败吗?
    • 没有。使用的 shell 必须存在。
    【解决方案2】:

    简短回答:

    长答案:虽然 bash 已成为 Linux shell 的事实上的标准,并且在实践中您可以指望使用 bash,但将 %_buildshell 指定为 /bin/bash 并没有什么坏处。 @Ignacio Vazquez-Abrams 的回答中提到

    【讨论】:

    • 尝试使用进程替换或此处字符串 而不 切换 shell 将失败。所以没有。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-01
    • 2023-03-13
    • 2013-04-15
    • 1970-01-01
    • 2015-08-25
    相关资源
    最近更新 更多