Skip to content
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

.bat(ch) files break in Windows with spaces in path #2

Closed
cweedall opened this issue Mar 29, 2017 · 4 comments
Closed

.bat(ch) files break in Windows with spaces in path #2

cweedall opened this issue Mar 29, 2017 · 4 comments

Comments

@cweedall
Copy link

I narrowed down an issue with the .bat(ch) files that are generated for Windows. Assuming you have spaces in the path to the .jar file (which most people will, if they install in the "Program Files" or "Program Files (x86)" folder), the .bat(ch) files do not properly save the full .jar path into the JARPATH variable. They only store the path up until the first space.

For example (with the argument --cmd):

@ECHO OFF
FOR /F %%I IN ('kpsewhich --progname=texosquery --format=texmfscripts texosquery-jre8.jar') DO SET JARPATH=%%I
java -Djava.locale.providers=CLDR,JRE -jar "%JARPATH%" %*

Has Java searching for the jar (on my system) as java -Djava.locale.providers=CLDR,JRE -jar "C:\Program" --cmd.

This obviously isn't good. Fortunately, there is a solution. The solution needs to be applied to all the .bat(ch) files.

REPLACE: FOR /F %%I IN

WITH: FOR /F "tokens=*" %%I IN

Adding "tokens=*" allows you to get all of the tokens separated by spaces from the output returned by the kpsewhich command.

I have tested this locally on a Windows 10 machine and it works fine. I am guessing it probably also works on Win7, 8, and 8.1. Previous versions...I'm not sure.

@nlct
Copy link
Owner

nlct commented Mar 31, 2017

Thank you! I've added your fix to texosquery.dtx. It will be available in version 1.3.

@nlct nlct closed this as completed Mar 31, 2017
@cweedall
Copy link
Author

cweedall commented Apr 1, 2017

I just wanted to add that the MiKTeX executable (via its package manager) does not seem to have this problem. Not sure why they act differently, but I mention it here to bring attention to the difference and hopefully avoid any confusion or complications in future versions and/or bug testing and fixing.

@nlct
Copy link
Owner

nlct commented Apr 3, 2017

I think the TeX distributions on Windows usually create an executable wrapper for convenience, but the .bat files may still be useful for anyone wanting to do a manual installation, for example, testing a new version that hasn't been released yet. Although in that case, it might be simpler just to create a .bat file with the actual path to the .jar file. I'm wondering if I should just drop the .bat files from the distribution. I don't know enough about TeX on Windows (or just Windows in general) to know if they'll be missed if I remove them.

@cweedall
Copy link
Author

cweedall commented Apr 5, 2017

Not sure I can answer this... But I would say that it may be worthwhile to keep them for awhile. When I manually compiled, it generated the .jar files and no .exe files - in the documentation/source, I saw something about why this occurs, but didn't completely understand. One or the other would be required either way, I believe. Probably worthwhile to keep them for a 6-12 month-ish period, then deprecate it, to give people a chance to chime in on the (lack of) need for .bat files.

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

No branches or pull requests

2 participants