Skip to content
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

split0 always exits with 1 #5701

Closed
hyperfekt opened this issue Feb 25, 2019 · 4 comments
Closed

split0 always exits with 1 #5701

hyperfekt opened this issue Feb 25, 2019 · 4 comments
Labels
bug Something that's not working as intended
Milestone

Comments

@hyperfekt
Copy link
Contributor

hyperfekt commented Feb 25, 2019

version: 3.0.1
happens without third-party customizations: yes
regression from fish 2.7.1: does not apply

echo -n -e "a\x00b" | string split0 correctly splits between a and b, but exits with status code 1 despite having performed a split. This is contrary to the statement in the documentation that if a split was performed, string split[0] returns with status code 0.
Compare echo -n -e "a b" | string split " ", which correctly exits with 0.

@floam floam added the bug Something that's not working as intended label Feb 25, 2019
@floam floam added this to the fish 3.1.0 milestone Feb 25, 2019
@faho
Copy link
Member

faho commented Feb 25, 2019

Yup. The problem is that split0 already receives the arguments from stdin split on NUL.

We need to add a mode that just soaks up all input from stdin and doesn't split it at all.

@hyperfekt
Copy link
Contributor Author

Out of curiosity: If split0 can't receive a null-separated string as argument, and receives stdin already split on NUL, what other modes are there?

@faho
Copy link
Member

faho commented Feb 26, 2019

Splitting on newline, for all other string commands.

builtin_string.cpp has a method "nextstr()" that every string subcommand uses to get "the next argument", whether that's the next line from stdin, or the next argument from argv.

Only that won't work for split0, because that needs to get argv separated as it is, and stdin completely unsplit. And the only difference is the exit code.

@faho faho closed this as completed in 47ff060 Feb 26, 2019
@faho
Copy link
Member

faho commented Feb 26, 2019

Okay, as it turns out we never split on NUL elsewhere, so I just changed it from picking between splitting on newline or nul to splitting or not split at all, and then split0 actually does something.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something that's not working as intended
Projects
None yet
Development

No branches or pull requests

3 participants