Commit Graph

7338 Commits

Author SHA1 Message Date
Mahmoud Al-Qudsi
34c2bf0f55 Using new complete --keep-order option for __fish_git_recent_commits
The primary motivation for --keep-order for `complete` was to support
something like commit history completions, which are returned by git in
reverse chronological order and make no sense alphabetically (they are
SHA1 hashes).

See https://github.com/fish-shell/fish-shell/issues/361 for more info.
2017-07-26 13:18:34 -07:00
Mahmoud Al-Qudsi
94041974e4 Added option to use completion source order without re-sorting
Introduce a -k/--keep-order switch to `complete` that can be used to
prevent fish from sorting/re-ordering the results provided by a completion
source.

In addition, this patch does so without doing away with deduplication
of completions by introducing a new unique_unsorted(..) helper function
that removes duplicates in-place without affecting the general order of
the vector/container.

Note that the code now uses a stable sort for completions, since the
behavior of is_naturally_less_than as of this patch now means that the
results are not necessarily _actually_ identical just because that function
repeatedly returns false for any ordering of any given two elements.

Fixes #361
2017-07-26 13:18:34 -07:00
Thales Mello
a071deaf61 Make npm run-script completion faster with jq (#4241)
* Make npm run-script completion faster with `jq`

When jq is available, it's actually faster to invoke jq and parse the `package.json`
invoking the `npm` command.

Also, prior to this commit, both `__fish_complete_npm` and `__fish_npm_run` were being run
whenever completions for `npm run` subcommand was being used, which was actually making
repetitive work (invoking npm command twice). This pull request is supposed to make completion
without `jq` faster as well

* Refactor npm.fish for code reutilization

Created function to handle both cases of npm run completion parse, with or without `jq` completion.

* Remove unecessary blank line
2017-07-26 13:31:35 +02:00
Kurtis Rader
1278cf2b6e document need for double-quotes around test args 2017-07-25 17:04:59 -07:00
Kurtis Rader
8e2d165756 document need for double-quotes around test args 2017-07-25 17:04:41 -07:00
Kurtis Rader
92f39f7b89 fix bug introduced by commit 86af63cd3 2017-07-25 14:03:40 -07:00
Kurtis Rader
35a7db50a2 fix bug introduced by commit 86af63cd3 2017-07-25 14:02:50 -07: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
54af9ace1a first step in refactoring the set implementation
The *src/builtin_set.cpp* code needs a major refactoring. This is the
first baby step in doing so.

Partial fix for #4236
2017-07-24 11:42:34 -07:00
Mohamed Akram
d2d707a6fa Ignore comments when creating man page completion 2017-07-22 21:32:56 -07:00
Rabah Meradi
f8fa69f817 Document how to erase a path from $PATH variable
Fixes #3161
2017-07-22 21:29:41 -07:00
Fabian Homborg
7304d82416 Fix file completion for tail 2017-07-22 14:09:34 +02:00
Raphael P
3fc0faaebb Update completions for heroku pg:backups
heroku pgbackups has been deprecated and replaced by heroku pg:backups command.
See: https://devcenter.heroku.com/changelog-items/623

Completion for new subcommand has been added as well.
2017-07-22 11:08:15 +02:00
Kurtis Rader
d068f846e8 simplify history function
The fix for #4232 allows us to simplify the `history` function slightly.
2017-07-21 16:26:15 -07:00
Kurtis Rader
d376cb316f simplify history function
The fix for #4232 allows us to simplify the `history` function slightly.
2017-07-21 16:25:03 -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
f3130ce70b 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:55:52 -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
Kurtis Rader
23c296f8d5 document first two fish 3.0 changes 2017-07-20 18:25:18 -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
c1ea9c7025 Document local-exported variable change
This is a bit minimal, but I'm not sure how often it should be mentioned.
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
Fabian Homborg
473dc16b2b Mark env_var_node as changing exports if it unexports an exported var
Fixes #2611 (hopefully).
2017-07-20 18:25:18 -07:00
Fabian Homborg
415c7ebbcc Fix local-exported vars with "--no-scope-shadowing"
This used to create copies even then, which meant it couldn't modify them.
2017-07-20 18:25:18 -07:00
Fabian Homborg
04205f36be Copy local-exported variables
When executing a function, local-exported (`set -lx`) variables
previously were not accessible at all. This is weird e.g. in case of
aliases, since

```fish
set -lx PAGER cat
git something # which will call $PAGER
```

would not work if `git` were a function, even if that ends up calling
`command git`.

Now, we copy these variables, so functions get a local-exported copy.

```fish
function x
    echo $var
    set var wurst
    echo $var
end
set -lx var banana
x # prints "banana" and "wurst"
echo $var # prints "banana"
```

One weirdness here is that, if a variable is both local and global,
the local-copy takes precedence:

```fish
set -gx var banana
set -lx var pineapple
echo $var # prints "pineapple"
x # from above, prints "pineapple" and "wurst"
echo $var # still prints "pineapple"
set -el var # deletes local version
echo $var # "banana" again
```

I don't think there is any more consistent way to handle this - the
local version is the one that is accessed first, so it should also be
written to first.

Global-exported variables are _not_ copied, instead they still offer
full read-write access.
2017-07-20 18:25:18 -07:00
Kurtis Rader
9ef47a43a4 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 17:54:06 -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
Fabian Homborg
627ce4ea34 Fix segfault related to getting the uvar pipe path
This tried setting $USER (again), but did it wrong.

Fixes #4229 TO THE MAXXX.
2017-07-20 20:18:07 +02:00
Fabian Homborg
e0f0164b16 Quote $USER when used with switch or test
Common in prompts, this would fail if $USER is empty.

See #4229.
2017-07-20 19:45:32 +02:00
Fabian Homborg
3b92d99277 Handle setting $HOME with missing $USER
Fixes #4229 harder.
2017-07-20 19:45:03 +02:00
Fabian Homborg
529ba30b1a Don't assert out if $HOME really cannot be found
In the rare case that we don't inherit $HOME _and_ can't read it from
/etc/passwd, this makes it so instead of triggering an assert() $HOME
is set to the empty list.

Tilde-expansion expands to nothing in such a case (and a string-empty
$HOME), `cd` errors out.

Fixes #4229.
2017-07-20 16:09:34 +02: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
8f548962b7 fix regression how fish_escape_delay_ms is handled
Fish 2.6.0 introduced a regression that keeps setting
`fish_escape_delay_ms` as a uvar from working. This also fixes a related
problem: callbacks generated from the initial loading of universal vars
were not being acted on.

Fixes #4196
2017-07-19 19:09:55 -07:00
Kurtis Rader
2d5b698f0b add entry about set -Ux to the FAQ
This was inspired by this stackoverflow question:
https://stackoverflow.com/questions/45119425/how-can-i-set-environment-variables-in-fish/
2017-07-19 13:21:56 -07:00
Kurtis Rader
9e08609f85 fix argparse --help
Also stop special-casing `printf` as if it were a syntactical keyword
with respect to handling `printf --help`. It should use the same pattern
as every other builtin command.
2017-07-19 12:19:40 -07:00
Kurtis Rader
f78ab085b5 Revert "argparse: let builtin_run() handle help."
This reverts commit bbc6bda843.
2017-07-19 11:13:59 -07:00
Aaron Gyes
bbc6bda843 argparse: let builtin_run() handle help.
Fixes #4228 and simplifies code a little. Most builtins shouldn't
need to do any work for -h/--help.
2017-07-19 07:23:40 -07:00
Kurtis Rader
0dc92fbb2d a make style-all cleanup 2017-07-18 22:40:25 -07:00
Kurtis Rader
5e2c14e7be fix a regression involving parser error output
The code for reporting parser errors needs a major overhaul. But rather
than do that I'm going to add another hack in the hope that this doesn't
introduce yet another problem.

Fixes #4221
2017-07-18 20:50:54 -07:00
Kurtis Rader
ed38db3370 refactor builtin_argparse to remove lint 2017-07-18 20:22:09 -07:00
Kurtis Rader
69ecda5082 update math to use the new argparse validation 2017-07-18 15:03:08 -07:00
Kurtis Rader
4e1303823b add ability for argparse to validate args
Fixes #4211
2017-07-18 14:42:50 -07:00
Fabian Homborg
2dfb615d7b Fix typo
Fixes #4225.
2017-07-18 23:37:14 +02:00
Kurtis Rader
403d9691cb fix handling of ssh aliases
Fixes #4213
2017-07-17 21:13:21 -07:00
Kurtis Rader
71af1a9566 don't die if read is invoked with no var names
Partial fix for #4220 by restoring the old behavior if no var name was
provided. But we still set an empty var if a var name was provided.
2017-07-17 14:54:43 -07:00