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

[#859]Support named FD in redirections #869

Merged
merged 4 commits into from Nov 16, 2019
Merged

[#859]Support named FD in redirections #869

merged 4 commits into from Nov 16, 2019

Conversation

@jiujieti
Copy link
Contributor

jiujieti commented Oct 29, 2019

this fixes the issue #859

default:
i, errInt := u.NonNegativeInt()
if errInt != nil {
return 0, fmt.Errorf("Fd must be standard stream names or integer; got %s", s)

This comment has been minimized.

Copy link
@xiaq

xiaq Oct 29, 2019

Member

Can you use u.errorpf to build the error, like in the error method above? This way the error will have the correct information about the range.

return u.NonNegativeInt()
fd, errFd := u.Fd()
if errFd != nil {
return 0, fmt.Errorf("redirection source must be standard stream names or integer; got %s", s)

This comment has been minimized.

Copy link
@xiaq

xiaq Oct 29, 2019

Member

There will be no need to build this new error if you address my comment above.

case "stderr":
return 2, nil
default:
i, errInt := u.NonNegativeInt()

This comment has been minimized.

Copy link
@xiaq

xiaq Oct 29, 2019

Member

You can reuse the name err here. It is common pattern in Go unless you have to store multiple errors.

func (u ValueUnwrapper) FdOrClose() (int, error) {
s, err := u.String()
if err == nil && s == "-" {
return -1, nil
}
return u.NonNegativeInt()
fd, errFd := u.Fd()

This comment has been minimized.

Copy link
@xiaq

xiaq Oct 29, 2019

Member

You can reuse the name err here. It is common pattern in Go unless you have to store multiple errors.

@xiaq xiaq merged commit aa52b2d into elves:master Nov 16, 2019
1 of 2 checks passed
1 of 2 checks passed
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.