Commit Graph

784 Commits

Author SHA1 Message Date
Kurtis Rader
fb54d34788 change string match --filter to --entire
Per discussion in PR#3998 to review adding a `--filter` flag to `string
replace` rename the same flag in the `string match` subcommand to avoid
confusion about the meaning of the flag.
2017-05-01 22:19:58 -07:00
Kurtis Rader
16816a1202 add string replace --filter flag
Fixes #3348
2017-05-01 22:07:30 -07:00
Kurtis Rader
48d5342601 style cleanups
Time for another `make style-all`.
2017-05-01 22:05:35 -07:00
Kurtis Rader
6b1c939b67 rename --metadata to --details
Discussion in issue #3295 resulted in a decisions to rename the
functions --metadata flag to --details.

This also fixes a bug in the definition of the short flags for the
`functions` command. The `-e` flag does not take an argument and
therefore should not be defined as `e:`. Notice that the long form,
`--erase`, specifies `no_argument`. This discrepency happened to work
due to a quirk of how the flag parsing loop was written.
2017-04-30 20:21:40 -07:00
Kurtis Rader
65c762f1e1 fix parser error message
Fixes #4000
2017-04-29 21:33:50 -07:00
David Adam
4fde67fa50 implement disown builtin
Closes #2810.

The syntax mirrors that of zsh.
2017-04-29 19:20:03 +08:00
David Adam
f52708a20f job_t: use the sentinel value of -2 for new job process group IDs
0 is not a good default PGID, because it's possible for a kernel process
to have the PGID of 0 under Linux.

This meant that job_get_from_pid could return incorrect jobs, as the PGID
for internal, non-forked jobs was the same as kernel processes.

Avoid this by using an invalid PGID as the initial PGID.
2017-04-29 19:20:03 +08:00
David Adam
16931f724b job_signal: confirm process group before signalling it
It is possible for fish to not be the process group leader; avoid
signalling the process group containing the current process by checking
with getpgrp() rather than assuming that getpid() is enough.
2017-04-29 19:20:03 +08:00
David Adam
8f77b1cdd2 use current PGID (not PID) for new processes when job control is off
If fish is not the first process in a pipeline, and jobs are started
from the fish process, it is possible for fish and the OS to have
different ideas about what the process group of the jobs are.

This change confirms the current PGID, rather than assuming that it is
the same as the PID.
2017-04-29 19:20:03 +08:00
David Adam
10e64fd548 job_get_from_pid: don't assume pgid == pid
Compare apples with apples by using getpgid() when checking a process
against the job list.
2017-04-29 19:20:03 +08:00
David Adam
d32e7f5ad7 job_get_from_pid: use canonical pid_t type 2017-04-29 19:20:03 +08:00
David Adam
8612ac592d add comments documenting use of negative IDs for PGIDs in events 2017-04-29 19:20:03 +08:00
David Adam
b8bf567514 postfork: correct terminology from parent group to process group 2017-04-29 19:20:03 +08:00
David Adam
c32032757e builtin.cpp: update template builtin function 2017-04-29 19:20:03 +08:00
Fabian Homborg
f5fac096c0 Don't move cursor in delete-char
Instead, move forward and backward in vi-mode.

Fixes #3899.
2017-04-28 22:53:03 +08:00
Andrei Dziahel
a26419557f fixes identical code in both if branches introduced in e52a04e34 2017-04-26 20:30:36 -07:00
Marc Garcia Sastre
980af4aa5b status returns the function name when called with -u parameter
Fixes #1743
2017-04-26 20:15:45 -07:00
Kurtis Rader
937c229b2e eliminate symbol aliases that obscure the code
Defining aliases for existing symbols serves only to obscure the code.
So remove the following symbols and replace them with the primary
symbols:

enum { BUILTIN_TEST_SUCCESS = STATUS_BUILTIN_OK, BUILTIN_TEST_FAIL =
STATUS_BUILTIN_ERROR };

See issue #3985.
2017-04-24 23:06:22 -07:00
Kurtis Rader
5b6814d6ad add string match --filter flag
Fixes #3957
2017-04-24 21:45:06 -07:00
Kurtis Rader
f1d40a3c7c limit bind mode names to the rules for var names
The bind mode names can be, and are, used in the construction of fish
variable names. So don't allow users to use names that are not legal as
a variable name. This should not break anything since, AFAICT, no
existing fish scripts, including those provided by Oh-My-Fish and
Fisherman define bind modes that would not be legal with this change.

Fixes #3965
2017-04-22 20:33:56 -07:00
Kurtis Rader
275d658616 simplify and clarify valid identifiers
This is the first step in addressing issue #3965. It renames some of the
functions involved in validating variable and function names to clarify
their purpose. It also augments the documentation to make the rules for
such identifiers clearly documented.
2017-04-21 21:55:06 -07:00
Fabian Homborg
3fa5d6c794 Force setting $USER if UID is 0
Works around some weird su implementations.

Fixes #3916.
2017-04-18 15:06:49 +02:00
Kurtis Rader
e332573fe1 remove transitory test directory
Reinstatate a command to remove a temporary directory that inadvertently
removed by commit 49518b71.
2017-04-15 22:28:59 -07:00
ridiculousfish
6bd47b8662 Kill an unused variable 2017-04-15 17:37:30 -07:00
Kurtis Rader
0be8d0d385 another __fish_sgrep replacement 2017-04-13 23:14:36 -07:00
Kurtis Rader
c3584111d6 fix unused parameter error
The recent change to improve the behavior of the `bg` command (commit
3edb7d538) resulted in the `send_to_bg()` no longer using the `name`
parameter it was given. This rectifies that lint warning by removing
that parameter as it never served a useful purpose.
2017-04-12 22:48:32 -07:00
Kurtis Rader
095e04cb0d remove mention of __fish_sgrep
This is a trivial change to address issue #2450 by eliminating a
inconsequential reference to `__fish_sgrep` in the core C++ code.
2017-04-11 22:11:45 -07:00
Andreas Nordal
08d42a0507 Error message prefix: Prefix the message, not the context
Fixes #3649
2017-04-11 20:00:29 -07:00
Marc Garcia Sastre
8213885491 Capture read command contents without displaying it via a silent flag.
Implement a `read --silent` flag. This echos the input using an
obfuscation character.
2017-04-11 19:06:48 -07:00
Kurtis Rader
8440308470 two more /tmp references that aren't necessary
Eliminate two more references to /tmp as part of removing our dependency
on /tmp being a valid directory.
2017-04-08 21:47:05 -07:00
Kurtis Rader
49518b71ab low level tests should not depend on /tmp
The low level tests should not depend on /tmp being a valid directory.
2017-04-08 21:13:34 -07:00
Kurtis Rader
03571b82be cleanup env code and contains()
Switch from null terminated arrays to `wcstring_list_t` for lists of
special env var names. Rename `list_contains_string` to `contains` and
modify the latter interface to not rely on a `#define`.

