lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re:Complex --evaluate command line option


From: Flaming Hakama by Elaine
Subject: Re:Complex --evaluate command line option
Date: Fri, 26 Oct 2018 17:57:29 -0700


---------- Forwarded message ----------
From: Peter Anglea <address@hidden>
To: address@hidden
Date: Fri, 26 Oct 2018 10:12:17 -0400
Subject: Complex --evaluate command line option
I’m trying to use the -e (--evaluate) option to define a hash, not just a single variable. For instance

        lilypond -e ‘((define myhash (make-hash-table))(hashq-set! myhash ‘foo “bar”))’ file.ly

The above doesn’t work. I think, obviously, it’s breaking at the single quote – ‘foo.

I’ve tried escaping it with a backslash (\’foo) and a couple other things, but nothing seems to work.

Is it possible to run complex Scheme code in the command line option, and/or am I just not escaping special characters the right way?

I'm just going to comment on bash shell syntax, since I'm not quite sure what to expect the scheme code to do in lilypond, or if there are any prerequisites of file.ly for this command to work.


In any case, for bash shell syntax:
    Within single quotes, there is no evaluation, no escaping, and everything is taken as-is.
    Within double quotes, things are evaluated, and the backslash character is used to escape (to prevent evaluation, as well as to include double quotes within the string).
    Outside of quotes, things are evaluated and the backslash character is used to escape.

The only difference in this regard between double quotes and no quotes is that everything within double quotes is taken as a "word", and outside of quotes, whitespace delineates "words".  (Outside quotes, you can escape spaces to prevent splitting of words on whitespace).


Your above line would parse into these "words"

    lilypond
    -e
    '((define myhash (make-hash-table))(hasq-set! myhash'
    foo
    "bar"
    ))
   'file.ly
 
with the last _expression_ having unmatched single quote, so it is not a complete _expression_


Since your scheme _expression_ has both single and double quotes, you would need to put the entire scheme _expression_ in double quotes, then escape the double quotes around "bar":

lilypond -e "((define myhash (make-hash-table))(hashq-set! myhash 'foo \"bar\"))" file.ly


Unfortunately, I'm not too familiar with what this should do, or if it should work with any file.ly.
When I tried it against a random .ly file, I got:

lilypond -e "((define myhash (make-hash-table))(hashq-set! myhash 'foo \"bar\"))" voices.ly
GNU LilyPond 2.19.80
<unnamed port>:1:8: In _expression_ ((begin #<unspecified>) (hashq-set! myhash # ...)):
<unnamed port>:1:8: Wrong type to apply: #<unspecified>



HTH,

Elaine Alt
415 . 341 .4954                                           "Confusion is highly underrated"
address@hidden
Producer ~ Composer ~ Instrumentalist
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]