Commit graph

182 commits

Author SHA1 Message Date
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
Kurtis Rader
5092904ea3 fix bind unit tests
In my rush to get the fix for the wrong default Vi mode escape delay merged
(commit 3e24ae80b3) I neglected to update the
unit test. This change corrects that oversight.
2016-04-28 21:12:58 -07:00
Kurtis Rader
6c329e8a83 provide a realpath implementation
Not all distros have a `realpath` command. Provide a function that uses the
real command if available else use the fish builtin.

Fixes #2932
2016-04-28 16:03:27 -07:00
Fabian Homborg
7ebafa53f6 Tests: Add fish_mode_prompt to except_prompt
Without this, the interactive tests fail when they receive a mode_prompt
in vi-mode.
2016-04-26 15:21:15 +02:00
Kurtis Rader
0993141334 retry flakey tests on failure
Fixes #2926
2016-04-11 16:47:46 -07:00
Kurtis Rader
59f0261dba enhance fish_indent to normalize keywords
Fish keywords can be quoted and split across lines. Prior to this change
`fish_indent` would retain such odd, obfuscated, formatting. This change
results in all keywords being converted to their canonical form.

This required fixing a bug: the keyword member of parse_node_t wasn't being
populated. This hadn't been noticed prior to now because it wasn't used.

Fixes #2921
2016-04-10 18:40:11 -07:00
Jak Wings
2d5eaed745 fix handling of line continuation in keywords
This behavior is more consistent with line continuation in strings other
than keywords.

Fixes #2897
2016-04-08 21:05:46 -07:00
ridiculousfish
e395a0eb69 Migrate PATH-completion logic from complete.cpp to expand.cpp
Prior to this fix, when completing a command that doesn't have a /, we
would prepend each component of PATH and then expand the whole thing. So
any special characters in the PATH would be interpreted when performing
tab completion.

With this fix, we pull the PATH resolution out of complete.cpp and
migrate it to expand.cpp. This unifies nicely with the CDPATH resolution
already in that file. This requires introducing a new expand flag
EXPAND_SPECIAL_FOR_COMMAND, which is analogous to EXPAND_SPECIAL_CD
(which is renamed to EXPAND_SPECIAL_FOR_CD). This flag tells expand to
resolve paths against PATH instead of the working directory.

Fixes #952
2016-04-07 20:15:32 -07:00
Aaron Gyes
790c7f80c7 Implement an --invert/-v for string match, like grep -v.
Only lines that do not match the pattern are shown.
2016-04-08 10:49:29 +08:00
Kurtis Rader
02f18cae0a fix setting of $argv for source w/no args
Fixes #139
2016-04-06 13:04:44 -07:00
Kurtis Rader
4ff8e6e781 change how redirections are formatted
Modify `fish_indent` to emit redirections without a space before the target of
the redirection; e.g., "2>&1" rather than "2>& 1" as the former is clearer to
humans.

Fixes #2899
2016-04-05 19:29:23 -07:00
Kurtis Rader
c2f1df1d4a fix handling of non-ASCII chars in C locale
The relevant standards allow the mbtowc/mbrtowc functions to reject
non-ASCII characters (i.e., chars with the high bit set) when the locale
is C or POSIX.  The BSD libraries (e.g., on OS X) don't do this but
the GNU libraries (e.g., on Linux) do. Like most programs we need the
C/POSIX locales to allow arbitrary bytes. So explicitly check if we're
in a single-byte locale (which would also include ISO-8859 variants)
and simply pass-thru the chars without encoding or decoding.

Fixes #2802.
2016-03-20 18:47:38 -07:00
Kurtis Rader
8b67a1b26f make testing on local servers hermetic
I noticed while fixing issue #2702 that the fish program being tested
was sourcing config.fish files outside of the current build. This also
happens when Travis CI runs the tests but isn't an issue there because
of how Travis is configured to execute the tests.

I also noticed that running `make test` was polluting my personal fish
history; which will become a bigger problem if and when the fishd universal
var file is moved from $XDG_CONFIG_HOME to $XDG_DATA_HOME.

This change makes it possible for an individual to run the tests on
their local machine secure in the knowledge that only the config.fish and
related files from their git repository will be used and doing so won't
pollute their personal fish history.

Resolves #469
2016-02-25 17:16:36 -08:00
Michael Steed
5b0996fd80 make fish compatible with pcre2 10.21
pcre2_substitute() now sets the output buffer length to PCRE2_UNSET (~0)
if the output buffer is determined to be too small. This change keeps
track of the buffer size separately where pcre2 can't touch it.

A better fix would be to let pcre2 tell fish what size buffer it needs.
This can be done with PCRE2_SUBSTITUTE_OVERFLOW_LENGTH, but this
requires pcre2 10.21 or later (released January 12), which may be too
new to introduce as a dependency at this point.

Fixes #2743
2016-02-21 19:32:08 -08:00
Kurtis Rader
83d3c9fc04 fix flakey test
I've run this more than twenty times through Travis CI (by adding/removing
a comment line). Without this tweak the longest sequence seems to be
around six successful runs.
2016-02-16 11:40:40 -08:00
Andreas Nordal
62b76b26b4 Reinstate failglob behaviour for most commands
Expand globs to zero arguments (nullglob) only for set, for and count.

The warning about failing globs, and setting the accompanying $status,
now happens regardless of mode, interactive or not.

