]> git.donarmstrong.com Git - lilypond.git/blobdiff - scripts/lilypond-book.py
ly:spawn: pass utf-8 strings to g_spawn. Fixes #1522.
[lilypond.git] / scripts / lilypond-book.py
index 674878c3fa60a20c9091d65ffd2014a180bbb607..9617f3666d3a4c878325a089b3d898def9771a8d 100644 (file)
@@ -113,7 +113,7 @@ def warranty ():
 
 %s
 %s
-''' % ( _ ('Copyright (c) %s by') % '2001--2010',
+''' % ( _ ('Copyright (c) %s by') % '2001--2011',
         '\n  '.join (authors),
         _ ("Distributed under terms of the GNU General Public License."),
         _ ("It comes with NO WARRANTY.")))
@@ -179,6 +179,11 @@ def get_option_parser ():
                   action='store',
                   dest='process_cmd', default='')
 
+    p.add_option ('-s', '--safe', help=_ ("Compile snippets in safe mode"),
+                  action="store_true",
+                  default=False,
+                  dest="safe_mode")
+
     p.add_option ('--skip-lily-check',
                   help=_ ("do not fail if no lilypond output is found"),
                   metavar=_ ("DIR"),
@@ -487,6 +492,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 = '<stdin>'
@@ -496,7 +502,10 @@ def do_file (input_filename, included=False):
         else:
             input_fullname = global_options.formatter.input_fullname (input_filename)
         # Normalize path to absolute path, since we will change cwd to the output dir!
-        input_fullname = os.path.abspath (input_fullname)
+        # 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_absname = os.path.abspath (input_fullname)
 
         note_input_file (input_fullname)
         in_handle = file (input_fullname)
@@ -523,7 +532,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)
@@ -533,7 +542,8 @@ def do_file (input_filename, included=False):
         source = in_handle.read ()
         progress ('\n')
 
-        global_options.formatter.init_default_snippet_options (source)
+        if not included:
+            global_options.formatter.init_default_snippet_options (source)
 
 
         progress (_ ("Dissecting..."))