Commit Graph

2933 Commits

Author SHA1 Message Date
Rosen Penev
d9ad5a2627 remove unreachable break statements
Found with clang's -Wunreachable-code-break

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-04-12 17:02:17 -07:00
Rosen Penev
6ab2da0e25 Fix -Wundef warnings
Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-04-12 17:02:17 -07:00
Rosen Penev
ca57bcbb00 add several noreturn statements
Found with clang's -Wmissing-noreturn

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-04-12 17:02:17 -07:00
Rosen Penev
202fe39d34 fix unreachable code warning
Found with clang's -Wunreachable-code

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-04-12 17:02:17 -07:00
Weisi Dai
07fb55d342 fish_indent: Add notes on SPACES_PER_INDENT. 2020-04-12 13:43:45 -07:00
Mahmoud Al-Qudsi
c249b1f2f0 Also catch zero-index errors when indexing into a command substiution
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]
```
2020-04-07 20:05:50 -05:00
Johannes Altmanninger
77d33a8eb9 Ignore SIGINT and SIGQUIT in non-interactive background processes
Fixes #6828
2020-04-07 22:18:15 +02:00
Johannes Altmanninger
90f67e4009 fish_test_helper: print only blocked 64 blocked signals
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.
2020-04-07 22:18:15 +02:00
Johannes Altmanninger
c1b2b6b7da Rename comp_empty to complete_did_insert and fix comments 2020-04-06 23:43:29 +02:00
Lior Stern
ca91c201c3 Remove unnecessary string duplication in handle_flag_f.
Prevents a memory leak.
2020-04-06 19:13:48 +02:00
Fabian Homborg
4eccc0f6d1 true/false: Stop erroring out for arguments
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.
2020-04-06 18:56:19 +02:00
Fabian Homborg
5dfaff4281 Make "." a builtin as well
Yeah, it's not going anywhere. This is one line in builtin.cpp vs 9
lines of script, most of which used to print an error that is never triggered.
2020-04-06 18:55:59 +02:00
Fabian Homborg
be0de5e2de Just define a ":" builtin
It's *less code* to define this as a builtin, and it's not going
anywhere. Plus it makes fish just a little more usable without share/config.fish.
2020-04-06 18:55:59 +02:00
ridiculousfish
3df05af809 Revert "Do not prevent multiple tab-completions with the same command line"
This reverts commit 41dcf84386.

This seems to have broken a lot of interactive scenarios.
2020-04-05 19:05:53 -07:00
ridiculousfish
41dcf84386 Do not prevent multiple tab-completions with the same command line
The comp_empty variable was assigned a sucecss value, leading fish
to think that the set of completions was empty when it is not.

Fixes #6863
2020-04-05 18:55:28 -07:00
ridiculousfish
866d506d11 Add a fish_test_helper command to print blocked signals 2020-04-05 15:07:42 -07:00
Rosen Penev
385b069eb2 [clang-tidy] remove pointless public
Found with readability-redundant-access-specifiers

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-04-05 10:13:43 +02:00
Rosen Penev
68467eeca7 [clang-tidy] remove redundant string initialization
Found with readability-redundant-string-init

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-04-05 10:13:13 +02:00
Rosen Penev
473a5250ae [clang-tidy] change several member functions to const
Found with readability-make-member-function-const

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-04-05 10:13:13 +02:00
Rosen Penev
312b575424 [clang-tidy] numeric literals to uppercase
Found with hicpp-uppercase-literal-suffix

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-04-05 10:13:13 +02:00
Rosen Penev
194fa4a548 [clang-tidy] performance
Found with performance*

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-04-05 10:13:13 +02:00
Rosen Penev
8d3377e923 [clang-tidy] Use C++ using instead of typedef
Found with modernize-use-using

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-04-05 10:13:13 +02:00
Rosen Penev
be036c443e [clang-tidy] use bool literals
Found with modernize-use-bool-literals

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-04-05 10:13:13 +02:00
Rosen Penev
27f607ae8b [clang-tidy] use range based loop
Found with modernize-loop-convert

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-04-05 10:13:13 +02:00
Rosen Penev
220f0a132d [clang-tidy] use auto when casting
Found with modernize-use-auto

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-04-05 10:13:13 +02:00
Lior Stern
321e1ed26a Check that parser is not nullptr before calling libdata.
Avoids a possible nullptr dereference in
parse_execution_context_t::check_end_execution
2020-04-04 14:47:58 -07:00
Lior Stern
1b23e5471d check the value of nodeptr in tnode_t::source_range.
Avoids a possible nullptr dereference
2020-04-04 14:47:58 -07:00
Johannes Altmanninger
bd91497de2 Refactor read_init, it is not meant to fail 2020-04-04 19:19:50 +02:00
Jason Nader
21bbd2ecb4 Return 1 if non-existent field is given 2020-04-04 15:30:09 +02:00
Jason Nader
1329a40e87 Allow simple ranges to be specified for --fields 2020-04-04 15:30:08 +02:00
Jason Nader
46dfc5ce0d IWYU keeps falsely flagging this 2020-04-04 15:30:08 +02:00
Jason Nader
7cb1d3a646 Add string split --fields 2020-04-04 15:30:08 +02:00
Soumya
61a9cdaa74 Add $fish_kill_signal to track the signal that terminated a command.
Set to `0` if the command exited normally.
2020-04-02 09:32:32 +02:00
Johannes Altmanninger
66ae1a1edb Add -h flag to builtin wait 2020-04-02 09:25:08 +02:00
Johannes Altmanninger
33d963dad9 Make job a background job when its child process is stopped
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.
2020-03-30 07:32:57 +02:00
Soumya
8c0ee6ebc9 Use an unlikely to collide username for tests
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.
2020-03-28 05:41:53 +01:00
Johannes Altmanninger
6699a72e0e Handle child receiving SIGCONT
Fixes #6818
2020-03-27 20:30:58 +01:00
Fabian Homborg
1406d63b85 Restyle
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.
2020-03-26 20:45:40 +01:00
Soumya
654a266b22 Fix typo: '\E' is not an escape sequence. 2020-03-26 17:09:52 +01:00
Soumya
96563d6eff jobs: suppress "No suitable job" if -q is given
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.
2020-03-26 17:09:09 +01:00
Johannes Altmanninger
64a89f882d Fix directory highlighting with custom CDPATH
Reproduce: `set CDPATH . /usr; mkdir foo` Then type "cd foo" and notice
that foo is highlighted incorrectly, because there is no /usr/foo.
2020-03-25 20:36:58 +01:00
Fabian Homborg
26c51817f2 Print better error if one argument is too long
Fixes #6800
2020-03-24 17:23:41 +01:00
George Christou
a45ffb7993 string/trim: Add VT to list of default chars 2020-03-23 18:37:08 +01:00
George Christou
a3436110c1
Add string sub --end (#6765) 2020-03-22 15:53:09 +01:00
Fabian Homborg
638a66c8ff pwd: Add "--physical" and "--logical" long options
These were already mentioned in the completions, and we don't
typically add short-only options.

Fixes #6787.
2020-03-21 16:21:15 +01:00
Johannes Altmanninger
75ae172ba2 token search: replace only until the end of the token
Fixes #6774
2020-03-20 14:05:49 +01:00
Johannes Altmanninger
390647ae34 Suppress history autosuggestion for command lines prefixed with a space
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')`
2020-03-19 18:59:20 +01:00
Fabian Homborg
4a9f52466a Set locale during timer test
Fixes #6757
2020-03-15 21:01:11 +01:00
Fabian Homborg
cb16d9e741 fish_indent: Allow escaped newlines only for certain things
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.
2020-03-15 21:01:00 +01:00
ridiculousfish
f9f5775ccc Switch to C++ random number generator for history vacuum interval 2020-03-14 15:22:46 -07:00