Commit graph

389 commits

Author SHA1 Message Date
Johannes Altmanninger
7d5b44e828 Support FOO=bar syntax for passing variables to individual commands
This adds initial support for statements with prefixed variable assignments.
Statments like this are supported:

a=1 b=$a echo $b        # outputs 1

Just like in other shells, the left-hand side of each assignment must
be a valid variable identifier (no quoting/escaping).  Array indexing
(PATH[1]=/bin ls $PATH) is *not* yet supported, but can be added fairly
easily.

The right hand side may be any valid string token, like a command
substitution, or a brace expansion.

Since `a=* foo` is equivalent to `begin set -lx a *; foo; end`,
the assignment, like `set`, uses nullglob behavior, e.g. below command
can safely be used to check if a directory is empty.

x=/nothing/{,.}* test (count $x) -eq 0

Generic file completion is done after the equal sign, so for example
pressing tab after something like `HOME=/` completes files in the
root directory
Subcommand completion works, so something like
`GIT_DIR=repo.git and command git ` correctly calls git completions
(but the git completion does not use the variable as of now).

The variable assignment is highlighted like an argument.

Closes #6048
2019-11-25 09:20:51 +01:00
Z. Grace Moreau
012a3137df update CHANGELOG 2019-11-10 22:19:15 +01:00
David Adam
e1e82ecd40 CHANGELOG: work towards 3.1.0
Up-to-date to eac9ec90.

[ci skip]
2019-11-05 21:50:05 +08:00
Johannes Altmanninger
6fb7f9b6b8 Fix completion for builtins (with subcommands)
Presently the completion engine ignores builtins that are part of the
fish syntax. This can be a problem when completing a string that was
based on the output of `commandline -p`.  This changes completions to
treat these builtins like any other command.

This also disables generic (filename) completion inside comments and
after strings that do not tokenize.

Additionally, comments are stripped off the output of `commandline -p`.

Fixes #5415
Fixes #2705
2019-11-04 16:44:51 +01:00
David Adam
5f99ec7eae Merge branch 'changelog' of git://github.com/faho/fish-shell into faho-changelog 2019-11-04 22:53:40 +08:00
ridiculousfish
a7f1d2c0c7 Add support for fish_trace variable to trace execution
This adds support for `fish_trace`, a new variable intended to serve the
same purpose as `set -x` as in bash. Setting this variable to anything
non-empty causes execution to be traced. In the future we may give more
specific meaning to the value of the variable.

The user's prompt is not traced unless you run it explicitly. Events are
also not traced because it is noisy; however autoloading is.

Fixes #3427
2019-11-02 14:40:57 -07:00
Fabian Homborg
ab011b0c28 Overhaul CHANGELOG
This reorders many CHANGELOG entries.
The main idea is to keep the "NOTABLE fixes and improvements" for the headline items,
so a bunch of entries (like "Empty uvars can now be exported") are moved to more specific sections.

Other than that, there's some rewording, and the new feature flag is mentioned in Deprecations,
because that's effectively what it is.

