Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix dirs returns false when $dirstack is empty#8211

Merged
faho merged 1 commit into
fish-shell:masterfish-shell/fish-shell:masterfrom
andrew-schulman:bugfix/dirs-returns-falseandrew-schulman/fish-shell:bugfix/dirs-returns-falseCopy head branch name to clipboard
Aug 9, 2021
Merged

Fix dirs returns false when $dirstack is empty#8211
faho merged 1 commit into
fish-shell:masterfish-shell/fish-shell:masterfrom
andrew-schulman:bugfix/dirs-returns-falseandrew-schulman/fish-shell:bugfix/dirs-returns-falseCopy head branch name to clipboard

Conversation

@andrew-schulman

Copy link
Copy Markdown
Contributor

Description

In fish 3.3.1, when $dirstack is empty, dirs returns false. This is undesirable, because no error occurred.

It happens because the string join at the end doesn't join anything, so it returns false. The solution is just to add a return 0 at the end of the function.

TODOs:

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

@kidonng

kidonng commented Aug 8, 2021

Copy link
Copy Markdown
Contributor

I would say current behavior seems right. There is a slight difference between printing nothing and matching nothing, and adding a return 0 unconditionally will make them indistinguishable.

EDIT: I'm being dumb here, just noticed string join " " is changing status, so my above statement is not true.

@krobelus

krobelus commented Aug 8, 2021

Copy link
Copy Markdown
Contributor

There is a slight difference between printing nothing and matching nothing, and adding a return 0 unconditionally will make them indistinguishable.

I don't understand, what's the difference here? I don't think "matching" applies here because we just print the dirstack entries one by one.


I think we should probably change string join here. Returning false on string join ' ' x is weird. Returning false on string join ' ' seems okay still, because in that case the output is empty.

@andrew-schulman

andrew-schulman commented Aug 8, 2021

Copy link
Copy Markdown
Contributor Author

dirs always prints at least one result, namely the current directory. So right now the return value is different depending on whether it prints only one (false) or more than one (true), which doesn't seem useful. It should just return true.

@faho faho added this to the fish 3.4.0 milestone Aug 9, 2021
@faho
faho merged commit afef67b into fish-shell:master Aug 9, 2021
@faho

faho commented Aug 9, 2021

Copy link
Copy Markdown
Member

Yeah, makes sense. Merged!

@andrew-schulman
andrew-schulman deleted the bugfix/dirs-returns-false branch September 9, 2021 13:55
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Sep 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.