Skip to content

Use string length -q over test -n - #6531

Closed
ammgws wants to merge 1 commit into
fish-shell:masterfrom
ammgws:testn-to-string
Closed

ammgws wants to merge 1 commit into
fish-shell:masterfrom
ammgws:testn-to-string

Conversation

@ammgws

@ammgws ammgws commented Jan 22, 2020 •

Copy link
Copy Markdown
Contributor

Description

Hopefully this isn't controversial.

Reason for changing:

  • promote "fishy" ways by using it in our own code (assuming this change is more fishy than current)
  • test -n $var returns true if $var is list-empty (or currently undefined)
  • current docs for string length mention the commands are "equivalent"

TODOs:

  • Changes to fish usage are reflected in user documentation/manpages.
  • Tests have been added for regressions fixed
  • User-visible changes noted in CHANGELOG.md

@faho

faho commented Jan 22, 2020

Copy link
Copy Markdown
Member

To be honest, I'm not enthusiastic enough about this that I'd want to merge it.

For one, as you can see from the test failures replacing test -n "$var" with string length -q "$var" isn't actually enough. It would have to be string length -q -- "$var".

And even that has little gain, but some risk associated with the change. I don't think the churn is worth it.

Let's implement something like #6124, and then we can make this nicer.

Hopefully that makes sense to you, sorry!

@faho faho closed this Jan 22, 2020
@ammgws

ammgws commented Jan 22, 2020

Copy link
Copy Markdown
Contributor Author

That's totally fine :)

@ammgws
ammgws deleted the testn-to-string branch January 22, 2020 15:29
@faho faho added this to the will-not-implement milestone Jan 22, 2020
@faho faho added the cleanup label Jan 22, 2020
@ammgws ammgws mentioned this pull request Jan 25, 2020
31 of 98 tasks
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Apr 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants