-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Script works well on macOS does not work on Windows due to the lines break by "|" #4059
Comments
Still has this issue on nu v0.59.0, we have to change the pipelines in one line to make it work: def 'git age' [
repo: path # The repo path to show git age
] {
$'(ansi p)(char nl)Last commit info of local branches: (ansi reset)(char nl)(char nl)'
cd $repo
let branches = (git branch | lines | str substring '2,' | wrap name)
$branches | update remote { |it| if (has-ref $'origin/($it.name)') { ' √' } else { '' } } | update author { |it| git show $it.name -s --format='%an' } | update last-commit {|it| git show $it.name --no-patch --format=%ci | into datetime } | sort-by last-commit
} |
It's interesting that this way will make it work both on mac and Windows: # Creates a table listing the branches of a git repository and the day of the last commit
def 'git age' [
repo: path # The repo path to show git age
] {
$'(ansi p)(char nl)Last commit info of local branches: (ansi reset)(char nl)'
cd $repo
( # Use `()` to wrap the pipes to make them work on windows
git branch
| lines
| str substring '2,'
| wrap name
| update remote { |it| if (has-ref $'origin/($it.name)') { ' √' } else { '' } }
| update author { |it| git show $it.name -s --format='%an' }
| update last-commit {|it| git show $it.name --no-patch --format=%ci | into datetime }
| sort-by last-commit
)
} @jntrnr Can you explain why? and is this a bug? |
This is a good question for design of the parser. Currently, I think it's written so that pipeline has to be wrapped in I was chatting with @kubouch a couple weeks ago, and he mentioned that he thought the first case should also work (I think? @kubouch can confirm) I think we should be able to make the first case work if we want. |
I just tried this on macOS, and, like you said it works okay:
I'm going to boot up a Windows machine and see why it doesn't work. I think the intent is that it should work across platforms. |
@jntrnr This simple case works on windows, Try this one:
|
Yeah, I think it should be more flexible. I'd also love to be able to line up the |
I have just tried the latest main, It's perfect now. |
Describe the bug
Hi,
The following script works well on my macOS, but not work on windows:
The output on windows:
It seems to be caused by the splitting of lines by "|", after change it to:
will make it work on windows.
How to reproduce
Described as the above.
Expected behavior
The script should work both on macOS and windows, with "|" at the end of line be supported for a better readability
Screenshots
No response
Configuration
Additional context
Thanks
The text was updated successfully, but these errors were encountered: