Commit Graph

8899 Commits

Author SHA1 Message Date
ridiculousfish
05d14f24d6 Fix a crash in bind
444f9f8715 introduced a bug where we would
use an iterator that had been invalidated by erase(). Fix that.
2018-09-30 18:00:52 -04:00
Fabian Homborg
35ce95f51d [Changelog] bind preset change
No reason to even mention them, people will care more about f_u_k_b.
2018-09-30 16:58:06 +02:00
Fabian Homborg
d62731a931 [CHANGELOG] Reorganize
This should make it more attractive to those not in the know.
2018-09-30 16:57:11 +02:00
Fabian Homborg
444f9f8715 Add separation of "preset" bindings
This allows for marking certain bindings as part of a preset, which allows us to

- only erase those when switching presets
- go back to the preset binding when erasing a user binding
- only show user customization if requested
- make bare bind statements in config.fish work (!!!11elf!!!)

Fixes #5191.
Fixes #3699.
2018-09-30 16:54:56 +02:00
ridiculousfish
36a149337b Eliminate / vet and whitelist some more globals 2018-09-29 01:11:15 -04:00
ridiculousfish
0170875ece Add an assert that builtin names are sorted 2018-09-29 00:30:02 -04:00
ridiculousfish
96da62ea87 Revert "Convert list of builtins from sorted array to unordered_set"
This reverts commit d8a1928c24.

It is better to have builtins as static const data to avoid unnecessary
initialization and allocation during startup.
2018-09-29 00:22:24 -04:00
ridiculousfish
20cb62440c Eliminate some mutable global variables
Make them const or otherwise get rid of them
2018-09-29 00:20:50 -04:00
ridiculousfish
d7b2576fb5 Mark short_options as const everywhere
These were needlessly mutable file-scoped variables.
2018-09-29 00:18:36 -04:00
ridiculousfish
f465760d1f Add a tool to locate global variables 2018-09-29 00:18:33 -04:00
ridiculousfish
9fd3f35c9a Fix some dead code
Delete some dead code, and migrate some other code under the appropriate
preprocessor check.
2018-09-28 21:26:21 -04:00
ridiculousfish
a17a815c87 Revert "Add vector of cleanup/termination events to be executed before quit"
This reverts commit 8c14f0f30f.

This list is not reliable - there are many ways for fish to quit that does not
invoke these functions. It's also not necessary since the history is correctly
saved on exec.
2018-09-28 20:21:23 -04:00
ridiculousfish
a389ca694c Revert "Save history on exec"
This reverts commit 9d0050023c.

This change was not necessary. History is already saved on exec().
2018-09-28 20:20:54 -04:00
ridiculousfish
7a0e72bfa9 env_get_pwd_slash to return L"/" if $PWD is empty or missing
Prior to this change, env_get_pwd_slash() would try to infer the PWD from
getcwd() if $PWD were missing. But this results env_get_pwd_slash() doing
something radically different than $PWD, and also is a lot of code for a
scenario that cannot be reliably reproduced. Just return "/" in this case.
2018-09-28 20:09:45 -04:00
Mahmoud Al-Qudsi
dd8c4cfb33 fixup! Move get_runtime_path() to env.cpp and expose it in env.h 2018-09-28 11:49:06 -05:00
Mahmoud Al-Qudsi
9d0050023c Save history on exec
See https://github.com/fish-shell/fish-shell/issues/907

May not fully resolve the issue, needs to be tested before #907 can be closed.
2018-09-28 11:34:07 -05:00
Mahmoud Al-Qudsi
8c14f0f30f Add vector of cleanup/termination events to be executed before quit 2018-09-28 11:34:07 -05:00
Mahmoud Al-Qudsi
e045b045da Move get_runtime_path() to env.cpp and expose it in env.h
It was previously a file-local static function in env_universal.cpp.
2018-09-28 11:33:11 -05:00
David Adam
5cc92ffd70 Documentation for while: note new exit status changes
Work on #4982.
2018-09-28 22:57:02 +08:00
ridiculousfish
a1728d61af Report errors on invalid replacements in string replace
If the replacement in `string replace` is invalid, prior to this fix we would
enter into an infinite loop trying to parse it. Instead report errors correctly.

