Commit Graph

404 Commits

Author SHA1 Message Date
ridiculousfish
d2bee105c9 Default math scale to 6
This changes the behavior of builtin math to floating point by default.
If the result of a computation is an integer, then it will be printed as an
integer; otherwise it will be printed as a floating point decimal with up to
'scale' digits past the decimal point (default is 6, matching printf).
Trailing zeros are trimmed. Values are rounded following printf semantics.

Fixes #4478
2018-08-04 15:32:09 -07:00
ridiculousfish
9d1fc1045e Implement 'functions -d' to set function description
This was documented, but didn't actually work.

Fixes #5105
2018-07-22 11:28:05 -07:00
ridiculousfish
73c747d162 Add string join0
string join0 joins its arguments using NUL byte, which complements
string split0. For example it allows piping a variable through sort -z.
2018-07-01 15:56:34 -07:00
ridiculousfish
d34a300818 Add string split0
This adds a new string command split0, which splits on zero bytes.
split0 has superpowers because its output is not further split on
newlines when used in command substitutions.
2018-07-01 15:56:33 -07:00
Fabian Homborg
81a987c39c Fix range expansion with negative ends
If just one of the range ends is negative, this now forces direction away from it.

I.e. if the beginning is negative, we go in reverse.
If the end is negative, we go forwards.

This fixes cases like

    $var[2..-1]

if $var only has one element.
2018-06-25 17:52:56 +02:00
Fabian Homborg
ca897807eb Add some tests for string and NUL 2018-05-28 12:10:40 +02:00
Mahmoud Al-Qudsi
7d33372d20 Fix __fish_complete_suffix behavior per __fish_complete_directories test 2018-05-20 14:35:52 -05:00
Fabian Homborg
c053065e91 Fix wait tests
This was probably the result of a botched merge.

Unfortunately these tests take quite a while, so maybe we should
remove some?
2018-05-11 16:58:55 +02:00
Fabian Homborg
7c5297e785
Merge branch 'master' into issue_4848 2018-05-11 16:06:27 +02:00
ridiculousfish
98d736f916 Teach fish_indent about escaped newlines
Correctly indents code like:

   alpha | \
     # comment
     beta
2018-05-07 21:40:53 -07:00
ridiculousfish
762c31be87 Feature flag support for ? wildcard
This partially reverts 6e56637cf0 and #4520
by bringing back the ? wildcard, guarded by the qmark-noglob feature flag.
2018-05-06 11:20:15 -07:00
ridiculousfish
dc8d603f98 Add a qmark-noglob feature flag
This adds a feature flag for controlling whether question marks are globs.
It is not yet hooked up.
2018-05-06 11:20:15 -07:00
ridiculousfish
902af26253 Bring back caret redirections under a feature flag
This partially reverts 5b489ca30f, with
carets acting as redirections unless the stderr-nocaret flag is set.
This flag is off by default but may be enabled on the command line:

fish --features stderr-nocaret
2018-05-06 11:20:14 -07:00
ridiculousfish
8a96f283ba Allow setting feature flags on the command line
This introduces a new command line option --features which can be used for
enabling or disabling features for a particular fish session.

Examples:
  fish --features stderr-nocaret
  fish --features 3.0,no-stderr-nocaret
  fish --features all

Note that the feature set cannot be changed in an existing session.
2018-05-06 11:20:14 -07:00
ridiculousfish
782cae2d21 Add status subcomannds: features and test-feature
This teaches the status command to work with features.
'status features' will show a table listing all known features and whether
they are currently on or off.
`status test-feature` will test an individual feature, setting the exit status to
0 if the feature is on, 1 if off, 2 if unknown.
2018-05-06 11:20:14 -07:00
Mahmoud Al-Qudsi
c2cfc65cf2 Correct read behavior for unset values and update tests accordingly
`read` with IFS empty was expected to set all parameters after the first
n filled variables to an empty string, but that was inconsistent with
the behavior of `read` everywhere else.

I'm not sure why fish differed from the spec with regards to the
behavior in the event of an empty IFS: we eschew IFS where possible, yet
here we adopt non-standard behavior splitting on every (unicode)
character instead of not splitting at all with IFS empty. We still do
that, but now the unset variables are treated as they normally would be,
i.e. cleared and not set to an empty string (which is what an empty
value between two IFS separators would contain).
2018-04-17 21:34:22 -05:00
Mahmoud Al-Qudsi
7ec761fc75 Revert "Fix wait test with no process expansion"
This reverts commit b38ac1e35d as wait now
supports process expansion (via the wait wrapper).
2018-04-14 21:42:57 -05:00
Fabian Homborg
ea49c14c62 Fix read to stdout output appearing first
echo banana (read)

will output whatever read reads _first_ because it uses a direct
write_loop().

This also removes some duplicate code.
2018-04-10 21:45:28 +02:00
Peter Ammon
5b489ca30f Remove caret redirection
This removes the caret as a shorthand for redirecting stderr.

Note that stderr may be redirected to a file via 2>/some/path...
and may be redirected with a pipe via 2>|.

Fixes #4394
2018-04-01 13:48:21 -07:00
Mahmoud Al-Qudsi
95e5af7814 fixup! Handle set -e result ENV_NOT_FOUND in tests 2018-03-31 22:25:38 -05:00
Mahmoud Al-Qudsi
95712125c9 Handle set -e result ENV_NOT_FOUND in tests 2018-03-31 22:21:22 -05:00
ridiculousfish
6e56637cf0 Remove support for the ? wildcard
Fixes #4520
2018-03-31 16:54:50 -07:00
ridiculousfish
4b079e16e5 Execute the conditions of if and while statements outside of their block
Variables set in if and while conditions are in the enclosing block, not
the if/while statement block. For example:

    if set -l var (somecommand) ; end
    echo $var

will now work as expected.

Fixes #4820. Fixes #1212.
2018-03-31 14:57:24 -07:00
ridiculousfish
669eafb55f Stop exporting empty variables as ENV_NULL
Localize the encoding of empty variables as ENV_NULL into the universal
variables component, and ensure they are not exported as ENV_NULL.

Fixes #4846
2018-03-24 23:42:09 -07:00
slama
233738d50a forget to set error message to the test with wait command in fish script. 2018-03-25 14:24:23 +09:00
slama
bb1956fd8d fix the problem that wait command doesn't work correctly in fish script. 2018-03-25 14:22:27 +09:00
slama
d078e47adc fix bug with test of wait command 2018-03-25 12:22:09 +09:00
slama
b758f84976 wait for processes by their name
- You can now specify the process name instead of process ids and wait for jobs.
- Refactor the code of wait command
2018-03-25 02:21:15 +09:00
Mahmoud Al-Qudsi
c0535b4e13 Fix $pid -> $fish_pid in signals.expect
This was a expect variable, not a fish one.
2018-03-24 12:15:58 -05:00
Mahmoud Al-Qudsi
6d80ab8d74 Rename $pid (née %self) to $fish_pid 2018-03-24 11:54:27 -05:00
Mahmoud Al-Qudsi
2951fadc6b Fix parameter expansion tests on Travis macOS 2018-03-12 07:50:37 -05:00
Mahmoud Al-Qudsi
1e5d7d98a8 Add tests for new parameter expansion features 2018-03-12 07:04:05 -05:00
Mahmoud Al-Qudsi
efb894fdae Fix read tests to reflect updated arguments 2018-03-09 12:19:20 -06:00
Mahmoud Al-Qudsi
b38ac1e35d Fix wait test with no process expansion 2018-03-09 10:50:43 -06:00
Fabian Homborg
2d08b5ee8a [math] Add tests for runtime errors
And fix "isinfinite" - it's called "isinf".
2018-03-07 18:13:26 +01:00
ridiculousfish
c7f16439bf Add support for ! as an analog to 'not'
! and not are effectively interchangeable now.
Mark them both as operators for syntax highlighting.
2018-03-05 14:04:49 -08:00
ridiculousfish
357d3b8c6d Rework 'and' and 'or' to be "job decorators"
This promotes "and" and "or" from a type of statement to "job
decorators," as a possible prefix on a job. The point is to rationalize
how they interact with && and ||.

In the new world 'and' and 'or' apply to a entire job conjunction, i.e.
they have "lower precedence." Example:

if [ $age -ge 0 ] && [ $age -le 18 ]
   or [ $age -ge 75 ] && [ $age -le 100 ]
   echo "Child or senior"
end
2018-03-05 13:41:36 -08:00
ridiculousfish
e1dafeab01 Add && and || support to the conditions of if and while
This updates the "boolean tail" feature of the if and while conditions
to know about job_conjunction, thereby respecting && and ||
2018-03-05 13:39:36 -08:00
ridiculousfish
8e9670ccd5 Implement execution of && and ||
This adds support for basic constructs. if and while is not yet
supported.
2018-03-05 12:20:56 -08:00
Mahmoud Al-Qudsi
9502ea8de3 Add tests for jobs -q 2018-03-04 15:33:36 -06:00
Fabian Homborg
0da8022081 [math] Fail without arguments
See #4768.
2018-03-01 22:27:24 +01:00
Fabian Homborg
f60e1549a9 [math] Better error for 2 + 2 4
This now reports "TOO_MANY_ARGS" instead of no error (and triggering
an assertion).

We might want to add a new error type or report the missing operator
before, but this is okay for now.
2018-03-01 13:09:35 +01:00
Fabian Homborg
6a38eb4f7d [math] Better error for 2 -
Instead of the catch-all, report too few arguments.
2018-03-01 13:09:35 +01:00
Fabian Homborg
20af969aba [math] Adjust tests for new error reporting
This shows how it's still weird - "2 - " and "max()" return the same
error.
2018-03-01 13:09:35 +01:00
ridiculousfish
973533e374 Teach alias about wrap argument injection
Update the alias function to pass arguments to 'wraps'. For example
alias gco='git checkout' now works like it ought to.
2018-02-27 14:12:44 -08:00
ridiculousfish
bb7b649132 Wrapping completions to allow injecting arguments
This enables some limited use of arguments for wrapping completions. The
simplest example is that complete gco -w 'git checkout' now works like
you would want: `gco <tab>` now invokes git's completions with the
`checkout` argument prepended.

Fixes #1976
2018-02-27 14:12:44 -08:00
Fabian Homborg
69f68d31df Reserve some builtin names
`argparse`, `read`, `set`, `status`, `test` and `[` now can't be used
as function names anymore.

This is because (except for `test` and `[`) there is no way to wrap these properly, so any
function called that will be broken anyway.

For `test` (and `[`), there is nothing that can be added and there
have been confused users who created a function that then broke
everything.

Fixes #3000.
2018-02-25 21:29:24 +01:00
slama
26ea8dc362 add tests for a pipe at the end of the line 2018-02-18 13:01:38 -08:00
ridiculousfish
c3f1961e36 Stop copying out function definition when executing a function
This switches function execution from the function's source code to
its stored node and pstree. This means we no longer have to re-parse
the function every time we execute it.
2018-02-12 10:55:00 -08:00
Fabian Homborg
aa31fb92f2 Skip interactive tests on macOS on Travis
These just add noise since Travis' macOS machines are apparently
hopelessly overloaded.

Fixes my sanity.
2018-02-06 18:54:27 +01:00