# installation issue when building with NO_CURL=YesPlease

22 messages from 2010-05-26 to 2010-07-06. Participants: Paul Walker, Ramkumar Ramachandra, Michael J Gruber, Dirk Süsserott, Bruce Stephens, Brandon Casey, Raja R Harinath, Johannes Sixt, Junio C Hamano, Andreas Schwab.
Thread: https://gitlist.dev/t/23914

## Paul Walker, 2010-05-26 13:35

Subject: installation issue when building with NO_CURL=YesPlease
Message-ID: <5B1E2CF0-4BC4-43FF-A372-EB3582DA6286@aol.com>
URL: https://gitlist.dev/e/5B1E2CF0-4BC4-43FF-A372-EB3582DA6286%40aol.com

```
As I could not find any bug reporting information on the wiki I  
thought I would mention this here, please let me know if there is a  
better forum for bug reports.  I believe the latest git release  
(1.7.1.) has an installation bug when building with  
"NO_CURL=YesPlease".  Looking at the Makefile line 1999 it reads

for p in $(REMOTE_CURL_ALIASES); do

which results in "/bin/sh: syntax error at line 1 : `;' unexpected" as  
REMOTE_CURL_ALIASES is empty.

```

## Michael J Gruber, 2010-05-26 13:58

Subject: Re: installation issue when building with NO_CURL=YesPlease
Message-ID: <4BFD290B.6050502@drmicha.warpmail.net>
URL: https://gitlist.dev/e/4BFD290B.6050502%40drmicha.warpmail.net
In-Reply-To: <5B1E2CF0-4BC4-43FF-A372-EB3582DA6286@aol.com>

```
Paul Walker venit, vidit, dixit 26.05.2010 15:35:
> As I could not find any bug reporting information on the wiki I  
> thought I would mention this here, please let me know if there is a  
> better forum for bug reports.  I believe the latest git release  
> (1.7.1.) has an installation bug when building with  
> "NO_CURL=YesPlease".  Looking at the Makefile line 1999 it reads
> 
> for p in $(REMOTE_CURL_ALIASES); do
> 
> which results in "/bin/sh: syntax error at line 1 : `;' unexpected" as  
> REMOTE_CURL_ALIASES is empty.

That seems to depend on the shell. My bash 4.1.2 doesn't care. What does
/bin/sh --version say for you?

Michael

```

## Ramkumar Ramachandra, 2010-05-26 13:58

Subject: Re: installation issue when building with NO_CURL=YesPlease
Message-ID: <AANLkTimsGdv-La_poLpdrvuGChD6_sAD77fcjqKn5PAd@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTimsGdv-La_poLpdrvuGChD6_sAD77fcjqKn5PAd%40mail.gmail.com
In-Reply-To: <5B1E2CF0-4BC4-43FF-A372-EB3582DA6286@aol.com>

```
Hi,

> As I could not find any bug reporting information on the wiki I thought I
> would mention this here, please let me know if there is a better forum for
> bug reports.

Bugs are usually reported on this mailing list.

> I believe the latest git release (1.7.1.) has an installation
> bug when building with "NO_CURL=YesPlease".  Looking at the Makefile line
> 1999 it reads
>
> for p in $(REMOTE_CURL_ALIASES); do
>
> which results in "/bin/sh: syntax error at line 1 : `;' unexpected" as
> REMOTE_CURL_ALIASES is empty.

I can't reproduce this. How exactly are you building? I'm using
$ NO_CURL=YesPlease make
... and it builds fine for me.

-- Ram

```

## Paul Walker, 2010-05-26 14:15

Subject: Re: installation issue when building with NO_CURL=YesPlease
Message-ID: <8E0CE121-DB2F-4017-AB46-282562B072FB@aol.com>
URL: https://gitlist.dev/e/8E0CE121-DB2F-4017-AB46-282562B072FB%40aol.com
In-Reply-To: <AANLkTimsGdv-La_poLpdrvuGChD6_sAD77fcjqKn5PAd@mail.gmail.com>

```

On 26 May 2010, at 14:58, Ramkumar Ramachandra wrote:

> Hi,
>
>> As I could not find any bug reporting information on the wiki I  
>> thought I
>> would mention this here, please let me know if there is a better  
>> forum for
>> bug reports.
>
> Bugs are usually reported on this mailing list.
>
>>  I believe the latest git release (1.7.1.) has an installation
>> bug when building with "NO_CURL=YesPlease".  Looking at the  
>> Makefile line
>> 1999 it reads
>>
>> for p in $(REMOTE_CURL_ALIASES); do
>>
>> which results in "/bin/sh: syntax error at line 1 : `;' unexpected"  
>> as
>> REMOTE_CURL_ALIASES is empty.
>
> I can't reproduce this. How exactly are you building? I'm using
> $ NO_CURL=YesPlease make
> ... and it builds fine for me.
>
> -- Ram

I used:

gmake prefix=<path> NO_CURL=YesPlease NO_PYTHON=YesPlease all

which works fine, followed by

gmake prefix=<path> NO_CURL=YesPlease NO_PYTHON=YesPlease install

which reported the above error

```

## Michael J Gruber, 2010-05-26 14:24

Subject: [PATCH] Makefile: reenable install with NO_CURL
Message-ID: <4f12dca01c2e72c5ba38ce5230422b394c1297d9.1274883851.git.git@drmicha.warpmail.net>
URL: https://gitlist.dev/e/4f12dca01c2e72c5ba38ce5230422b394c1297d9.1274883851.git.git%40drmicha.warpmail.net
In-Reply-To: <8E0CE121-DB2F-4017-AB46-282562B072FB@aol.com>

```
Setting NO_CURL leaves some variables like REMOTE_CURL_ALIASES
empty, which creates no fun when for-looping over
$(REMOTE_CURL_ALIASES) unconditionally. Make it conditional.

Reported-by: Paul Walker <PWalker752@aol.com>
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
Against master but suggested for maint.
Note that the problem occurs during "make install", not "make".

 Makefile |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 07cab8f..d5d6565 100644
--- a/Makefile
+++ b/Makefile
@@ -2008,12 +2008,13 @@ endif
 		ln -s "git$X" "$$execdir/$$p" 2>/dev/null || \
 		cp "$$execdir/git$X" "$$execdir/$$p" || exit; \
 	  done; } && \
-	{ for p in $(REMOTE_CURL_ALIASES); do \
+	{ test x"$(REMOTE_CURL_ALIASES)" = x || \
+		{ for p in $(REMOTE_CURL_ALIASES); do \
 		$(RM) "$$execdir/$$p" && \
 		ln "$$execdir/git-remote-http$X" "$$execdir/$$p" 2>/dev/null || \
 		ln -s "git-remote-http$X" "$$execdir/$$p" 2>/dev/null || \
 		cp "$$execdir/git-remote-http$X" "$$execdir/$$p" || exit; \
-	  done; } && \
+	  done; } ; } && \
 	./check_bindir "z$$bindir" "z$$execdir" "$$bindir/git-add$X"
 
 install-gitweb:
-- 
1.7.1.232.g2311e.dirty

```

## Paul Walker, 2010-05-26 14:41

Subject: Re: installation issue when building with NO_CURL=YesPlease
Message-ID: <24D3B56E-0EA0-4E1C-BF42-F5BF71891F78@aol.com>
URL: https://gitlist.dev/e/24D3B56E-0EA0-4E1C-BF42-F5BF71891F78%40aol.com
In-Reply-To: <4BFD290B.6050502@drmicha.warpmail.net>

```

On 26 May 2010, at 14:58, Michael J Gruber wrote:

> Paul Walker venit, vidit, dixit 26.05.2010 15:35:
>> As I could not find any bug reporting information on the wiki I
>> thought I would mention this here, please let me know if there is a
>> better forum for bug reports.  I believe the latest git release
>> (1.7.1.) has an installation bug when building with
>> "NO_CURL=YesPlease".  Looking at the Makefile line 1999 it reads
>>
>> for p in $(REMOTE_CURL_ALIASES); do
>>
>> which results in "/bin/sh: syntax error at line 1 : `;' unexpected"  
>> as
>> REMOTE_CURL_ALIASES is empty.
>
> That seems to depend on the shell. My bash 4.1.2 doesn't care. What  
> does
> /bin/sh --version say for you?
>
> Michael

I am struggling to work this out as my version of sh does not support  
the --version flag.
I tried a bunch of other options provided by google with not success.
If it helps I believe that /bin/sh is a version of ksh that comes with  
AIX 6.1

