Commit graph

333 commits

Author SHA1 Message Date
Kurtis Rader
99d2a344c7 Fix indexing of $history
cherry-picked from krader1961/fish-shell commit b69df4fe72

Fixes #4353 (regression in indexing of history contents) and introduces
new unit tests to catch bad $history indexing in the future.
2017-08-25 20:28:45 -05:00
Kurtis Rader
c95b9f06e1 Implement support for bare vars by math
This change allows you to type `math x + 3` rather than `math $x + 3`.

Another step to resolving issue #3157.
2017-08-23 20:41:45 -07:00
Kurtis Rader
d10decabda Make builtin math the default implementation
Remove our `math` function that wraps `bc`. Our math builtin is now good
enough that it can be the default implementation.

Another step in resolving #3157.
2017-08-23 17:32:49 -07:00
Kurtis Rader
ba53242b26 Report error when using read-only var in for loop
Using a read-only variable like `status` as a for loop control variable
has never worked. But without this change you simply get non-sensical
behavior that leaves you scratching your head in puzzlement. This change
replaces the non-sensical behavior with an explicit error message.

Fixes #4342
2017-08-20 12:02:45 -07:00
Kurtis Rader
704517e237 Fix set --local when var is not in local scope
Fixes #4321
2017-08-19 21:39:21 -07:00
Kurtis Rader
f872f25f5b change env_var_t to a vector of strings
Internally fish should store vars as a vector of elements. The current
flat string representation is a holdover from when the code was written
in C.

Fixes #4200
2017-08-18 16:24:30 -07:00
Georgy Yakovlev
58425ed463 Do not redirect to / in status.in/err test. 2017-08-17 10:22:30 -07:00
Kurtis Rader
ea45541d53 fix set --show of semi-empty var
A semi-empty var is one with a single empty string element. The
`env_var_t::empty()` method returns true for such vars but we want
`set --show` to report that it has a single empty element.
2017-08-16 13:39:48 -07:00
peoro
5ceac038b1 Improved warning message when exiting with jobs still active
Fixes #4303
2017-08-14 18:18:09 -07:00
Kurtis Rader
728a4634a1 replace var_entry_t with env_var_t
This is a step to storing fish vars as actual vectors rather than flat
strings.
2017-08-14 18:18:09 -07:00
Kurtis Rader
67de733b9b implement set --append and set --prepend
Fixes #1326
2017-08-04 17:23:24 -07:00
Kurtis Rader
cddc4cfb1d fix set --show output
I realized I was printing individual var entries using zero based
indexing (like C++) when the indexes should be one based.
2017-08-04 17:08:25 -07:00
Kurtis Rader
9028104536 use new logmsg and set --show in tests 2017-08-04 13:36:51 -07:00
Kurtis Rader
2f1e70dc1b use new logmsg and set --show in tests 2017-08-04 13:33:47 -07:00
Kurtis Rader
a4ed0837a1 use new logmsg and set --show in tests 2017-08-04 12:51:48 -07:00
Kurtis Rader
e198ed0b2d use new logmsg and set --show in tests 2017-08-04 12:04:32 -07:00
Kurtis Rader
abc9be0250 use new logmsg and set --show in tests 2017-08-04 12:01:16 -07:00
Kurtis Rader
82ff27387a use new logmsg and set --show in tests 2017-08-04 11:41:51 -07:00
Kurtis Rader
03fa5dad12 use new logmsg and set --show in tests 2017-08-04 11:39:43 -07:00
Kurtis Rader
0c69e99d8b use new logmsg and set --show in tests 2017-08-04 11:02:11 -07:00
Kurtis Rader
26472593aa remove the now unused show test util function 2017-08-03 22:02:06 -07:00
Kurtis Rader
10fae1836e use new logmsg and set --show in tests 2017-08-03 22:02:06 -07:00
Kurtis Rader
864dbaeb43 use new logmsg and set --show in tests 2017-08-03 21:37:02 -07:00
Kurtis Rader
7619e62b70 use new logmsg and set --show in tests
Also modify `logmsg` to output additional separator lines to make the
demarcation between tests even clearer.
2017-08-03 21:25:20 -07:00
Kurtis Rader
ecf06f2eb4 use new logmsg and set --show in tests 2017-08-03 20:56:14 -07:00
Kurtis Rader
4197420f39 implement limits on command substitution output
This makes command substitutions impose the same limit on the amount
of data they accept as the `read` builtin. It does not limit output of
external commands or builtins in other contexts.

Fixes #3822
2017-08-03 17:40:25 -07:00
Kurtis Rader
e825415917 implement set --show
This adds a new capability to the `set` command. It is similar to
running `set` with no other arguments but provides far more detail about
each variable. Such as whether it is set in each of the local, global,
and universal scopes. And the values in each scope. You can also ask for
specific variables to be shown.

Fixes #4265
2017-08-03 15:49:52 -07:00
Kurtis Rader
b4ce749c69 the | tee /dev/stderr trick doesn't work on linux 2017-08-03 15:44:58 -07:00
Kurtis Rader
17dff8c569 rewrite abbr function
Rewrite the `abbr` function to store each abbreviation in a separate
variable. This greatly improves the efficiency. For the common case
it is 5x faster. For pathological cases it is upwards of 100x faster.
Most people should be able to unconditionally define abbreviations in
their config.fish without a noticable slow down.

Fixes #4048
2017-08-03 14:35:06 -07:00
Fabian Homborg
b1866b18dc Implement read --delimiter
This takes a string that is then split upon like `string split`.

Unlike $IFS, the string is used as one piece, not a set of characters.

There is still a fallback to IFS if no delimiter is given, that
behaves exactly as before.

Fixes #4156.
2017-07-28 12:15:46 +02:00
Kurtis Rader
0745f7dbe7 remove some uses of $IFS
This is a step towards resolving issue #4156. It replaces uses of `$IFS`
with other solutions.
2017-07-25 12:44:26 -07:00
Kurtis Rader
8e87d595b7 remove some uses of $IFS
This is a step towards resolving issue #4156. It replaces uses of `$IFS`
with other solutions.
2017-07-24 20:45:43 -07:00
Kurtis Rader
6f46f6b45a refactor set builtin
This completes the refactoring of the `set` builtin. It also removes a
seemingly never used feature of the `set` command. It also eliminates all
the lint warnings about this module.

Fixes #4236
2017-07-24 16:28:58 -07:00
Kurtis Rader
4f7a01af44 fix argparse handling of short flag only specs
@faho noticed that option specs which don't have a long flag name are
not handled correctly. This fixes that and adds unit tests.

Fixes #4232
2017-07-21 15:57:32 -07:00
Kurtis Rader
72968bec42 change how argparse handles boolean flags
When reporting whether a boolean flag was seen report the actual flags
rather than a summary count. For example, if you have option spec `h/help`
and we parse `-h --help -h` don't do the equivalent of `set _flag_h 3`
do `set _flag_h -h --help -h`.

Partial fix for #4226
2017-07-20 18:26:04 -07:00
Fabian Homborg
427b8f5c52 Comment and test that we shouldn't copy for blocks
Seems important.
2017-07-20 18:25:18 -07:00
Fabian Homborg
f2a6ae20e5 Test copying local-exported vars 2017-07-20 18:25:18 -07:00
Fabian Homborg
9ca6cb9fc8 Test that exported vars remain exported
I.e. the fix for #2611.
2017-07-20 18:25:18 -07:00
Kurtis Rader
4a7aa98e93 modify read to require at least one var
Fixes #4220
2017-07-20 13:07:30 -07:00
Kurtis Rader
2c77b24ced modify show test helper to work around BSD quirk
The BSD `seq` command handles `seq 0` weird.
2017-07-20 12:44:19 -07:00
Kurtis Rader
bb344bbd8f replace another custom show with the util func
Replace the `show_ary` function with the `show` test utility function.
2017-07-19 22:42:52 -07:00
Kurtis Rader
dc33c1afe1 change show test utility function
Due to how various tests show the status of variables I decided to
modify the `show` test utility function I recently added.
2017-07-19 22:28:24 -07:00
Kurtis Rader
4e1303823b add ability for argparse to validate args
Fixes #4211
2017-07-18 14:42:50 -07:00
Kurtis Rader
8f22def8f7 return to psub --file being the default
The recent change to switch `psub` to use `argparse` caused it to use
a fifo by default because it inadvertently fixed a long standing bug in
the fish script. This changes the behavior back to `psub --file` being
the default behavior and introduces a `--fifo` flag. It also updates the
documentation to make it clearer when and why `--fifo` mode should not
be used.

Fixes #4222
2017-07-17 14:33:51 -07:00
Kurtis Rader
3e226f0a5e implement a new implicit int option spec
While updating the `history` function to use `argparse` I realized it is
useful to define an option that can be used in three ways. First by
using the short flag; e.g., `-n NNN`. Second by using the long flag;
e.g., `--max NNN`. Third, as an implicit int flag; e.g., `-NNN`. This
use case is now supported by a spec of the form `n#max`.
2017-07-16 18:27:41 -07:00
Kurtis Rader
c22df3b823 update history to use argparse 2017-07-16 15:13:39 -07:00
Kurtis Rader
5dc78dd858 fix regression involving read from scripts
Fixes #4206
2017-07-15 21:21:24 -07:00
Kurtis Rader
f2c8e73891 add more alias unit tests
A recent regression to the `alias` command points out the need for more
unit tests of its behavior. I also decided to use it as an opportunity
to normalize the output of just `alias` to list aliases.
2017-07-15 17:36:36 -07:00
Kurtis Rader
98449fec51 fix math regression
The previous change to use `argparse` for parity with every other
builtin and function introduced a regression. Invocations that start
with a negative number can fail because the negative value looks like an
invalid flag.
2017-07-14 16:03:31 -07:00
Kurtis Rader
63d601610d implement -nnn style flags in argparse
This implements support for numeric flags without an associated short or
long flag name. This pattern is used by many commands. For example `head
-3 /a/file` to emit the first three lines of the file.

Fixes #4214
2017-07-13 20:36:59 -07:00