Commit Graph

14167 Commits

Author SHA1 Message Date
Fabian Homborg
4b2bce7b83 screen: Remove useless .c_str() and wcslen calls
This passed the wchar_t* to outputter::writestr(), which then had to
do a wcslen on it, when it already has a perfectly cromulent
wcstring overload.

Just use that one.
2021-05-18 09:11:56 +02:00
Fabian Homborg
25595a94c7 screen: Also move cursor after printing the prompt
This helps with width issues when no right prompt is used.
2021-05-18 09:09:59 +02:00
Fabian Homborg
0660ea5be7 Move the cursor to the beginning before printing right prompt
This makes the right prompt position independent of the width of the
commandline, which prevents staircase effects. That means, with "X"
standing in as a character that the terminal and fish disagree on:

```
> echo X           rightprompt
```

will stay like that instead of creating a staircase like

```
> echo X            rightpromp
t> echo X             rightpromp
pt> echo X
```

and so on.

The cursor still won't be *correct*, but it will be wrong in a less
annoying way.
2021-05-18 09:09:59 +02:00
ridiculousfish
d3ceba107e Clear to eol before outputting line in multi-line prompt
If the user has a multi-line prompt, we will emit a clr_eol on every
line except the last (see #7404). Prior to this change we would emit
clr_eol after the line, but in some terminals, if the line extended the
width of the tty, the last character would be deleted. Switch to
emitting clr_eol first; now the last character will not be cut off.

Fixes #8002
2021-05-17 21:44:17 -07:00
ridiculousfish
c0b33774ca Update docs on detecting fish_private_mode
fish_private_mode is active if set to something non-empty, but the docs
suggested checking if it is set at all. Switch the docs to match the
implementation through `test -n "$fish_private_mode"`

Fixes #8001
2021-05-17 18:42:52 -07:00
ridiculousfish
6d00ad1045 Ensure that on-process-exit events fire for reaped jobs
This ensures that if a job exits before we have set up the
on-process-exit handler, the handler will still fire.

Fixes #7210
2021-05-17 15:28:32 -07:00
ridiculousfish
60d75e9aa0 Remove proc_create_event
Switch to a set of factory functions inside event_t.
No user-visible change here.
2021-05-17 15:26:59 -07:00
ridiculousfish
962b0f8b90 Pass $status to process-exit event handlers in all cases
Previously, an event handler would receive -1 if the process exited due
to a signal. Instead pass the same value as $status.
2021-05-17 15:25:27 -07:00
ridiculousfish
82fd8fe9fb Refactor wait handles
In preparation for using wait handles in --on-process-exit events, factor
wait handles into their own wait handle store. Also switch them to
per-process instead of per-job, which is a simplification.
2021-05-17 15:25:21 -07:00
Fabian Homborg
b63b511b0a docs: Clarify when on-variable handlers will be run
Fixes #8010.
2021-05-17 17:20:36 +02:00
Fabian Homborg
a427bf207a reader: Fix crash when text is empty after stripping spaces
This crashed on Fedora with the rpm packages, but not when building
from source, so some compiler option triggers it.

But the root cause is us running `text.front()` on an empty string,
which isn't something you should do.

Fixes #8009.
2021-05-16 22:16:22 +02:00
Karolina Gontarek
31f3c16857 Resolve relative paths in command names for complete -p
Fixes #6001
2021-05-16 21:52:38 +02:00
Fabian Homborg
c38f4980f9 docs: Some tweaks on initialization 2021-05-16 21:27:00 +02:00
Fabian Homborg
af84c35282 docs: A bit more on autoloading 2021-05-16 21:27:00 +02:00
Johannes Altmanninger
e10cab8104 Tweak documentation wording to include non-option arguments 2021-05-16 20:48:53 +02:00
Kid
e714ce238e Add missing options for complete 2021-05-16 17:33:49 +08:00
ridiculousfish
63ee28c1de Fix a misleading comment 2021-05-15 22:05:35 -07:00
ridiculousfish
5de63c9cbb Reimplement builtin_wait using wait handles
This switches builtin_wait from waiting on jobs in the active job list, to
waiting on the wait handles. The wait handles may be either derived from
the job list itself, or from saved wait handles from jobs that exited in
the background.

Fixes #7210
2021-05-15 21:48:15 -07:00
ridiculousfish
632e150152 Introduce notion of "wait handles"
This is preparing to address the problem where fish cannot wait on a
reaped job, because it only looks at the active job list. Introduce the
idea of a "wait handle," which is a thing that `wait` can use to check if
a job is finished. A job may produce its wait handle on demand, and
parser_t will save the wait handle from wait-able jobs at the point they
are reaped.

This change merely introduces the idea; the next change makes builtin_wait
start using it.
2021-05-15 20:20:50 -07:00
Fabian Homborg
d15a51897d Rationalize $LESS uses
Stop using "--no-init"/"-X" because we have no actual reason to and it
may break mouse initialization on my best friend macOS.

Use --RAW-CONTROL-CHARS, the capital version that only lets through
specific escape sequences, not *everything* - we shouldn't have
anything weird here, but less heavily discourages the other version.

Allow a user's $LESS to override.

Fixes #7997.
2021-05-14 22:18:59 +02:00
Fabian Homborg
2cfb4343ed man: Remove useless dirname call
This removed "/fish" just to add it back.
2021-05-14 21:49:53 +02:00
Érico Nogueira
3ac2242c68 completions: fix pacmd completions when using pipewire-pulse.
In such cases, `pacmd help` prints

  No PulseAudio daemon running, or not running as session daemon.

to stderr, which ends up printed to the user terminal.
2021-05-14 21:19:06 +02:00
ridiculousfish
aeabc76b2e Use internal job ids in builtin_wait
This avoids any potential issues due to recycled job IDs.
No user visible change.
2021-05-13 12:11:00 -07:00
ridiculousfish
6bae9ebe62 Add an Alpine Dockerfile build
This may be run with:

    ./docker/docker_run_tests.sh ./docker/alpine.Dockerfile
2021-05-13 11:00:05 -07:00
Fabian Homborg
240fb9fd45 docs: Unbreak sphinx' man directories
Apparently new sphinxen want to create an *additional* section
directory, so things end up in /usr/share/fish/man/man1/1, instead of /usr/share/fish/man/man1

Why? No idea.

I can't reproduce it but I'm told this section fixes it.

Fixes #7996
2021-05-13 18:20:47 +02:00
Fabian Homborg
678fa2e6a9 docs: A bit on index ranges
Try to make list-ness more accessible.
2021-05-12 19:40:43 +02:00
Fabian Homborg
127eaded96 docs: Mention set in variable expansion
This isn't strictly speaking variable expansion, but it's so related
that we should at least tease it.

See #7990.
2021-05-12 19:28:34 +02:00
Fabian Homborg
9fd69acd1a docs: Clean up set a bit
More links! Links good! Link link linky link!
2021-05-12 18:52:24 +02:00
Fabian Homborg
dbc6bffe3c __fish_set_locale: Ignore $LANGUAGE
This isn't really a "locale" variable as such. It has no effect on
encoding and stuff, it's just the output language.

What we really want here is get something better than the awkward "C"
or "POSIX" for LC_CTYPE specifically - everything else doesn't really
matter.
2021-05-11 21:53:58 +02:00
ridiculousfish
786b0463b6 Fix a unique_ptr build error with gcc 4.8 2021-05-10 16:49:11 -07:00
ridiculousfish
04535e9701 Fix a few mild warnings with gcc 4.8 2021-05-10 16:49:01 -07:00
ridiculousfish
91a4059a8f Changelog fix for #7968 2021-05-10 16:03:33 -07:00
ridiculousfish
71df8f8622 Do not flock the uvars file on remote filesystems
In rare cases this may cause the universal variable file to drop
an update, if two happen at the same time and HOME is on an nfs mount.
But this is considered better than hanging if nfs is lockless.

Fixes #7968.
2021-05-10 15:24:32 -07:00
ridiculousfish
ba33b6dcc8 Mild refactoring of flock logic inside env_universal_t
This reorganizes the flock code in env_universal_t, removing a static
variable and making the behavior more explicit.
2021-05-10 15:23:57 -07:00
ridiculousfish
083f2698f9 Remove internal lock from env_universal_t
env_universal_t locking discipline is now managed by env.cpp.
That is, the shared instance of env_universal_t is managed by a lock.
We no longer need to have an internal lock, so remove it.
2021-05-10 15:23:57 -07:00
ridiculousfish
8d06357fbb Take advantage of empty uvars
Now that we allow uvars to be empty and uninitialized, we can always
instantiate it; we don't need to test whether it is null or not.
2021-05-10 15:23:56 -07:00
ridiculousfish
e2a1b25a24 Continue refactoring env_universal_t
Previously an instance of env_universal_t had to be created with a file
path. Switch to allowing it to be created as empty, and later initialized
with the file path. This will help simplify the case where universal
variables are not used; they may simply be not initialized and so just
appear empty.
2021-05-10 15:23:08 -07:00
ridiculousfish
16ba45fe64 Early work towards changing locking discipline of uvars
Rather than universal variables holding their own lock, we will wrap the
instance in a lock.
2021-05-10 14:23:07 -07:00
ridiculousfish
fa7402c415 Reorganize env_universal_t so that the public bits are at the top
No functional change here.
2021-05-10 14:23:07 -07:00
ridiculousfish
0d8cb0125a Remove the narrow_vars_path from universal variables
This was a cache of the wide vars_path, but it's not worth its
complexity.
2021-05-10 14:23:07 -07:00
ridiculousfish
6ab7945623 Mild refactoring of universal variables
This removes some unnecessary returns and other miscellaneous cleanup.
2021-05-10 14:23:07 -07:00
ridiculousfish
c8d909b2b2 Remove fd_check_is_remote
This function is no longer used; instead we detect if a given path is
remote, once, typically at startup.
2021-05-10 14:23:07 -07:00
ridiculousfish
1af441b4cc Do not lock the history file on remote filesystems
This avoids using locks for the history file if the file appears to be on
a remote file system, like NFS. This is to avoid hangs if the filesystem
does not support locking.

If locking is not enabled, then in rare cases, history items may be
dropped if multiple sessions try to write to the history file at once.
This is thought to be better than hanging. Hopefully the recent change to
require a trailing newline will avoid propagating partial items.
2021-05-10 14:23:07 -07:00
ridiculousfish
d1fd3d5825 Detect at startup whether config and data paths are remote
This is in preparation for changing the locking regime of history.
2021-05-10 14:23:07 -07:00
ridiculousfish
541e1d2fad base_directory_t to stop storing explicit success bool
This can be trivially computed from the error code.
2021-05-10 14:23:07 -07:00
ridiculousfish
f85f6a0127 Enforce that history items must end with trailing newlines
This helps prevent seeing partially written items from other sessions,
in preparation to reducing the amount of flocking done.
2021-05-10 14:23:07 -07:00
ripytide
8c19b6105f Not quite accurate code example heading 2021-05-10 19:28:06 +02:00
ripytide
40704ba7a2 Explanation of list range example wrong way round.
I'm assuming the first number before the **..** is the FROM and the number after it is the TO.
2021-05-10 17:01:12 +02:00
ridiculousfish
aa02cbd090 Wrap up history's mmap logic into its own type
This improves the factoring a bit.
2021-05-09 11:59:29 -07:00
ridiculousfish
d1befee19e Fix some potential leaks in history file contents
If history is corrupt and cannot be read, fish would return an error
without munmaping the file. Ensure it is properly munmapped.
2021-05-09 11:59:29 -07:00