[ << Running lilypond ] | [Top][Contents][Index] | [ Updating files with convert-ly >> ] |
[ < Invoking lilypond ] | [ Up: Command-line usage ] | [ Advanced command-line options for LilyPond > ] |
Basic command-line options for LilyPond
Please bear in mind that option arguments with spaces in it must
be quoted. For example, to write LilyPond’s output to a
directory called ‘foo bar’, a user must add -o "foo
bar" (or --output="foo bar") to the command-line arguments
of lilypond. Double quotes around such arguments work
with virtually all command-line interpreters on both Windows and
Unix-like operating systems (including macOS).
The following options are supported.
-d,--define-default=var[=val]-e,--evaluate=exprEvaluate the Scheme expression expr before parsing any .ly files. Multiple -e options may be given, they are evaluated sequentially.
The expression is evaluated in the
guile-usermodule, so if you want to use a definition like(define-public a 42)as expr, uselilypond -e "(define-public a 42)"
on the command line, and include
#(use-modules (guile-user))
at the top of the .ly file.
-E,--epsGenerate EPS files.
This option is equivalent to specifying
-dseparate-page-formats=eps -dtall-page-formats=eps.-f,--format=formatThe format of the (main) output file or files. Possible values for format are
ps,pdf,pngorsvg.Example:
lilypond -fpng foo.lySVG internally uses a specific backend, and therefore cannot be obtained in the same run as other formats; using
-fsvgor--svgis actually equivalent to using the-dbackend=svgoption. See Advanced command-line options for LilyPond.-h,--helpShow a summary of usage.
-H,--header=fieldDump a header field to file BASENAME.field.
As an example, let’s assume that you have an input file foo.ly containing
\header { title = "bar" } \score { c1 }The command
lilypond -H title foo.ly
then creates a plain text file foo.title containing the string
bar.-i,--init=fileSet init file to file (default: init.ly).
-I,--include=directoryAppend directory to the search path for input files with relative paths. By default, only the current working directory gets searched.
Multiple -I options may be given. The search starts in the current working directory, and if the file to be included is not found the search continues in the directory given by the first -I option, then the directory in the second -I option, and so on.
Note: Using the tilde character (
~) with the -I switch may produce unexpected results in some shells.Windows users need to include a trailing slash for the directory’s path.
-j,--jail=user,group,jail,dir[This option is only available if your operating system supports the
chrootfunctionality. In particular, Windows doesn’t support it.]Run
lilypondin a chroot jail.The --jail option can be used for security when LilyPond formatting is being provided via a web server, or whenever LilyPond executes commands sent by external sources (see Advanced command-line options for LilyPond). Because LilyPond provides the ability to run Guile programs, it is essential in such scenarios to run it in a sandboxed way so that the file being compiled does not wreak havoc on the system, for example with
% too dangerous to write correctly #(s ystem "rm -rf /") % malicious but not destructive { c4^$(ly:gulp-file "/etc/passwd") }--jail is one way to achieve sandboxing. Another one is running LilyPond in a Docker container.
The --jail option works by changing the root of
lilypondto jail just before starting the actual compilation process. The user and group are then changed to match those provided, and the current directory is changed to dir. This setup guarantees that it is not possible (at least in theory) to escape from the jail. Note that for --jail to work,lilypondmust be run as root, which is usually accomplished in a safe way usingsudo.Setting up a jail can be a relatively complex matter, as we must be sure that LilyPond is able to find whatever it needs to compile the source inside the jail itself. A typical chroot jail comprises the following steps:
- Setting up a separate filesystem
A separate filesystem should be created for LilyPond, so that it can be mounted with safe options such as
noexec,nodev, andnosuid. In this way, it is impossible to run executables or to write directly to a device from LilyPond. If you do not want to create a separate partition, just create a file of reasonable size and use it to mount a loop device. A separate filesystem also guarantees that LilyPond cannot write more space than it is allowed.- Setting up a separate user
A separate user and group (say,
lily/lily) with low privileges should be used to run LilyPond inside the jail. There should be a single directory writable by this user, which should be passed in dir.- Preparing the jail
LilyPond needs to read a number of files while running. All these files are to be copied into the jail, under the same path they appear in the real root filesystem. The entire content of the LilyPond installation (e.g., /usr/share/lilypond) should be copied.
If problems arise, the simplest way to trace them down is to run LilyPond using
strace, which allows you to determine which files are missing.- Running LilyPond
In a jail mounted with
noexecit is impossible to execute any external program. Therefore LilyPond must be run with a backend that does not require any such program. As we have already mentioned, it must be run with superuser privileges (which, of course, it loses immediately), possibly usingsudo. It is also good practice to limit the number of seconds of CPU time LilyPond can use (e.g., usingulimit -t), and, if your operating system supports it, the amount of memory that can be allocated. See LilyPond in chroot jail for more.
-l,--loglevel=levelSet the verbosity of the console output to level. Possible values are:
NONENo output at all, not even error messages.
ERROROnly error messages, no warnings or progress messages.
WARNWarnings and error messages, no progress.
BASICBasic progress messages (success), warnings and errors.
PROGRESSAll progress messages, warnings and errors.
INFOProgress messages, warnings, errors and further execution information. This is the default.
DEBUGAll possible messages, including verbose debug output.
-o,--output=file-o,--output=folderSet the default output file to file or, if a folder with that name exists, direct the output to folder, taking the file name from the input file. The appropriate suffix is added (e.g., .pdf for PDF) in both cases.
-O,--pspdfopt=key ¶-
Set the PS/PDF output optimization to key. Possible values are:
sizeGenerate a very small PS/EPS/PDF document. This is the default.
Using this value is equivalent to setting LilyPond’s Scheme command-line options
-dmusic-font-encodings="#f"and-dgs-never-embed-fonts="#f".TeXProduce files that are optimized for inclusion in pdfTeX, LuaTeX, or XeTeX documents.
Using this value is equivalent to setting LilyPond’s Scheme command-line options
-dmusic-font-encodings="#t"and-dgs-never-embed-fonts="#f".TeX-GSIf you want to include more than one PDF generated by LilyPond in a TeX document, use this option and postprocess the PDF generated by TeX with Ghostscript.
Using this value is equivalent to setting LilyPond’s Scheme command-line options
-dmusic-font-encodings="#t"and-dgs-never-embed-fonts="#t".
--psGenerate PostScript. This option is equivalent to
-fps.--pngGenerate pictures of each page, in PNG format. This option is equivalent to
-fpng.The resolution of the image may be set to N DPI with
-dresolution=N
--pdfGenerate PDF. This is the default, being equivalent to
-fpdf.-s,--silentShow no progress, only error messages. This is equivalent to
-lERROR.--svgGenerate SVG files for each page. This option is equivalent to
-fsvg.-v,--versionShow version information.
-V,--verboseBe verbose: show full paths of all files read, give timing information, etc. It is equivalent to
-lDEBUG.-w,--warrantyShow the warranty with which GNU LilyPond comes. (It comes with NO WARRANTY!)
[ << Running lilypond ] | [Top][Contents][Index] | [ Updating files with convert-ly >> ] |
[ < Invoking lilypond ] | [ Up: Command-line usage ] | [ Advanced command-line options for LilyPond > ] |