Complex --evaluate command line option

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Complex --evaluate command line option

Peter Anglea
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?
_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Complex --evaluate command line option

Thomas Morley-2
Am Fr., 26. Okt. 2018 um 16:44 Uhr schrieb Peter Anglea <[hidden email]>:

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

Well, from here it looks you used “” ‘’ -signs instead of " and '.
But even with correct ones your example will fail.

But you could do (at  least on Linux):

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

and in file.ly

#(use-modules (guile-user))
#(write (hashq-ref myhash 'foo))

returning "bar" as wished.

Otoh, I think the -e option is not very convenient for longer and/or
complex expressions.

Cheers,
  Harm

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Complex --evaluate command line option

David Kastrup
In reply to this post by Peter Anglea
Peter Anglea <[hidden email]> writes:

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

Can you try telling your mail client that it shouldn't mangle quotes?
It's hard to guess what you actually wrote.  At any rate, you have an
extra level of parens that is meaning-changing.  Assuming we are talking
about a Bourne-style shell, you probably want to write something like

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

Or, if you prefer the other kind of quotes:

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

Or, evading the problem

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

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

Maybe read up on the quoting conventions of your shell?

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

Probably the latter.

--
David Kastrup

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Complex --evaluate command line option

Hans Åberg-2
In reply to this post by Thomas Morley-2

> On 26 Oct 2018, at 17:41, Thomas Morley <[hidden email]> wrote:
>
> But you could do (at  least on Linux):
>
> lilydevel -e "(begin (define myhash (make-hash-table))(hashq-set!
> myhash 'foo \"bar\"))" file.ly
>
> and in file.ly
>
> #(use-modules (guile-user))
> #(write (hashq-ref myhash 'foo))
>
> returning "bar" as wished.

The program "lilydevel" is not in the MacOS distribution, though.



_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Complex --evaluate command line option

Thomas Morley-2
Am Fr., 26. Okt. 2018 um 18:18 Uhr schrieb Hans Åberg <[hidden email]>:

>
>
> > On 26 Oct 2018, at 17:41, Thomas Morley <[hidden email]> wrote:
> >
> > But you could do (at  least on Linux):
> >
> > lilydevel -e "(begin (define myhash (make-hash-table))(hashq-set!
> > myhash 'foo \"bar\"))" file.ly
> >
> > and in file.ly
> >
> > #(use-modules (guile-user))
> > #(write (hashq-ref myhash 'foo))
> >
> > returning "bar" as wished.
>
> The program "lilydevel" is not in the MacOS distribution, though.

Sorry, I rename my lily-versions ...
"lilydevel" is always my latest released devel-version, currently 2.19.82

lilypond -e "(begin (define myhash (make-hash-table))(hashq-set!
myhash 'foo \"bar\"))"
works as well, invoking 2.18.2

Cheers,
  Harm

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Complex --evaluate command line option

Hans Åberg-2

> On 26 Oct 2018, at 18:27, Thomas Morley <[hidden email]> wrote:
>
> Am Fr., 26. Okt. 2018 um 18:18 Uhr schrieb Hans Åberg <[hidden email]>:
>>
>>
>>> On 26 Oct 2018, at 17:41, Thomas Morley <[hidden email]> wrote:
>>>
>>> But you could do (at  least on Linux):
>>>
>>> lilydevel -e "(begin (define myhash (make-hash-table))(hashq-set!
>>> myhash 'foo \"bar\"))" file.ly
>>>
>>> and in file.ly
>>>
>>> #(use-modules (guile-user))
>>> #(write (hashq-ref myhash 'foo))
>>>
>>> returning "bar" as wished.
>>
>> The program "lilydevel" is not in the MacOS distribution, though.
>
> Sorry, I rename my lily-versions ...
> "lilydevel" is always my latest released devel-version, currently 2.19.82

The devel is in the details. :-)



_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Complex --evaluate command line option

Jacques Menu Muzhic


Le 26 oct. 2018 à 18:42, Hans Åberg <[hidden email]> a écrit :

The devel is in the details. :-)

That’s an excellent one!

JM



_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Complex --evaluate command line option

Hans Åberg-2

> On 27 Oct 2018, at 10:29, Jacques Menu <[hidden email]> wrote:
>
>> Le 26 oct. 2018 à 18:42, Hans Åberg <[hidden email]> a écrit :
>>
>> The devel is in the details. :-)
>
> That’s an excellent one!

Thanks! Something to watch out for!



_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user