Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecate builtin test's one- and zero-argument modes (#10365)
This introduces a feature flag, "test-require-arg", that removes builtin test's zero and one argument special modes. That means: - `test -n` returns false - `test -z` returns true - `test -x` with any other option errors out with "missing argument" - `test foo` errors out as expecting an option `test -n` returning true is a frequent source of confusion, and so we are breaking with posix in this regard. As always the flag defaults to off and can be turned on. In future it will default to on and then eventually be made read-only. There is a new FLOG category "deprecated-test", run `fish -d deprecated-test` and it will show any test call that would change in future.
- Loading branch information
Showing
8 changed files
with
164 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# RUN: %fish %s | ||
# | ||
# Tests for the posix-mandated zero and one argument modes for the `test` builtin, aka `[`. | ||
|
||
test -n | ||
echo $status | ||
#CHECK: 0 | ||
|
||
test -z | ||
echo $status | ||
#CHECK: 0 | ||
|
||
test -d | ||
echo $status | ||
#CHECK: 0 | ||
|
||
test "foo" | ||
echo $status | ||
#CHECK: 0 | ||
|
||
test "" | ||
echo $status | ||
#CHECK: 1 | ||
|
||
test -z "" -a foo | ||
echo $status | ||
#CHECK: 0 | ||
|
||
set -l fish (status fish-path) | ||
echo 'test foo; test; test -z; test -n; test -d; echo oops' | $fish -d 'deprecated-*' >/dev/null | ||
#CHECKERR: test: called with one argument. This will return false in future. | ||
#CHECKERR: Standard input (line 1): | ||
#CHECKERR: test foo; test; test -z; test -n; test -d; echo oops | ||
#CHECKERR: ^ | ||
#CHECKERR: test: called with no arguments. This will be an error in future. | ||
#CHECKERR: Standard input (line 1): | ||
#CHECKERR: test foo; test; test -z; test -n; test -d; echo oops | ||
#CHECKERR: ^ | ||
#CHECKERR: test: called with one argument. This will return false in future. | ||
# (yes, `test -z` is skipped because it would behave the same) | ||
#CHECKERR: Standard input (line 1): | ||
#CHECKERR: test foo; test; test -z; test -n; test -d; echo oops | ||
#CHECKERR: ^ | ||
#CHECKERR: test: called with one argument. This will return false in future. | ||
#CHECKERR: Standard input (line 1): | ||
#CHECKERR: test foo; test; test -z; test -n; test -d; echo oops | ||
#CHECKERR: ^ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters