diff mbox series

[1/2] t/lib-gpg: quote path to ${GNUPGHOME}/trustlist.txt

Message ID 20190208031746.22683-2-tmz@pobox.com (mailing list archive)
State New, archived
Headers show
Series t/lib-gpg: a gpgsm fix, a minor improvement, and a question | expand

Commit Message

Todd Zullinger Feb. 8, 2019, 3:17 a.m. UTC
When gpgsm is installed, lib-gpg.sh attempts to update trustlist.txt to
relax the checking of some root certificate requirements.  The path to
"${GNUPGHOME}" contains spaces which cause an "ambiguous redirect"
warning when bash is used to run the tests:

  $ bash t7030-verify-tag.sh
  /git/t/lib-gpg.sh: line 66: ${GNUPGHOME}/trustlist.txt: ambiguous redirect
  ok 1 - create signed tags
  ok 2 # skip create signed tags x509  (missing GPGSM)
  ...

No warning is issued when using bash called as /bin/sh, dash, or mksh.

Quote the path to ensure the redirect works as intended and sets the
GPGSM prereq.  While we're here, drop the space after ">>".

Signed-off-by: Todd Zullinger <tmz@pobox.com>
---
 t/lib-gpg.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

SZEDER Gábor Feb. 8, 2019, 8:11 p.m. UTC | #1
On Thu, Feb 07, 2019 at 10:17:45PM -0500, Todd Zullinger wrote:
> When gpgsm is installed, lib-gpg.sh attempts to update trustlist.txt to
> relax the checking of some root certificate requirements.  The path to
> "${GNUPGHOME}" contains spaces which cause an "ambiguous redirect"
> warning when bash is used to run the tests:

s/error/warning/

>   $ bash t7030-verify-tag.sh
>   /git/t/lib-gpg.sh: line 66: ${GNUPGHOME}/trustlist.txt: ambiguous redirect
>   ok 1 - create signed tags
>   ok 2 # skip create signed tags x509  (missing GPGSM)
>   ...
> 
> No warning is issued when using bash called as /bin/sh, dash, or mksh.

Likewise.

POSIX says that no field splitting should be performed on the result
of a parameter expansion that is used as the target of a redirection,
but Bash doesn't conform in this respect (unless in POSIX mode).

> Quote the path to ensure the redirect works as intended and sets the
> GPGSM prereq.  While we're here, drop the space after ">>".
> 
> Signed-off-by: Todd Zullinger <tmz@pobox.com>
> ---
>  t/lib-gpg.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/t/lib-gpg.sh b/t/lib-gpg.sh
> index f1277bef4f..207009793b 100755
> --- a/t/lib-gpg.sh
> +++ b/t/lib-gpg.sh
> @@ -63,7 +63,7 @@ then
>  		cut -d" " -f4 |
>  		tr -d '\n' >"${GNUPGHOME}/trustlist.txt" &&
>  
> -		echo " S relax" >> ${GNUPGHOME}/trustlist.txt &&
> +		echo " S relax" >>"${GNUPGHOME}/trustlist.txt" &&
>  		(gpgconf --kill gpg-agent >/dev/null 2>&1 || : ) &&
>  		echo hello | gpgsm --homedir "${GNUPGHOME}" >/dev/null \
>  			-u committer@example.com -o /dev/null --sign - 2>&1 &&
> -- 
> Todd
Todd Zullinger Feb. 8, 2019, 8:25 p.m. UTC | #2
SZEDER Gábor wrote:
> On Thu, Feb 07, 2019 at 10:17:45PM -0500, Todd Zullinger wrote:
>> When gpgsm is installed, lib-gpg.sh attempts to update trustlist.txt to
>> relax the checking of some root certificate requirements.  The path to
>> "${GNUPGHOME}" contains spaces which cause an "ambiguous redirect"
>> warning when bash is used to run the tests:
> 
> s/error/warning/

Did you mean s/warning/error/ so the sentence reads:

    The path to "${GNUPGHOME}" contains spaces which cause
    an "ambiguous redirect" error when bash is used to run
    the tests

?

Is it worth a resend before Junio queues it?

>>   $ bash t7030-verify-tag.sh
>>   /git/t/lib-gpg.sh: line 66: ${GNUPGHOME}/trustlist.txt: ambiguous redirect
>>   ok 1 - create signed tags
>>   ok 2 # skip create signed tags x509  (missing GPGSM)
>>   ...
>> 
>> No warning is issued when using bash called as /bin/sh, dash, or mksh.
> 
> Likewise.
> 
> POSIX says that no field splitting should be performed on the result
> of a parameter expansion that is used as the target of a redirection,
> but Bash doesn't conform in this respect (unless in POSIX mode).

I wish I'd remembered reading your detailed explanation of
this¹ when I was testing and writing the commit message. :)

¹ https://public-inbox.org/git/20180926121107.GH27036@localhost/
SZEDER Gábor Feb. 8, 2019, 8:35 p.m. UTC | #3
On Fri, Feb 08, 2019 at 03:25:05PM -0500, Todd Zullinger wrote:
> SZEDER Gábor wrote:
> > On Thu, Feb 07, 2019 at 10:17:45PM -0500, Todd Zullinger wrote:
> >> When gpgsm is installed, lib-gpg.sh attempts to update trustlist.txt to
> >> relax the checking of some root certificate requirements.  The path to
> >> "${GNUPGHOME}" contains spaces which cause an "ambiguous redirect"
> >> warning when bash is used to run the tests:
> > 
> > s/error/warning/
> 
> Did you mean s/warning/error/ so the sentence reads:
> 
>     The path to "${GNUPGHOME}" contains spaces which cause
>     an "ambiguous redirect" error when bash is used to run
>     the tests

Oh, wow.  Indeed that's what I meant.

> Is it worth a resend before Junio queues it?

I remember Junio taking care of minor touchups to commit messages like
this, so maybe not.
diff mbox series

Patch

diff --git a/t/lib-gpg.sh b/t/lib-gpg.sh
index f1277bef4f..207009793b 100755
--- a/t/lib-gpg.sh
+++ b/t/lib-gpg.sh
@@ -63,7 +63,7 @@  then
 		cut -d" " -f4 |
 		tr -d '\n' >"${GNUPGHOME}/trustlist.txt" &&
 
-		echo " S relax" >> ${GNUPGHOME}/trustlist.txt &&
+		echo " S relax" >>"${GNUPGHOME}/trustlist.txt" &&
 		(gpgconf --kill gpg-agent >/dev/null 2>&1 || : ) &&
 		echo hello | gpgsm --homedir "${GNUPGHOME}" >/dev/null \
 			-u committer@example.com -o /dev/null --sign - 2>&1 &&