[ci skip]
2019-10-31 20:08:32 +01:00
Amy Grace
ba56a2ec0e Add completions for irb (#6260) 2019-10-29 19:11:25 +01:00
LawAbidingCactus
21a6a192ae refactor gpg.fish completions
refactor gpg completions into functions
comment changes; improve gpg version detection

[ci skip]
2019-10-29 19:07:35 +01:00
ridiculousfish
2a92e66902 Support for &> and &| as convenience redirections
This adds support for &> and &| syntax, which both redirect stdout, and
also apply a redirection of stderr to stdout.
2019-10-27 15:24:57 -07:00
Akatsuki
0ef6a136e8 completions: add btrfs (#6243)
* completions: add btrfs
Completion definitions for the btrfs-progs.

* completes/btrfs.fish: using `not set -q argv[1]` instead of `test -z $argv`

* CHANGELOG: add btrfs completions
2019-10-26 18:15:42 +02:00
Z. Grace Moreau
b6fbec8107 update CHANGELOG 2019-10-26 18:13:15 +02:00
239
6a9ab0599f completion: zpaq archiver (#6245) 2019-10-25 15:22:09 +02:00
David Adam
4fbc6cd3f8 CHANGELOG: minor work on 3.1.0 2019-10-24 17:13:50 +08:00
Johannes Altmanninger
44c311b5df Update changelog 2019-10-24 11:06:19 +02:00
Z. Grace Moreau
8c9f3c7bd4 update CHANGELOG 2019-10-23 19:41:53 +02:00
Johannes Altmanninger
b7f35f949e Do not import vars that are equivalent to a universal exported var
Universal exported variables (created by `set -xU`) used to show up
both as universal and global variable in child instances of fish.

As a result, when changing an exported universal variable, the
new value would only be visible after a new login (or deleting the
variable from global scope in each fish instance).

Additionally, something like `set -xU EDITOR vim -g` would be imported
into the global scope as a single word resulting in failures to
execute $EDITOR in fish.

We cannot simply give precedence to universal variables, because
another process might have exported the same variable.  Instead, we
only skip importing a variable when it is equivalent to an exported
universal variable with the same name.  We compare their values after
joining with spaces, hence skipping those imports does not change the
environment fish passes to its children. Only the representation in
fish is changed from `"vim -g"` to `vim -g`.

Closes #5258.
This eliminates the issue #5348 for universal variables.
2019-10-19 12:41:57 +02:00
Johannes Altmanninger
5e274066e3 Always return absolute path in path_get_cdpath
Fixes #6220
2019-10-19 12:38:17 +02:00
Johannes Altmanninger
2fed311d4c builtin commandline: fix flags -p and -j not splitting on && and ||
Fixes #6214
2019-10-18 09:36:52 +02:00
Z. Grace Moreau
4c63ae357a update CHANGELOG 2019-10-15 13:05:08 -07:00
Johannes Altmanninger
9b86d5dd16 Export all local exported variables in a new scope
Fixes #6153
2019-10-06 12:10:21 -07:00
Fabian Homborg
eca1fcad90 CHANGELOG: Document the new binding changes
[ci skip]
2019-10-06 15:38:11 +02:00
Fabian Homborg
8bc44b2bff CHANGELOG: Introduce sub-headers for interactive improvements
These are just too many and too different to keep them under one heading.
2019-10-06 15:31:58 +02:00
David Adam
75bd821495 CHANGELOG: minor work on 3.1.0 2019-10-04 07:11:04 +08:00
David Adam
3ca4dbb2b9 CHANGELOG: work on 3.1.0
[ci skip]
2019-09-26 22:59:02 +08:00
David Adam
10f38c6865 CHANGELOG: work on 3.1.0
[ci skip]
2019-09-23 23:29:43 +08:00
ridiculousfish
6bbf3726fc Relnote expand-abbr and self-insert changes 2019-09-21 16:06:19 -07:00
ridiculousfish
d903fe6073 Relnote fix for #3189 2019-09-14 16:42:28 -07:00
David Adam
77ef2ef6c3 jobs: return success when a job is found via --last
Closes #6104.
2019-09-14 13:01:36 -05:00
LawAbidingCactus
35b64b0470 add completions for qubes-gpg-client 2019-08-27 15:20:07 +08:00
ridiculousfish
124def8f4b Un-changelog the history fix
Turns out the bug never actually shipped in a release; it bisected to
3ae5b23971
2019-08-15 19:59:35 -07:00
ridiculousfish
a87e0183df Stop rewriting the history file on every command
fish is designed to append to the history file in most cases. However
save_internal_via_appending was never returning success, so we were
always doing the slow rewrite path. Correctly return success.

Fixes #6042
2019-08-15 13:49:17 -07:00
Aaron Gyes
47798510bd tests, CHANGELOG: regex-easyesc
Oops, missed these the first time around.
2019-08-13 22:56:31 -07:00
LawAbidingCactus
1693b53221 document changes in CHANGELOG.md 2019-08-08 18:49:26 +02:00
Klaus Alexander Seistrup
28a17c4b05 Document that the : command now always exits successfully 2019-08-03 18:14:12 +02:00
Fabian Homborg
6500765256 Allow switch with something that expands to nothing
Meaning empty variables, command substitutions that don't print
anything.

A switch without an argument

```fish
switch
   case ...
end
```

is still a syntax error, and more than one argument is still a runtime
error.

The none-argument matches either an empty-string `case ''` or a
catch-all `case '*'`.

Fixes #5677.

Fixes #4943.
2019-07-31 14:08:28 +02:00
ridiculousfish
822b53c67a Don't color a whole string invalid because of an unclosed quote
When syntax highlighting a quoted string, if the string is not closed,
only show the opening quote as an error, not the whole string.
2019-07-24 12:43:47 -07:00
ridiculousfish
554ee240b3 Correct handling of explicitly separated output when all elements are empty
Previously when propagating explicitly separated output, we would early-out
if the buffer was empty, where empty meant contains no characters. However
it may contain one or more empty strings, in which case we should propagate
those strings.

Remove this footgun "empty" function and handle this properly.

Fixes #5987
2019-07-21 14:00:27 -07:00
ridiculousfish
e8c6de8055 Correctly export empty universal variables
Fixes #5992
2019-07-21 12:45:29 -07:00
ridiculousfish
d577eb4aaa Only use the global fish_complete_path and fish_function_path
Prior to this fix, fish would attempt to react if a local fish_complete_path
or fish_function_path were set. However this has never been very well tested
and will become impossible with concurrent execution. Always use the global
values.
2019-07-12 12:40:12 -07:00
Fabian Homborg
5133287873 CHANGELOG: List path_helper changes
Just replace the issue number because this is effectively a
replacement of the previous.

[ci skip]
2019-07-02 22:18:40 +02:00
Fabian Homborg
427a18c1ea fish_git_prompt: Add a way to use the informative chars
$__fish_git_prompt_use_informative_chars will use the informative
chars without requiring informative mode (which is really frickin'
slow!).

See #5726.

[ci skip]
2019-06-25 16:11:18 +02:00
Fabian Homborg
e921bd60c3 docs: Build index, tutorial and faq as man pages
This was clearly intended for index, but because it was called "fish"
it was overwritten by the "fish" command man page.

I also added the tutorial and faq. Both of those might not be *ideal*
as man pages (the tutorial makes references to colors that won't show
up), but it's better to provide them than not.

Hat-tip to @wwared

See #5521.

[ci skip]
2019-06-23 16:16:44 +02:00
Fabian Homborg
9b54a53758
Prevent not-yet-loaded functions from loaded when erased (#5951)
* Prevent not-yet-loaded functions from loaded when erased

Today, `functions --erase $function` does nothing if the function
hasn't been autoloaded yet.

E.g. run, in an interactive session

    > functions --erase ls
    > type ls

and be amazed that it still shows our default `ls --color=auto`
wrapper function.

This seems counter-intuitive - removing a function ought to remove it,
whether it had been executed before or not.

* doc/changelog
2019-06-22 11:08:36 +02:00
Lily Ballard
181e44d331 Invert the flag for string collect
Instead of requiring a flag to enable newline trimming, invert it so the
flag (now `--no-trim-newlines`) disables newline trimming. This way our
default behavior matches that of sh's `"$(cmd)"`.

Also change newline trimming to trim all newlines instead of just one,
again to match sh's behavior.
2019-06-16 16:40:14 -07:00
Lily Ballard
b41e5cbbb7 Add string collect
The `string collect` subcommand behaves quite similarly in practice to
`string split0 -m 0` in that it doesn't split its output, but it also
takes an optional `--trim-newline` flag to trim a single trailing
newline off of the output.

See issue #159.
2019-06-16 15:51:57 -07:00
Fabian Homborg
5e78d6dcc9 CHANGELOG math "x"
[ci skip]
2019-06-10 18:46:06 +02:00
Fabian Homborg
d1d5716ae1 CHANGELOG read history
[ci skip]
2019-06-06 19:14:11 +02:00
Fabian Homborg
77be5b05c6 CHANGELOG complete -F
[ci skip]
2019-05-30 19:20:15 +02:00
Fabian Homborg
97507a24a2 Increase default read limit to 100MiB
Someone has hit the 10MiB limit (and of course it's the number of
javascript packages), and we don't handle it fantastically currently.

And even though you can't pass a variable of that size in one go, it's
plausible that someone might do it in multiple passes.

See #5267.
2019-05-29 11:01:45 +02:00