带引号的棘手 makefile 语法

发布于 2024-08-14 13:49:11 字数 476 浏览 0 评论 0原文

我在 makefile 规则上有以下开始(感谢其他人的帮助),但它还没有完全起作用:

test_svn_version:
    @if [ $$(svn --version --quiet \ 
            perl -ne '@a=split(/\./); \
                      print $$a[0]*10000 + $$a[1]*100 + $$a[2]') \
          -lt 10600 ]; \
    then \
        echo >&2 "Svn version $$(svn --version --quiet) too old; upgrade to v1.6";
        false; \
    fi

条件中的单引号似乎是不匹配的。

请帮助纠正语法。我尝试了很多变体,但似乎没有一个是正确的。

谢谢。

——威廉

I have the following start on a makefile rule (thanks to help from others), but it doesn't quite work yet:

test_svn_version:
    @if [ $(svn --version --quiet \ 
            perl -ne '@a=split(/\./); \
                      print $a[0]*10000 + $a[1]*100 + $a[2]') \
          -lt 10600 ]; \
    then \
        echo >&2 "Svn version $(svn --version --quiet) too old; upgrade to v1.6";
        false; \
    fi

It seems the single quote in the conditional is unmatched.

Please help correct the syntax. I've tried many variants, but none seem correct.

Thanks.

-William

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

零度℉ 2024-08-21 13:49:11

您在 svn 和 perl 之间缺少管道 |,并且在 echo 之后缺少反斜杠 \。这对我有用:

test_svn_version:
    @if [ $(svn --version --quiet | \
             perl -ne '@a=split(/\./); \
                       print $a[0]*10000 + $a[1]*100 + $a[2]') \
          -lt 10600 ]; \
    then \
        echo >&2 "Svn version $(svn --version --quiet) too old; upgrade to v1.6"; \
        false; \
    fi

You're missing a pipe | between svn and perl, and you're missing a backslash \ after the echo. This works for me:

test_svn_version:
    @if [ $(svn --version --quiet | \
             perl -ne '@a=split(/\./); \
                       print $a[0]*10000 + $a[1]*100 + $a[2]') \
          -lt 10600 ]; \
    then \
        echo >&2 "Svn version $(svn --version --quiet) too old; upgrade to v1.6"; \
        false; \
    fi
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文