Commit Graph

562 Commits

Author SHA1 Message Date
Kurtis Rader
25e0a39165 fix bug introduced by lint cleanup commit 42458ff 2016-10-22 21:14:21 -07:00
Kurtis Rader
d982427216 remove unused function
The fish_key_reader program was the only user of the
`set_wait_on_escape_ms()` function and that use was removed with commit
0461743. So remove it from the main fish code. This was found by `make
lint`.
2016-10-22 21:08:53 -07:00
Kurtis Rader
21521b2953 lint: too few branches in switch statement
Someone was way too enamored of the `switch` statement. Using it in
places where a simple `if...else if...else` was clearer and shorter.
2016-10-22 21:01:27 -07:00
Kurtis Rader
42458ff7ab lint: "collapsible if statements" warnings 2016-10-22 19:09:40 -07:00
Kurtis Rader
6e6b294a3f lint: deal with "double negative" warnings 2016-10-20 21:14:40 -07:00
Kurtis Rader
00303ed07f lint cleanup: parameter reassignment 2016-10-20 18:53:31 -07:00
Kurtis Rader
8a2d6a9752 fix/unify tests for chars in fish reserved ranges 2016-10-17 18:46:53 -07:00
Aaron Gyes
8a7b30d3f0 Fix null pointer deref in job_reap()
Coverity believes in this one in job_reap().
Proactively apply same check to format_job_info().
2016-10-17 14:38:52 -07:00
Kurtis Rader
a26f68d63f handle multiline commands in history search output
Fixes #31
2016-10-16 21:33:12 -07:00
Kurtis Rader
bff6a6e66a eliminate compile warnings and augment changelog
Update the CHANGELOG to more accurately reflect what will be included in
the 2.4.0 release vis-a-vis the `history` command behavior.

I noticed that the compiler was emitting some harmless warnings related
to the history changes so deal with those as well.
2016-10-16 21:15:40 -07:00
Kurtis Rader
f490b56378 make history searching case insensitive by default
Fixes #3236
2016-10-16 20:18:16 -07:00
Kurtis Rader
dc6b538f56 improve set PATH warning message
This modifies the code path for `set PATH` and `set CDPATH` to emit an
easier to understand warning when an entry in those vars is invalid. For
example

$ set PATH $PATH /tmp/arglebargle
set: Warning: $PATH entry "/tmp/arglebargle": No such file or directory
$ mkdir /tmp/d
$ chmod 0 /tmp/d
$ set PATH $PATH /tmp/d
set: Warning: $PATH entry "/tmp/d": Permission denied
$ touch /tmp/x
$ set PATH $PATH /tmp/x
set: Warning: $PATH entry "/tmp/x": Not a directory

