Or alternatively (if you only need basepitch, not different octaves) you may avoid parsing and directly pull the pitch from the pitch name mapping (less powerful, but less chaotic and safer):
#(assoc-get (string->symbol "c") pitchnames) or even (to avoid problems when changing language) from a specific language set: #(assoc-get (string->symbol "c") (assoc-get 'nederlands language-pitch-names)) (if you need different octaves you might of course specify this one separately). Evaluating strings passed from outside is a very good opportunity to allow injection of arbitrary code, as you can see here: #(ly:parse-string-expression (ly:parser-clone) "#(system \"echo Doing evil stuff ...; killall lilypond\")") Also this makes no guarantee on what type of thing you get back, it might not be a pitch! "c4" will evaluate to music, "(" will evaluate to a post event. Unexpected and malformatted stuff like "{" will result in an uncaught error. Using #(assoc-get (string->symbol "c") pitchnames) on the other hand will guarantee that the result is either a pitch or #f if no valid pitch string was given (which then gives you the possibility of either falling back to a default / not applying certain things or to exit with an informative message. Cheers, Valentin Am Sonntag, 24. September 2023, 23:09:33 CEST schrieb Jean Abou Samra: > Try > > (ly:parse-string-expression (ly:parser-clone) (getenv "FROM_KEY"))
signature.asc
Description: This is a digitally signed message part.