This repository was archived by the owner on Jun 16, 2025. It is now read-only.
Should test -t
with no arg be supported? #1350
Open
Description
I was mildly surprised to find this block of code was not covered by a unit test since we had explicit test -t
tests:
ast/src/cmd/ksh93/bltins/test.c
Lines 302 to 315 in 1a5e6ef
After looking at the code I realized the code in the if (cp)
block would only be executed by doing something like test -t 1 -a -t 1
. The problem is that omitting the file descriptor as implied by the source code as being acceptable produces inconsistent results. Basically, this undocumented "feature" only works correctly if -t
is the final, or only, term in a test expression and is missing its argument.
Note too that bundling the value (e.g., test -t1
) is also silently, and incorrectly, handled.