Commit Graph

131 Commits

Author SHA1 Message Date
Mahmoud Al-Qudsi
1f0085bc08 fixup! Add status fish-path
Fixes broken macOS build. I'm not sure how the code used to compile
without including `dyld.h` previously, perhaps a different header used
to pull it in?
2018-10-10 00:29:45 -05:00
Mahmoud Al-Qudsi
e212269ab1 Add status fish-path
Retrieves the fully resolved path to the currently executing fish binary
(regardless of PATH). Can be used to ensure that the same fish is
launched again from a script.

`get_executable_path()` moved from fish binary to libfish, also cleaned
up some duplicated (but differing!) definitions of PATH_MAX (which was
used by that function) in the process.
2018-10-09 22:34:41 -05: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
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
Mahmoud Al-Qudsi
8c14f0f30f Add vector of cleanup/termination events to be executed before quit 2018-09-28 11:34:07 -05: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
Amos Bird
a483643626 fix enum warning. 2018-09-22 11:58:55 +02:00
ridiculousfish
ca61fc1bf8 Stop retrying close() on EINTR
https://lwn.net/Articles/576478/
http://austingroupbugs.net/view.php?id=529
https://sourceware.org/bugzilla/show_bug.cgi?id=14627
2018-09-05 21:49:31 -07:00
ridiculousfish
274c77cf0c Add autoclose_fd_t for helping to manage file descriptors 2018-09-01 14:27:36 -07:00
ridiculousfish
1473f952d4 Make contains() more general
Allow contains() to find arbitrary values in arbitrary vectors, and adopt it
in place of std::find.
2018-08-11 22:23:20 -07:00
ridiculousfish
44bae29039 Add a debug_escape function
This function for debugging makes it easier to understand what special
characters are present in a string.
2018-06-23 13:15:32 -07:00
Mahmoud Al-Qudsi
dcced5f1bc Replace \e with \x1B, as the former is a gcc extension
While supported by gcc and clang, \e is a gcc-specific extension and not
formally defined in the C or C++ standards.

See [0] for a list of valid escapes.

[0]: https://stackoverflow.com/a/10220539/17027
2018-06-18 00:01:47 -05:00
Fabian Homborg
583d771b10 Fix escape_string_var for UTF-16
We're now actually handling wchar_t here, so comparing the 0x80 bit
would break for UTF-16, causing ASCII false-positives.

Also simplifies a bit, since we no longer need a second variable.
2018-05-28 12:10:40 +02:00
Fabian Homborg
b2b4ab4bab constref more things
Thanks @ridiculousfish!
2018-05-28 12:10:40 +02:00
Fabian Homborg
4dc1c6ca39 [string] Allow url/var escaping to handle NULs
Fixes #4605.
2018-05-28 12:10:40 +02:00
Fabian Homborg
a229f703ae Allow escape_string_url from escape_string with wcstring
This was an oversight.
2018-05-28 12:10:39 +02:00
Fabian Homborg
338b40bb43 Trust the passed size in escape_string_script
This allows it to handle NULs.
2018-05-28 12:10:39 +02:00
ridiculousfish
4194b4efee Add a feature_test() function
This is a convenience over fish_features().test()
2018-05-06 11:20:15 -07:00
ridiculousfish
762c31be87 Feature flag support for ? wildcard
This partially reverts 6e56637cf0 and #4520
by bringing back the ? wildcard, guarded by the qmark-noglob feature flag.
2018-05-06 11:20:15 -07:00
ridiculousfish
902af26253 Bring back caret redirections under a feature flag
This partially reverts 5b489ca30f, with
carets acting as redirections unless the stderr-nocaret flag is set.
This flag is off by default but may be enabled on the command line:

fish --features stderr-nocaret
2018-05-06 11:20:14 -07:00
Fabian Homborg
baeeef3233 Remove triggerable assert in unescape_string_internal
Fixes #4954 - in a hacky way.
2018-05-02 16:35:56 +02:00
Mahmoud Al-Qudsi
a9b582d2a8 Block .dll files from completion as potential heads under WSL 2018-04-14 23:56:30 -05:00
Peter Ammon
5b489ca30f Remove caret redirection
This removes the caret as a shorthand for redirecting stderr.

Note that stderr may be redirected to a file via 2>/some/path...
and may be redirected with a pipe via 2>|.

Fixes #4394
2018-04-01 13:48:21 -07:00
ridiculousfish
6e56637cf0 Remove support for the ? wildcard
Fixes #4520
2018-03-31 16:54:50 -07:00
Mahmoud Al-Qudsi
412c5aeaa6 Use alternative Unicode glyphs if compiled under Windows/WSL
The two unicode glyphs used to represent missing new lines and redacted
characters for secure entry are both not present in the glyph tables of
the default font under Windows (Consolas and Lucida Console), use an
alternative glyph instead.

The "return" symbol is replaced with a pilcrow (¶) and the "redacted
character" symbol is replaced with a bullet (•). Both of these are
well-defined in almost all fonts as they're very old symbols. This
change only takes place if -DWSL is supplied by the build toolchain.

Note: this means a Windows SSH client connecting to a fish remote
instance on a non-Windows machine will still use the (unavailable)
default glyphs instead.
2018-03-28 14:27:25 -05:00
ridiculousfish
669eafb55f Stop exporting empty variables as ENV_NULL
Localize the encoding of empty variables as ENV_NULL into the universal
variables component, and ensure they are not exported as ENV_NULL.

Fixes #4846
2018-03-24 23:42:09 -07:00
Mahmoud Al-Qudsi
0b96b516d5 Improve and expand is_whitespace helper functions 2018-03-12 08:06:50 -05:00
Mahmoud Al-Qudsi
24afff1c77 Handle whitespace within parameter expansion tokens
From the discussion in #3802, handling spaces within braces more
gracefully. Leading and trailing whitespace that isn't quoted or escaped
is stripped, whitespace in the middle is preserved. Any whitespace
encountered within expansion tokens is treated as a single space,
similar to how programming languages that don't hard break tokens/quotes
on line endings would.
2018-03-11 22:02:43 -05:00
Mahmoud Al-Qudsi
1629d339de Properly parse spaces and escaped/quoted spaces in expansion braces 2018-03-11 19:51:54 -05:00
Mahmoud Al-Qudsi
65a03c86cb Rename BRACKET in reference to { to BRACE instead per #3802
This `{` is a curly brace. This `[` is a square bracket.
2018-03-10 13:16:53 -06:00
Mahmoud Al-Qudsi
1fbf810946 Unify ellipsis_str[ing] with common variable set once 2018-03-09 14:40:35 -06:00
Mahmoud Al-Qudsi
e45e2bf20e Initial removal of '%' syntax for process/job expansion 2018-03-09 03:36:10 -06:00
Mahmoud Al-Qudsi
3c895c2839 Add whitespace helpers to complete.h/cpp 2018-03-06 12:52:42 -06:00
Mahmoud Al-Qudsi
000892e315 Use constexpr for is_windows_subsystem_for_linux()
To guarantee that at runtime there will be no branching, using a CMAKE
test/define combined with a constexpr wrapper for code-friendliness.
2018-03-04 21:13:31 -06:00
ridiculousfish
74e6a82849 Remove explicit 'void' parameters. 2018-02-18 19:12:45 -08:00
ridiculousfish
3a45cad12e Introduce fish_mutex_t wrapping std::mutex
Add a fish-specific wrapper around std::mutex that records whether it is
locked in a bool. This is to make ASSERT_IS_LOCKED() simpler (it can just
check the boolean instead of relying on try_lock) which will make Coverity
Scan happier.

Some details: Coverity Scan was complaining about an apparent double-unlock
because it's unaware of the semantics of try_lock(). Specifically fish
asserts that a lock is locked by asserting that try_lock fails; if it
succeeds fish prints an error and then unlocks the lock (so as not to leave
it locked). This unlock is of course correct, but it confused Coverity Scan.
2018-02-08 22:18:59 -08:00
Mahmoud Al-Qudsi
fbc6c68f3d Handle error opening /dev/null in redirect_tty_output
This fixes coverity scan defect number 7520299
2018-02-08 17:05:13 -06:00
Mahmoud Al-Qudsi
3083e0ea80 Work around false positive RESOURCE_LEAK in coverity scan
Fixes defect number 7520322
2018-02-08 16:59:38 -06:00
Mahmoud Al-Qudsi
82b7e6de69 Fix unused code (coverity defect #7520283)
Due to the logic above, isz cannot be zero if we take the else branch.
2018-02-08 16:54:28 -06:00
ridiculousfish
cef39cdcc0 Add is_windows_subsystem_for_linux to detect WSL 2018-02-07 12:49:11 -08:00
Fabian Homborg
aa58cae601 Don't count successive "," as literal in brace expansion
This was highly surprising.

Fixes #3002.
2018-01-07 15:00:44 +01:00
ridiculousfish
457213a768 Turn debug() into a macro
A large portion of time was spent constructing strings and passing
them to debug(). Turn debug into a macro so that the strings are only
constructed if they're going to be printed.
2017-12-22 15:19:08 -08:00
Fabian Homborg
f9d883dd74 Add and use str2wcstring(string, size_t)
This is just for convenience.
2017-12-20 14:31:29 +01:00
David Adam
216c4b811a only call ioctl to export new termsize if process is in the foreground
Closes #4477.
2017-10-21 07:21:17 +08:00
Kurtis Rader
026cb48dce Remove unintended change from prev commit 2017-09-21 12:45:54 -07:00
Kurtis Rader
b241bf4140 Use \uXXXX consistently for unicode code points
A recent discussion involving whether `can_be_encoded()` was broken
caused me to notice that we are inconsistent about whether Unicode code
points are specified using `\xXXXX` or `\uXXXX` notation. Which is
harmless but silly and potentially confusing.
2017-09-20 22:00:14 -07:00
Mahmoud Al-Qudsi
039c3c1673 Drop unused parameters to show_stackframe on non-Linux systems
Fixed a warning about unused parameters on systems where
HAVE_BACKTRACE_SYMBOLS is not defined.
2017-09-10 10:52:41 -05:00
ridiculousfish
cb352317bd Simplify the cached_esc_sequences_t structure
The type cached_esc_sequences_t caches escape sequences, and is tasked
with finding an escape sequence that prefixes a given string. Before
this fix, it did so by storing the lengths of cached escape sequences,
and searching for substrings of that length. The new implementation
instead stores all cached escape sequences in a sorted vector, and uses
binary search to find the shortest escape sequence that is a prefix of
the input. This is a substantial simplification that also reduces
allocations.
2017-09-01 14:36:16 -07:00
ridiculousfish
3d40292c00 Switch env_var to using maybe_t
This eliminates the "missing" notion of env_var_t. Instead
env_get returns a maybe_t<env_var_t>, which forces callers to
handle the possibility that the variable is missing.
2017-09-01 00:14:42 -07:00