From 9c73fd4215e86ecbb0630b9b9bfc19e82430d7d7 Mon Sep 17 00:00:00 2001 From: HAYAMA_Kaoru Date: Mon, 2 Dec 2024 10:20:28 +0900 Subject: [PATCH] Implement `$EXECUTABLE_NAME` --- main.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 3be582f..b355504 100644 --- a/main.go +++ b/main.go @@ -54,9 +54,14 @@ func mains(args []string) error { for _, s := range args[1:] { posixArgv = append(posixArgv, gmnlisp.String(s)) } + executable := os.Args[0] + if value, err := os.Executable(); err == nil { + executable = value + } lisp = lisp.Let(gmnlisp.Variables{ - gmnlisp.NewSymbol("args"): gmnlisp.List(posixArgv...), - gmnlisp.NewSymbol("$PROGRAM_NAME"): gmnlisp.String(args[0]), + gmnlisp.NewSymbol("args"): gmnlisp.List(posixArgv...), + gmnlisp.NewSymbol("$PROGRAM_NAME"): gmnlisp.String(args[0]), + gmnlisp.NewSymbol("$EXECUTABLE_NAME"): gmnlisp.String(executable), }) ctx, cancel := context.WithCancel(context.Background())