git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] thunderbird-patch-inline: avoid bashism

From
D. Ben Knoble <ben.knoble@gmail.com>
Date
Feb 4, 2025, 02:11 UTC
Message-ID
<CALnO6CAib-p1+1VHMfqo4VGLVvWs63z_xCjkCANJS-NLK5FpdQ@mail.gmail.com>
In-Reply-To
<20250204014652.3509928-1-sandals@crustytoothpaste.net>

On Mon, Feb 3, 2025 at 8:55 PM brian m. carlson <sandals@crustytoothpaste.net> wrote:

Show 34 quoted lines
>
> The use of "echo -e" is not portable and not specified by POSIX.  dash
> does not support any options except "-n", and so this script will not
> work on operating systems which use that as /bin/sh.
>
> Fortunately, the solution is easy: switch to printf(1), which is
> specified by POSIX and allows the escape sequences we want to use.  This
> will allow the script to work with any POSIX shell.
>
> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
> ---
>  contrib/thunderbird-patch-inline/appp.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> I noticed this in Debian bug 772238[0], while looking for any bug
> reports that I might be able to fix.  It was reported in 2014 and has
> gone unfixed since then, so possibly this script is seeing relatively
> little use on Debian and Ubuntu.
>
> I have not CC'd any of the authors because nobody's touched this in over
> 9 years and none of those people are still active.
>
> [0] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=772238
>
> diff --git a/contrib/thunderbird-patch-inline/appp.sh b/contrib/thunderbird-patch-inline/appp.sh
> index 1053872eea..c55c2caa41 100755
> --- a/contrib/thunderbird-patch-inline/appp.sh
> +++ b/contrib/thunderbird-patch-inline/appp.sh
> @@ -31,7 +31,7 @@ BODY=$(sed -e "1,/${SEP}/d" $1)
>  CMT_MSG=$(sed -e '1,/^$/d' -e '/^---$/,$d' "${PATCH}")
>  DIFF=$(sed -e '1,/^---$/d' "${PATCH}")
>
> -CCS=$(echo -e "$CMT_MSG\n$HEADERS" | sed -n -e 's/^Cc: \(.*\)$/\1,/gp' \
> +CCS=$(printf '%s\n%s' "$CMT_MSG" "$HEADERS" | sed -n -e 's/^Cc: \(.*\)$/\1,/gp' \

Looks obviously correct to me (I once wrote POSIX-compatible echos just to see how hard it was [1]), though I find it interesting that `sed` can process input lacking a final newline.

>         -e 's/^Signed-off-by: \(.*\)/\1,/gp')
>
>  echo "$SUBJECT" > $1
>
[1]: https://github.com/benknoble/echocho
-- 
D. Ben Knoble
Previous: brian m. carlsonNext: brian m. carlson
Message 2 of 6 in “thunderbird-patch-inline: avoid bashism”
  1. thunderbird-patch-inline: avoid bashismbrian m. carlson, Feb 4, 2025
  2. D. Ben KnobleFeb 4, 2025
  3. brian m. carlsonFeb 4, 2025
  4. Junio C HamanoFeb 4, 2025
  5. thunderbird-patch-inline: avoid bashismbrian m. carlson, Feb 10, 2025
  6. Junio C HamanoFeb 11, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.