mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-04-24 11:41:15 -03:00
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.
This commit is contained in:
@@ -2010,6 +2010,7 @@ You can see the current list of features via ``status features``::
|
||||
regex-easyesc on 3.1 string replace -r needs fewer \\'s
|
||||
ampersand-nobg-in-token on 3.4 & only backgrounds if followed by a separating character
|
||||
remove-percent-self off 3.8 %self is no longer expanded (use $fish_pid)
|
||||
test-require-arg off 3.8 builtin test requires an argument
|
||||
|
||||
Here is what they mean:
|
||||
|
||||
@@ -2018,6 +2019,7 @@ Here is what they mean:
|
||||
- ``regex-easyesc`` was introduced in 3.1. It makes it so the replacement expression in ``string replace -r`` does one fewer round of escaping. Before, to escape a backslash you would have to use ``string replace -ra '([ab])' '\\\\\\\\$1'``. After, just ``'\\\\$1'`` is enough. Check your ``string replace`` calls if you use this anywhere.
|
||||
- ``ampersand-nobg-in-token`` was introduced in fish 3.4. It makes it so a ``&`` i no longer interpreted as the backgrounding operator in the middle of a token, so dealing with URLs becomes easier. Either put spaces or a semicolon after the ``&``. This is recommended formatting anyway, and ``fish_indent`` will have done it for you already.
|
||||
- ``remove-percent-self`` turns off the special ``%self`` expansion. It was introduced in 3.8. To get fish's pid, you can use the :envvar:`fish_pid` variable.
|
||||
- ``test-require-arg`` removes :doc:`builtin test <cmds/test>`'s one-argument form (``test "string"``. It was introduced in 3.8. To test if a string is non-empty, use ``test -n "string"``. If disabled, any call to ``test`` that would change sends a :ref:`debug message <debugging-fish>` of category "deprecated-test", so starting fish with ``fish --debug=deprecated-test`` can be used to find offending calls.
|
||||
|
||||
|
||||
These changes are introduced off by default. They can be enabled on a per session basis::
|
||||
|
||||
Reference in New Issue
Block a user