From 08fa04b8e1abcc1cfdb92a40c69583f0405658ba Mon Sep 17 00:00:00 2001 From: Reinhold Kainhofer Date: Mon, 6 Sep 2010 21:25:16 +0200 Subject: [PATCH] Lilypond-book: Fix problem with os.path.abspath in Windows The check whether input file == output file needs to use the absolute path to the input file, since the CWD has changed meanwhile (and is the output dir at that point). Unfortunately, we can't call os.path.abspath right at the beginning and use the abspath for all of the processing, because os.path.abspath will replace forward slashes by backslashes in Windows (the path is normalized!). That path with backslashes are then printed to the snippet map files and cause l-p to fail with wrongly escaped characters... As a solution, use the relative pathname of the input file for all processing, but also store the abspath for that one particular infile==outfile check. --- scripts/lilypond-book.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py index 832cea0c62..f8f09966fd 100644 --- a/scripts/lilypond-book.py +++ b/scripts/lilypond-book.py @@ -487,6 +487,7 @@ def samefile (f1, f2): def do_file (input_filename, included=False): # Ugh. + input_absname = input_filename if not input_filename or input_filename == '-': in_handle = sys.stdin input_fullname = '' @@ -499,7 +500,7 @@ def do_file (input_filename, included=False): # Otherwise, "lilypond-book -o out test.tex" will complain that it is # overwriting the input file (which it is actually not), since the # input filename is relative to the CWD... - input_fullname = os.path.abspath (input_fullname) + input_absname = os.path.abspath (input_fullname) note_input_file (input_fullname) in_handle = file (input_fullname) @@ -526,7 +527,7 @@ def do_file (input_filename, included=False): input_base + global_options.formatter.default_extension) if (os.path.exists (input_filename) and os.path.exists (output_filename) - and samefile (output_filename, input_fullname)): + and samefile (output_filename, input_absname)): error ( _ ("Output would overwrite input file; use --output.")) exit (2) -- 2.39.5