We had previously added a more helpful error message when a literal zero
index was specified when indexing into an array. This patch extends that
coverage to cases indexing into a command substitution, e.g.
```fish
echo (printf "hello\nworld\n")[0]
```
Otherwise it would print "Unknown Signal" on Linux. I didn't see an
obvious way to check signal validity, plus it hardly matters.
Also mimic the output from BSD strsignal on Linux.
For `true`, this makes uses like the
: some description of the job &
we used to have impossible, also it's just *wrong* that true can
return something that isn't true.
For false it's not super important but it should generally be
symmetrical with true.
Fixes#6830
For some reason, with this change, typing "vi", Control-Z, and 2 x Control-D,
results in the cursor not moving correctly, but this only
seems to happen when starting fish from a fish that doesnt have this fix.
I hope that is a temporary glitch.
The prefix 'haha' is short enough, (and phonetic enough), that it could collide with an existing user on the system where the tests are running, causing the test to fail.
I kinda hate how fussy clang-format is. It reflows text
constantly (line limit), forces things onto one line *except* when
they're too long, and wants to turn this:
```c++
return true;;
```
into this:
```c++
return true;
;
```
instead of, you know, eliminating the second semicolon?
Anyway, it is what it is and we use it, I'll just look into getting some
more slack.
This allows code of the form `if jobs -q $some_pid` in scripts to check whether a previously started job is still running. Previously this would return the correct value, but also print an error message.
The invalid argument errors will still be printed.
Added test cases for both.
Currently we do not add such command lines to the history, so there
won't be a suggestion from history anyway.
Fixes#6763 which occurs because midnight commander feeds fish commands
like this one (note the loading space)
` cd (printf '%b' '\0057home\0057johannes\0057git\0057fish\0055shell\0057build')`
Things like
```fish
\
echo foo
```
or
```fish
echo foo; \
echo bar
```
are a formatting blunder and should be handled.
This makes it so the escaped newline is removed, and the
semicolon/token_type_end handling will then put the statements on
different lines.
One case this doesn't handle brilliantly is an escaped newline after a
pipe:
```fish
echo foo | \
cat
```
is turned into
```fish
echo foo | cat
```
which here works great, but in long pipelines can cause issues.
Pipes at the end of the line cause fish to continue parsing on the
next line, so this can just be written as
```fish
echo foo |
cat
```
for now.