-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
eval should set exit status if no commands are executed #5692
Comments
The See e.g. $ cat /dev/null | read -lz FOO
$ true
$ eval "$FOO"; or echo "eval failed" |
I expect |
Oh, I see, the |
So it was my expectation of |
Yup. Also, you probably want |
Thanks for the explanation and the suggestion to use The behavior of $ false; eval ''; echo $?
0 bash documents this in its man page as follows:
It would probably make sense to add a comment about this to the entries for FWIW, my intuition is that |
That seems reasonable. |
I'm pretty sure I broke this again. It should have a regression test added, as well. |
This plays very dirty with a fish behavior I honestly find confusing. Current unit tests expect function empty
end
false
eval empty
echo $status to return the status of I feel that all of
should return the same thing, and that thing should be |
For what it's worth, an empty function still sets a 0 return value in |
That unit test was the only place I could find anywhere that had that expectation; I pushed a few commits that bring all the diffferent permutations in line with what's above and close this PR again. |
I'm trying to use
read -lz FOO
to save the multi-line output of a command inFOO
and then evaluate it witheval "$FOO"
. Now, what I see is that whenever the command outputs nothing, the call toeval "$FOO"
will fail, but only the first time around, which I find puzzling. Here's a short example:I'm seeing this behavior both in 3.0.1 and 2.7.1, under nixos.
The text was updated successfully, but these errors were encountered: