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.
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.
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
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.
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.
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.
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.
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.
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.
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.