When reporting whether a boolean flag was seen report the actual flags
rather than a summary count. For example, if you have option spec `h/help`
and we parse `-h --help -h` don't do the equivalent of `set _flag_h 3`
do `set _flag_h -h --help -h`.
Partial fix for #4226
When executing a function, local-exported (`set -lx`) variables
previously were not accessible at all. This is weird e.g. in case of
aliases, since
```fish
set -lx PAGER cat
git something # which will call $PAGER
```
would not work if `git` were a function, even if that ends up calling
`command git`.
Now, we copy these variables, so functions get a local-exported copy.
```fish
function x
echo $var
set var wurst
echo $var
end
set -lx var banana
x # prints "banana" and "wurst"
echo $var # prints "banana"
```
One weirdness here is that, if a variable is both local and global,
the local-copy takes precedence:
```fish
set -gx var banana
set -lx var pineapple
echo $var # prints "pineapple"
x # from above, prints "pineapple" and "wurst"
echo $var # still prints "pineapple"
set -el var # deletes local version
echo $var # "banana" again
```
I don't think there is any more consistent way to handle this - the
local version is the one that is accessed first, so it should also be
written to first.
Global-exported variables are _not_ copied, instead they still offer
full read-write access.
When reporting whether a boolean flag was seen report the actual flags
rather than a summary count. For example, if you have option spec `h/help`
and we parse `-h --help -h` don't do the equivalent of `set _flag_h 3`
do `set _flag_h -h --help -h`.
Partial fix for #4226
In the rare case that we don't inherit $HOME _and_ can't read it from
/etc/passwd, this makes it so instead of triggering an assert() $HOME
is set to the empty list.
Tilde-expansion expands to nothing in such a case (and a string-empty
$HOME), `cd` errors out.
Fixes#4229.
Fish 2.6.0 introduced a regression that keeps setting
`fish_escape_delay_ms` as a uvar from working. This also fixes a related
problem: callbacks generated from the initial loading of universal vars
were not being acted on.
Fixes#4196
Also stop special-casing `printf` as if it were a syntactical keyword
with respect to handling `printf --help`. It should use the same pattern
as every other builtin command.
The code for reporting parser errors needs a major overhaul. But rather
than do that I'm going to add another hack in the hope that this doesn't
introduce yet another problem.
Fixes#4221
The recent change to switch `psub` to use `argparse` caused it to use
a fifo by default because it inadvertently fixed a long standing bug in
the fish script. This changes the behavior back to `psub --file` being
the default behavior and introduces a `--fifo` flag. It also updates the
documentation to make it clearer when and why `--fifo` mode should not
be used.
Fixes#4222
While updating the `history` function to use `argparse` I realized it is
useful to define an option that can be used in three ways. First by
using the short flag; e.g., `-n NNN`. Second by using the long flag;
e.g., `--max NNN`. Third, as an implicit int flag; e.g., `-NNN`. This
use case is now supported by a spec of the form `n#max`.
A recent regression to the `alias` command points out the need for more
unit tests of its behavior. I also decided to use it as an opportunity
to normalize the output of just `alias` to list aliases.
The previous change to use `argparse` for parity with every other
builtin and function introduced a regression. Invocations that start
with a negative number can fail because the negative value looks like an
invalid flag.
This implements support for numeric flags without an associated short or
long flag name. This pattern is used by many commands. For example `head
-3 /a/file` to emit the first three lines of the file.
Fixes#4214