Fixes #3450
2016-10-16 19:58:57 -07:00
Kurtis Rader
4f397e86d7 fix use after free bug
Fixes #3466
2016-10-16 12:51:31 -07:00
Fredrik Fornwall
fe8727fb71 Fix building on Android by avoiding getpwent() (#3441)
* Fix building on Android by avoiding getpwent() if missing with autoconf check

The getpwent() function does not link when building for Android,
and user names on that platform are not interesting anyway.
2016-10-15 17:20:53 -07:00
Kurtis Rader
cda415cb5d fix more style bogosities that have crept in 2016-10-10 19:52:22 -07:00
Fredrik Fornwall
36f320598e Check for struct stat.st_ctime_nsec before using
Using a configure check for stat.st_ctime_nsec fixes building on
Android which has that field but does not define STAT_HAVE_NSEC.

Before this change the Android build failed on the st_ctim.tv_nsec
fallback #else clause.
2016-10-10 19:33:25 -07:00
Aaron Gyes
d8497f0f1e Use the nonbright variant of brights on lame terms
With this change, 'set_color brred; echo bright red' will
at leaat be red on Linux/FreeBSD virt consoles.
2016-10-10 13:53:11 -07:00
Aaron Gyes
f464704884 escape_code_length: test all setaf parameters
Taking a different approach here. I can't see why we'd only want to
recognize certain colors. Now, we'll just try all the colors fish might
use.

This could probably be optimized now that there are more
than 8 (or 16) colors fish can do.
2016-10-10 11:56:25 -07:00
Aaron Gyes
14efcb7cc5 escape_code_length: cast to size_t, not int 2016-10-09 21:58:14 -07:00
Kurtis Rader
4ffc6e02b7 fix a couple of "unused parameter" warnings
This fixes two of the three "unused parameter" compiler warnings in the
fish_tests.cpp module. The third I'm deferring to issue #3439.
2016-10-09 19:52:02 -07:00
Kurtis Rader
a5034874ab eliminate warnings in auxiliary programs
Partially addresses issue #3430.
2016-10-09 14:43:25 -07:00
Kurtis Rader
37c4247cb7 eliminate more "unused parameter" warnings
Partially addresses issue #3430.
2016-10-09 14:41:56 -07:00
Kurtis Rader
c07c98ac05 eliminate many "unused parameter" warnings
Partially addresses issue #3430.
2016-10-09 14:38:26 -07:00
Kurtis Rader
851e449347 eliminate signed/unsigned comparison warnings
This partially addresses #3430.
2016-10-09 14:36:08 -07:00
Aaron Gyes
30e56c0237 Make calc_prompt_layout detect bright escapes 2016-10-09 07:37:39 -07:00
Aaron Gyes
5d4fffcae4 Remove nan() fallback
We stopped using nan() when @krader1961 changed the timef() function
a while back. I removed the autoconf check recently as well.
2016-10-09 07:09:52 -07:00
Aaron Gyes
22558f9e7b fix null pointer deref clang's static analyzer believes in
Check cur_term before exit_attribute_mode.
2016-10-07 15:43:59 -07:00
Aaron Gyes
b71aa8f9e8 wrealpath: fix compiler warning
unsigned long -> int conversion
2016-10-07 15:42:05 -07:00
Kurtis Rader
7fd3079bb6 remove one of the wrealpath() definitions
It is believed there are no longer any platforms we support that do not
support passing NULL as the second argument to realpath(). So rather
than duplicating the logic to get reasonable behavior from our
wrealpath() wrapper simply remove the redundant implementation.
2016-10-04 20:20:11 -07:00
Kurtis Rader
f7f39b8c90 make fish's realpath compatible with GNU realpath
After implementing `builtin fish_realpath` it was noticed that it did
not behave like GNU `realpath` without options. Which is super annoying
since that was the whole point of implementing the command. Major
failure on my part since I wrote the unit tests to match the behavior of
the existing `wrealpath()` function that I simply exposed as a builtin
command. Rather than actually verifying it behaved in a manner
compatible with GNU realpath.

Also, while the decision to call the builtin `fish_realpath` seemed to
make sense at the time of the original commit further reflection has
shown that to be a silly, idiosyncratic, thing to have done. So rename
it to simply `realpath`.

Fixes 3400
2016-10-04 20:19:44 -07:00
Kurtis Rader
d389b22afc make style-all C++ style cleanup
It's time once again to run `make style-all` to fix some style bogosities
that have crept in.
2016-10-04 20:06:14 -07:00
Aaron Gyes
d2739f10e1 Fix typo. 2016-10-03 15:28:36 -07:00
Aaron Gyes
a863f74fc4 Fix term_supports_color_natively() off-by-one
When max_colors is 16, we support up to color 15.
2016-10-03 15:25:44 -07:00
Aaron Gyes
41bf002049 Use bools in set_color()
This usage of ints is pretty common in pre-C++ fish code, which did
not use (c99) bool often.
2016-10-03 14:39:39 -07:00
Aaron Gyes
ce6e9b52ce screen.cpp: fix omitted newline char color on VCs
It's the ninth color - on virtual consoles this was likely to
try a color that doesn't work because we checked if max_colors >= 8.

Add another way to reach that color on terminals with only 8 colors
by using bold mode to get a bright.

This has potential to fail by simply rendering as black which can cause
it to be invisible on a white-on-black terminal. Not bad as it's just
making this bell/whistle invisible:

We *really* want to set the omitted newline character apart by having
it appear grey. On (FreeBSD consoles, at least) VCs it's not uncommon
for it to render as a "?". It's particularly confusing if it doesn't
render in a darker color as it cannot be discerned from actual program
output.
2016-10-03 12:51:21 -07:00
Aaron Gyes
0c23b5652a color 8 wasn't white, it's brblack
Fixes wrong comment.

Pick a better grey shade.
2016-10-03 08:48:09 -07:00
Aaron Gyes
40a83e4018 screen.cpp: try grey for the newline character.
what we really were using before was color 8 (white).
2016-10-03 05:57:49 -07:00
ridiculousfish
cd84587c3a Fix a "loop will execute at most once" warning 2016-10-01 18:03:44 -07:00
ridiculousfish
c0c2e1d4fa Don't modify valid directory segments in fuzzy completions
When performing fuzzy completion, if a directory segment is
valid, then don't consider it for a fuzzy match even if
the literal match produces no results.

Fixes #3211
2016-10-01 17:58:15 -07:00
ridiculousfish
d17f2585fa Revert "Tighten up empty string checks."
The use of wcstoimax causes certain out-of-range values
to be silently truncated (e.g. when converted to a pid),
and is incompatible with FreeBSD (see #626)

This reverts commit 6faa2f9866.
2016-10-01 17:21:40 -07:00
ridiculousfish
b05c09429d Revert "Add a template to parse integers easily/correctly (#3405)"
The template has different behavior around interpreting
non-decimal sequences. This doesn't seem to have been intended.

This reverts commit f843eb3d31.
2016-10-01 17:15:31 -07:00
ridiculousfish
7ec205d59c Remove some over-commenting for builtin_count_args
These comments were throwing warnings in Xcode
2016-10-01 16:55:33 -07:00
Kurtis Rader
92dd6de73c deal with broken unicode implementations
Both GNU and BSD have bugs regarding the classification of
non-characters and private use area characters. Provide wrappers around
iswalnum(), iswalpha(), and isgraph() to provide a consistent
experience. We don't bother to autoconf the use of these wrappers for
several reasons. Including the fact that a binary built for one distro
release should behave correctly on another release (e.g., FreeBSD 10
does the right thing while FreeBSD 11 and 12 do not with respect to
iswalnum() of code points in the range 0xFDD0..0xFDFF).

Also move a few functions from common.* to wutil.* because they are wide
char specific and really belong in the latter module.

Fixes #3050
2016-09-27 21:34:02 -07:00
Aaron Gyes
f843eb3d31 Add a template to parse integers easily/correctly (#3405)
* Adds a template to parse integers easily.

It's not enough to use intmax_t and check for empty strings: there are
limits. Adds a template to make it easy to parse an integer of any type.

Adds a compiler flag to flag existing dangers.

* nix warning, include <limits>, fix namespace error.

on MacOS `xcodebuild -quiet` will flag these intmax_t -> * conversions,
just use that if you want to find them.
2016-09-25 21:50:55 -07:00
Kurtis Rader
e9b5505169 add a flag to limit history search results
This adds a flag to the `history search` command to limit the number of
matching entries to the first "n". The default is unlimited. This is
mostly useful in conjunction with aliases (i.e., functions) that are
intended to report the "n" most recent matching history entries without
piping the result through the user's pager.

Fixes #3244
2016-09-23 19:43:58 -07:00
Aaron Gyes
c2a8de4873 Make fish find config directories in source tree
If one does a make fish; ./fish - don't use the make-installed paths.

Also, remove huge chunk of nearly duplicated code #ifdef'd __APPLE__
for relocatable dirs in fish.app: the directories under Resources
in the bundle followed by the changes I made around here a few months
ago now are not different enough that they require a special case.
This works fine for fish.app.
2016-09-23 11:52:51 -07:00
Aaron Gyes
503edf2d49 Report exec_path and the final config paths via debug()
I was surprised fish_indent was running from /usr/local/bin
instead of the git checkout when I ran ./fish
after building fish there. This was more easily noticable after my last
commit. I added some debug lines which probably fish could have been
doing already when looking into that.

This is a pretty major thing during fish initialization, commit it for
everyone.
2016-09-23 08:55:26 -07:00
Kurtis Rader
204e79105a allow customizing history --show-time format
It would make fish more friendly if we allowed the user to specify the
format of the history entry timestamps.

Fixes #3361
2016-09-20 20:14:02 -07:00
Kurtis Rader
76c73aa8ce alter history sub-command handling
This deprecates the use of long options for history sub-commands (e.g.,
`history --delete`) in favor of proper sub-commands (e.g., `history
delete`). It also eliminates the short options for those sub-commands.

Also change option processing to allow options anywhere on the command
line to match how the vast majority of fish builtins handle flags.

Replace --with-time with --show-time.

Fixes #3367
2016-09-18 20:09:06 -07:00
Aaron Gyes
f7c6426b21 Merge floam/colorfix #3260 2016-09-11 03:14:08 -07:00
Aaron Gyes
90e535f66f Update pager colors, tweak pager.cpp
Adds a color reset thing, to ensure fish tries to use hard colors during
testing.

Also, work on a discrepancy (not introduced by my changes, afaik) when
with some combinations of color settings, and usage of --bold, caused super
flakey color paninting in the pager. Downwards movements that trigger
scrolling vs. upwards movement in the pager would only apply bold to
selections when moving upwards. The bold state of the command completions in
the pager was flipping flops on and off, depending on if there is a description
on the preceding line.

Implement a lame fix by reseting the color to normal and applying a
different style on the rightmost ')' which seems to be what was influencing it.

Makes fish use terminfo for coloring the newline glich char.
2016-09-11 03:04:53 -07:00
Aaron Gyes
af95813514 Merge branch 'master' of https://github.com/fish-shell/fish-shell into colorfix 2016-09-10 15:09:12 -07:00
Aaron Gyes
ae32d0288b Remove fish_wcstoi decl - fix style 2016-09-10 14:56:43 -07:00
Aaron Gyes
b17ebb4551 Merge branch 'master' of https://github.com/fish-shell/fish-shell 2016-09-10 14:52:15 -07:00
Aaron Gyes
6faa2f9866 Tighten up empty string checks.
Fixes various spots throughout fish where broken strtoi checks
were converting empty strings to zero. Zero is not a valid pid and
this was causing breakage as well when input.

Nix fish_wcstoi - wcstoimax does the same thing.
Improve comments and some general cleanup.
2016-09-10 14:46:06 -07:00
Kurtis Rader
af0a2add10 fix check for unsupported op on BSD
Fixes #3362
2016-09-09 19:36:26 -07:00
Kurtis Rader
87a532f533 make it hard to use history command incorrectly
Fixes #3307
2016-09-09 19:23:06 -07:00
ridiculousfish
fa837a2e4a Prevent crash when reaping jobs in exit handlers
If an interactive job is started, and it is reaped within fish's
exit handler, we may attempt to print its status message after
cur_term has been set to NULL. This results in a crash.

This change makes fish only print the status message if cur_term is
not NULL.

Fixes #3222
2016-09-09 13:13:45 -07:00
Aaron Gyes
87fd9bca02 Group history items together with timestamps on separate line (#3333 from floam/historyout) 2016-09-07 07:57:06 -07:00
Aaron Gyes
3d6cb59b31 Use %Y-%m-%d %H:%M:%S format, update tests
Update history docs.

Note - the omission of a mention of timezone was intentional. These were recorded as naive timestamps lacking timezone information in the first place.
2016-09-07 07:52:45 -07:00
Aaron Gyes
6936e64b34 Show history timestamps on seperate lines #-prefixed.
Improves the grouping of multiline history entries
by sepearating the timestamps and history entires onto seperate lines.

Use wcsftime() Saves us a conversion, might as well.
2016-09-07 07:51:32 -07:00
Fabian Homborg
a0623e870b Only set bind mode if it changed
This is potentially costly (as functions listening for the variable will
be executed).

Fixes #3216.
2016-09-05 00:58:52 +02:00
Kurtis Rader
6b1801063b fix raw_string_to_scalar_type locale handling
Fixes #3334
2016-09-02 18:48:16 -07:00
David Adam
35bee00802 env_universal_common: drop MAP_FILE flag
MAP_FILE is unspecified or ignored on Linux, Solaris, FreeBSD and Haiku;
it is the default on OS X.

Work on #3317 & #3340.
2016-08-30 21:43:25 +08:00
Kurtis Rader
cfefaaf4ee revert the --shadow-builtin flag
Implementing the --shadow-builtin flag has proven to be highly controversial.
Revert the introduction of that flag to the `function` command. If someone
shoots themselves in the foot by redefining a builtin as a function that's
their problem and not our responsibility to protect them from doing so.

Fixes #3319
2016-08-24 22:56:19 -07:00
jscipione
a872d9c299 make sure p->ifa_addr is not NULL before using it 2016-08-23 20:33:49 -07:00
Kurtis Rader
df10ffab9c tell static code analysis we know what we're doing 2016-08-16 21:56:18 -07:00
Aaron Gyes
9b5625a66b Some doc omissions in complete.cpp
And undo a couple unrelated changes that came along.
2016-08-16 18:43:00 -07:00
Aaron Gyes
6f53709b65 Complete.cpp docs omissions
Missed a few. Add back an assert we didn't intend to remove
2016-08-16 18:34:42 -07:00
Aaron Gyes
9daffc7080 HeaderDoc code documentation improvements
Some cleanup too, move things to builtin.h from builtin.cpp that seem
to belong there.
2016-08-16 18:00:07 -07:00
Kurtis Rader
f3e93f0666 fix handling input in the C locale
In the C/POSIX locale EOF on the tty wasn't handled correctly due to a change
a few months ago to fix an unrelated problem with that locale. What is
surprising is that the core fish code doesn't explicitly depend on
input_common_readch returning WEOF if a character isn't seen within
`wait_on_escape_ms` after an escape.

Fixes #3214
2016-08-12 20:33:43 -07:00
Kurtis Rader
2dbc7ddcb8 fix bind command example given by fkr
The `fish_key_reader` program emits an example `bind` command for the sequence
of keystrokes it sees. However, if that sequence includes a space or del
character the example `bind` command includes extraneous commentary that makes
the command invalid.

Fixes #3262
2016-08-10 22:15:52 -07:00
Kurtis Rader
710addde16 fix history --delete regression
The recent change to reconcile the history builtin command and function
broke an undocumented behavior of `history --delete`. This change
reinstates that behavior. It also adds an explicit `--exact` search mode
for the `--search` and `--delete` subcommands.

Fixes #3270
2016-08-10 21:51:01 -07:00
Kurtis Rader
6c8ecab44b fix copy/paste bug in moving a block of code 2016-07-30 19:59:34 -07:00
Kurtis Rader
5da3d2f27b revert part of earlier "cleanup" change
Commit acfd3801 included a legitimate bug fix and a second change that
didn't correct an actual bug but made the code more fragile. Revert the
second part of that commit (while also suppressing the uninitialized
variable compiler warning that caused the ill-advised change).
2016-07-30 19:32:05 -07:00
Aaron Gyes
d51a1e4fe2 kill CAST_INIT, use reinterpret_cast<> on sockaddr
Just use static_cast directly instead of inscrutible "shortcut"
macro.

It was not always used and doesn't seem to do much besides scramble
things up; encountering CAST_INIT() in the code seems likely to lead
to head scratching due to the transformation taking place.

It was added to save folks typing the type twice, now with 100
columns available, let's roll that convenience macro back.

sockaddr_dl:

Perform reinterpret_cast<sockaddr_dl> conversion. The cast affected
alignment and looks fishy to a compiler (but it's fine). Ditch
C-style cast and communicate we're doing that on purpose.
2016-07-30 13:10:25 -07:00
Aaron Gyes
ee26eafc25 Ensure we continue to cover enums in switches
Where we already manage to cover an enum entirely in a switch
statement such that default: cannot be reached, help ensure
it stays that way by condemning that route.

Also adjust a 'const' I came across that is ignored.
2016-07-30 13:10:21 -07:00
Aaron Gyes
acfd380176 Fix two things -Wconditional-uninitialized warned about
Rather minor stuff:
* Initliaze first case to 0.
* The other (saved_errno), move the error output it is for
  in-scope and not need at all.
2016-07-30 03:34:46 -07:00
Kurtis Rader
3a08a24259 remove diagnostic no one likes 2016-07-28 16:15:58 -07:00
Kurtis Rader
375de96016 deal with missing argv
A user reported that fish was dying from a SIGSEGV when launched by the
sjterm terminal app. This was traced to a bug in sjterm passing an empty
argv array to the shell. Which, while technically legal, is very unusual
and a bad practice.

Fixes #3269
2016-07-27 16:38:18 -07:00
Aaron Gyes
5afd939f3e Stop swallowing the cartesian product
This should work:
 > env TERM=vt100 ./fish -c 'echo (set_color red)"hi"'

We do a ::reset() if setting the color doesn't happen.

Fixes #2951
2016-07-24 17:56:34 -07:00
Aaron Gyes
3669805627 Improve compatibility with 0-16 color terminals.
Fish assumed that it could use tparm to emit escapes to set colors
as long as the color was under 16 or max_colors from terminfo was 256::

 if (idx < 16 || term256_support_is_native()) {
    // Use tparm to emit color escape
    writembs(tparm(todo, idx);

If a terminal has max_colors = 8, here is what happenened, except
inside fish:

 > env TERM=xterm tput setaf 7 | xxd
   00000000: 1b5b 3337 6d                             .[37m
 > env TERM=xterm tput setaf 9 | xxd
   00000000: 1b5b 3338 6d                             .[39m

The first escape is good, that second escape is not valid.
Bright colors should start at \e[90m:

 > env TERM=xterm-16color tput setaf 9 | xxd
   00000000: 1b5b 3931 6d                             .[91m

This is what caused "white" not to work in #3176 in Terminal.app, and
obviously isn't good for real low-color terminals either.

So we replace the term256_support_is_native(), which just checked if
max_colors is 256 or not, with a function that takes an argument and
checks terminfo for that to see if tparm can handle it. We only use this
test, because otherwise, tparm should be expected to output garbage:

 /// Returns true if we think tparm can handle outputting a color index
 static bool term_supports_color_natively(unsigned int c) { return max_colors >= c; }
...

 if (term_supports_color_natively(idx) {

And if terminfo can't do it, the "forced" escapes no longer use the fancy
format when handling colors under 16, as this is not going to be compatible with
low color terminals. The code before used:

 else {
     char buff[16] = "";
     snprintf(buff, sizeof buff, "\x1b[%d;5;%dm", is_fg ? 38 : 48, idx);

I added an intermediate format for colors 0-15:

 else {
     // We are attempting to bypass the term here. Generate the ANSI escape sequence ourself.
     char buff[16] = "";
     if (idx < 16) {
         snprintf(buff, sizeof buff, "\x1b[%dm", ((idx > 7) ? 82 : 30) + idx + !is_fg * 10);
     } else {
         snprintf(buff, sizeof buff, "\x1b[%d;5;%dm", is_fg ? 38 : 48, idx);
     }

Restores harmony to white, brwhite, brblack, black color names.
We don't want "white" to refer to color color #16, but to the
standard color #8. #16 is "brwhite".

Move comments from output.h to output.cpp

Nuke the config.fish set_color hack for linux VTs.

Sync up our various incomplete color lists and fix all color values.
Colors 0-8 are assumed to be brights - e.g. red was FF0000. Perplexing!

Using this table:
 <http://www.calmar.ws/vim/256-xterm-24bit-rgb-color-chart.html>

Fixes #3176
2016-07-24 17:02:29 -07:00
Kurtis Rader
10ae6d8b26 fix some style problems that have crept in 2016-07-21 19:36:32 -07:00
Aaron Gyes
2fa4bd8fd7 Add missing debug output for two cases. 2016-07-21 07:23:14 -07:00
Aaron Gyes
3468fbc605 Tighten up support_term256 logic. Add missing Apple_Terminal underscore
Add some debug output like there is for 24bit mode.

I see now there is no need to setup terminal here - we get called early
sometimes for colors to work in config.fish to work but that is not so fatal.
Just check cur_term and trust get called again soon.
2016-07-21 07:10:00 -07:00
Kurtis Rader
8140f74d75 simplify oclint error suppression for scoped_buffer_t 2016-07-20 22:43:48 -07:00
Kurtis Rader
1d2fff9686 simplify oclint error suppression for scoped_lock 2016-07-20 22:30:58 -07:00
Kurtis Rader
b53f42970c correct handling of history args
This fixes several problems with how the builtin `history` command handles
arguments. It now complains and refuses to do anything if the user specifies
incompatible actions (e.g., `--search` and `--clear`). It also fixes a
regression introduced by previous changes with regard to invocations that
don't explicitly specify `--search` or a search term.

Enhances the history man page to clarify the behavior of various options.

This change is already far larger than I like so unit tests will be added
in a separate commit.

Fixes #3224.

Note: This fixes only a couple problems with the interactive `history
--delete` command in the `history` function. The main problem will be
dealt with via issue #31.
2016-07-20 21:18:48 -07:00
Aaron Gyes
4fbc476b19 Make the SnowLeopard exception only apply to SL.
Check TERM_PROGRAM_VERSION. It's < 300.0 on 10.6.
2016-07-19 08:53:55 -07:00
Aaron Gyes
9aad3781fb Check max_colors with rest of checks in input.cpp.
... with a terminal set up.
2016-07-19 08:02:00 -07:00
Aaron Gyes
23ea77be76 Fix term256 w/ max_colors=256 sans xterm/-256color
We were effectively inferring 256 color support **only**.
If terminfo reports 256 max_colors for this $TERM but
that is not named xterm or does not contain "256color" in name,
term256_support_is_native()'s result did not affect the recorded
support.

Noticed with Terminal.app set to nsterm, and a newer ncurses
with good terminfo for the terminal on modern OS X:

http://invisible-island.net/ncurses/terminfo.src.html#toc-_Apple__Terminal_app
2016-07-19 07:31:08 -07:00
Aaron Gyes
51e25e5a8d Add missing f_k_r includes 2016-07-18 08:47:37 -07:00
Kurtis Rader
20f28c2ef3 fish_indent --dump should deal with invalid code
Fixes #3241
2016-07-15 19:45:54 -07:00
ridiculousfish
f08ac969e9 Correctly handle trailing escaped spaces when completing
Fixes #2447
2016-07-11 14:03:53 -07:00
Aaron Gyes
1e27910b60 Merge branch 'master' of https://github.com/fish-shell/fish-shell 2016-07-11 01:49:13 -07:00
Aaron Gyes
09291735e6 Use locales preferred date format, fix up options
We don't seem to mention in the documentation that we were forcing
-t for all interactive uses. If we want to do that we should apply
that in the builtin.

history.fish reimplementing every option and doing things kind of
differently is a real pain and it's not clear if the docs are
referring to the or the wrapper script or both.
2016-07-11 01:45:30 -07:00
Kurtis Rader
512506f0f9 don't print internal token in error message
Attempting to execute something like `exec "$test"` results in a fish internal
token (a Unicode private use char) being printed in the resulting error
message. That's obviously not desirable as well as confusing.

Fixes #3187
2016-07-10 20:02:39 -07:00
Aaron Gyes
8cb560dc7e seems -t is what args.empty() tried to accomodate.
--with-time with no other arguments was showing no output.
2016-07-10 18:42:54 -07:00
Aaron Gyes
b2b327fec4 History's option handling broke --merge
Fixes #3220
2016-07-10 18:22:49 -07:00
ridiculousfish
ba12bcad33 Correctly set the generation count for background highlighting threads
Fixes #2789
2016-07-09 16:13:40 -07:00
ridiculousfish
8b06d2ad66 Untangle some fuzzy completion logic
Prior to this fix, when performing completions, we would prepend
the wildcard to the resulting files. When doing fuzzy completions,
we would take some wildcard segment, attempt to locate it in the
final completion, and then replace it with our fuzzy-matched directory.

With this fix, we pass along the "resolved so far" path, and prepend
that instead of doing "surgery" on the completion. This simplifies the
logic.

Fixes #3185
2016-07-09 15:27:10 -07:00
Kurtis Rader
14c7cfa84b make kill/pkill completions more robust (#3200)
Someone running fish in an unusual locale reported that an `assert()` was
firing when they typed `pkill c`. I traced it to two bugs. First, the
__fish_make_completion_signals command was producing a weird result. Second,
the builtin `complete` command wasn't adequately verifying its arguments.

Fixes #3129
2016-07-07 18:44:35 -07:00
Kurtis Rader
3c4e322ec1 make fish_indent options consistent with fish
Make `fish_indent`, `fish_key_reader` and `fish` recognize and assign
the same meaning to the `-d` and `-D` flags. Also, fix some errors and
stylistic issues in the associated man pages.

Fixes #3191
2016-07-05 20:22:44 -07:00
Aaron Gyes
f839282ac0 fish_key_reader had no -h output 2016-07-03 05:03:32 -07:00
Aaron Gyes
89c96c2114 Newline between fkr output should go to stderr 2016-07-03 02:16:39 -07:00
Aaron Gyes
86d9e5251a key_reader: status/diagnostic outputs to stderr
Remove isatty() check for stdout - this was added for both stdout
and stdin because "there is no reason to do that", but there is one:

Leaves only the bind command printed ot stdout, this allows
for one to do `fish_key_reader > bind_command.fish` to capture the bind
command while seeing the rest of the output.
2016-07-03 00:09:11 -07:00
Aaron Gyes
dff384e42d Fix fish_indent leaving colors set/messing up type
After the colorized syntax output in type -a foo, "foo is /usr/..."
would also be colored. (or 'test' in fish_indent foo.fish; echo test).

Make fish_indent reset the color when it's done.
2016-07-01 06:22:23 -07:00
Aaron Gyes
3d8e8a8715 Fix when fish isn't already installed
This was still wrong.
2016-07-01 04:34:04 -07:00
Aaron Gyes
af0f9e5308 Mispelling - surprised it didn't care. 2016-07-01 04:27:24 -07:00
Aaron Gyes
63120a9962 Fix fish_config in .app
* Copy docs into Resrouces
* Export $__fish_bin_dir
* Fix incorrect path in fish.cpp - fish is not in MacOS (it should be!)
2016-07-01 03:57:16 -07:00
Aaron Gyes
0045b46af8 Rename things to avoid conflicts with headers
Was breaking builds

 * ncurses.h: can declare `char *const key_name'.
 * netbsd term.h: has `newline', `lines' macros.
2016-07-01 02:48:50 -07:00
Kurtis Rader
68e167d576 f-k-r should use the user's locale
I did some research and experiments. For good or bad the `bind` command
requires the use of wide char codepoints (e.g., \u1234) for non-ASCII
chars.  So don't force the use of the POSIX locale, but do provide it as
an option for people who want to see the individual bytes rather than a
decoded wide char.

Simplify the format of the information displayed for each character. There
really isn't much point in providing decimal, octal, and hexadecimal. Just
print hex and symbolic representations.

Add an example `bind` command that a user can copy/paste.

Closes #3183
2016-06-30 20:49:56 -07:00
Kurtis Rader
262452d0b1 fix stupid copy/paste comment error from prev commit
When I fixed handling the TZ env var in commit dda890c I introduced a couple
of silly copy/paste comment errors. This corrects those comments.
2016-06-28 21:25:25 -07:00
Benjamin Barenblat
7e08679f1b history: Add option to show timestamps
Closes #677.
2016-06-28 19:46:54 -07:00
Kurtis Rader
dda890cf88 reset timezone state when TZ env var changes
When the TZ env var is modified change fish's internal timezone state.

Fixes #3181.
2016-06-28 18:06:39 -07:00
Aaron Gyes
44cde9e0e9 fish_key_reader #includes need to be updated 2016-06-28 02:57:14 -07:00
Kurtis Rader
d7bc20c933 don't allow f-k-r to run if stdin/stdout not a tty
Another developer noticed that redirecting stdin of `fish_key_reader`
results in weird behavior.  Which is not at all surprising. So add checks
to ensure stdin and stdout are attached to a tty.

Add some rudimentary unit tests for this program.
2016-06-26 21:51:00 -07:00
Kurtis Rader
e5011fbcdf fix fish_key_reader.cpp so it builds on linux 2016-06-26 17:38:19 -07:00
Kurtis Rader
0f5bfeead2 add more ways to exit fish_key_reader
A discussion on Gitter proposed allowing the user to signal their desire to
exit fish_key_reader by pressing \cC or \cD twice in a row. This implements
that.

I also decided to refactor how signals are handled. Most notably receiving a
signal will no longer print a diagnostic message unless you've enabled
debugging with `-d2` (or higher level).
2016-06-26 17:12:03 -07:00
David Adam
0f3b4d2bd8 Rewrite error messages for incorrect TERM 2016-06-26 16:24:01 +08:00
Kurtis Rader
046174397b fix setting the fish_key_reader locale
In addition to fixing the setting of the locale to C/POSIX this also
corrects several problems introduced by the commits made in the past
couple of days.  As a consequence of dealing with all of this I decided
to refactor the code to simplify one of the overly long functions I
introduced in my previous change.

Fixes #3168
2016-06-25 19:55:49 -07:00
Aaron Gyes
a6ec2dc3ed Remove oopsies while pasting.
(also, last commit log had a typo. "3.4.0-Microsoft" is the string we
should check for. Actual string in my code was correct.)
2016-06-25 01:10:58 -07:00
Aaron Gyes
6ec83568b5 Check for "Windows-3.4.0" as per MS's suggestion.
https://github.com/Microsoft/BashOnWindows/issues/545

Just looking for "Mirosoft" is rather general - we don't want to
enforce this strange behavior for Windows 12 (or the next beta.)
2016-06-25 00:31:46 -07:00
Kurtis Rader
b2a2705df4 croak if gettimeofday() fails
There is no conceivable way in which timef()'s invocation of gettimeofday()
can fail where it makes sense to continue running.  Yes, one such,
legitimate, failure mode is a 32-bit kernel and the date is greater than
2038-01-19 03:14:07. If you're running a fish binary on such a system
it's time to upgrade.  Otherwise, either the hardware or OS is broken.

Fixes #3167.
2016-06-24 19:32:46 -07:00
Aaron Gyes
0d6bdb38e6 Style fixes. 2016-06-23 22:48:45 -07:00
ridiculousfish
02cef2da23 history --merge to properly interleave items
Fixes #2312
2016-06-23 22:03:07 -07:00
Aaron Gyes
9c53019d95 fish_key_reader: ms were off by factor of ten.
Improve output.
2016-06-23 21:10:31 -07:00
Aaron Gyes
7a4065eb9f std::isnan() 2016-06-23 20:20:49 -07:00
Aaron Gyes
13eb302f3c proc_init() doesn't need to be called.
I don't know why I added that, that's how "bogosities" are born.
2016-06-23 18:28:49 -07:00
Aaron Gyes
6122ae83a6 Remove inadvertent change in fish_tests.cpp 2016-06-23 17:36:20 -07:00
Aaron Gyes
fa78a7101c Make IWYU output in lint.cpp less messy
And re-run IWYU, adjust #includes.
2016-06-23 17:26:08 -07:00
Aaron Gyes
290e936322 Fix up key_reader
* Correct notice about ^C
* Move time deltas to end of the line away from the important info on
  left.
* Use timef() instead of gettimteofday() ourselves
* Show time in ms (is this even useful in any unit? Maybe testing escape
  delays...)
* Make init more similar to other apps.
2016-06-23 07:43:55 -07:00
Aaron Gyes
db2c128b24 Fix crash with empty $TERM
```
~ $ set -e TERM; fish
Assertion failed: (!is_missing), function c_str, file src/env.cpp, line 690.
fish: 'fish' terminated by signal SIGABRT (Abort)
```
2016-06-21 10:30:53 -07:00
Kurtis Rader
8e21d5de92 deal with broken ttys on MS Windows
The tty device timestamps on MS Windows aren't usable because they're always
the current time. So fish can't use them to decide if the entire prompt needs
to be repainted.

Fixes #2859
2016-06-18 19:33:54 -07:00
Aaron Gyes
2cabcf4ad4 bg had also had wrong exit code for some errors
Stop printing usage information when error isn't a usage problem.
Add simple test for bg and fg
2016-06-18 08:26:07 -07:00
Aaron Gyes
20d36f16d3 fg: fix exit code (was 1 if success else 0)
returning a C boolean for builtin_fg success was backwards
2016-06-18 07:41:27 -07:00
Kurtis Rader
0ca103686f remove unset vars from the environment
Remove vars from the environment that are no longer set. Simplify the code by
removing an unnecessary loop. Add some tests.

Fixes #3124
2016-06-15 22:10:11 -07:00
Kurtis Rader
3cecc1f475 trivial locale cleanups
Clarify the purpose of the `N_()` macro. Remove inconsistent capitalization of
two strings in the parser module.
2016-06-14 19:57:07 -07:00
Aaron Gyes
9f0c31611c Lint Cleanup
This remove some stores that clang assures me are very dead.

And an assert() for an unlikely NULL pointer dereference I can't quite
figure out.
2016-06-14 19:27:00 -07:00
Kurtis Rader
d70be18c42 use fish_wcwidth rather than wcwidth
Minor cleanup related to issue #2199.
2016-06-14 17:17:31 -07:00
Aaron Gyes
1499ade89c Restyle touched .cpp files 2016-06-12 11:34:35 -07:00
Aaron Gyes
0310d3bd8c Improve fish_indent -w error output
Show small usage blurb, add newline to end.
2016-06-12 11:25:38 -07:00
Aaron Gyes
02375982df Hand-build 256, 24-bit color esc strings same way
... using snprintf() for the 256-color function in same manner as the
24-bit function.
2016-06-12 11:22:31 -07:00
Aaron Gyes
5435f60f31 Improve comments, update Doxyfile
Some changes were cribbed from #1317
2016-06-12 11:19:44 -07:00
Aaron Gyes
b72ed1fa8c Fix env_universal_common.cpp filesize comparisons.
* if (result == ULLONG_MAX) is always false, likely a typo as
  result is unsigned long, and the comment says ULONG_MAX.

* use off_t instead of size_t for file size where it can mismatch
  st_size's type in stat.h
2016-06-12 03:52:58 -07:00
ridiculousfish
3a7719015d Don't allow specifying an fd with a caret redirection
For example, an argument 12345^ is a real argument, not a redirection
There's no reason to use ^ here instead of >, and it's annoying to git
users.

Fixes #1873
2016-06-12 02:16:46 -07:00
Aaron Gyes
0ee03cbf98 Error on -w without a path before reading stdin
Oops, `fish_indent -w` just sits there waiting for input if nothing
is pointing at it, only to give user the error afterwards.
2016-06-12 01:07:33 -07:00
Aaron Gyes
c4e322d3ad Fix crash when fish_indent is using stdin with -w
When given no path, the logic was happy to try to use
an unitialized output_location.

  $ fish_indent -w < test.fish
  Opening "(null)" failed: Bad address

Initialize the string, and repair the logic to catch this case
and report the problem correctly.
2016-06-10 08:02:12 -07:00
Corey Ford
9d2092bf9f don't print header for each job 2016-06-08 21:15:07 -07:00
Aaron Gyes
7ef40f4e53 Merge pull request #3118 from floam/headerdoc-fixes
Update Xcode project, HeaderDoc comments.

Fix various invalid HeaderDoc comments.  Normalize autoload.cpp/autoload.h as an example of something closer to "proper" HeaderDoc formatting.

Have clang/Xcode validate HeaderDoc comments. Remove key_reader.cpp from Xcode project.
2016-06-05 21:42:01 -07:00