Commit graph

4130 commits

Author SHA1 Message Date
Kevin Ballard
22fd8e65ad Disable fish_title on interactive tests
This was apparently what was interfering with the tests working on
Linux.

Tweak .travis.yml to install expect so the tests run on Linux.
2014-09-08 00:16:42 -07:00
Kevin Ballard
190712d4b0 Add a test harness for interactive behavior
Add a test harness that uses `expect` to drive Fish to test interactive
behavior.

Include some tests for `read`.
2014-09-07 23:56:59 -07:00
Kevin Ballard
efb1467e4e Cleanup fish tests a bit
Split `make test` into two targets `make test_low_level` and `make
test_fishscript`, primarily so fishscript tests can be rechecked quickly
after edits.

Reformat the test.fish file and update some of the code to be a little
more straightforward (e.g. `if not cmd` instead of `if cmd; else`).
2014-09-07 23:50:44 -07:00
Noah Frederick
8643a5e266 Clean up typos and style in design doc
This includes:

- Fixing some typos and misspellings
- Being consistent with pronouns (she/he)
- Hyphenating "built-in" and "command-line" where appropriate
2014-09-07 16:08:10 -07:00
David Adam
cb46ed3701 make_tarball: build from the current checkout, ignore Travis 2014-09-07 09:37:43 +08:00
Kevin Ballard
15cf06438e Suppress PATH errors in sudo tab-completion
Setting a non-existant path component to PATH logs an error to stderr.
This is not appropriate for non-interactive temporary modifications,
like the one done by the `sudo` completion helper function.
2014-09-04 13:22:06 -07:00
Iuri Rezende Souza
93b296d899 translations: Add portuguese translation 2014-09-04 23:00:22 +08:00
Iuri Rezende Souza
6e133c90e8 pager: translate additional strings 2014-09-04 23:00:22 +08:00
Kevin Ballard
4b7dc525b8 Fix the fix for commandline -i in binds 2014-09-03 23:05:48 -07:00
Joseph Tannhuber
4acea72700 New -n option for read builtin
Usage: read -n nchars
Reads maximum of nchars characters. If nchars <= 0, there's no limit.
2014-09-03 22:48:37 -07:00
Chris Wolfe
677cee44ad failiure/failure
Fix misspelling of failure in the fish shell design doc
2014-09-03 14:48:21 +02:00
Kevin Ballard
1c4223889b Fix test output for complete -e tests
GNU sort behaves stupidly when LC_ALL is not C. This caused the test
output to be sorted wrong.
2014-09-02 15:52:56 -07:00
Kevin Ballard
90a4fd34d2 Add tests for the various complete -e changes 2014-09-02 15:30:58 -07:00
Kevin Ballard
2820c7a9cd Erase all completions with complete -c foo -e
When passing `-e` to `complete -c foo` without any other options, all
options for the command should be erased.

Fixes #380.
2014-09-02 15:30:58 -07:00
Kevin Ballard
edd4f3d5ad Don't erase old-style options with complete -l foo -e
When erasing long option completions, distinguish between gnu-style and
old-style options, just like we do when adding and printing completions.
2014-09-02 15:30:58 -07:00
Kevin Ballard
aa7fe3b132 Don't erase all long opts with complete -e
When using `complete -c foo -l bar -e`, all long options for the command
were being erased because it was also comparing the short option, which
was 0.
2014-09-02 15:30:58 -07:00
Kevin Ballard
1d9886d0f7 Don't segfault when erasing short option completions
When using `complete -s x -e`, the long option is unspecified, which
makes it NULL. Comparing this to a `wcstring` segfaults.

Fixes #1182.
2014-09-02 15:30:51 -07:00
Konrad Borowski
1d0279eac5 Fix F1 binding to work with multiple tokens. 2014-08-30 11:18:56 +02:00
ridiculousfish
f8b21fe199 Merge pull request #1655 from xakon/master
Fix small typo in documentation
2014-08-29 23:21:34 -07:00
Christos Kontas
0f330d7226 Fix small typo in documentation 2014-08-30 08:03:24 +02:00
Nikolai Aleksandrovich Pavlov
cb29350954 Fix fish_vi_mode.fish 2014-08-29 13:15:13 -07:00
Kevin Ballard
7fce9e2411 Trim trailing newline on cmdsubst when IFS=''
When $IFS is empty, command substitution no longer splits on newlines.
However we still want to trim off a single trailing newline, as most
commands will emit a trailing newline and it makes it harder to work
with their output.
2014-08-29 12:48:45 -07:00
Kevin Ballard
cc52a59e1a Rework how screen size is tracked
The screen size is fetched after a SIGWINCH is delivered. The current
implementation has two issues:

