echo -e working in terminal but not in bash script

前端 未结 2 597
被撕碎了的回忆
被撕碎了的回忆 2021-01-02 02:27

I developed and maintain a ruby gem called Githug and I am trying to write an automated test script for it. Githug basically manipulates a directory to put it into differen

相关标签:
2条回答
  • 2021-01-02 02:41

    As commented, printf is the preferred option, as illustrated in Git 2.14.x/2.15 (Q4 2017)

    printf '%s\n%s' "$FULL_NAME" "$EMAIL"
    

    See commit 1a6d468 (17 Sep 2017) by Torsten Bögershausen (tboegi).
    (Merged by Torsten Bögershausen -- tboegi -- in commit 1a6d468, 21 Sep 2017)

    test-lint: echo -e (or -E) is not portable

    Some implementations of echo support the '-e' option to enable backslash interpretation of the following string.
    As an addition, they support '-E' to turn it off.

    However, none of these are portable, POSIX doesn't even mention them, and many implementations don't support them.

    A check for '-n' is already done in check-non-portable-shell.pl, extend it to cover '-n', '-e' or '-E'.

    0 讨论(0)
  • 2021-01-02 02:46

    Wrong shebang:

    #! /bin/sh
    

    When it shall be a bash script, use

    #! /bin/bash
    

    Bash has a buildin echo, which isn't 100% identic with /bin/echo.

    0 讨论(0)
提交回复
热议问题