Repository navigation
Fix ls behaviour when directory is empty - #8439
Merged
Merged
Conversation
sholderbach
approved these changes
Mar 13, 2023
sholderbach
left a comment
Member
There was a problem hiding this comment.
Makes also sense from a perspective of consistent types.
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #8439 +/- ##
=======================================
Coverage 68.50% 68.50%
=======================================
Files 620 620
Lines 99723 99723
=======================================
Hits 68316 68316
Misses 31407 31407
|
sophiajt
pushed a commit
that referenced
this pull request
Jun 20, 2023
In my view we should revert #8395 for now ## Potentially inconsistent application of semantic change #8395 (1d5e7b4) was loosening the type coercion rules significantly, to let missing data / void returns that were either expressed by `PipelineData::Empty` or the `Value::nothing` be accept by specifically those commands/operations that made use of `PipelineData::into_iter_strict()`. This could apply the new rules inconsistently. ## Turning explicit failures into silent continuations Furthermore the effect of this breaking change to the missing data semantics could make previous errors into silent failures. This could either just reduce the effectiveness of teaching error messages in interactive use: ### Contrived example before ```bash > cd . | where blah Error: nu::shell::only_supports_this_input_type × Input type not supported. ╭─[entry #13:1:1] 1 │ cd . | where blah · ──┬──┬ · │ ╰── input type: null · ╰── only list, binary, raw data or range input data is supported ╰──── ``` ### ...after, with #8395 ```bash > cd . | where blah ╭────────────╮ │ empty list │ ╰────────────╯ ``` In rare cases people could already try to rely on catching an error of a downstream command to actually deal with the missing data, so it would be a breaking change for their existing code. ## Problem with `PipelineData::into_iter_strict()` Maybe this makes `_strict` a bit of a misnomer for this particular iterator construction. Further we did not actively test the `PipelineData::empty` branch before  ## Parsimonious solution exists For the motivating issue #8393 there already exists a fix that makes `ls` more consistent with the type system by returning an empty `Value::List` #8439
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prior to this PR,
lswould returnnothingin an empty directory. After this PR, it returns an emptyList. This makes the behaviour oflsmore consistent and easier to reason about (IMO).This was prompted by a user noticing that
ls | where size == 0KB and type == filebreaks when run in an empty directory:If people agree with this change, let's wait until after the 0.77 release so we have a bit more time to test it.