```

## Dirk Süsserott, 2010-05-26 18:27

Subject: Re: installation issue when building with NO_CURL=YesPlease
Message-ID: <4BFD680E.8000603@dirk.my1.cc>
URL: https://gitlist.dev/e/4BFD680E.8000603%40dirk.my1.cc
In-Reply-To: <8E0CE121-DB2F-4017-AB46-282562B072FB@aol.com>

```
Am 26.05.2010 16:15 schrieb Paul Walker:
> 
> On 26 May 2010, at 14:58, Ramkumar Ramachandra wrote:
> 
>> Hi,
>>
>>> As I could not find any bug reporting information on the wiki I 
>>> thought I
>>> would mention this here, please let me know if there is a better 
>>> forum for
>>> bug reports.
>>
>> Bugs are usually reported on this mailing list.
>>
>>>  I believe the latest git release (1.7.1.) has an installation
>>> bug when building with "NO_CURL=YesPlease".  Looking at the Makefile 
>>> line
>>> 1999 it reads
>>>
>>> for p in $(REMOTE_CURL_ALIASES); do
>>>
>>> which results in "/bin/sh: syntax error at line 1 : `;' unexpected" as
>>> REMOTE_CURL_ALIASES is empty.
>>
>> I can't reproduce this. How exactly are you building? I'm using
>> $ NO_CURL=YesPlease make
>> ... and it builds fine for me.
>>
>> -- Ram
> 
> I used:
> 
> gmake prefix=<path> NO_CURL=YesPlease NO_PYTHON=YesPlease all
> 
> which works fine, followed by
> 
> gmake prefix=<path> NO_CURL=YesPlease NO_PYTHON=YesPlease install
> 
> which reported the above error
> 

I had a similar problem when "make install"ing under AIX. Not with 
NO_CURL but with some other NO_* option. I forgot which.
This yealded to an empty $(REMOTE_***_ALIASES) macro 
(REMOTE_CURL_ALIASES in your case) which my AIX shell cannot handle.

It reads "for p in; do" which makes it unhappy. I solved my problem with 
  the SHELL_PATH environment variable (look at the first few lines in 
the Makefile).

$ SHELL_PATH=/bin/bash NO_SOMETHING=YesPlease make install

then worked fine for me.

HTH,
     Dirk

```

## Bruce Stephens, 2010-05-26 18:45

Subject: Re: installation issue when building with NO_CURL=YesPlease
Message-ID: <80typu1ozt.fsf@tiny.isode.net>
URL: https://gitlist.dev/e/80typu1ozt.fsf%40tiny.isode.net
In-Reply-To: <4BFD680E.8000603@dirk.my1.cc>

```
Dirk Süsserott <newsletter@dirk.my1.cc> writes:

[...]

> I had a similar problem when "make install"ing under AIX. Not with
> NO_CURL but with some other NO_* option. I forgot which.
> This yealded to an empty $(REMOTE_***_ALIASES) macro
> (REMOTE_CURL_ALIASES in your case) which my AIX shell cannot handle.
>
> It reads "for p in; do" which makes it unhappy. I solved my problem
> with the SHELL_PATH environment variable (look at the first few lines
> in the Makefile).
>
> $ SHELL_PATH=/bin/bash NO_SOMETHING=YesPlease make install
>
> then worked fine for me.

It wouldn't be too horrible to fix the Makefiles, though.  Doing stuff
like this works portably (judging by what some OpenSSL Makefiles do):

	foo="$(REMOTE_CURL_ALIASES)"; for i in $$foo; do \

[...]

```

## Dirk Süsserott, 2010-05-26 19:03

Subject: Re: installation issue when building with NO_CURL=YesPlease
Message-ID: <4BFD7082.1080608@dirk.my1.cc>
URL: https://gitlist.dev/e/4BFD7082.1080608%40dirk.my1.cc
In-Reply-To: <80typu1ozt.fsf@tiny.isode.net>

```
Am 26.05.2010 20:45 schrieb Bruce Stephens:
> Dirk Süsserott <newsletter@dirk.my1.cc> writes:
> 
> [...]
> 
>> I had a similar problem when "make install"ing under AIX. Not with
>> NO_CURL but with some other NO_* option. I forgot which.
>> This yealded to an empty $(REMOTE_***_ALIASES) macro
>> (REMOTE_CURL_ALIASES in your case) which my AIX shell cannot handle.
>>
>> It reads "for p in; do" which makes it unhappy. I solved my problem
>> with the SHELL_PATH environment variable (look at the first few lines
>> in the Makefile).
>>
>> $ SHELL_PATH=/bin/bash NO_SOMETHING=YesPlease make install
>>
>> then worked fine for me.
> 
> It wouldn't be too horrible to fix the Makefiles, though.  Doing stuff
> like this works portably (judging by what some OpenSSL Makefiles do):
> 
> 	foo="$(REMOTE_CURL_ALIASES)"; for i in $$foo; do \
> 
> [...]
> 

Bruce,

I just saw that Michael posted a patch which tests for the emptyness of 
REMOTE_CURL_ALIASES. Probably that's a more convenient solution.

Dirk

