Commit Graph

1710 Commits

Author SHA1 Message Date
Fabian Homborg
b193df8b42 tinyexpr: Move enums together and stop explicit numbering
We should _not_ be doing bit-fiddling with these, so there's no reason
to care about the number.

This also removes the unused "TE_VARIABLE" symbol.
2018-12-30 19:34:45 +01:00
Fabian Homborg
3bbec871e4 tinyexpr: Free all parameters again
This used implicit fallthrough to free all.

We still iterate back-to-front (i--) because maybe that's important?
2018-12-30 19:34:45 +01:00
Fabian Homborg
84ca265b48 tinyexpr: Unfiddle the bits
Mainly this removes the "TYPE_MASK" macro that just masks off the
higher bits, which I don't think were ever actually used.

Much of this seems like anticipation of future direction, but we're
going somewhere else.
2018-12-30 19:34:44 +01:00
Fabian Homborg
61e7f84e29 tinyexpr: Remove PURE flag
This was unused because all functions were marked as pure. We don't
have any plans to add any that aren't, and if we did we'd still have
this in git.
2018-12-30 19:34:41 +01:00
Fabian Homborg
cbc25d7829 [tinyexpr] Port to C++
This removes the need to run c-compilation on one file, and allows us
to in future c++-ify this a bit.

There's a lot of bit-fiddling here that is quite unnecessary, better
error-handling would be nice...

So far this removes a few more unused things (because I would have had
to port them), including:

- Functions with ARITY > 3 (even 3 isn't used, but just so we don't
get complacent)

- Variables

- Most functions moved out of the header, because only te_interp is used.

- The te_print function
2018-12-30 19:34:06 +01:00
Fabian Homborg
a7998c4829 Don't ASSERT_IS_NOT_FORKED_CHILD so much
This is hammered sooo much that it actually hurts performance.

    for i in (seq 100000); test 1 = 1; end

is about 40% (!) slower with it.
2018-12-30 18:59:41 +01:00
Mahmoud Al-Qudsi
040d921fa1 Fix check for valid disowned pgids
The function `add_disowned_pgid` adds process *group* ids and not
process ids. It multiplies the value by negative 1 to indicate a wait
on a process group, so the original value must be positive.
2018-12-30 10:15:07 -06:00
Fabian Homborg
4a3ac6e91e Don't wait for disowned pgids if they are special
If a job is disowned that, for some reason, has a pgid that is special
to waitpid, like 0 (process with pgid of the calling process), -1 (any
process), or our actual pgid, that would lead to us waiting for too
many processes when we later try to reap the disowned processes (to
stop zombies from appearing).

And that means we'd snag away the processes we actually do want to
wait for, which would end with us in a waiting loop.

This is tough to reproduce, the easiest I've found was

    fish -ic 'sleep 5 &; disown; set -g __fish_git_prompt_showupstream auto; __fish_git_prompt'

in a git repo.

What we do is to not allow special pgids in the disowned_pids list.
That means we might leave a zombie around (though we probably wait on
0 somewhere), but that's preferable to infinitely looping.

See #5426.
2018-12-30 16:04:57 +01:00
Fabian Homborg
742fde0dd6 Don't use less in highlighting test
It doesn't have to be installed.

`cat` is in our dependencies, so we can assume it's there.

Fixes #5436.
2018-12-28 17:57:53 +01:00
David Adam
05222a055a Merge branch 'Integration_3.0.0' 2018-12-28 22:10:49 +08:00
Fabian Homborg
14ee19cc1b Use HAVE_WCSTOD_L also in header 2018-12-18 11:03:33 +01:00
Aaron Gyes
57d6124e6e builtin_test: don't exit 1 for eval errors, add tests for big args
Return STATUS_INVALID_ARGS when failing due to evaluation errors,
so we can tell the difference between an error and falseness.

Add a test for the ERANGE error
2018-12-16 14:51:26 -08:00
Aaron Gyes
cf2b40040a STATUS_INVALID_ARGS = 2
The rest of the high-numbered exit codes are not values used by scripts
or builtins, they are internal to fish and come out of
the parser for example.

Prior to adding STATUS_INVALID_ARGS, builtins were usually exiting 2
if they had a special exit status for the situation of bad arguments.

Set it to 2.
2018-12-16 14:51:18 -08:00
Aaron Gyes
b404b9392c builtin_test.cpp: split a long line, add braces 2018-12-16 14:51:10 -08:00
Aaron Gyes
1f871c4d0c builtin_test.cpp: check for ERANGE and special fish_wcstoll errno
We were not parsing an in-range number when we claimed we were,
and were thus failing to error with invalid numbers and returned
a wrong test result. Fixed #5414

