On Wed, 2021-06-16 at 09:22 -0600, Kevin Locke wrote: > I've attached a patch which changes the quoting to fix the issue with > the hope that you may find it more acceptable than Christophe's patch.
Please ignore the previous patch. It was sent with insufficient testing and did not handle the quoting in ${TB_GDB_DEFAULT_OPTS} in the way it appears to be intended. I've attached v2 of the patch which quotes ${TB_ARGS[@]} using `printf ' %q'` then uses eval to perform word splitting on the combined command string. In my testing it handled spaces and special characters in ${TB_GDB_DEFAULT_OPTS} and arguments following -g in the way that I would expect. See what you think. Cheers, Kevin
>From 50bcc2bb310a25fe2a1e6e39528c385c4c98569d Mon Sep 17 00:00:00 2001 Message-Id: <50bcc2bb310a25fe2a1e6e39528c385c4c98569d.1623858686.git.ke...@kevinlocke.name> From: Kevin Locke <ke...@kevinlocke.name> Date: Wed, 16 Jun 2021 09:08:10 -0600 Subject: [PATCH v2] Fix quoting for -g in thunderbird-wrapper.sh Running `thunderbird -g` produces the following error: INFO -> Starting Thunderbird with GDB ... INFO -> LANG= /usr/bin/gdb -ex "handle SIG38 nostop" -ex "handle SIGPIPE nostop" -ex "run" /usr/lib/thunderbird/thunderbird /usr/bin/thunderbird: line 254: /usr/bin/gdb -ex "handle SIG38 nostop" -ex "handle SIGPIPE nostop" -ex "run" /usr/lib/thunderbird/thunderbird : No such file or directory This occurs because exec is passed a single argument, which it interprets as a file name that does not exist. Instead, use the following steps: 1. Build a command string which combines ${TB_GDB_DEFAULT_OPTS} and ${TB_ARGS[@]} (using `printf ' %q'`). 2. Print the command string with output_info. 3. Run it using `eval` (for word splitting) and `exec` (to replace the shell process with gdb, as before). Signed-off-by: Kevin Locke <ke...@kevinlocke.name> --- Changes since v1: - Use eval to handle quoting in ${TB_GDB_DEFAULT_OPTS}, since word splitting does not consider quotes in variables. debian/thunderbird-wrapper.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/debian/thunderbird-wrapper.sh b/debian/thunderbird-wrapper.sh index 7546724f136..b76f522654e 100755 --- a/debian/thunderbird-wrapper.sh +++ b/debian/thunderbird-wrapper.sh @@ -250,8 +250,9 @@ else if [ -f /usr/bin/gdb ]; then if dpkg-query -W -f='${Version}' thunderbird-dbgsym &>/dev/null ; then output_info "Starting Thunderbird with GDB ..." - output_info "LANG= /usr/bin/gdb ${TB_GDB_DEFAULT_OPTS} -ex \"run\" ${MOZ_LIBDIR}/${MOZ_APP_NAME} ${TB_ARGS[@]}" - LANG='' exec "/usr/bin/gdb ${TB_GDB_DEFAULT_OPTS} -ex \"run\" ${MOZ_LIBDIR}/${MOZ_APP_NAME} ${TB_ARGS[@]}" + TB_ARGS_LINE="/usr/bin/gdb ${TB_GDB_DEFAULT_OPTS} -ex run ${MOZ_LIBDIR}/${MOZ_APP_NAME}$(printf ' %q' "${TB_ARGS[@]}")" + output_info "LANG= $TB_ARGS_LINE" + LANG='' eval "exec $TB_ARGS_LINE" else output_info "No package 'thunderbird-dbgsym' installed! Please install first and restart." output_info "More information how to adjust your sources.list to being able installing" -- 2.30.2