Subject: bug#62896: [Configure] Bug with check for PERL when path has spaces (i.e. Windows)

From: Bogdan <[email-masked]>
Date: Fri, 21 Apr 2023 19:47:31 +0200

Hello.

  Thank you for the bug report. The problem is a bit more complicated, 
unfortunately. At least from my point of view.
  I did a bit of an analysis. The problem can be replicated on current 
master on a Linux - just do

	ln -s /usr/bin 'User bins'
	export PATH='User bins':$PATH

and reconfigure.

  I can surround $PERL and $(PERL) with parentheses (patch attached), but:

1) this doesn't fix the "shebang" lines, like #!/bin/bash, leaving 
e.g. bin/aclocal with

	#!User bins/perl

   and that not only will not work, it still stops the build with

	help2man: can't get `--help' info from bin/aclocal

   because of

	$ bin/aclocal --help
    bash: bin/aclocal: User: bad interpreter: No such file or directory

2) this won't work if the correct perl command has options, like when 
we need to, for some reason, have e.g. PERL=perl -W

3) I noticed problem 2) because my fake "User bins" appears also in 
$(INSTALL) and in $(MKDIR_P) in the generated Makefile. Those cannot 
be quoted, because "/whatever/mkdir -p" is not a correct program name. 
It's "/whatever/mkdir" and "-p" is a parameter.

Sorry to say this, but until someone provides a better solution, I 
recommend installing Perl (and other GNU tools - MinGW, coreutils, 
etc.) in paths without spaces, like c:\perl or 
c:\users\your_username\perl (assuming "your_username" doesn't have 
spaces, of course). This may also save you headaches with all those 
scripts which have "#!/bin/bash" or just "bash".

-- 
Regards - Bogdan ('bogdro') D.                 (GNU/Linux & FreeDOS)
X86 assembly (DOS, GNU/Linux):    http://bogdro.evai.pl/index-en.php
Soft(EN): http://bogdro.evai.pl/soft  http://bogdro.evai.pl/soft4asm
www.Xiph.org  www.TorProject.org  www.LibreOffice.org  www.GnuPG.org

From f354e9c74d4b8d6c3a51016fb6bffe698cc741c9 Mon Sep 17 00:00:00 2001
From: Bogdan Drozdowski <>
Date: Fri, 21 Apr 2023 19:34:57 +0200
Subject: [PATCH] Partial fix for spaces in Perl path

---
 configure.ac   | 4 ++--
 doc/local.mk   | 2 +-
 lib/gendocs.sh | 2 +-
 t/local.mk     | 4 ++--
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/configure.ac b/configure.ac
index d095ccb1a..e952c3d1a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -72,8 +72,8 @@ if test -z "$PERL"; then
    AC_MSG_ERROR([perl not found])
 fi
 # Save details about the selected perl interpreter in config.log.
-AM_RUN_LOG([$PERL --version])
-$PERL -e 'require 5.006;' || {
+AM_RUN_LOG(["$PERL" --version])
+"$PERL" -e 'require 5.006;' || {
    AC_MSG_ERROR(
 [perl 5.6 or better is required; perl 5.10 or better
 is recommended.  If you have several perl versions
diff --git a/doc/local.mk b/doc/local.mk
index d72e8e6bb..8b7d98caa 100644
--- a/doc/local.mk
+++ b/doc/local.mk
@@ -37,7 +37,7 @@ EXTRA_DIST += %D%/help2man
 update_mans = \
   $(AM_V_GEN): \
     && $(MKDIR_P) %D% \
-    && AUTOMAKE_HELP2MAN=true ./pre-inst-env $(PERL) $(srcdir)/%D%/help2man --output=$@ --info-page=automake
+    && AUTOMAKE_HELP2MAN=true ./pre-inst-env "$(PERL)" $(srcdir)/%D%/help2man --output=$@ --info-page=automake
 
 %D%/aclocal.1 %D%/automake.1:
 	$(AM_V_GEN): \
diff --git a/lib/gendocs.sh b/lib/gendocs.sh
index 9afe3100e..58ea6cee0 100755
--- a/lib/gendocs.sh
+++ b/lib/gendocs.sh
@@ -246,7 +246,7 @@ copy_images()
   local odir
   odir=$1
   shift
-  $PERL -n -e "
+  "$PERL" -n -e "
 BEGIN {
   \$me = '$prog';
   \$odir = '$odir';
diff --git a/t/local.mk b/t/local.mk
index 4fa46a071..912de5311 100644
--- a/t/local.mk
+++ b/t/local.mk
@@ -256,7 +256,7 @@ installcheck-local: installcheck-testsuite
 installcheck-testsuite:
 	$(AM_V_GEN)$(MAKE) $(AM_MAKEFLAGS) check \
 	  LOG_COMPILER=$(AM_TEST_RUNNER_SHELL) \
-	  PL_LOG_COMPILER=$(PERL) \
+	  PL_LOG_COMPILER="$(PERL)" \
 	  am_running_installcheck=yes
 
 # Ensure that the installed Automake perl modules are found when running 'installcheck' target
@@ -278,6 +278,6 @@ EXTRA_DIST += $(perf_TESTS)
 clean-local: clean-local-check
 .PHONY: clean-local-check
 clean-local-check:
-	$(AM_V_GEN)$(PERL) $(srcdir)/t/ax/deltree.pl t/*.dir t/*/*.dir */t/*.dir
+	$(AM_V_GEN)"$(PERL)" $(srcdir)/t/ax/deltree.pl t/*.dir t/*/*.dir */t/*.dir
 
 # vim: ft=automake noet
-- 
2.35.1