Also, provide the detail we can for the other error cases.
2018-12-16 14:51:02 -08:00
Aaron Gyes
1adcd2d591 builtin_test: don't exit 1 for eval errors, add tests for big args
Return STATUS_INVALID_ARGS when failing due to evaluation errors,
so we can tell the difference between an error and falseness.

Add a test for the ERANGE error
2018-12-15 22:05:19 -08:00
Aaron Gyes
b8113f8e97 STATUS_INVALID_ARGS = 2
The rest of the high-numbered exit codes are not values used by scripts
or builtins, they are internal to fish and come out of
the parser for example.

Prior to adding STATUS_INVALID_ARGS, builtins were usually exiting 2
if they had a special exit status for the situation of bad arguments.

Set it to 2.
2018-12-15 21:05:27 -08:00
Mahmoud Al-Qudsi
3855c2217f Remove scripted XDG_CONFIG_HOME uses
Cleaned up the code to no longer replicate in fishscript what fish
already does (and caches to boot) in C++ in setting up the paths to the
user configuration directory.

Also introduced a `$__fish_user_data_dir` instead of the sporadic
definitions of `$userdatadir` that may or may not go through
`XDG_DATA_HOME`.
2018-12-14 22:09:29 -06:00
Aaron Gyes
1634c0fa49 builtin_test.cpp: split a long line, add braces 2018-12-14 12:43:18 -08:00
Aaron Gyes
4aa069a8ff builtin_test.cpp: check for ERANGE and special fish_wcstoll errno
We were not parsing an in-range number when we claimed we were,
and were thus failing to error with invalid numbers and returned
a wrong test result. Fixed #5414

Also, provide the detail we can for the other error cases.
2018-12-14 11:42:23 -08:00
David Adam
f8338d63ed Merge branch 'Integration_3.0.0'
Post-3.0b1 fixes merge.
2018-12-14 13:09:39 +08:00
Fabian Homborg
ffab420e43 Add fallback wcstod_l for musl
Just sets locale to "C" (because that's the only one we need), does
wcstod and resets the locale.

No idea why uselocale(loc) failed for me, but it did.

Fixes #5407.
2018-12-12 15:12:12 +01:00
Aaron Gyes
40de04cc6c input.cpp: remove impossible switch case
R_BEGIN_INPUT_FUNCTIONS <= c < R_END_INPUT_FUNCTIONS, so c cannot be
R_EOF.
2018-12-11 10:02:25 -08:00
Fabian Homborg
cf16d39872 Explicitly mark fallthrough
Silences a compiler warning (that is otherwise a good thing!)
2018-12-11 18:23:37 +01:00
Aaron Gyes
d080182686 fish_indent: skip past illegal byte sequences
garbage input, indented garbage output.
We print a warning, and will eventually exit 1
2018-12-11 06:45:07 -08:00
Aaron Gyes
0b45b474f3 Update bugreport()
I left this out of the last commit accidentally.
2018-12-11 02:50:03 -08:00
Fabian Homborg
88f7d50633 Acquire terminal even if our pgroup is 0
`tcsetpgrp` still works.

[ci skip]

(This isn't tested)
2018-12-08 16:21:52 +01:00
Fabian Homborg
0a0060481f Guard against pgid == 0
This happens in firejail, and it means that we can't use it as an
argument to most pgid-taking functions.

E.g. `wait(0)` means to wait for the _current_ process group,
`tcsetpgrp(0)` doesn't work etc.

So we just stop doing this stuff and hope it works.

Fixes #5295.
2018-12-08 16:21:52 +01:00
ridiculousfish
df4a41ff81 Fix a crash with -d5 and block processes 2018-12-02 14:53:26 -08:00
Fabian Homborg
366c21ca47 parser_keywords: Pre-create "begin" and "else" wcstrings
Otherwise this creates two wcstrings every call.

C++ is silly.
2018-12-01 23:03:41 +01:00
ridiculousfish
5012fb0e36 Add 'round' function to builtin math 2018-12-01 13:25:00 -08:00
Aaron Gyes
fe67cc4f6e Revert "Show how fish was executed, using argv[0] for program_name"
This reverts commit 1cb8b2a87b.

argv[0] has the full path in it for a user when he executes it
out of $PATH. This is really annoying in the title which uses $_.
2018-11-28 06:08:24 -08:00
Aaron Gyes
dd582abcc5 Revert "argv: don't reassign parameters"
This reverts commit ba455c81b4.
2018-11-28 06:07:58 -08:00
Fabian Homborg
d91b48b866 screen: Avoid crash if clr_eol is undefined
This crashes if the terminfo entry does not have the el capability.
Which is unusual but happens with the (outdated) "terminology" entry.

Fixes #5371.
2018-11-28 13:37:40 +01:00
Fabian Homborg
047fcb3224 proc: Don't hardcode clr_eol
Also check if that is actually defined, not the cur_term proxy.

In #5371, we figured out that there are terminfo entries without this
capability, so this would do a NULL-dereference.
2018-11-28 13:37:40 +01:00
Fabian Homborg
a730f9fc90 history: Move profiler message to debug level 5
This message would print when the prompt had just been printed, and
nobody really needs this currently.
2018-11-28 13:37:40 +01:00
Aaron Gyes
ba455c81b4 argv: don't reassign parameters
OCLINT was ignoring this, but we can just not do the bad thing.
Declare argc and argv const. These are in the stack, they can
be modified, but we won't.

Fix a typo
2018-11-27 13:27:21 -08:00
Aaron Gyes
1cb8b2a87b Show how fish was executed, using argv[0] for program_name
... rather than hard code it to "fish". This affects
what is found in $_ and improves the errors:

For example, if fish was ran with ./fish, instead of
something like:

  fish: Expected 3 surprises, only got 2 surprises

we'll see:

 ./fish: Expected 3 surprises, only got 2 surprises

like most other shell utilities. It's just a tiny bit
of detail that can avoid confusion.
2018-11-27 11:57:09 -08:00
Fabian Homborg
a1c481c06a source: Actually check if stdin is a tty, not just redirected
This broke fishtape, which did

    somestuff | fish -c "source"

Because `source` didn't have a redirection, it refused to read from
stdin.

So, to keep the common issue of `source (command that does not print)`
from seeminly stopping fish, we instead actually check if stdin is a terminal.
2018-11-26 23:48:19 +01:00
Aaron Gyes
9e7034c903 fish.cpp: Dirs relative to CMAKE_SOURCE_DIR, don't assume 'fish'
This was causing problems if "fish" wasn't in exec_path, like
if the binary had been renamed.

I also noticed that even with 'fish' not renamed, only paths.data
was made relative to my source tree. paths.sysconf, paths.doc, and
paths.bin were all relative to /usr/local.
2018-11-25 14:37:12 -08:00
Fabian Homborg
7e854e072a reader: Deduplicate some movements
This had a bunch of "do_{backward,forward}" movements that differed
only in one argument.

Just keep them together, so it's less code, and less needs to be
changed.
2018-11-25 18:57:35 +01:00
David Adam
2dab869b41 Restore legacy CMD_DURATION and FISH_VERSION variables
Work on #4154.

Effectively reverts fb8ae04f80.

Discussed extensively in
https://github.com/fish-shell/fish-shell/pull/5320
2018-11-24 12:37:26 +08:00
ridiculousfish
d6a5792ce2 Allow nested square brackets again
Code like echo $list[$var[1]] was producing an error because of
nested square brackets. Allow these brackets again.

Fixes #5362
2018-11-22 17:57:27 -08:00
Fabian Homborg
c729a97c43 builtin_read: Remove --all-lines
This was unused and needed to be warned about in the docs. Remove it
so nobody stumbles over it.

Fixes #5332.
2018-11-20 16:56:52 +01:00
Fabian Homborg
7367e545f2 Revert "wrealpath: Fail for file/something"
Apparently macOS realpath is broken.

This reverts commit ca1c499069.
2018-11-19 09:12:26 +01:00
Mahmoud Al-Qudsi
3d557518d5 Replace 0/1 with true/false in calls to job_reap 2018-11-18 17:40:18 -06:00
Mahmoud Al-Qudsi
d0085cae3c Fix zombie job on failed redirection in exec_job
Closes #5346.
2018-11-18 17:40:18 -06:00
ridiculousfish
a8ce7bad7b Always pass in the working directory in path_get_cdpath
If the user is in a directory which has been unlinked, it is possible
for the path .. to not exist, relative to the working directory.
Always pass in the working directory (potentially virtual) to
path_get_cdpath; this ensures we check absolute paths and are immune
from issues if the working directory has been unlinked.

Also introduce a new function path_normalize_for_cd which normalizes the
"join point" of a path and a working directory. This allows us to 'cd' out of
a non-existent directory, but not cd into such a directory.

Fixes #5341
2018-11-18 14:36:42 -08:00
Mahmoud Al-Qudsi
8730b482a7 Prevent zombie processes after disowned child procs exit
Closes #5346.
2018-11-18 15:27:58 -06:00
Fabian Homborg
58b29fb5d1 Revert "Remove unnecessary "string_set_contains" function"
I have no idea why this worked or passed the tests?

This reverts commit 1836e704c4.

Fixes #5349.
2018-11-18 22:25:17 +01:00