It is assumed that the above commands are the common cases where
nullglob behaviour is desirable.
More importantly, doing this with `set` is a real feature enabler,
since the resulting empty array can be passed on to any command.

The previous behaviour was actually all nullglob (since commit
cab115c8b9), but this was undocumented;
the failglob warning was still printed in interactive mode,
and the documentation was bragging about failglob behaviour.
2016-02-15 13:13:28 -08:00
ridiculousfish
4c5aa8860a Update bind.expect for travis-CI
Travis-CI runs with clang ASAN enabled, which makes fish slow enough
that certain timing tests fail. Sleep a little so that fish can
catch up.
2016-02-04 16:33:02 -08:00
ridiculousfish
25ad8866c9 Merge change for lengthened and configurable escape key timeout 2016-02-04 13:56:49 -08:00
Kurtis Rader
2646d51a0b change default escape timeout
This changes the default escape timeout for the default keybindings (emacs
mode) to 300ms and the default for vi keybindings to 10ms.

I couldn't resist fixing a few nits in the fish_vi_key_bindings.fish file
since I was touching it to set the escape timeout.
2016-02-04 13:39:19 -08:00
Kurtis Rader
4e465ee04c make travis-ci happy again 2016-02-04 13:38:55 -08:00
ridiculousfish
1b8face1a3 Fix t-binding test for new escape behavior 2016-02-02 18:13:08 -08:00
ridiculousfish
b4a44deb7b Merge branch 'fix-jump' of git://github.com/cpick/fish-shell into cpick-fix-jump 2016-02-02 17:00:27 -08:00
Kurtis Rader
11785c2bf4 make bind unit tests more robust on travis-ci
My previous commit failed in the travis-ci environment despite passing on my
local computer. This appears to be due to expect timing out looking for the
expected input. See if increasing the expect timeout slightly fixes the
problem.
2016-01-17 19:14:54 -08:00
Kurtis Rader
4b9fece9f4 allow configuring the escape delay timeout
Introduce a "fish_escape_delay_ms" variable to allow the user to configure the
delay used when seeing a bare escape before assuming no other characters will
be received that might match a bound character sequence. This is primarily
useful for vi mode so that a bare escape character (i.e., keystroke) can
switch to vi "insert" to "normal" mode in a timely fashion.
2016-01-17 17:45:30 -08:00
Fabian Homborg
ed1919b266 abbr: Ensure we don't split on "=" if the given separator is " "
This fails on e.g. an abbr that uses `env a=b`, like the included test demonstrates.

Unfortunately it decreases the speed again (2s vs 2.2s vs 4s original),
but correctness is more important.
2016-01-14 16:58:29 +01:00
Fabian Homborg
fdb2559425 abbr tests: Don't expect quoted "--*"
This doesn't seem necessary given we already prefix it with "--".

If this is backed out, the part about using string escape also needs to be removed.
2016-01-14 16:58:29 +01:00
Kevin Ballard
1dac0041d5 Stop unescaping strings with commandline -b
The fix for #2075 inadvertently started unescaping the strings emitted
from `commandline -b`. Only strings emitted with the `-o` flag are
supposed to be unescaped.

Fixes #2210.
2016-01-10 17:25:22 -08:00
Kurtis Rader
6969cfab3d fix unit tests related to the escape timeout 2015-12-23 21:41:48 -08:00
ridiculousfish
594b460ba2 Allow and/or statements to attach to the if/while header
For example:

  if false; or true; echo hello; end

will output 'hello' now.

Fixes #1428
2015-12-19 14:49:07 -08:00
ridiculousfish
0a6f62358b Write tests for new if/and/or behavior (#1428)
They fail for now.
2015-12-19 11:32:57 -08:00
Eugene Sharygin
5db811253e psub: add -s, --suffix 2015-11-14 13:15:30 +01:00
David Adam
d3bcee9e2e tests: try longer timeout in case setting fish_key_bindings is taking too long 2015-10-30 13:31:02 +08:00
ridiculousfish
d5f3a09ce9 Make 'set -ql' search up to function scope
Previously 'set -ql' would only look for variables in the
immediate local scope. This was not very useful. It's also
arguably surprising, since a 'set -l' in a function, followed
by a 'set -ql' in a child block, would fail. There was also no
way to check for a function-scoped variable, since omitting the
scope would also pull in global variables.

We could revisit this and introduce an explicit function scope.

Fixes #2502
2015-10-23 15:15:39 -07:00
David Adam
55abe105ea tests/bind.expect: re-enable but at human typing speed only
The interactive bind tests work if the keys are treated like there is a
human pressing them.

This reverts commit 0006d23df8.
2015-10-18 21:12:12 +08:00
Fabian Homborg
0006d23df8 Disable the bind test for now
This isn't pretty, but it fails for, as far as I can see, no _real_
reason.

It doesn't seem to be possible to trigger the failure in real usage, no
matter how fast you press the ESC key followed by something else.

So now this is known and constant travis emails don't help it in any way.
2015-10-18 14:14:22 +02:00
David Adam
0b3406bdc0 tests/string.in: add tests for string builtin 2015-10-09 11:27:18 +08:00
Fabian Homborg
b85a8bbbfe Rename sgrep to __fish_sgrep
Makes it harder to cause issues with aliases, see fish-shell#2245
2015-09-09 20:55:04 +02:00