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

Gregoriotex falis when there is a space in filename. #1224

Closed
warej opened this issue Sep 10, 2016 · 16 comments
Closed

Gregoriotex falis when there is a space in filename. #1224

warej opened this issue Sep 10, 2016 · 16 comments
Assignees
Milestone

Comments

@warej
Copy link

warej commented Sep 10, 2016

At first sorry if I'll write something stupid - I'm not much experienced with TeX and I'm absolutely new to Gregorio.

But from what I've observed, there is a bug with not quoting file names, which leads to compilation errors, when gabc file, tex file, or some directory on path to them contains a space in it's name ("ResHodie Nobis.gabc").

At first I've found the bug (missing quotes) at this line. Fixing them locally was not enough - caused another error, so I decided to leave it to someone, who's more into the project.

Environment info

OS: Windows 7 x64
Gregoriotex version (comment from gregoriotex.tex file):
% [2016/07/05 v4.2.0-rc2 GregorioTeX system.]% PARSE_VERSION_DATE_LTX

Compilation log

This is LuaTeX, Version 0.95.0 (TeX Live 2016/W32TeX) 
 system commands enabled.
("./Res_Hodie nobis.tex"
LaTeX2e <2016/03/31> patch level 2
Babel <3.9r> and hyphenation patterns for 1 language(s) loaded.
(c:/texlive/2016/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(c:/texlive/2016/texmf-dist/tex/latex/base/size10.clo))
(c:/texlive/2016/texmf-dist/tex/latex/fontspec/fontspec.sty
(c:/texlive/2016/texmf-dist/tex/latex/l3kernel/expl3.sty
(c:/texlive/2016/texmf-dist/tex/latex/l3kernel/expl3-code.tex)
(c:/texlive/2016/texmf-dist/tex/latex/l3kernel/l3pdfmode.def))
(c:/texlive/2016/texmf-dist/tex/latex/l3packages/xparse/xparse.sty)
(c:/texlive/2016/texmf-dist/tex/luatex/luaotfload/luaotfload.sty(using write ca
che: C:/texlive/2016/texmf-var/luatex-cache/generic)(using read cache: C:/texli
ve/2016/texmf-var/luatex-cache/generic C:/Users/virt/.texlive2016/texmf-var/lua
tex-cache/generic)
luaotfload | main : initialization completed in 0.344 seconds)
(c:/texlive/2016/texmf-dist/tex/latex/fontspec/fontspec-luatex.sty
(c:/texlive/2016/texmf-dist/tex/latex/base/fontenc.sty
(c:/texlive/2016/texmf-dist/tex/latex/euenc/eu2enc.def)
(c:/texlive/2016/texmf-dist/tex/latex/euenc/eu2lmr.fd)(load luc: C:/texlive/201
6/texmf-var/luatex-cache/generic/fonts/otl/lmroman10-regular.luc))
(c:/texlive/2016/texmf-dist/tex/xelatex/xunicode/xunicode.sty
(c:/texlive/2016/texmf-dist/tex/latex/tipa/t3enc.def(load luc: C:/texlive/2016/
texmf-var/luatex-cache/generic/fonts/otl/lmromanslant10-regular.luc)(load luc: 
C:/texlive/2016/texmf-var/luatex-cache/generic/fonts/otl/lmroman10-italic.luc)(
load luc: C:/texlive/2016/texmf-var/luatex-cache/generic/fonts/otl/lmroman10-bo
ld.luc) (c:/texlive/2016/texmf-dist/tex/latex/euenc/eu2lmss.fd)(load luc: C:/te
xlive/2016/texmf-var/luatex-cache/generic/fonts/otl/lmsans10-regular.luc))
(c:/texlive/2016/texmf-dist/tex/latex/graphics/graphicx.sty
(c:/texlive/2016/texmf-dist/tex/latex/graphics/keyval.sty)
(c:/texlive/2016/texmf-dist/tex/latex/graphics/graphics.sty
(c:/texlive/2016/texmf-dist/tex/latex/graphics/trig.sty)
(c:/texlive/2016/texmf-dist/tex/latex/graphics-cfg/graphics.cfg)
(c:/texlive/2016/texmf-dist/tex/latex/graphics-def/luatex.def
(c:/texlive/2016/texmf-dist/tex/generic/oberdiek/infwarerr.sty)
(c:/texlive/2016/texmf-dist/tex/generic/oberdiek/ltxcmds.sty)))))
(c:/texlive/2016/texmf-dist/tex/latex/fontspec/fontspec.cfg)))
(c:/texlive/texmf-local/tex/lualatex/gregoriotex/gregoriotex.sty
(c:/texlive/2016/texmf-dist/tex/latex/xcolor/xcolor.sty
(c:/texlive/2016/texmf-dist/tex/latex/graphics-cfg/color.cfg))
(c:/texlive/2016/texmf-dist/tex/latex/oberdiek/kvoptions.sty
(c:/texlive/2016/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty
(c:/texlive/2016/texmf-dist/tex/generic/oberdiek/etexcmds.sty
(c:/texlive/2016/texmf-dist/tex/generic/oberdiek/ifluatex.sty))))
(c:/texlive/2016/texmf-dist/tex/luatex/luatexbase/luatexbase.sty
(c:/texlive/2016/texmf-dist/tex/luatex/ctablestack/ctablestack.sty))
(c:/texlive/2016/texmf-dist/tex/luatex/luamplib/luamplib.sty)
(c:/texlive/2016/texmf-dist/tex/generic/xstring/xstring.sty
(c:/texlive/2016/texmf-dist/tex/generic/xstring/xstring.tex))
(c:/texlive/texmf-local/tex/luatex/gregoriotex/gregoriotex-main.tex
("Res_Hodie nobis".gaux)
(c:/texlive/texmf-local/tex/luatex/gregoriotex/gregoriotex-spaces.tex)(load luc
: C:/texlive/2016/texmf-var/luatex-cache/generic/fonts/otl/greciliae.luc)
(c:/texlive/texmf-local/tex/luatex/gregoriotex/gregoriotex-chars.tex)
(c:/texlive/texmf-local/tex/luatex/gregoriotex/gregoriotex-signs.tex)
(c:/texlive/texmf-local/tex/luatex/gregoriotex/gregoriotex-syllable.tex)
(c:/texlive/texmf-local/tex/luatex/gregoriotex/gregoriotex-symbols.tex(load luc
: C:/texlive/2016/texmf-var/luatex-cache/generic/fonts/otl/greextra.luc))
(c:/texlive/texmf-local/tex/luatex/gregoriotex/gsp-default.tex)
(c:/texlive/texmf-local/tex/luatex/gregoriotex/gregoriotex-nabc.tex)))

LaTeX Warning: Unused global option(s):
    [14pt].

No file "Res_Hodie nobis".aux.
(c:/texlive/2016/texmf-dist/tex/latex/tipa/t3cmr.fd)
(c:/texlive/2016/texmf-dist/tex/context/base/mkii/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
) (c:/texlive/2016/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty
(c:/texlive/2016/texmf-dist/tex/latex/oberdiek/grfext.sty
(c:/texlive/2016/texmf-dist/tex/generic/oberdiek/kvdefinekeys.sty))
(c:/texlive/2016/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty
(c:/texlive/2016/texmf-dist/tex/generic/oberdiek/ifpdf.sty)
(c:/texlive/2016/texmf-dist/tex/generic/oberdiek/luatex-loader.sty
(c:/texlive/2016/texmf-dist/scripts/oberdiek/oberdiek.luatex.lua)))
(c:/texlive/2016/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))ignored arguments: nobis-4_2_0-rc2.glog Res_Hodie nobis.gabc
Usage: gregorio [OPTION]... [-s | INPUT_FILE]
Try 'gregorio --help' for more information.
Proceeding anyway...
error: can't open file nobis-4_2_0-rc2.gtex for reading
c:/texlive/
2016/texmf-dist/tex/latex/base/ltluatex.lua:109: 
Module gregoriotex Error: 
(gregoriotex)             An error occured when compiling the score file
(gregoriotex)             'Res_Hodie nobis.gabc' with gregorio.
(gregoriotex)             Please check your score file. on input line 10

stack traceback:
    [C]: in function 'error'
    c:/texlive/2016/texmf-dist/tex/latex/base/ltluatex.lua:109: in function <c:/te
xlive/2016/texmf-dist/tex/latex/base/ltluatex.lua:108>
    (...tail calls...)
    ...xlive/texmf-local/tex/luatex/gregoriotex/gregoriotex.lua:737: in function '
compile_gabc'
    ...xlive/texmf-local/tex/luatex/gregoriotex/gregoriotex.lua:791: in function '
include_score'
    [\directlua]:1: in main chunk.
\gre@gregorioscore ...allowdeprecated@asboolean )}
                                                  \or \gre@debugmsg {compile...

l.10 \gregorioscore{Res_Hodie nobis}

? 
@eroux
Copy link
Contributor

eroux commented Sep 10, 2016

Interesting, thanks a lot for the report! Here the culprit is more LuaTeX than Gregorio, but the line you indicated clearly could be improved, and we could also replace all filename-unfriendly characters (_, @, space, etc.) with hyphens...

@eroux eroux added this to the 5.0 milestone Sep 10, 2016
@eschwab eschwab modified the milestones: 4.2, 5.0 Sep 12, 2016
@eschwab eschwab self-assigned this Sep 13, 2016
@eschwab
Copy link
Contributor

eschwab commented Sep 13, 2016

I thought that we allow _ in filenames since we tack on the version number as 4_2_0-rc3? In any case I have the following list of characters in filenames to swap out with hyphens:

space + & % * ? $ @ : ; & ! #

Am I missing any?

@eroux
Copy link
Contributor

eroux commented Sep 13, 2016

oh, you're right about _. I think your list is enough, it should be quite easy to add a character if we missed one anyway

@henryso
Copy link
Contributor

henryso commented Sep 13, 2016

How about ", ', and `?

@warej
Copy link
Author

warej commented Sep 13, 2016

Well, but if I get it right, the file names are created on the basis of existing .tex or .gabc files, so if previous file exists in the filesystem => it must contain only valid characters.
That's why I'd suggest to only escape spaces|quote whole name to support names with spaces.
Just 0.02€ from my side.

@eroux
Copy link
Contributor

eroux commented Sep 13, 2016

well, why not all these characters also, although I doubt it will be helpful... but who knows...

@warej
Copy link
Author

warej commented Sep 13, 2016

imo quoting each parameter (e.g. $> command -file "some/test/file with spaces and $%") prevents shell from interpreting them.
And having the same name for tex file, gabc file and all other, created automatically is convenient. When you'd replace some signs with - or _, the name will be different (not much, but different). I'm not sure if it won't break some features (e.g. automatic temporary files cleanup).

@henryso
Copy link
Contributor

henryso commented Sep 13, 2016

The problem is with TeX. TeX interprets certain characters in a weird way, doing things like collapsing multiple spaces into one, and there's no perfect way to "quote" the filename, which is why @eroux said the problem is more with LuaTeX than Gregorio per se. The proposition is really a workaround to the weirdness of TeX. It's pretty much not a good idea to have filenames with spaces in them when dealing with TeX.

@eschwab
Copy link
Contributor

eschwab commented Sep 13, 2016

The implementation that I am working on does this (for auto or force compile only):

  • Takes the filename given in \gregorioscore.
  • Separates the path to the file and the root of the filename: Chant/Hymns/Salve Regina.gabc becomes Chant/Hynms/ and Salve Regina
  • Cleans up unwanted characters from the root of the filename: Salve Regina becomes Salve-Regina
  • Adds the path back to the cleaned up name with the necessary extensions: Chant/Hymns/Salve-Regina.{glog,gtex}
  • Then what gets put in the gregorio command is properly quoted for the shell.
  • What goes to TeX is a clean "TeX friendly" filename.

The benefit of this is that the original filename is not changed on disk, so no surprises to the user. All the auto-generated files are "TeX friendly" and should still picked up by our garbage collection / old version cleanup.

@eroux
Copy link
Contributor

eroux commented Sep 13, 2016

sounds good to me

@eroux
Copy link
Contributor

eroux commented Dec 14, 2016

@eschwab any news on this?

@eschwab
Copy link
Contributor

eschwab commented Dec 14, 2016

Yes, I have a fix ready. Just need to run the tests which I should have time to do tomorrow since the semester is finally over.

eschwab added a commit to eschwab/gregorio that referenced this issue Dec 15, 2016
@eschwab
Copy link
Contributor

eschwab commented Dec 27, 2016

For the changlog entry should this be filed under the Fixed or Added section?

@henryso
Copy link
Contributor

henryso commented Dec 28, 2016 via email

@rpspringuel
Copy link
Contributor

What's the status here? Can this go into 5.0?

eschwab added a commit to eschwab/gregorio that referenced this issue Apr 1, 2017
eschwab added a commit to eschwab/gregorio that referenced this issue Apr 1, 2017
@eschwab
Copy link
Contributor

eschwab commented Apr 5, 2017

Fixed by #1344

@eschwab eschwab closed this as completed Apr 5, 2017
rpspringuel added a commit to rpspringuel/gregorio that referenced this issue May 17, 2017
* release-5.0: (44 commits)
  Fix some typos in fonts readme.
  Fix some typos in supplemental fonts documentation.
  CHANGELOG entry for bugfix and update version number
  Lua-based fixes from Akira Kakuto.
  The version number on the executable is a suffix, not a prefix.
  Update Version number and consolidate CHANGELOG entries
  Changed --enable-texlive to --disable-version-in-exe per Élie Roux. Part of the implementation for gregorio-project#1292.
  Added documentation of --enable-texlive to README.md. Part of the implementation for gregorio-project#1292.
  Added --enable-texlive flag and support for a suffix-less executable. Fixes gregorio-project#1292.
  Distribution additions
  Fix test
  TeXShop engine modifications
  Modifications to doc_check.sh and def_check.sh
  Corrected copy-paste error.
  Corrected macro name.
  Updated documentation for version 5.0.0.
  Update Version Number
  Add Changelog entry for fix gregorio-project#1224.
  Rename gabc files containing non-filename friendly symbols.
  Add trace messages to rest of functions in gregoriotex-signs.tex
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants