Commit Graph

218 Commits

Author SHA1 Message Date
Kurtis Rader
2e38cf2a4b implement means to learn about a functions source
This implements a way to use the `functions` command to perform
introspection to learn about the characteristics of a function. Such as
where it came from.

Fixes #3295
2017-01-20 21:48:41 -08:00
Kurtis Rader
5809608bd2 implement chunked reads
Provide a more efficient method for reading lines (or null terminated
sequences) when the input is seekable.

Another partial fix for #2007
2017-01-14 20:51:54 -08:00
Fabian Homborg
7ffcb828fe Add test for long numbers in math
This should catch the error in 26e781ef5a.
2016-12-29 14:00:15 +01:00
ridiculousfish
dce9453d25 Add a new completion test for optional arguments 2016-12-21 15:46:46 -08:00
Olivier Perret
1ace742b6c implement an improved random command
Fixes #2642
2016-12-20 16:46:33 -08:00
Kurtis Rader
9f8d854c2a fix race condition in fkr test 2016-12-19 17:44:54 -08:00
ridiculousfish
05a640b027 Increase test coverage and improve completion commenting 2016-12-09 12:14:35 -08:00
ridiculousfish
8e1661cd22 Add a test for complete and -- 2016-12-08 02:00:24 -08:00
Michael Steinert
e2ed561264 Fixes behavior of 'x' in normal mode
After 'x' is used to delete a character at the end of a line the cursor
should be repositioned at the last character, i.e. repeatedly pressing
'x' in normal mode should delete the entire string.
2016-12-01 16:23:59 -08:00
Radomír Bosák
1fbcb1ee9d Add the possibility to rename abbreviations
The abbr function doesn't have the possiblity to rename abbreviations.
You have to delete the old one and create a new one. This commit adds
this functionality and uses the syntax:

abbr -r OLD_KEY NEW_KEY

Fixes #2155.
2016-12-01 14:42:20 -08:00
Kurtis Rader
7cfe028b9d fix functions --copy
Fixes #3601
2016-11-28 18:04:37 -08:00
Kurtis Rader
54a76bb9e5 emit error message when test is given invalid int
This augments the previous change for issue #3346 by adding an error
message when an invalid integer is seen. This change is likely to be
controversial so I'm not going to squash it into the previous change.
2016-11-27 20:37:30 -08:00
Kurtis Rader
320cb6857f an invalid flag to function is handled wrong
Specifically, an invalid flag keeps the function from being defined but
does not emit an error message.

Fixes #2827
2016-11-22 16:17:51 -08:00
Kurtis Rader
acd8363c38 allow complete -d ''
There isn't a good reason to disallow an explicitly empty completion
description. Since I'm touching the code also modify the argument
parsing the match the style of most of the builtins.

Fixes #3557.
2016-11-17 14:53:50 -08:00
Kurtis Rader
2e81ade66a don't use set_color reset
There was a discussion recently on Gitter about `set_color reset`. The
result was @floam creating commit bd03c3fbc to change it to `set_color
normal` in share/functions/vared.fish. This does the same for
tests/test_util.fish.
2016-11-11 19:07:52 -08:00
Kurtis Rader
9e922a6e02 make status saner vis-a-vis arg parsing
The `status` command currently silently allows incompatible flags (i.e.,
subcommands). Too, using flags to specify subcommands misleads the user
into thinking they can specify multiple subcommands.

We recently modified the `history` command to deprecate using flags for
subcommands. This change does the same for the `status` command.

Fixes #3509
2016-11-07 12:11:08 -08:00
Kurtis Rader
f490b56378 make history searching case insensitive by default
Fixes #3236
2016-10-16 20:18:16 -07:00
Kurtis Rader
c07c98ac05 eliminate many "unused parameter" warnings
Partially addresses issue #3430.
2016-10-09 14:38:26 -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
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
93bea5b321 make unit tests more hermetic regarding env vars
Specifically, the `TERM` and `ITERM_PROFILE` env vars. If we don't set
them to known values the unit tests can fail in unexpected ways.

Fixes #3395
2016-09-19 22:13:55 -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
Kurtis Rader
87a532f533 make it hard to use history command incorrectly
Fixes #3307
2016-09-09 19:23:06 -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
Kurtis Rader
363fa0a598 make printf test resilient to missing locale
Another dev noticed that tests/printf.in was failing because they didn't have
the fr_FR.UTF-8 locale installed. Make that test more resilient by trying
other locales and if no suitable locale is found skipping the test.
2016-09-05 20:59:09 -07:00
Kurtis Rader
6b1801063b fix raw_string_to_scalar_type locale handling
Fixes #3334
2016-09-02 18:48:16 -07: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
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
Fabian Homborg
93b9e7443e Share some bindings between vi- and emacs-mode
This undoes the inheritance since it shared too much.

The idea here is to share bindings that aren't something the editors we're inspired by do - there's no "execute" in vi.
The basic editing and moving bindings are now vi-style in vi-mode and emacs-style in default mode.
2016-08-04 14:03:13 +02: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
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
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
2f0cb2a32b remove the tests/*.status files
The tests/*.status files aren't useful so eliminate them. Just verify whether
a given test module exited with a success status. There isn't any point in
having a "status" file that indicates the test module should exit with a
success (zero) status.

Closes #3208
Closes #3209
2016-07-06 21:37:29 -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
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
Aaron Gyes
7ab65595cb 'jobs.status' change missing from last commit. 2016-06-18 08:33:42 -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
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
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
Corey Ford
9d2092bf9f don't print header for each job 2016-06-08 21:15:07 -07:00
Kurtis Rader
0b385f145c simplify, and fix, setting the current locale
Fix test setup bogosities. Specifically, they weren't hermetic with respect to
locale env vars.

Rewrite the handling of locale vars to simplify the code and make it more like
the pattern most programs employ.

Fixes #3110
2016-06-05 15:49:34 -07:00
Beni Cherniavsky-Paskin
63a851cfd6 mention nullglob exceptions in failglob error msg 2016-06-02 19:51:19 -07:00
Fabian Homborg
8d6735cb41 Make string match -rnv work
Fixes #3098.
2016-05-31 23:24:08 +02:00
Kurtis Rader
d1208386d2 tty driver ignore lnext (\cV) and werase (\cW)
Configure the tty driver to ignore the lnext (\cV) and werase (\cW) characters
so they can be bound to fish functions.

Correct the `fish_key_bindings` program to initialize the tty in the same
manner as the `fish` program.

Fixes #3064
2016-05-25 12:05:39 -07:00
Fabian Homborg
8b44358c53 Bring abbr test in line with new behavior
Previously, `--erase` would not accept any options and wouldn't read
"--" as option-separator. Now it does like every other "command", and it
could conceivably gain e.g. a "--prefix" option.
2016-05-23 20:19:22 +02:00
Fabian Homborg
309e10e7a2 Don't mangle arguments in abbr
This now (rightly) throws an error if there's a space in the
key (because we can't store it).

Fixes #2997.
2016-05-23 19:59:02 +02:00
Kurtis Rader
73f2992a2e make debug() output more useful
This change does several things. First, and most important, it allows
dumping the "n" most recent stack frames on each debug() call. Second,
it demangles the C++ symbols. Third, it prepends each debug() message
with the debug level.

Unrelated to the above I've replaced all `assert(!is_forked_child());`
statements with `ASSERT_IS_NOT_FORKED_CHILD()` for consistency.
2016-05-17 14:52:55 -07:00
Kurtis Rader
51468b7646 add function --shadow-builtin flag
It's currently too easy for someone to bork their shell by doing something
like `function test; return 0; end`. That's obviously a silly, contrived,
example but the point is that novice users who learn about functions are
prone to do something like that without realizing it will bork the shell. Even
expert users who know about the `test` builtin might forget that, say, `pwd`
is a builtin.

This change adds a `--shadow-builtin` flag that must be specified to
indicate you know what you're doing.

Fixes #3000
2016-05-14 20:38:32 -07:00
Kurtis Rader
d97c22df2d add floating point output to math command
This makes it easy for the user to request floating point output with the
desired number of digits after the decimal point (not to be confused with
significant digits).

Note that this is just a thin wrapper so someone can say `math -s3 10 / 3`
rather than `math "scale=3; 10 /3"`.

Resolves #1643
2016-05-03 19:29:04 -07:00