Commit Graph

441 Commits

Author SHA1 Message Date
Aaron Gyes
5fc17dcc82 Non-exported vars: rename SHLVL to shlvl
Fixes #4414
2017-10-15 04:33:27 -07:00
Aaron Gyes
7be8a1707c Rename FISH_READ_BYTE_LIMIT to fish_read_limit
Fixes #4414
2017-10-14 08:33:02 -07:00
Mahmoud Al-Qudsi
101ada83cb Fix unit tests for read to stdout behavior 2017-10-10 08:34:50 +02:00
Mahmoud Al-Qudsi
e99f137356 Merge branch 'master' into history-glob-search 2017-10-10 08:16:21 +02:00
David Adam
472e186c2b Rename FISH_HISTORY to fish_history
Work on #4414.
2017-09-24 14:07:45 +08:00
Kurtis Rader
65dcd06ca1 mplement history search glob searches
Instead of treating the search term as a literal string to be matched
treat it as a glob. This allows the user to get a more useful set of
results by using the `*` glob character in the search term.

Partial fix for #3136
2017-09-15 13:43:45 -07:00
Kurtis Rader
ee1d310651 Implement history search --reverse (#4375)
* Implement `history search --reverse`

It should be possible to have `history search` output ordered oldest to
newest like nearly every other shell including bash, ksh, zsh, and csh.
We can't make this the default because too many people expect the
current behavior. This simply makes it possible for people to define
their own abbreviations or functions that provide behavior they are
likely used to if they are transitioning to fish from another shell.

This also fixes a bug in the `history` function with respect to how it
handles the `-n` / `--max` flag.

Fixes #4354

* Fix comment for format_history_record()
2017-09-14 15:44:17 -07:00
Kurtis Rader
905766fca2 Hoist for loop control var to enclosing scope (#4376)
* Hoist `for` loop control var to enclosing scope

It should be possible to reference the last value assigned to a `for`
loop control var when the loop terminates. This makes it easier to detect
if we broke out of the loop among other things.  This change makes fish
`for` loops behave like most other shells.

Fixes #1935

* Remove redundant line
2017-09-08 21:14:26 -07:00
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
Kurtis Rader
c149f4f301 add argparse unit tests and fix some bugs
This implements some unit tests for the new `argparse` command and fixes
a couple of bugs those tests brought to light.

Fixes #4190
2017-07-12 22:38:32 -07:00
Kurtis Rader
a4dc2b872b implement fish_opt helper command
This implements a `fish_opt` command that provides a way for people
to create option specs for the `argparse` command as an alternative to
creating such strings by hand.

Fixes #4190
2017-07-12 22:38:32 -07:00
Kurtis Rader
80df9053b3 count -h should report 1
The count command should not treat any flag specially. Not even `-h` and
`--help`. It should simply return a count of the number of arguments it
received.

Fixes #4189
2017-07-05 17:24:34 -07:00
Kurtis Rader
e4aedcd22c check that TMPDIR is set before using it 2017-07-04 13:56:35 -07:00
Kurtis Rader
f3d025bd75 always define argv for scripts
Found when testing what breaks when dereferencing undefined vars is an
errors (#4163).

Fixes #4181
2017-07-03 16:58:14 -07:00
Kurtis Rader
d383e3b92c define the var when the read limit is exceeded
This problem was found when testing the change for issue #4163 to make
dereferencing an undefined variable an error.

Fixes #4180
2017-07-03 16:14:28 -07:00
Kurtis Rader
d51f82d1b5 fix bug in test3
The change for issue #4163 brought to light a bug in tests/test.in.
2017-07-03 15:36:38 -07:00
Kurtis Rader
b759ba8a3d harden test3 against undef vars
This is only needed if we make undefined vars an error as proposed in
issue #4163 but it's a good idea anyway.
2017-07-03 15:21:42 -07:00
Kurtis Rader
0ec9acf0f0 harden abbr against undef vars
This is only needed if we make undefined vars an error as proposed in
issue #4163 but it's a good idea anyway.
2017-07-03 13:05:50 -07:00
Kurtis Rader
763063e741 more changes to better handle undef vars
This is only needed if we make undefined vars an error as proposed in
issue #4163 but it's a good idea anyway.
2017-07-03 10:16:31 -07:00
Kurtis Rader
ec14527545 don't import bash history if not default fish hist
Don't import the bash history if the user has specified that a non-default
fish history file should be used. Also, rename the var that specifies
the fish history session ID from `FISH_HISTFILE` to `FISH_HISTORY`.

Fixes #4172
2017-06-30 20:24:55 -07:00
tomassedovic
aec0973196 Make the history session configurable
Using the FISH_HISTFILE variable will let people customise the session
to use for the history file. The resulting history file is:

    `$XDG_DATA_HOME/fish/name_history`

Where `name` is the name of the session. The default value is `fish`
which results in the current history file.

If it's set to an empty string, the history will not be stored to a
file.

Fixes #102
2017-06-30 17:13:02 -07:00
Charles Ferguson
bf2a9f3835 Fix for bad-switch test failing on Darwin; system-specific output.
Because the 'getopt' library differs between systems, it's likely
that there will be different output. This is the case between the
GNU-based Linux and the BSD-based Darwin, for the 'getopt' library,
it seems. It causes the tests to produce different results.

To allow us to test, and check for regressions, on the different
platforms, the invocation code has been updated to allow a
system-specific suffix to be used on the test files. If this suffix
is found, the test will also be flagged as being system-specific
which should ensure the change in behaviour is noted.
2017-06-29 21:00:08 -07:00
Charles Ferguson
8d83c967d3 Support reporting diffs even when colordiff is not present.
The Travis macOS test systems do not appear to have colordiff present, so any
failures would mean that no output would be shown. This may also be a
problem for the other test scripts as well, but the invocation tests are
the ones being affected here.

We change our behaviour to downgrade to the plain diff tool if colordiff is
not present.
2017-06-29 21:00:08 -07:00
Charles Ferguson
cc24485503 Add documentation into the 'tests/invocation.sh' script.
The invocation tests were not especially clear on how they should be
used, without reading the code. And who really wants to do that? So,
a description of what the test does (and thus what each file is) is
now present in the file prologue comment.
2017-06-29 21:00:08 -07:00
Charles Ferguson
eb8b92fce7 Add tests for some other command line option invocations.
Some more of the invocations are tested in this change:

  - bad switches
  - errors in configuration files
  - regular command, configuration and init command ordering
  - persistence of variables over command invocation.
  - interactive and login switch use
  - terminal exit code return
  - version request

There are sure to be other invocations that should be tested, but
these give a fair number of them a go.
2017-06-29 21:00:08 -07:00
Charles Ferguson
3f129b570c Add test harness for fish command invocation, and tests for init command.
The new '-C' initial command needs some tests, and as there are no
tests just yet for the command invocation, this change adds a harness
and calls it from the high-level tests in the Makefile.

The tests are similar in style to the other high level tests, in that
we capture the output and compare it to that which we expect. The
harness itself is written in bash - sorry - because we're testing the
fish shell's invocation, and trying to do that with the fish we've
just built wouldn't actually make for a very useful test when things
go wrong.

The 'tests/invocation.sh' script can be executed manually, or as part
of the 'make test' target, to make it easy to use both as part of the
development and as part of automation.

The harness has only been tested on linux with bash 4.3.11, and requires
grep and sed. Although not tested with OS X, I believe I have avoided
the syntax which is inconsistent.

The tests added here cover just the initial command's basic execution,
and when it is mixed with the regular '-c' command.
2017-06-29 21:00:08 -07:00
Kurtis Rader
f3cb625802 implement string unescape
Fixes #3543
2017-06-23 22:23:01 -07:00
Kurtis Rader
60bca14b37 implement string escape --style=xxx
We need a way to encode arbitrary strings into valid fish variable
names. It would also be nice if we could convert strings to valid URLs
without using the slow and hard to understand `__fish_urlencode` function.
In particular, eliminating the need to manipulate the locale.

Fixes #4150
2017-06-23 22:23:01 -07:00
Kurtis Rader
30368d5526 implement status function when in a breakpoint
Another step to fixing #1310. This changes means that `status -L0
function` reports the correct function when inside a breakpoint.
2017-06-23 22:14:21 -07:00
Fabian Homborg
897dba9f07 Ignore too large indices in parse_slice
Fixes #4127.
2017-06-20 17:52:31 -07:00
Fabian Homborg
44f2f37bd4 Remove "Array index out of bounds" errors
This just removes every invalid index.

That means with `set foo a b c` and the "show" function from tests/expand.in:

- `show $foo[-5..-1]` prints "3 a b c"
- `show $foo[-10..1]` prints "1 a"
- `show $foo[2..5]` prints "2 b c"
- `show $foo[1 3 7 2]` prints "3 a c b"

and similar for command substitutions.

Fixes #826.
2017-06-20 17:52:23 -07:00
Kurtis Rader
bd299e96b2 implement status is-breakpoint
This implements `status is-breakpoint` that returns true if the current
shell prompt is displayed in the context of a `breakpoint` command.

This also fixes several bugs. Most notably making `breakpoint` a no-op if
the shell isn't interactive. Also, typing `breakpoint` at an interactive
prompt should be an error rather than creating a new nested debugging
context.

Partial fix for #1310
2017-06-20 17:18:59 -07:00
Kurtis Rader
2302db4dc7 add unit test for echo -h 2017-06-18 22:25:00 -07:00
Kurtis Rader
422b1bd066 split builtin bg into its own module 2017-06-16 21:01:56 -07:00
Kurtis Rader
f6c9bfc0e8 implement string lower and string upper
Fixes #4080
2017-06-10 17:35:25 -07:00
Kurtis Rader
c75c6b4204 fix typo in unit test 2017-06-09 13:35:00 -07:00
Kurtis Rader
6c4a51d56e improve bash history importing
Reject more invalid commands from the bash history file.

Fixes #3636
2017-05-20 21:03:31 -07:00
Kurtis Rader
e6e1805c5f another step in fixing issue #3985
This changes all of the builtins to behave like `string` to return
STATUS_INVALID_ARGS (121) if the args passed to the command don't make
sense. Also change several of the builtins to use the existing symbols
(e.g., STATUS_CMD_OK and STATUS_CMD_ERROR) rather than hardcoded "0"
and "1" for consistency and to make it easier to find such values in
the future.

Fixes #3985
2017-05-07 21:20:31 -07:00
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
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
David Adam
4fde67fa50 implement disown builtin
Closes #2810.

The syntax mirrors that of zsh.
2017-04-29 19:20:03 +08: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
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
Fabian Homborg
c0d80ab996 Tighten MANPATH test
This is to fix tests on Travis, since that stores the commit message in an environment variable.

`env | grep MANPATH` of course picks it up and generates unwanted output.

Yes.
2017-04-18 22:42:38 +02:00
Kurtis Rader
3ade72266c fix bug I introduced by previous squash merge
When I squash merged to create commit a9db99ac5 I overlooked updating
the unit test.
2017-04-17 21:23:03 -07:00
Ivan Trubach
a9db99ac52 Rename replace-one to replace_one
Fixes invalid character in variable name $fish_cursor_replace-one (used by fish_vi_cursor[_handle]) by renaming bind mode 'replace-one' to 'replace_one'.
2017-04-17 21:10:23 -07:00
Kurtis Rader
0be8d0d385 another __fish_sgrep replacement 2017-04-13 23:14:36 -07:00
Kurtis Rader
ef313dc8c5 a step to remove __fish_sgrep per issue #2450 2017-04-11 21:53:13 -07:00
Kurtis Rader
c272584fec a step to remove __fish_sgrep per issue #2450 2017-04-11 21:46:46 -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
da09a915f2 improve __fish_complete_directories function
Reviewing a PR for a completion script caused me to look at the
implementation for the `__fish_complete_directories` function. Which in
turn lead me to create this change to improve its implementation and add
unit tests for the function.
2017-04-11 13:45:53 -07:00
Kurtis Rader
75600b6b53 fix setenv and add unit tests
Fixes #3937
2017-04-05 15:31:13 -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
Kurtis Rader
62244f01c2 fix umask handling of symbolic modes
This fixes the handling of symbolic umask values. It also removes two
invocations of `perl` and all but two `math` commands.

Fixes #738
2017-03-28 16:28:24 -07:00
Fabian Homborg
70354f9f5e Add bind --list-modes option
Fixes #3872.
2017-03-20 16:42:53 +01: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
1afea1b650 add description to functions -m -v output
Fixes #597
2017-03-13 20:52:31 -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
Kurtis Rader
7a9efa7930 tweak gitignore rules for *tests* directory 2017-02-20 20:29:43 -08:00
Kurtis Rader
9dd0c47d0b harden alias against foo; bar
If the first word of the alias body ends with a semicolon we need to
strip that character, and otherwise escape the extracted command, to
ensure the subsequent function definition is valid.

Fixes #3860
2017-02-20 20:23:55 -08:00
Kurtis Rader
992e1d0059 use a consistent ERANGE message
The previous change neglected to consider that numbers too large for the
long long datatype will result in calling strerror(ERANGE) whose return
value can vary depending on the platform. Which breaks the unit test.
2017-02-20 18:43:13 -08:00
Kurtis Rader
3d0a377e26 correct printf handling of %x with long ints
Fixes #3352
2017-02-20 17:58:08 -08:00
Kurtis Rader
af7f5f42b6 put upper bound on data read will consume
This puts a hard upper bound of 10 MiB on the amount of data that read
will consume. This is to avoid having the shell consume an unreasonable
amount of memory, possibly causing the system to enter a OOM condition,
if the user does something non-sensical.

Fixes #3712
2017-02-09 21:04:46 -08:00
Kurtis Rader
0541a34201 improve bash command history importing
Fixes #2091
2017-02-08 20:50:57 -08:00
Kurtis Rader
44cfe3e340 remove dependency on xxd
Fixes #3797
2017-01-31 22:10:53 -08:00
Kurtis Rader
06282f02fd don't run fish_update_completions in unit tests
Running `fish_update_completions` in unit tests is not needed and
hideously expensive. To the point it can cause flakey test behavior.
2017-01-29 18:00:48 -08:00
Kurtis Rader
a447a9aeff correct handling of SIGHUP by interactive fish
This is a partial fix for issue #3737. It only addresses the SIGHUP
aspect of the problem. Fixing SIGTERM is TBD.
2017-01-24 15:24:13 -08:00
Kurtis Rader
64485167e9 Revert "correct handling of SIGHUP by interactive fish"
This reverts commit 31adc221d9.
2017-01-24 07:34:15 -08:00
Kurtis Rader
31adc221d9 correct handling of SIGHUP by interactive fish
This is a partial fix for issue #3737. It only addresses the SIGHUP
aspect of the problem. Fixing SIGTERM is TBD.
2017-01-23 19:42:27 -08:00
ridiculousfish
812e977e62 Clean up /tmp/fish_chunked_read_test.txt after tests 2017-01-21 12:47:05 -08:00
ridiculousfish
5a5a6a6968 Correctly handle multiple chunks from read_in_chunks
read_in_chunks does not clear the intermediate string 'str'
between iterations, so every chunk has every other chunk prepended
to it.

A secondary issue is that it calls str2wcstring() on an intermediate
chunk, which may split multi-byte sequences. This needs to be deferred
to the end.

Test added. Fixes #3756
2017-01-21 12:43:20 -08:00
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