Commit Graph

275 Commits

Author SHA1 Message Date
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