diff --git a/internal/env/env.go b/internal/env/env.go index 8a2748f7..436b0729 100644 --- a/internal/env/env.go +++ b/internal/env/env.go @@ -16,6 +16,7 @@ const ( CARAPACE_LENIENT = "CARAPACE_LENIENT" // allow unknown flags CARAPACE_LOG = "CARAPACE_LOG" // enable logging CARAPACE_MATCH = "CARAPACE_MATCH" // match case insensitive + CARAPACE_NOSPACE = "CARAPACE_NOSPACE" // nospace suffixes CARAPACE_SANDBOX = "CARAPACE_SANDBOX" // mock context for sandbox tests CARAPACE_ZSH_HASH_DIRS = "CARAPACE_ZSH_HASH_DIRS" // zsh hash directories CLICOLOR = "CLICOLOR" // disable color @@ -65,3 +66,7 @@ func isGoRun() bool { return strings.HasPrefix(os.Args[0], os.TempDir()+"/go-bui func Match() string { // see match.Match return os.Getenv(CARAPACE_MATCH) } + +func Nospace() string { + return os.Getenv(CARAPACE_NOSPACE) +} diff --git a/internal/shell/shell.go b/internal/shell/shell.go index 6859432a..780b291a 100644 --- a/internal/shell/shell.go +++ b/internal/shell/shell.go @@ -86,8 +86,13 @@ func Value(shell string, value string, meta common.Meta, values common.RawValues filtered = meta.Messages.Integrate(filtered, value) } - if !meta.Messages.IsEmpty() && shell != "export" { - meta.Nospace.Add('*') + if shell != "export" { + switch { + case !meta.Messages.IsEmpty(): + meta.Nospace.Add('*') + case env.Nospace() != "": + meta.Nospace.Add([]rune(env.Nospace())...) + } } sort.Sort(common.ByDisplay(filtered))