From: "Torsten Bögershausen" <tboegi@web.de>
To: Jeff King <peff@peff.net>
Cc: "Torsten Bögershausen" <tboegi@web.de>, git@vger.kernel.org
Subject: Re: [PATCH 1/4] test: Add target test-lint-shell-syntax
Date: Thu, 03 Jan 2013 00:58:45 +0100 [thread overview]
Message-ID: <50E4C9B5.8070308@web.de> (raw)
In-Reply-To: <20130102232239.GA27952@sigill.intra.peff.net>
On 03.01.13 00:22, Jeff King wrote:
> On Thu, Jan 03, 2013 at 12:14:32AM +0100, Torsten Bögershausen wrote:
>
>>> This is wrong if $(PERL_PATH) contains spaces, no? Doing "$(PERL_PATH)"
>>> is also wrong, because the expansion happens in 'make', and a
>>> $(PERL_PATH) with double-quotes would fool the shell. Since we export
>>> $PERL_PATH, I think doing:
>>>
>>> "$$PERL_PATH"" check-non-portable-shell.pl $(T)
>> Thanks, but:
>> - The double "" after PERL_PATH makes the string un-terminated.
>
> Yeah, sorry, typo on my part.
>
>> - Using "$$PERL_PATH" expands from make into "$PERL_PATH" on the command line
>
> Right. That's what I intended.
>
>> - If the Makefile looks like this:
>> PERL_PATH = "/Users/tb/projects/git/tb/pe rl"
>> [snip]
>> $(PERL_PATH) check-non-portable-shell.pl $(T)
>> The command line will look like this:
>> "/Users/tb/projects/git/tb/pe rl" check-non-portable-shell.pl t0000-basic.sh ...
>>
>> So I think that PERL_PATH should be quoted when it is defined in the Makefile.
>
> Does a $PERL_PATH with quotes actually work?
At least on my system the following combination works:
git diff
diff --git a/t/Makefile b/t/Makefile
index f8f8c54..391a5ca 100644
--- a/t/Makefile
+++ b/t/Makefile
@@ -8,7 +8,7 @@
#GIT_TEST_OPTS = --verbose --debug
SHELL_PATH ?= $(SHELL)
-PERL_PATH ?= /usr/bin/perl
+PERL_PATH = "/Users/tb/projects/git/tb/pe rl"
TAR ?= $(TAR)
RM ?= rm -f
PROVE ?= prove
~/projects/git/tb/t> ls -l "/Users/tb/projects/git/tb/pe rl"
lrwxr-xr-x 1 tb staff 13 Jan 3 00:33 /Users/tb/projects/git/tb/pe rl -> /usr/bin/perl
====================================================
And this works as well, is that what you intended?
Note: "single Dollar"
====================================================
git diff
diff --git a/t/Makefile b/t/Makefile
index f8f8c54..f624f95 100644
--- a/t/Makefile
+++ b/t/Makefile
@@ -8,7 +8,7 @@
#GIT_TEST_OPTS = --verbose --debug
SHELL_PATH ?= $(SHELL)
-PERL_PATH ?= /usr/bin/perl
+PERL_PATH = /Users/tb/projects/git/tb/pe rl
TAR ?= $(TAR)
RM ?= rm -f
PROVE ?= prove
@@ -57,7 +57,7 @@ test-lint-executable:
echo >&2 "non-executable tests:" $$bad; exit 1; }
test-lint-shell-syntax:
- $(PERL_PATH) check-non-portable-shell.pl $(T)
+ "$(PERL_PATH)" check-non-portable-shell.pl $(T)
> Usually in our runtime environment, commands that are handed to git are
> assumed to be passed directly to the shell, and you need to quote. E.g.,
> setting diff.external to:
>
> [diff]
> external = "foo --bar"
>
> will let the shell split the argument out; if you have a space, you
> would want to set it like:
>
> [diff]
> external = "'command with space'"
>
> This is the most flexible way to do it.
>
> However, for Makefile variables, I think we do not (and cannot) follow
> the same rule. Notice that all of the uses of $PERL_PATH in the test
> suite enclose it in quotes. Having extra quotes would break those
> invocations. And the value of $PERL_PATH will be put on the #!-line,
> which cannot not be quoted.
>
> -Peff
I followed these lines as an example:
test-results/git-smoke.tar.gz: test-results
$(PERL_PATH) ./harness \
--archive="test-results/git-smoke.tar.gz" \
$(T)
(and make smoke did not work, as we don't have ./harness :-(
Do we need some cleanup/improvements here as well?
/Torsten
next prev parent reply other threads:[~2013-01-02 23:59 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-01 21:40 [PATCH 1/4] test: Add target test-lint-shell-syntax Torsten Bögershausen
2013-01-01 22:07 ` Junio C Hamano
2013-01-02 0:14 ` Torsten Bögershausen
2013-01-02 2:22 ` Junio C Hamano
2013-01-02 9:46 ` Jeff King
2013-01-02 16:28 ` Junio C Hamano
2013-01-02 23:14 ` Torsten Bögershausen
2013-01-02 23:22 ` Jeff King
2013-01-02 23:58 ` Torsten Bögershausen [this message]
2013-01-03 0:16 ` Junio C Hamano
2013-01-03 0:23 ` Torsten Bögershausen
2013-01-03 2:02 ` Junio C Hamano
2013-01-03 7:17 ` [PATCH] tests: turn on test-lint by default Jeff King
2013-01-03 0:01 ` [PATCH 1/4] test: Add target test-lint-shell-syntax Junio C Hamano
2013-01-03 0:08 ` Junio C Hamano
2013-01-07 17:43 ` Torsten Bögershausen
2013-01-07 18:07 ` Junio C Hamano
2013-01-08 4:11 ` Torsten Bögershausen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50E4C9B5.8070308@web.de \
--to=tboegi@web.de \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).