diff --git a/replacer.go b/replacer.go index 57979205..7f97f347 100644 --- a/replacer.go +++ b/replacer.go @@ -308,6 +308,10 @@ func globalDefaultReplacements(key string) (any, bool) { return string(filepath.Separator), true case "system.os": return runtime.GOOS, true + case "system.wd": + // OK if there is an error; just return empty string + wd, _ := os.Getwd() + return wd, true case "system.arch": return runtime.GOARCH, true case "time.now": diff --git a/replacer_test.go b/replacer_test.go index 09b41c29..41ada7d6 100644 --- a/replacer_test.go +++ b/replacer_test.go @@ -372,6 +372,7 @@ func TestReplacerNew(t *testing.T) { } else { // test if default global replacements are added as the first provider hostname, _ := os.Hostname() + wd, _ := os.Getwd() os.Setenv("CADDY_REPLACER_TEST", "envtest") defer os.Setenv("CADDY_REPLACER_TEST", "") @@ -395,6 +396,10 @@ func TestReplacerNew(t *testing.T) { variable: "system.arch", value: runtime.GOARCH, }, + { + variable: "system.wd", + value: wd, + }, { variable: "env.CADDY_REPLACER_TEST", value: "envtest",