Re:Complex --evaluate command line option

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Re:Complex --evaluate command line option

Flaming Hakama by Elaine

---------- Forwarded message ----------
From: Peter Anglea <[hidden email]>
To: [hidden email]
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”))’

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 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"

    '((define myhash (make-hash-table))(hasq-set! myhash'
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\"))"

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

lilypond -e "((define myhash (make-hash-table))(hashq-set! myhash 'foo \"bar\"))"
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>


Elaine Alt
415 . 341 .4954                                           "Confusion is highly underrated"
[hidden email]
Producer ~ Composer ~ Instrumentalist

lilypond-user mailing list
[hidden email]