8000 cmd.bat (WPy64-3980) fails with syntax-error · Issue #1039 · winpython/winpython · GitHub
[go: up one dir, main page]

Skip to content

cmd.bat (WPy64-3980) fails with syntax-error #1039

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jcwinkler opened this issue Dec 1, 2021 · 5 comments · Fixed by #1043
Closed

cmd.bat (WPy64-3980) fails with syntax-error #1039

jcwinkler opened this issue Dec 1, 2021 · 5 comments · Fixed by #1043

Comments

@jcwinkler
Copy link

Steps to reproduce
In the following, it is assumed that WinPython is located at C:\Progs\WPy64-3980.

  • Open a Windows command prompt
  • Change into a directory outside of the WinPython installation location
  • Call C:\Progs\WPy64-3980\Scripts\cmd.bat
  • This results in a syntax error:
    grafik

Expected behaviour
The WinPython environment should have been set up successfully.

Reason
After some investigation it turns out that the problem is located in env_for_icons.bat and has been introduced by commit d5d7950

The syntax error is thrown here:

winpython/make.py

Lines 1382 to 1383 in e1b823e

rem remove some potential last \
if "%WINPYWORKDIR1:~-1%"=="\" set WINPYWORKDIR1=%WINPYWORKDIR1:~0,-1%

There, %WINPYWORKDIR1:~-1% is expanded to a ", not \ or another allowed character as expected. This is since %WINPYWORKDIR1 is set in quotationsmarks now due to the commit mentioned above

winpython/make.py

Lines 1378 to 1379 in e1b823e

rem if it it launched from another directory , we keep it that one echo %__CD__%
if not "%__CD__%\"=="%~dp0" set WINPYWORKDIR1="%__CD__%"

Solution
I am not a Windows batch expert but I guess changing

winpython/make.py

Line 1383 in e1b823e

if "%WINPYWORKDIR1:~-1%"=="\" set WINPYWORKDIR1=%WINPYWORKDIR1:~0,-1%

to

if "%WINPYWORKDIR1:~-2,-1%"=="\" set WINPYWORKDIR1=%WINPYWORKDIR1:~0,-2%"

should fix the problem. I tested this on my systems (Windows 8.1 and Windows 10 21H1) and it works. However, I do not overlook all possible side effects. @stonebig If you agree with this approach I can make a PR.

Background
I call cmd.bat from a menu entry in my Windows Explorer context menu "Open WinPython 3.9 command prompt here...". This worked well for years (up to at least WPy64-3950), with WPy64-3980 the mentioned problems occured.

@stonebig
Copy link
Contributor
stonebig commented Dec 4, 2021 8000

need to check my errors...

@stonebig
Copy link
Contributor
stonebig commented Dec 4, 2021

I think doublequoting in very first place was a bad idea

@stonebig
Copy link
Contributor
stonebig commented Dec 4, 2021

after a certain quantity of workarounds, DOS programing becomes non-comprehensible.

I will rather add this line before the offending line

rem remove potential doublequote
set WINPYWORKDIR1=%WINPYWORKDIR1:"=%
rem remove some potential last \
if "%WINPYWORKDIR1:~-1%"=="\" set WINPYWORKDIR1=%WINPYWORKDIR1:~0,-1%

stonebig added a commit to stonebig/winpython that referenced this issue Dec 4, 2021
@stonebig
Copy link
Contributor
stonebig commented Dec 4, 2021

tell me if it works too.
expected advantage is that:

  • it works also
  • it gets rid of the doublequotes in the final WINPYWORKDIR1
  • it works if later I get 100% rid of the doublequote initial workaround

@stonebig stonebig mentioned this issue Dec 4, 2021
8 tasks
@jcwinkler
Copy link
Author

@stonebig I tested your fix and it works fine now. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
0