Implement $PROGRAM_NAME for script name

This commit is contained in:
HAYAMA_Kaoru
2024-12-02 10:16:19 +09:00
parent 3c5630327a
commit 69968caa69
+4 -1
View File
@@ -54,7 +54,10 @@ func mains(args []string) error {
for _, s := range args[1:] {
posixArgv = append(posixArgv, gmnlisp.String(s))
}
lisp = lisp.Let(&gmnlisp.Pair{Key: gmnlisp.NewSymbol("args"), Value: gmnlisp.List(posixArgv...)})
lisp = lisp.Let(gmnlisp.Variables{
gmnlisp.NewSymbol("args"): gmnlisp.List(posixArgv...),
gmnlisp.NewSymbol("$PROGRAM_NAME"): gmnlisp.String(args[0]),
})
ctx, cancel := context.WithCancel(context.Background())
_, err = lisp.Interpret(ctx, string(script))