Commit Graph

1680 Commits

Author SHA1 Message Date
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
Aaron Gyes
4221d6c3e6 Realpath styling tweaks.
Add braces I forgot, improve comments, make line spacing more
consistent around if blocks.
2018-11-18 12:29:35 -08:00
Fabian Homborg
442eb028c1 wrealpath: Simplify
- Reuse the buffer
- Don't duplicate the code for no "/"
2018-11-18 20:30:26 +01:00
Fabian Homborg
ca1c499069 wrealpath: Fail for file/something
This incorrectly allowed "file/something" if file existed (as a file), because it
checked "afile".

Fixes #5352.
2018-11-18 20:30:21 +01:00
Aaron Gyes
b00b1af152 Improve realpath error reporting, fix a crasher
realpath() will return NULL and sets errno if it fails.
We asserted that realpath(".") does not fail. We also didn't really
check that it was successful. Made sure we'll get a perror telling
us about what went wrong if something like this happens again.

Updated tests and added test case

Fixes #5351
2018-11-18 09:35:58 -08:00
Mahmoud Al-Qudsi
31d17f4559 Rename string escape --style=pcre2 to string escape --style=regex 2018-11-16 20:22:06 -06:00
Mahmoud Al-Qudsi
e160cde606 Implement PCRE2 escaping
Closes #5309.
2018-11-15 12:00:56 -06:00
Fabian Homborg
1fffdbce79 Fix status current-command
As it turns out, this just always printed "fish".

The solution here is a bit hacky as we go via the $_ variable.

Fixes #5339.
2018-11-14 12:15:40 +01:00
Fabian Homborg
278cbc5ff1 env_universal_common: Constref env_var_t as well 2018-11-14 12:15:40 +01:00
Fabian Homborg
534f694cee parse_execution: Check array index before using it 2018-11-14 12:15:40 +01:00
Mahmoud Al-Qudsi
6dafcc4960 Partially revert 55b3c45 to create pgrp when launched with invalid pgrp
If fish detects that it was started with a pgrp of 0 (which appears to
oddly be the case when run under firejail), create new process group for
fish and give it control of the terminal.

This selectively reverts 55b3c45 in cases where an invalid pgrp is
detected. Note that this is known to cause problems in other cases, such
as #3805 and Microsoft/WSL#1653, although the former may have been
ameliorated or even addressed by the recent job control overhaul, so
that's why we are careful to only assign fish to its own pgroup if an
invalid pgroup was detected and not as the normal case.
2018-11-13 15:00:52 +01:00
ridiculousfish
121991b98c Revert "Convert job list to a dequeue"
This reverts commit 54050bd4c5.

Type job_list_t was changed from a list to a deque in
commit 54050bd4c5.

In process_clean_after_marking(), we remove jobs while iterating.
dequeues do not support that. Make it a list again.
2018-11-11 16:57:30 -08:00
ridiculousfish
6f46eaaeeb Revert "Fix a stale comment"
This reverts commit efa9553dc1.

The comment was not stale.
2018-11-11 16:56:49 -08:00
ridiculousfish
efa9553dc1 Fix a stale comment 2018-11-11 16:08:45 -08:00
ridiculousfish
aa6be9bee4 Pass the original string into wildcard's decsription function
wildcard_complete was invoking the description function with some fragment
of the wildcard string. Instead pass in the original string.

Fixes #5327
2018-11-11 14:15:45 -08:00
Fabian Homborg
77229effb5 expand: Fix get_home_directory_name
This fixes the `~floam/` case, where the out_tail_idx pointer needs to
point to the "/", not the last letter.

The `~/` and `~floam` cases still work.

Unfortunately, I'm unsure of how to test this.

Fixes #5325.
2018-11-08 10:07:45 +01:00
Fabian Homborg
460bc00698 Fix string escape var and url styles
Turns out I broke these in my zeal to remove wcs2string.

This reverts commit 583d771b10.

Fixes #5322.
2018-11-07 12:48:11 +01:00
ridiculousfish
bfd50863b8 Correct fish_wcstod and fix Linux build failure
Limit the fish_wcstod fast path to ASCII digits only, to fix the problem
observed in the discussion for a700acadfa
where LANG=de_DE.UTF-8 would cause `test` to interpret commas instead of
periods inside floating point values.
2018-11-06 23:17:41 -08:00
ridiculousfish
a700acadfa Implement fish_wcstod and adopt it in builtin_test
wcstod_l is enormously slow on the Mac. This makes arithmetic comparisons
using builtin_test about 250% as fast on macOS.
2018-11-04 20:28:10 -08:00
Fabian Homborg
a7ec158373 env: Use preexisting_flags to determine pathiness
We've already checked if the variable exists above, and we've already
gotten the preexisting_flags, so we can just use them.

Saves a lookup.
2018-11-04 17:05:22 +01:00
ridiculousfish
73537fc7c3 Remove NESTED and WAIT_BY_PROCESS
Now jobs are aware of their parent jobs, and can interrogate those jobs,
to determine if every job in the chain is fully constructed.
Remove flags and the static stacks that manipulated them.
2018-11-04 01:52:17 -08:00
ridiculousfish
30990e8069 Replace WAIT_BY_PROCESS with a parent job check
Instead of manipulating the WAIT_BY_PROCESS flag, have each job interrogate
its "parent chain" to decide if it is safe to waitpid() on its pgid.
2018-11-04 01:51:21 -08:00
ridiculousfish
3770d9fb7a Teach each job about its parent
The parent of a job is the parent pipeline that executed the function or
block corresponding to this job. This will help simplify
process_mark_finished_children().
2018-11-04 01:40:07 -08:00
ridiculousfish
93aa95d8c4 Remove proc_last_bg_pid
It wasn't used.
2018-11-03 19:28:16 -07:00
ridiculousfish
0373a87867 Remove shell_pgid from process_mark_finished_children
It was unused.
2018-11-03 19:19:52 -07:00
ridiculousfish
182d7ce732 Teach cd completions about logical paths
Prior to this fix, cding into a symlink and then completing .. would complete
from the physical directory instead of the logical directory, which could not
actually be cd'd to. Teach cd completiond to use the logical directory.
2018-11-03 13:30:55 -07:00
ridiculousfish
cf01694def Migrate token_infos inside token_for_string and reformat 2018-11-03 12:16:56 -07:00
Fabian Homborg
e1c0ab8edb test: Switch to std::map
Massively improves the time to lookup the token type.

This speeds up `test 1 = 1` by ~8%.
2018-11-03 19:58:51 +01:00
Fabian Homborg
9300ec55f0 parser_keywords: Use unordered_set instead of arrays
This makes the test mentioned in #5305:

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

run ~5% faster.
2018-11-02 12:28:09 +01:00
Fabian Homborg
1836e704c4 Remove unnecessary "string_set_contains" function 2018-11-02 11:46:05 +01:00
Mahmoud Al-Qudsi
dfcf140e00 Add warning about broken zombie support on setpgid() fail under WSL 2018-10-31 06:23:57 +00:00