Rename `list_contains_string()` to `contains()` and eliminate the
current variadic implementation. Update all callers of the removed
version to use the string list version.
2017-04-05 17:09:12 -07:00
Kurtis Rader
a4f925d822 empty path components are equivalent to "."
There are at least three env vars describing a sequence of paths to be
searched where an empty path element is implicitly equivalent to ".".
This change converts the implicit "." to explicit whenever the variable
is imported or set. This makes the variable much easier to use in fish
scripts.

Fixes #3914
2017-04-04 17:32:45 -07:00
Fabian Homborg
3edb7d538f Improve bg argument handling
- Error out if anything that is not a PID is given

- Otherwise background all matching existing jobs, even if not all
  PIDs exist (but print a message for the non-existing ones)

Fixes #3909.
2017-04-04 14:59:43 +02:00
Fabian Homborg
cd16676911 Make "trying to match mapping" debug priority 4
Instantly makes debug output _much_ more usable.
2017-04-01 10:43:01 +02:00
Fabian Homborg
d7ef7eb484 Also give subshells the terminal
Fixes #1362.
2017-03-31 19:34:42 -07:00
Kurtis Rader
c0de8afaf3 untokenize string before printing it
Fixes #3915
2017-03-28 19:15:08 -07:00
ridiculousfish
dec0f7aa84 Make s_generation_count a std::atomic
This should improve safety and satisfy tsan
2017-03-26 13:44:27 -07:00
ridiculousfish
44b3554a11 Reorder a lock to prevent a potential deadlock in uvars
A call to default_vars_path() takes the environment variable
lock while the uvars lock is held. Ensure that doesn't happen by
deferring the uvars lock to later in the function.
2017-03-26 13:22:23 -07:00
ridiculousfish
9f13edbe4a Fix a buffer overflow in cached_esc_sequences_t::find_entry
cached_esc_sequences_t::find_entry was constructing a wcstring
from a c string, using lengths longer than the length of the cstring.

Detected with asan.
2017-03-26 12:55:15 -07:00
Kurtis Rader
38c851f4cf let read take a simple string for the prompt
Fixes #802
2017-03-25 20:24:43 -07:00
Kurtis Rader
ae0321778f empty CDPATH elements are equivalent to "."
In the process of fixing the issue I decided it didn't make sense to
have two, incompatible, ways of converting variable strings to arrays.
Especially since the one I'm removing does not return empty array elements.

Fixes #2106
2017-03-22 19:30:42 -07:00
Fabian Homborg
70354f9f5e Add bind --list-modes option
Fixes #3872.
2017-03-20 16:42:53 +01:00
Kurtis Rader
a811ae25dc don't preemptively send SIGPIPE
Fixes #1926
2017-03-16 18:59:34 -07:00
Kurtis Rader
84cf391faa style cleanups 2017-03-15 14:06:58 -07:00
Kurtis Rader
f0469d829a string repeat of an empty string is an error
Fixes #3898
2017-03-15 13:55:53 -07:00
Kurtis Rader
6fd8dc44fb support test -k to test the sticky bit
Fixes #733
2017-03-14 21:43:15 -07:00
Kurtis Rader
1afea1b650 add description to functions -m -v output
Fixes #597
2017-03-13 20:52:31 -07:00
Kurtis Rader
8efe88201e correct escape_string corner case
Fixes #3892
2017-03-13 20:38:57 -07:00
Greynad
98f4e49669 Add string 'repeat' subcommand
This feature add the ability to repeat a string a given number of times.
For example: string repeat -n 3 foo
2017-03-12 20:30:36 -07:00