Fixes #3381
2018-09-27 22:28:39 -04:00
ridiculousfish
ae54b66799 Fix string 2018-09-27 22:23:03 -04:00
ridiculousfish
cc99e8d510 Switch tokenizer_error back to just an error code
Rather than having tokenizer_error as pointers to objects, switch it back
to just an error code value. This makes reasoning about it easier since
it's immutable values instead of mutable objects, and it avoids allocation
during startup.
2018-09-27 21:40:51 -04:00
ridiculousfish
f28f9792b3 Remove ENUM_FLAGS
This define added operator overloading via preprocessor macros, which is
more magic than necessary. It was only used in one place.
2018-09-27 21:25:58 -04:00
Mahmoud Al-Qudsi
f15dd314e0 Revert "Add hash function for compatibility with sh/bash"
This reverts commit dbd228cc75.
2018-09-27 17:21:12 -05:00
Mahmoud Al-Qudsi
f5083d7bab Set $status after while depending on whether loop was entered
Closes #4982.
2018-09-27 08:15:45 -05:00
Mahmoud Al-Qudsi
8ff0e7441f fixup! Escape command name in __fish_default_command_not_found_handler 2018-09-27 07:56:02 -05:00
Fabian Homborg
3b3361685a [completions/git] Skip bare repositories
Otherwise this would print an unsightly error.
2018-09-27 13:18:26 +02:00
Fabian Homborg
6c1ea03e9c [pager] Do full fuzzy search
Just like the completion code, this now matches e.g. `f-p` to
`format-branch`.

Fixes #5213.
2018-09-27 13:18:26 +02:00
Mahmoud Al-Qudsi
1f440eb063 Fix crash when nodeptr is null and node->get_source() is called
Responsible for the crash during the low-level tests after
9c63ad3209.
2018-09-26 21:03:55 -05:00
Mahmoud Al-Qudsi
a0110d296c Refactor function_get_[desc/definition] to pass-by-reference 2018-09-26 21:03:55 -05:00
Mahmoud Al-Qudsi
a02c54c8c7 Fix completion descriptions for functions
At some point the completion code was refactored and in the event where
no explicit function description was passed into `resolve_description()`
it would attempt to use the `desc_func` parameter but pass in the
_remaining_ part of the completion rather than the full text, which
would obviously fail.

e.g. if completing `foo<TAB>`, for function `foobar` it would attempt to
find the description for a function named `bar` instead of `foobar`.

Closes #5206.
2018-09-26 21:03:55 -05:00
Mahmoud Al-Qudsi
2db759813d Revert "Fix completion descriptions for functions"
This reverts commit 9c63ad3209 until I can
figure out what is causing the assertion and test failures.

It *seems* to be that passing in the correct function name to the
description lookup is causing a previously present error to be realized,
but I can't yet be certain.
2018-09-26 14:10:46 -05:00
Mahmoud Al-Qudsi
9c63ad3209 Fix completion descriptions for functions
At some point the completion code was refactored and in the event where
no explicit function description was passed into `resolve_description()`
it would attempt to use the `desc_func` parameter but pass in the
_remaining_ part of the completion rather than the full text, which
would obviously fail.

e.g. if completing `foo<TAB>`, for function `foobar` it would attempt to
find the description for a function named `bar` instead of `foodbar`.

Closes #5206.
2018-09-26 13:18:29 -05:00
Mahmoud Al-Qudsi
dbd228cc75 Add hash function for compatibility with sh/bash 2018-09-26 12:43:40 -05:00
Mahmoud Al-Qudsi
d31cc08fd9 Add basic RAII wrapper for DIR*
At some point we should also fold the wreaddir_* functions into this new
dir_t struct as well.
2018-09-26 12:36:20 -05:00
Digital
794b448c00 Add completions for openbsd's doas (#5196)
* Add completions for openbsd's doas

* Update CHANGELOG.md

* Implement requested changes
2018-09-25 12:31:46 +02:00
Amos Bird
a483643626 fix enum warning. 2018-09-22 11:58:55 +02:00
equal-l2
b4a6daef11 Fix the total page count in the history tab 2018-09-22 11:58:29 +02:00
David Adam
f823611c2e Move abbr_old to __fish_abbr_old
This is an internal function that should not be used except by the migration process.
2018-09-21 09:25:16 +08:00
Mahmoud Al-Qudsi
deb6d477d4 Escape parameters in rustc completions
Closes #5057.
2018-09-20 18:59:57 -05:00
Mahmoud Al-Qudsi
38ac7693e9 Escape command name in __fish_default_command_not_found_handler
Closes #5102
2018-09-19 18:25:47 -05:00
Mahmoud Al-Qudsi
5b59ab3d9c Add workaround to env_get_pwd_slash() for cases where PWD is not set
There's been no reproducible case entered for #5080, but the stack trace
indicates the problem is with env_get_pwd_slash() returning an empty
string, which isn't a string that terminates in `/`.

In addition to making the failure case to return the path `./` (which
has the benefit of having the same meaning as $PWD), trying a little bit
harder to retrieve the real PWD by using getcwd(3). While
get_current_dir(3) is documented as relying on PWD, getcwd(3) does not
mention any such caveats, so it's possible that it will work even if
something is breaking PWD.

Just a thought, but it's possible if due to some recursion PWD surpassed
some predetermined value (maybe PATH_MAX) that PWD (on certain platforms
or under certain enivronments) won't be set (hence the code that deals
with ERANGE errors from the getcwd(3) call).

Closes #5080.
2018-09-19 18:16:54 -05:00
David Adam
fde74d489c Fix build on Linux
Broken in dc250e0c29
2018-09-19 10:55:36 +08:00
Mahmoud Al-Qudsi
dc250e0c29 Fix fish startup behavior in presence of unset $USER
As reported in fish-shell/fish-shell#5180, when the USER environment
variable is not set and fish is started, `get_runtime_path()` returns a
blank string. At some point in the past, this was called after
`setup_user()` in env.cpp, but this is no longer the case.

This commit removes the reliance on the $USER environment variable
entirely, and instead uses `getpwuid(geteuid()).pw_name` to retrieve the
current username.

Closes #5180.
2018-09-18 21:03:04 -05:00
Fabian Homborg
0e82fcd999 Always notify about crashes
And by crash I mean anything that exits with SIGABRT, SIGBUS, SIGFPE, SIGILL, SIGSEGV, SIGSYS.

Fixes #4962.
2018-09-18 21:22:15 +02:00
Sam Yu
17643ef12c Fix zypper completion
* complete installed packages only for `zypper rm`
* remove incorrect local file completion
2018-09-16 21:15:32 -07:00
ridiculousfish
e6863a90c8 Don't reset the screen after emitting a BEL
Fixes #3693
2018-09-16 16:25:49 -07:00
ridiculousfish
f3da54d99c Convert some iterators to C++-11 range-based loops 2018-09-16 15:49:18 -07:00
ridiculousfish
62870abe34 Remove newlines from Doxyfile.user aliases
For some reason I started getting literal \n appearing in Doxygen-generated
help files. These are coming from newlines in aliases defined in
Doxyfile.user. These should be safe to remove because they are HTML-specific
and there is still whitespace before them. Remove these newlines.

This didn't reproduce on Linux; Doxygen is full of mysteries.
2018-09-16 15:42:46 -07:00
Fabian Homborg
3ba74b3195 [string] Match everything with an empty pattern and -e
I.e. `string match --entire "" -- banana` used to match nothing, now
it matches everything.

Fixes #4971.
2018-09-16 13:03:15 +02:00