Closed sisyphus closed 3 months ago
Thanks Rob. It looks like the change in 6def322571eee0e17703edfbbfe17504bb4e19d2 does not work.
Changing L45 to this gets it to work.
if %ERRORLEVEL% == "1" echo FATAL ERROR: 'perl' does not work; check if your strawberry pack is complete!
Oh, yes.
I had played around with alterations to that line but, obviously, the wind here was blowing in the wrong direction.
I still don't quite get it.
Out of curiosity, what changed such that if ERRORLEVEL==1
needed to be altered to if %ERRORLEVEL% == "1"
?
I've uploaded new versions with that line amended. ~I still need to change the base code, though.~
The reason for the change is in #196
I had seen https://github.com/StrawberryPerl/Perl-Dist-Strawberry/issues/196, but it doesn't really explain (to me, at least) the need for the change.
If ERRORLEVEL==1
works fine on my Windows 11 box with perl-5.38.2, then I would expect it to work fine on the same box with perl-5.40.0.
I can only think that the difference comes back to that perl command (on the previous line of portableshell.bat) being handled differently by perl-5.38.2 and perl-5.40.0. And I can't see why perl-5.38.2 and perl-5.40.0 should handle that line of code differently. I'm thinking "perl bug" ... but maybe the only bug is inside my head ;-)
I'll close this now, as the immediate issue is fixed.
But I'll strive to get a better understanding of what is happening here ... and update this thread if I'm successful.
Reopening because I now think the "fix" of replacing ERRORLEVEL 1
with %ERRORLEVEL% == "1"
merely hides the problem, rather than fixing it.
Although there is then no report of an error, the perl one-liner outputs nothing ... because it died.
We might just as well remove that one-liner (and the check on ERRORLEVEL) from portableshell.bat.
Changing the one-liner to:
perl -MConfig -MPDL -e "printf(\"Perl executable: %%s\nPerl version : %%vd / $Config{archname}\nPDL version : %%s\n\n\", $^X, $^V, $PDL::VERSION)" 2>nul
(as suggested at https://www.perlmonks.org/?node_id=11160849) fixes the problem for me - without (I think) any need to alter the following line (line 45). But I don't know why it wasn't always done that way.
That perlmonks thread also presents the notion that the change in behaviour arises from a change in underlying C library, which also seems reasonable. But I don't think it has been caused by the change from MSVCRT to UCRT. My own builds of perl-5.38 are UCRT (unlike SP-5.38 which is MSVCRT), but they handle the original one-liner construct just fine.
UPDATE: It's apparently the white space between the 2 triplets of double-quotes that stuffs things up:
C:\>perl -wle "printf("""SP-Version:%s\n""", $]);"
SP-Version:5.040000
C:\>perl -wle "printf("""SP-Version: %s\n""", $]);"
Can't find string terminator '"' anywhere before EOF at -e line 1.
SP-5.40.0-RC1 avoided the issue by using qq{...}
instead of \" ... \"
.
I'm not sure which (if any) is the preferred solution.
qq{}
is the simplest means of avoiding all the escaping of double quotes. I'll modify the .bat files accordingly.
Even so, the command needs to use %%s
to escape the %
when run as a batch file. I'm not fully across batch file escape rules but it otherwise throws errors when run as a script.
I think I'll also revert the error level check. The old style seems to work well enough now I have tested it more thoroughly.
Even so, the command needs to use
%%s
to escape the%
when run as a batch file.
FWIW (probably not much) you can actually emit the same output from portableshell.bat using print() instead of printf() - thereby avoiding the printf formatting completely:
perl -MConfig -MPDL -e "print qq{Perl executable: $^X\nPerl version : $^V / $Config{archname}\nPDL version : $PDL::VERSION\n\n}" 2>nul
Maybe that doesn't have the desired effect on ERRORLEVEL if something is missing. (I don't know.)
UPDATE: Duh ... not quite the same as perl version appears as "v5.40.0" instead of "5.40.0".
Thanks Rob.
A plain print()
call seems to me to be a simpler approach.
I don't see issues with printing versions with the leading v
. It is purely feedback for when the shell starts. If args are passed then perl is called and the script exits before it gets to this code.
5.40.0.1 has the changes discussed in this issue. I'll close this once that is promoted to the latest release.
Edit: link is https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/tag/SP_54001_64bit_UCRT
SP 5.40.0.1 is now the latest release so I'll close this.
Thanks again @sisyphus for the report and discussion.
On my Windows 11 machine, the execution of 5.40.0.1-PDL's portableshell.bat culminates with:
However, perl itself seems to be basically fine.
It seems that 5.38.2.2-PDL and 5.40.0.1-PDL are handling the command
perl -MConfig -MPDL -e "printf("""Perl executable: %%s\nPerl version : %%vd / $Config{archname}\nPDL version : %%s\n\n""", $^X, $^V, $PDL::VERSION)"
a little differently. On 5.38.2.2-PDL:On 5.40.0.1-PDL:
After spending more time than I'm prepared to admit, I still haven't got to the bottom of it. I'll keep poking at it, but someone else might pinpoint the problem quicker than I can.