* It calls ioctl() from the SIGWINCH signal handler, despite ioctl() not
  being a function that is known to be safe to call.
* It's not thread-safe.

Signals can be delivered on arbitrary threads, so we don't know if it's
actually safe to be modifying the cached winsize in response to a
signal. It's also plausible that the winsize may be requested from a
background thread.

To solve the first issue, we twiddle a volatile boolean flag in the
signal handler and defer the ioctl() call until we actually request the
screen size.

To solve the second issue, we introduce a pthread rwlock around the
cached winsize. A rwlock is used because it can be expected that there
are likely to be far more window size reads than window size writes. If
we were using C++11 we could probably get away with atomics, but since
we don't have that (or boost), a rwlock should suffice.

Fixes #1613.
2014-08-29 12:46:03 -07:00
Kevin Ballard
24ac7d2698 Fix commandline behavior in bind functions
When a key is bound to a fish function, if that function invokes
`commandline`, it gets a stale copy of the commandline. This is because
any keys passed to `self-insert` (the default) don't actually get added
to the commandline until a special character is processed, such as the
R_NULL that gets returned after running a binding for a fish command.

To fix this, don't allow fish commands to be run for bindings if we're
processing more than one key. When a key wants to invoke a fish command,
instead we push the invocation sequence back onto the input, followed by
an R_NULL, and return. This causes the input loop to break out and
update the commandline. When it starts up again, it will re-process the
keys and invoke the fish command.

This is primarily an issue with pasting text that includes bound keys in
it. Typed text is slow enough that fish will update the commandline
between each character.

---

I don't know of any way to write a test for this, but the issue can be
reproduced as follows:

    > bind _ 'commandline -i _'

This binds _ to a command that inserts _. Typing the following works:

    > echo wat_is_it

But if you copy that line and paste it instead of typing it, the end
result looks like

    > _echo wat_isit

With this fix in place, the pasted output correctly matches the typed
output.
2014-08-29 12:29:48 -07:00
Kevin Ballard
130619d6b0 Fix $SHLVL
Due to being read-only, SHLVL wasn't being incremented properly for
recursive invocations of fish.
2014-08-29 12:22:35 -07:00
Konrad Borowski
71ab40e536 Add Fossil command completions. 2014-08-29 14:19:55 +02:00
Philipp Klose
7638a7d531 Fix typo in German translation 2014-08-29 11:23:08 +02:00
Kevin Ballard
b92a09d5e7 Fix the assertion failure in expand_variables()
expand_variables() is slightly confused about how to handle last_idx. On
input, it expects it to be the index to start processing at, but when
called recursively it always passes the current index. This means that
it may sometimes pass an index 1 past the end of the input string.
Notably, that happens when typing something like

> echo "$foo

(where "foo" is any string that is not a prefix of some existing
variable name)

Fix this by explicitly defining last_idx as being the last processed
index, meaning the next index to process is actually last_idx-1. This
means we should call it with next.size() instead of next.size()-1.
2014-08-28 13:29:43 -07:00
Kevin Ballard
02a07164f3 Make commandline -P actually work
`commandline --paging-mode` worked but the short flags list accidentally
omitted the documented `-P`.
2014-08-24 14:47:05 -07:00
ridiculousfish
9419191aa6 Clean up variable expansion, and properly handle embedded NULs 2014-08-24 14:39:56 -07:00
ridiculousfish
f71b10df8c Don't suggest after | & or in comments
Fixes #1631
2014-08-24 14:39:41 -07:00
ridiculousfish
0b7735d279 Merge pull request #1630 from kballard/expand_variables_in_quoted_strings
Fix various expansions issues with variables
2014-08-23 16:13:25 -07:00
Konrad Borowski
1f3a93a3af
Fix the compilation under gcc 4.9.0.
gcc interpretes C99's compound literals more strictly by invalid the
compound literal on implicit to pointer cast (because of automatic
storage duration, 6.5.2.5.6 in C99 standard draft).

