www
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYestin L. Harrison <yestin@ylh.io>2021-07-25 23:58:53 -0600
committerYestin L. Harrison <yestin@ylh.io>2021-07-26 00:45:50 -0600
commitbc8f82547c4eb317b85b112b35888755bb2040f5 (patch)
treee39003c68be9b80ffbbc08576aca6edacaf556ee
parent399c8339215efd243a45916cb09321654f22dcee (diff)
downloadcgd-bc8f82547c4eb317b85b112b35888755bb2040f5.tar.gz
cgd-bc8f82547c4eb317b85b112b35888755bb2040f5.tar.xz
cgd-bc8f82547c4eb317b85b112b35888755bb2040f5.zip
make the p9p rc hack more robust, no more ././
-rw-r--r--main.go22
1 files changed, 10 insertions, 12 deletions
diff --git a/main.go b/main.go
index b3d4aa3..de3870b 100644
--- a/main.go
+++ b/main.go
@@ -30,24 +30,22 @@ func main() {
os.Exit(2)
}
+ h := &cgi.Handler{
+ Path: *cmd,
+ Root: "/",
+ Dir: *pwd,
+ InheritEnv: []string{"PATH", "PLAN9"},
+ }
+
// This is a hack to make p9p's rc happier for some unknown reason.
- c := *cmd
- if c[0] != '/' {
- c = "./" + c
+ if h.Path[0] != '/' && strings.Split(h.Path, "/")[0][0] != '.' {
+ h.Path = "./" + h.Path
}
os.Setenv("PATH", os.Getenv("PATH")+":.")
- envList := []string{"PATH", "PLAN9"}
for _, envVar := range strings.Split(*envVars, ",") {
- envList = append(envList, envVar)
- }
-
- h := &cgi.Handler{
- Path: c,
- Root: "/",
- Dir: *pwd,
- InheritEnv: envList,
+ h.InheritEnv = append(h.InheritEnv, envVar)
}
var err error