Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(bash): nounset unbound file filter variable on empty extension #2228

Merged
merged 1 commit into from
Feb 2, 2025

Conversation

scop
Copy link
Contributor

@scop scop commented Feb 1, 2025

Happens at least if a flag is marked as filename, with "" given as extensions.

Foe example, current goreleaser (2.6.1) gives this

$ set -o nounset
$ goreleaser build --output <TAB>bash: fullFilter: unbound variable

https://github.com/goreleaser/goreleaser/blob/fb003f17c26e9388be64eb3930fe1b337325cf8d/cmd/build.go#L100

Arguably a bug to set an empty string there. Not sure if this should be filtered before it enters bash code, but at least this is a "cheap" workaround.

Happens at least if a flag is marked as filename, with "" given as
extensions.
scop added a commit to scop/goreleaser that referenced this pull request Feb 1, 2025
Passing the empty string as an extension is a functional no-op, but
causes actual problems: spf13/cobra#2228

Remove marking the flag as taking filename altogether, as there's no
need to do that; cobra comments doing so as a mistake:
https://github.com/spf13/cobra/blob/41b26ec8bb59dfba580f722201bf371c4f5703dd/completions.go#L387-L390

Leave MarkFlagFilename in comments so it's clear it's not
inadvertently left out.
Copy link
Collaborator

@marckhouzam marckhouzam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Thanks!

@marckhouzam marckhouzam merged commit 4ba5566 into spf13:main Feb 2, 2025
20 checks passed
@marckhouzam marckhouzam added this to the 1.9.0 milestone Feb 2, 2025
@scop scop deleted the fix/bash-unbound-full-filter branch February 2, 2025 08:24
caarlos0 pushed a commit to goreleaser/goreleaser that referenced this pull request Feb 3, 2025
Passing the empty string as an extension is a functional no-op, but
causes actual problems: spf13/cobra#2228

Remove marking the flag as taking filename altogether, as there's no
need to do that; cobra comments doing so as a mistake:
https://github.com/spf13/cobra/blob/41b26ec8bb59dfba580f722201bf371c4f5703dd/completions.go#L387-L390

Leave MarkFlagFilename in comments so it's clear it's not inadvertently
left out.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants