Skip to content

Commit

Permalink
env: added CARAPACE_NOSPACE
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Nov 3, 2024
1 parent 70e49cf commit 7c7b1fb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions internal/env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
9 changes: 7 additions & 2 deletions internal/shell/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 7c7b1fb

Please sign in to comment.