-
Notifications
You must be signed in to change notification settings - Fork 29.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
tty,doc: add type-check to isatty #15567
Conversation
Where does this fall on the semver scale? Bugfix? |
@lpinca Yes, I'd call it a patch/bugfix, since it fixes a previously incorrect API. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. It would be nice if the messages could be improved though, but it is not a must.
test/pseudo-tty/test-tty-isatty.js
Outdated
|
||
strictEqual(isatty(-1), false, 'number that isn\'t a tty, is'); | ||
strictEqual(isatty(5), false, 'number that isn\'t a tty, is'); | ||
strictEqual(isatty(1.1), false, 'number that isn\'t a tty, is'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The messages here are somewhat confusing out of my perspective. Maybe write something like e.g.
-1 reported to be a tty but should not
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I'll clarify these.
This is definitely semver-patch
|
@BridgeAR I think the latest change clarifies it? |
Definitely! Thanks a lot |
Defensively marked as semver-major but I'd be ok with semver-minor or patch. |
@nodejs/tsc please weight in about semver-major / semver-patch. |
Ping @nodejs/tsc |
@@ -123,4 +123,5 @@ added: v0.5.8 | |||
* `fd` {number} A numeric file descriptor | |||
|
|||
The `tty.isatty()` method returns `true` if the given `fd` is associated with | |||
a TTY and `false` if is not. | |||
a TTY and `false` if it is not, including whenever `fd` is not a non-negative |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like there ought to be clearer wording than not a non-negative integer
. How about just a negative integer
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd also be fine with simply removing the additional text here, as a negative number is not a valid fd
. But since a negative integer can be returned from a sys call to retrieve a file descriptor if there is an error, I'm OK with leaving it too for explicitness.
Seems patch to me. I'm in favor of "when in doubt, mark it semver-major" but I'm not seeing any real doubt on this one. |
Seems like there are some related failures https://ci.nodejs.org/job/node-test-commit-osx/12738/nodes=osx1010/console
|
+1 to semver-patch |
Does |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm I guess
Ping @bengl |
Cool I'll land this later today. @Fishrock123 Unfortunately, giving it a negative number results in an abort (#15567 (comment)), which can't be handled in JS. Also, giving it a non-number always returns true, due to |
@bengl the CI reported a error that looked related. See my former comment #15567 (comment). |
@BridgeAR Oh weird! I'll take a look at that first. |
Previously, various inputs other than non-negative integers would produce incorrect results. Added type-checking on input, returning false for anything other than non-negative integers. Also clarified in docs.
Looks like New CI: https://ci.nodejs.org/job/node-test-pull-request/10864/ |
CI failures seem unrelated. @BridgeAR LGTY? |
Previously, various inputs other than non-negative integers would produce incorrect results. Added type-checking on input, returning false for anything other than non-negative integers. Also clarified in docs. PR-URL: #15567 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]>
Landed in 27e12e7 |
Previously, various inputs other than non-negative integers would produce incorrect results. Added type-checking on input, returning false for anything other than non-negative integers. Also clarified in docs. PR-URL: #15567 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]>
Previously, various inputs other than non-negative integers would produce incorrect results. Added type-checking on input, returning false for anything other than non-negative integers. Also clarified in docs. PR-URL: nodejs/node#15567 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]>
Since this fixes a core dump I've gone ahead and backported to v6.x please lmk if it should be backed out |
Previously, various inputs other than non-negative integers would produce incorrect results. Added type-checking on input, returning false for anything other than non-negative integers. Also clarified in docs. PR-URL: #15567 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]>
Previously, various inputs other than non-negative integers would produce incorrect results. Added type-checking on input, returning false for anything other than non-negative integers. Also clarified in docs. PR-URL: #15567 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]>
Previously, various inputs other than non-negative integers would produce incorrect results. Added type-checking on input, returning false for anything other than non-negative integers. Also clarified in docs. PR-URL: #15567 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]>
Previously, various inputs other than non-negative integers would produce incorrect results. Added type-checking on input, returning false for anything other than non-negative integers. Also clarified in docs. PR-URL: nodejs/node#15567 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]>
Previously, various inputs other than non-negative integers would
produce incorrect results.
Added type-checking on input, returning false for anything other than
non-negative integers.
Also clarified in docs.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
tty, doc