```

## Brandon Casey, 2010-07-02 18:50

Subject: [PATCH 1/2] Makefile: remove some unnecessary curly braces
Message-ID: <8YdP-GcDDflOVZnykNVIGZV2ru1dwSkd6psWipKx3nNQK-C4OmEK2ZwFAj1tSIK1LUawtXDhUrxEeO95yG3lXQ@cipher.nrlssc.navy.mil>
URL: https://gitlist.dev/e/8YdP-GcDDflOVZnykNVIGZV2ru1dwSkd6psWipKx3nNQK-C4OmEK2ZwFAj1tSIK1LUawtXDhUrxEeO95yG3lXQ%40cipher.nrlssc.navy.mil
In-Reply-To: <80typu1ozt.fsf@tiny.isode.net>

```
From: Brandon Casey <drafnel@gmail.com>


Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---
 Makefile |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index 9aca8a1..527d872 100644
--- a/Makefile
+++ b/Makefile
@@ -2079,19 +2079,19 @@ endif
 		test -z "$(NO_CROSS_DIRECTORY_HARDLINKS)" && \
 		ln "$$bindir/git$X" "$$execdir/git$X" 2>/dev/null || \
 		cp "$$bindir/git$X" "$$execdir/git$X"; } ; } && \
-	{ for p in $(BUILT_INS); do \
+	for p in $(BUILT_INS); do \
 		$(RM) "$$execdir/$$p" && \
 		ln "$$execdir/git$X" "$$execdir/$$p" 2>/dev/null || \
 		ln -s "git$X" "$$execdir/$$p" 2>/dev/null || \
 		cp "$$execdir/git$X" "$$execdir/$$p" || exit; \
-	  done; } && \
+	done && \
 	{ test x"$(REMOTE_CURL_ALIASES)" = x || \
-		{ for p in $(REMOTE_CURL_ALIASES); do \
+		for p in $(REMOTE_CURL_ALIASES); do \
 		$(RM) "$$execdir/$$p" && \
 		ln "$$execdir/git-remote-http$X" "$$execdir/$$p" 2>/dev/null || \
 		ln -s "git-remote-http$X" "$$execdir/$$p" 2>/dev/null || \
 		cp "$$execdir/git-remote-http$X" "$$execdir/$$p" || exit; \
-	  done; } ; } && \
+	done; } && \
 	./check_bindir "z$$bindir" "z$$execdir" "$$bindir/git-add$X"
 
 install-gitweb:
-- 
1.7.2.rc1

```

## Brandon Casey, 2010-07-02 18:50

Subject: [PATCH 2/2] Makefile: work around ksh's failure to handle missing list argument to for loop
Message-ID: <8YdP-GcDDflOVZnykNVIGceOm01bqeg9PDvdgIfgqUnh29RKC-6Qi8_KBVoqLIt5iyt7g1TX5l96M5KyLrfOqg@cipher.nrlssc.navy.mil>
URL: https://gitlist.dev/e/8YdP-GcDDflOVZnykNVIGceOm01bqeg9PDvdgIfgqUnh29RKC-6Qi8_KBVoqLIt5iyt7g1TX5l96M5KyLrfOqg%40cipher.nrlssc.navy.mil
In-Reply-To: <80typu1ozt.fsf@tiny.isode.net>

```
From: Brandon Casey <drafnel@gmail.com>

ksh does not like it when the list argument is missing in a for loop.  This
can happen when NO_CURL is set which causes REMOTE_CURL_ALIASES to be unset.
In this case, the for loop in the Makefile expands to look like this:

   for p in ; do

and ksh complains like this:

   /bin/ksh: syntax error at line 15 : `;' unexpected

The existing attempt to work around this issue, introduced by 70b89f87,
tried to protect the for loop by first testing whether REMOTE_CURL_ALIASES
was empty, but it does not seem to work.  So adopt Bruce Stephens's
suggestion (which comes from OpenSSL) for working around this issue.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---
 Makefile |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 527d872..bc3c570 100644
--- a/Makefile
+++ b/Makefile
@@ -2085,13 +2085,13 @@ endif
 		ln -s "git$X" "$$execdir/$$p" 2>/dev/null || \
 		cp "$$execdir/git$X" "$$execdir/$$p" || exit; \
 	done && \
-	{ test x"$(REMOTE_CURL_ALIASES)" = x || \
-		for p in $(REMOTE_CURL_ALIASES); do \
+	remote_curl_aliases="$(REMOTE_CURL_ALIASES)" && \
+	for p in $$remote_curl_aliases; do \
 		$(RM) "$$execdir/$$p" && \
 		ln "$$execdir/git-remote-http$X" "$$execdir/$$p" 2>/dev/null || \
 		ln -s "git-remote-http$X" "$$execdir/$$p" 2>/dev/null || \
 		cp "$$execdir/git-remote-http$X" "$$execdir/$$p" || exit; \
-	done; } && \
+	done && \
 	./check_bindir "z$$bindir" "z$$execdir" "$$bindir/git-add$X"
 
 install-gitweb:
-- 
1.7.2.rc1

```

## Raja R Harinath, 2010-07-03 06:21

Subject: Re: [PATCH 2/2] Makefile: work around ksh's failure to handle missing list argument to for loop
Message-ID: <87d3v56q6o.fsf@hariville.hurrynot.org>
URL: https://gitlist.dev/e/87d3v56q6o.fsf%40hariville.hurrynot.org
In-Reply-To: <8YdP-GcDDflOVZnykNVIGceOm01bqeg9PDvdgIfgqUnh29RKC-6Qi8_KBVoqLIt5iyt7g1TX5l96M5KyLrfOqg@cipher.nrlssc.navy.mil>

```
Hi,

Brandon Casey <casey@nrlssc.navy.mil> writes:

> ksh does not like it when the list argument is missing in a for loop.  This
> can happen when NO_CURL is set which causes REMOTE_CURL_ALIASES to be unset.
> In this case, the for loop in the Makefile expands to look like this:
>
>    for p in ; do
>
> and ksh complains like this:
>
>    /bin/ksh: syntax error at line 15 : `;' unexpected
[snip]
> -	{ test x"$(REMOTE_CURL_ALIASES)" = x || \
> -		for p in $(REMOTE_CURL_ALIASES); do \
> +	remote_curl_aliases="$(REMOTE_CURL_ALIASES)" && \
> +	for p in $$remote_curl_aliases; do \

I believe the idiom

  test x'$(foo)' = x || for p in ''$(foo); do

works equally well in this case, and is less invasive.

- Hari

```

## Michael J Gruber, 2010-07-04 18:37

Subject: Re: [PATCH 2/2] Makefile: work around ksh's failure to handle missing list argument to for loop
Message-ID: <4C30D4D5.3020900@drmicha.warpmail.net>
URL: https://gitlist.dev/e/4C30D4D5.3020900%40drmicha.warpmail.net
In-Reply-To: <8YdP-GcDDflOVZnykNVIGceOm01bqeg9PDvdgIfgqUnh29RKC-6Qi8_KBVoqLIt5iyt7g1TX5l96M5KyLrfOqg@cipher.nrlssc.navy.mil>

```
Brandon Casey venit, vidit, dixit 02.07.2010 20:50:
> From: Brandon Casey <drafnel@gmail.com>
> 
> ksh does not like it when the list argument is missing in a for loop.  This
> can happen when NO_CURL is set which causes REMOTE_CURL_ALIASES to be unset.
> In this case, the for loop in the Makefile expands to look like this:
> 
>    for p in ; do
> 
> and ksh complains like this:
> 
>    /bin/ksh: syntax error at line 15 : `;' unexpected
> 
> The existing attempt to work around this issue, introduced by 70b89f87,
> tried to protect the for loop by first testing whether REMOTE_CURL_ALIASES
> was empty, but it does not seem to work.  So adopt Bruce Stephens's

What does that mean? Either it works or it doesn't. I did work back
then. Does it (i.e.: the test for emtyness) fail to work for certain shells?

Michael

```

## Johannes Sixt, 2010-07-05 06:19

Subject: Re: [PATCH 2/2] Makefile: work around ksh's failure to handle missing list argument to for loop
Message-ID: <4C31796E.9050109@viscovery.net>
URL: https://gitlist.dev/e/4C31796E.9050109%40viscovery.net
In-Reply-To: <4C30D4D5.3020900@drmicha.warpmail.net>

```
Am 7/4/2010 20:37, schrieb Michael J Gruber:
> Brandon Casey venit, vidit, dixit 02.07.2010 20:50:
>> In this case, the for loop in the Makefile expands to look like this:
>>
>>    for p in ; do
>>
>> and ksh complains like this:
>>
>>    /bin/ksh: syntax error at line 15 : `;' unexpected
>>
>> The existing attempt to work around this issue, introduced by 70b89f87,
>> tried to protect the for loop by first testing whether REMOTE_CURL_ALIASES
>> was empty, but it does not seem to work.  So adopt Bruce Stephens's
> 
> What does that mean? Either it works or it doesn't. I did work back
> then. Does it (i.e.: the test for emtyness) fail to work for certain shells?

Before the test for emptyness can happen, the complete statement must be
parsed, but ksh finds a syntax error in the statement and, therefore,
cannot even begin to execute the statement. (ksh doesn't follow POSIX in
this regard, where this would not be a syntax error.)

-- Hannes

```

## Michael J Gruber, 2010-07-05 08:14

Subject: Re: [PATCH 2/2] Makefile: work around ksh's failure to handle missing list argument to for loop
Message-ID: <4C319478.4070903@drmicha.warpmail.net>
URL: https://gitlist.dev/e/4C319478.4070903%40drmicha.warpmail.net
In-Reply-To: <4C31796E.9050109@viscovery.net>

```
Johannes Sixt venit, vidit, dixit 05.07.2010 08:19:
> Am 7/4/2010 20:37, schrieb Michael J Gruber:
>> Brandon Casey venit, vidit, dixit 02.07.2010 20:50:
>>> In this case, the for loop in the Makefile expands to look like this:
>>>
>>>    for p in ; do
>>>
>>> and ksh complains like this:
>>>
>>>    /bin/ksh: syntax error at line 15 : `;' unexpected
>>>
>>> The existing attempt to work around this issue, introduced by 70b89f87,
>>> tried to protect the for loop by first testing whether REMOTE_CURL_ALIASES
>>> was empty, but it does not seem to work.  So adopt Bruce Stephens's
>>
>> What does that mean? Either it works or it doesn't. I did work back
>> then. Does it (i.e.: the test for emtyness) fail to work for certain shells?
> 
> Before the test for emptyness can happen, the complete statement must be
> parsed, but ksh finds a syntax error in the statement and, therefore,
> cannot even begin to execute the statement. (ksh doesn't follow POSIX in
> this regard, where this would not be a syntax error.)

OK, thanks for clarifying. I suggest this to go into the commit message
so that the "does not seem to work" is qualified.

The OP back then (before 70b89f87) used ksh on AIX 6.1, but maybe he
left the thread without testing. I assume Hari's suggestion works on
ksh, as well?

If we go for Brandon's version: Is there a reason for small-casing the
var name? It looks as if we had two different variables with different
case (which we don't).

BTW: Is the $$var gmake specific? Has anyone tested the new version on,
say, AIX, not just on Linux with ksh?

Michael

```

## Johannes Sixt, 2010-07-05 09:15

Subject: Re: [PATCH 2/2] Makefile: work around ksh's failure to handle missing list argument to for loop
Message-ID: <4C31A298.1030005@viscovery.net>
URL: https://gitlist.dev/e/4C31A298.1030005%40viscovery.net
In-Reply-To: <4C319478.4070903@drmicha.warpmail.net>

```
Am 7/5/2010 10:14, schrieb Michael J Gruber:
> BTW: Is the $$var gmake specific?

No. $ is a (special?) make variable that contains only a dollar sign. To
expand the variable in the Makefile, you have to write $$ (like for any
other Makefile variable whose name has only a single character, like $@,
$<, etc). As a result, you get a single dollar sign in the shell command
text. :-)

-- Hannes

```

## Michael J Gruber, 2010-07-05 09:31

Subject: Re: [PATCH 2/2] Makefile: work around ksh's failure to handle missing list argument to for loop
Message-ID: <4C31A65C.7030002@drmicha.warpmail.net>
URL: https://gitlist.dev/e/4C31A65C.7030002%40drmicha.warpmail.net
In-Reply-To: <4C31A298.1030005@viscovery.net>

```
Johannes Sixt venit, vidit, dixit 05.07.2010 11:15:
> Am 7/5/2010 10:14, schrieb Michael J Gruber:
>> BTW: Is the $$var gmake specific?
> 
> No. $ is a (special?) make variable that contains only a dollar sign. To
> expand the variable in the Makefile, you have to write $$ (like for any
> other Makefile variable whose name has only a single character, like $@,
> $<, etc). As a result, you get a single dollar sign in the shell command
> text. :-)

I guess I need this in my personal tree:

diff --git a/Michael b/Michael
index 5318944..2ff6a75 100644
--- a/Michael
+++ b/Michael
@@ -0815,2 +0815,2 @@ endif

-stupid remark about lower case
-stupid question about escaping $
+compensate for lack of morning coffee
+note that an empty shell var is more than nothing at all

Michael

```

## Junio C Hamano, 2010-07-05 18:18

Subject: Re: [PATCH 2/2] Makefile: work around ksh's failure to handle missing list argument to for loop
Message-ID: <7vy6dpyeqf.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vy6dpyeqf.fsf%40alter.siamese.dyndns.org
In-Reply-To: <4C31796E.9050109@viscovery.net>

```
Johannes Sixt <j.sixt@viscovery.net> writes:

> Before the test for emptyness can happen, the complete statement must be
> parsed, but ksh finds a syntax error in the statement and, therefore,
> cannot even begin to execute the statement. (ksh doesn't follow POSIX in
> this regard, where this would not be a syntax error.)

I had to stare at Brandon's patch that was essentially:

-    for p in $(FOO); do echo $$p; done
+    foo=$(FOO); for p in $$foo; do echo $$p; done

and the above two doesn't look like there should be any difference; your
explanation makes quite a lot of sense but that's arcane.  I doubt I will
be able to justify and explain the latter construction without consulting
your message I am responsing to, if somebody asks "why do we assign $(FOO)
to a shell variable and then iterate over it?" 6 months from now.

It might make sense to use $(foreach) instead of rolling our own loop in
the shell to avoid glitches like this.

 Makefile |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/Makefile b/Makefile
index 9aca8a1..8bbb574 100644
--- a/Makefile
+++ b/Makefile
@@ -2085,13 +2085,13 @@ endif
 		ln -s "git$X" "$$execdir/$$p" 2>/dev/null || \
 		cp "$$execdir/git$X" "$$execdir/$$p" || exit; \
 	  done; } && \
-	{ test x"$(REMOTE_CURL_ALIASES)" = x || \
-		{ for p in $(REMOTE_CURL_ALIASES); do \
-		$(RM) "$$execdir/$$p" && \
-		ln "$$execdir/git-remote-http$X" "$$execdir/$$p" 2>/dev/null || \
-		ln -s "git-remote-http$X" "$$execdir/$$p" 2>/dev/null || \
-		cp "$$execdir/git-remote-http$X" "$$execdir/$$p" || exit; \
-	  done; } ; } && \
+	$(foreach p,$(REMOTE_CURL_ALIASES), \
+		{ \
+		$(RM) "$$execdir/$p" && \
+		ln "$$execdir/git-remote-http$X" "$$execdir/$p" 2>/dev/null || \
+		ln -s "git-remote-http$X" "$$execdir/$p" 2>/dev/null || \
+		cp "$$execdir/git-remote-http$X" "$$execdir/$p" || exit; \
+		} && ) : \
 	./check_bindir "z$$bindir" "z$$execdir" "$$bindir/git-add$X"
 
 install-gitweb:

```

## Andreas Schwab, 2010-07-05 20:00

Subject: Re: [PATCH 2/2] Makefile: work around ksh's failure to handle missing list argument to for loop
Message-ID: <m2hbkd66nn.fsf@igel.home>
URL: https://gitlist.dev/e/m2hbkd66nn.fsf%40igel.home
In-Reply-To: <7vy6dpyeqf.fsf@alter.siamese.dyndns.org>

```
Junio C Hamano <gitster@pobox.com> writes:

> +	$(foreach p,$(REMOTE_CURL_ALIASES), \
> +		{ \
> +		$(RM) "$$execdir/$p" && \
> +		ln "$$execdir/git-remote-http$X" "$$execdir/$p" 2>/dev/null || \
> +		ln -s "git-remote-http$X" "$$execdir/$p" 2>/dev/null || \
> +		cp "$$execdir/git-remote-http$X" "$$execdir/$p" || exit; \
> +		} && ) : \
                       ^^
>  	./check_bindir "z$$bindir" "z$$execdir" "$$bindir/git-add$X"

Missing && at the end of the preceding line (otherwise the last line is
effectively commented out).

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

```

## Brandon Casey, 2010-07-05 21:29

Subject: Re: [PATCH 2/2] Makefile: work around ksh's failure to handle missing list argument to for loop
Message-ID: <AANLkTin0h8DUWo3sfhRdA7NCCCPLKXfQzSDvWX7p1OPq@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTin0h8DUWo3sfhRdA7NCCCPLKXfQzSDvWX7p1OPq%40mail.gmail.com
In-Reply-To: <7vy6dpyeqf.fsf@alter.siamese.dyndns.org>

```
It looks like Johannes has already supplied the explanation that was
missing from my commit message.  Thanks.


On Mon, Jul 5, 2010 at 1:18 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Johannes Sixt <j.sixt@viscovery.net> writes:
>
>> Before the test for emptyness can happen, the complete statement must be
>> parsed, but ksh finds a syntax error in the statement and, therefore,
>> cannot even begin to execute the statement. (ksh doesn't follow POSIX in
>> this regard, where this would not be a syntax error.)
>
> I had to stare at Brandon's patch that was essentially:
>
> -    for p in $(FOO); do echo $$p; done
> +    foo=$(FOO); for p in $$foo; do echo $$p; done
>
> and the above two doesn't look like there should be any difference; your
> explanation makes quite a lot of sense but that's arcane.  I doubt I will
> be able to justify and explain the latter construction without consulting
> your message I am responsing to, if somebody asks "why do we assign $(FOO)
> to a shell variable and then iterate over it?" 6 months from now.
>
> It might make sense to use $(foreach) instead of rolling our own loop in
> the shell to avoid glitches like this.

$(foreach) works too.  I only avoided it because it has already caused a
problem once before by creating a command line that exceeded the
maximum argument list length on IRIX.

REMOTE_CURL_ALIASES only has 3 items in it right now, and probably
won't grow much larger, if it grows at all, so there is little chance of
exceeding the maximum argument list length on IRIX.  So $(foreach) is
fine with me if you think that reads better.

-Brandon

```

## Junio C Hamano, 2010-07-06 02:36

Subject: Re: [PATCH 2/2] Makefile: work around ksh's failure to handle missing list argument to for loop
Message-ID: <7v630t72vo.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v630t72vo.fsf%40alter.siamese.dyndns.org
In-Reply-To: <AANLkTin0h8DUWo3sfhRdA7NCCCPLKXfQzSDvWX7p1OPq@mail.gmail.com>

```
Brandon Casey <drafnel@gmail.com> writes:

> $(foreach) works too.  I only avoided it because it has already caused a
> problem once before by creating a command line that exceeded the
> maximum argument list length on IRIX.

Ok, fair enough.

> REMOTE_CURL_ALIASES only has 3 items in it right now, and probably
> won't grow much larger, if it grows at all, so there is little chance of
> exceeding the maximum argument list length on IRIX.  So $(foreach) is
> fine with me if you think that reads better.

Well your patch fixes the issue, and I would actually prefer it as long as
it is explained well ;-).

Thanks.

```

## Brandon Casey, 2010-07-06 21:56

Subject: [PATCH 2/2 v2] Makefile: work around ksh's failure to handle missing list argument to for loop
Message-ID: <vUheaJEBKF4RpCQidVNBD1qrdnnqrcfK_TfSmMUj8l53PCm3F-faBNN2Pxk97G5Mf5GY3dVoDgwkpzK8xO7nXw@cipher.nrlssc.navy.mil>
URL: https://gitlist.dev/e/vUheaJEBKF4RpCQidVNBD1qrdnnqrcfK_TfSmMUj8l53PCm3F-faBNN2Pxk97G5Mf5GY3dVoDgwkpzK8xO7nXw%40cipher.nrlssc.navy.mil
In-Reply-To: <7v630t72vo.fsf@alter.siamese.dyndns.org>

```
From: Brandon Casey <drafnel@gmail.com>

ksh does not like it when the list argument is missing in a 'for' loop.
This can happen when NO_CURL is set which causes REMOTE_CURL_ALIASES to be
unset.  In this case, the 'for' loop in the Makefile is expanded to look
like this:

   for p in ; do

and ksh complains like this:

   /bin/ksh: syntax error at line 15 : `;' unexpected

The existing attempt to work around this issue, introduced by 70b89f87,
tried to protect the 'for' loop by first testing whether REMOTE_CURL_ALIASES
was empty, but this does not work since, as Johannes Sixt explains, "Before
the test for emptyness can happen, the complete statement must be parsed,
but ksh finds a syntax error in the statement and, therefore, cannot even
begin to execute the statement. (ksh doesn't follow POSIX in this regard,
where this would not be a syntax error.)".

Make's $(foreach) function could be used to avoid this shell glitch, but
since it has already caused a problem once before by generating a command
line that exceeded the maximum argument list length on IRIX, let's adopt
Bruce Stephens's suggestion for working around this issue in the same way
the OpenSSL folks have done it.  This solution first assigns the contents
of the REMOTE_CURL_ALIASES make variable to a shell variable and then
supplies the shell variable as the list argument in the 'for' loop.  This
satisfies ksh and has the expected behavior even if $(REMOTE_CURL_ALIASES)
is empty.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---


On 07/05/2010 09:36 PM, Junio C Hamano wrote:
> Well your patch fixes the issue, and I would actually prefer it as long as
> it is explained well ;-).

Heh, ok, hopefully this commit message does a better job.

-Brandon


 Makefile |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 527d872..bc3c570 100644
--- a/Makefile
+++ b/Makefile
@@ -2085,13 +2085,13 @@ endif
 		ln -s "git$X" "$$execdir/$$p" 2>/dev/null || \
 		cp "$$execdir/git$X" "$$execdir/$$p" || exit; \
 	done && \
-	{ test x"$(REMOTE_CURL_ALIASES)" = x || \
-		for p in $(REMOTE_CURL_ALIASES); do \
+	remote_curl_aliases="$(REMOTE_CURL_ALIASES)" && \
+	for p in $$remote_curl_aliases; do \
 		$(RM) "$$execdir/$$p" && \
 		ln "$$execdir/git-remote-http$X" "$$execdir/$$p" 2>/dev/null || \
 		ln -s "git-remote-http$X" "$$execdir/$$p" 2>/dev/null || \
 		cp "$$execdir/git-remote-http$X" "$$execdir/$$p" || exit; \
-	done; } && \
+	done && \
 	./check_bindir "z$$bindir" "z$$execdir" "$$bindir/git-add$X"
 
 install-gitweb:
-- 
1.7.2.rc1

```
