add str escape-glob command#11664
Merged
WindSoilder merged 3 commits intonushell:mainfrom Jan 29, 2024
Merged
Conversation
fdncred
reviewed
Jan 29, 2024
fdncred
approved these changes
Jan 29, 2024
Contributor
fdncred
left a comment
There was a problem hiding this comment.
Except for the one minor thing in the example, I think this is an interesting approach.
Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
Contributor
|
This kind of works ❯ ls test* | get name | str escape-glob | each {|it| ls -D $it} | flatten
╭─#─┬──name───┬─type─┬─size──┬───modified────╮
│ 0 │ test[a] │ file │ 0 B │ 3 minutes ago │
│ 1 │ tests │ dir │ 480 B │ 2 days ago │
╰───┴─────────┴──────┴───────┴───────────────╯but this shows a different result. ❯ touch "test[a]"
❯ ls test* | $in.name | str escape-glob
╭───┬─────────────╮
│ 0 │ test[[]a[]] │
│ 1 │ tests │
╰───┴─────────────╯I'm not sure if that's intended or not? |
Contributor
Author
|
I think it's intended, it shows escaped result. And that's why it works in the first case you provided. |
dmatos2012
pushed a commit
to dmatos2012/nushell
that referenced
this pull request
Feb 20, 2024
# Description This pr is a follow up to nushell#11621, it introduces a `str escape-glob` command as a workaround for the case: ```nushell let f = "a[123]b" ls $f ``` It will glob `a[123]b`, we can get rid of the behavior through `str escape-glob` command: ```nushll let f = "a[123]b" ls ($f | str escape-glob) ``` It's more useful in the `each` context: `ls | get name | str escape-glob | each {|it| ls $it}` # User-Facing Changes NaN # Tests + Formatting Done # After Submitting --------- Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
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.
Description
This pr is a follow up to #11621, it introduces a
str escape-globcommand as a workaround for the case:It will glob
a[123]b, we can get rid of the behavior throughstr escape-globcommand:It's more useful in the
eachcontext:ls | get name | str escape-glob | each {|it| ls $it}User-Facing Changes
NaN
Tests + Formatting
Done
After Submitting