This fixes the issue by not using compound literals at all.
2014-08-22 21:52:41 +02:00
ridiculousfish
f9f773cc28 Comment on why we run 'false' in web_config.py 2014-08-22 12:04:23 -07:00
Kevin Ballard
d9bf53c6e5 Show a non-zero status in the fish_config prompt
When selecting a prompt with fish_config, render the prompt with a
non-zero status so the user knows what it looks like.
2014-08-22 12:00:16 -07:00
Kevin Ballard
f549ada16c Set up fish_{function,complete}_path properly
In the base config.fish, fish_function_path and fish_complete_path have
$__fish_datadir/{functions,completions} added to them if not already
present. For some reason they were replacing the final path component
instead of being added on to the end.
2014-08-22 11:54:58 -07:00
ridiculousfish
d8b955294a Add a test for syntax highlighting pipes 2014-08-22 11:53:20 -07:00
Kevin Ballard
8aad53556d Highlight pipe characters correctly
According to `fish_config`'s colors page, the pipe operator `|` is
supposed to be colored the same as a statement terminator.
2014-08-22 11:45:05 -07:00
Kevin Ballard
61ce9db4ba Make the alias built-in function work better
The new --wraps functionality was breaking aliases of the form
`alias foo='bar baz'`. That is, aliases where the body is multiple
words. Extract the first word of the body and use that instead.

Use better errors for aliases with no name or no body.
2014-08-22 11:40:59 -07:00
ridiculousfish
2da435712a Merge branch 'master' of github.com:fish-shell/fish-shell 2014-08-22 11:39:41 -07:00
Andy Lutomirski
9079ec459c webconfig: fixes for token security
* Use 16-byte tokens
 * Use os.urandom (random.getrandbits shouldn't be used for security)
 * Convert to hex correctly
2014-08-22 15:44:43 +08:00
Andy Lutomirski
aaddccfdb1 webconfig: Use a constant-time token comparison
This prevents a linear-time attack to recover the auth token.
2014-08-22 15:39:13 +08:00
ridiculousfish
033373f078 Merge branch 'make_type_better' of github.com:kballard/fish-shell into kballard-make_type_better 2014-08-21 21:36:39 -07:00
Kevin Ballard
d63db59ade Clean up the IFS handling in command substitution
Remove the useless ASCII test of the first byte of IFS. We don't split
on the first character, we only use a non-empty IFS as a signal to split
on newlines.
2014-08-21 20:57:23 -07:00
Kevin Ballard
20899f2df9 doc: Document how IFS affects command substitution
IFS is used for more than just the read builtin. Setting it to the empty
string also disables line-splitting in command substitution, and it's
done this for the past 7 years. Some day we may have a better way to do
this, but for now, document the current solution.
2014-08-21 20:57:23 -07:00
Kevin Ballard
b9948ca297 doc: Fix docs on $HOME/$USER
The docs claimed that the $HOME and $USER variables could only be
changed by the root user. This is untrue. They can be changed by
non-root users as well.
2014-08-21 20:57:23 -07:00
Kevin Ballard
f33e6a053e doc: Fix links in "Further help and development"
Hyperlink the mailing list to the proper info page.

Tweak the GitHub link to use https.
2014-08-21 19:15:58 -07:00
Kevin Ballard
9f725bee1f set: Print an error when setting umask to a bad value
Repurpose the ENV_INVALID return value for env_set(), which wasn't
currently used by anything. When a bad value is passed for the 'umask'
key, return ENV_INVALID to signal this and print a good error message
from the `set` builtin.

This makes `set umask foo` properly produce an error.
2014-08-21 19:06:21 -07:00
Kevin Ballard
2974025010 Fix error span for invalid slice indexes
The span now properly points at the token that was invalid, rather than
the start of the slice.

Also fix the span for `()[1]` and `()[d]`, which were previously
reporting no source location at all.
2014-08-21 01:10:07 -07:00
Kevin Ballard
9a90e041f3 Color "$foo[1" as an error
We can't color the whole argument as an error, since the tokenizer is
responsible for that and doesn't care abou this case, but we can color
the `$foo[` bit as an error.
2014-08-20 22:55:24 -07:00