Skip to content

Commit

Permalink
Merge pull request #1052 from carapace-sh/env-nospace
Browse files Browse the repository at this point in the history
env: added `CARAPACE_NOSPACE`
  • Loading branch information
rsteube authored Nov 3, 2024
2 parents 70e49cf + 7c7b1fb commit 633eaba
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 633eaba

Please sign in to comment.