Commit graph

8245 commits

Author SHA1 Message Date
ridiculousfish
3b2de931cd Simplify tokenize_variable_array() 2018-03-05 22:05:05 -08:00
ridiculousfish
37e748ad54 Remove an unused type 2018-03-05 21:58:22 -08:00
ridiculousfish
014b91488d Merge branch 'andand_oror_exclam'
This merges support for && || !

Fixes #4620
2018-03-05 14:14:34 -08:00
ridiculousfish
0938c9f427 Document && and || 2018-03-05 14:05:37 -08:00
ridiculousfish
9bb2d1e79f Note support for && || ! in CHANGELOG 2018-03-05 14:05:35 -08: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
f83742d579 Highlight && and || as operators
This also switches 'and' and 'or' to operators as well.
2018-03-05 13:51:05 -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
ridiculousfish
23d4f93556 Add && and || to fish grammar
This teaches the parser about && and ||, implemented via a new
production "job_conjunction".

These do not yet have execution support.
2018-03-05 12:20:56 -08:00
ridiculousfish
8ded041352 Add && and || support to tokenizer 2018-03-05 12:20:56 -08:00
ridiculousfish
a5dd96558f Remove special && and || error detection
Soon these will no longer be errors.
2018-03-05 12:20:56 -08:00
ridiculousfish
df4b03d859 Fix CMake documentation build path
This fixes a variety of issues related to building the documentation
with CMake. In particular it cleans up the dependency management and
fixes some issues where the documentation build was using generated
files from the source directory.
2018-03-05 12:13:34 -08:00
Mahmoud Al-Qudsi
a85d2bf27a Add intelligent package completion to yarn
Now parses package.json and uses results to provide a list of possible
completions to `yarn remove`. There may be other subcommands that could
benefit from this.

Could have parsed yarn output, but yarn is slow and packages.json format
is generally standard since it's machine-generated json.
2018-03-05 08:28:19 -06:00
Mahmoud Al-Qudsi
225f748f79 Add __fish_parent_directories helper function for completions
Can be used to retrieve a list of parent paths, useful for searching
ancestors recursively via their absolute paths. Paths are returned from
deepest to shallowest, starting from the path passed in. Paths are not
validated for performance reasons. (Usually the input to
__fish_parent_directories would be (pwd) or (dir $file).)
2018-03-05 08:25:25 -06:00
Mahmoud Al-Qudsi
2f2a221c56 Don't spawn keepalive for WSL when only one command
This should speed things up on slower PCs given that the vast majority
of shell commands are simple jobs consisting of a single command without
any pipelines, in which case there's no need for a keepalive process at
all. Applies to WSL only.
2018-03-04 21:54:12 -06:00
Mahmoud Al-Qudsi
000892e315 Use constexpr for is_windows_subsystem_for_linux()
To guarantee that at runtime there will be no branching, using a CMAKE
test/define combined with a constexpr wrapper for code-friendliness.
2018-03-04 21:13:31 -06:00
Mahmoud Al-Qudsi
cf8850a33f Add temporary fix for #4778 (background processes on WSL)
As a temporary workaround for the behavior described in
Microsoft/WSL#2997 wherein WSL does not correctly assign the spawned
child its own PID as its PGID, explicitly set the PGID for the newly
spawned process.
2018-03-04 20:18:38 -06:00
Mahmoud Al-Qudsi
912dbd85d8 Sprinkle in some job control asserts 2018-03-04 20:17:26 -06:00
Mahmoud Al-Qudsi
71329a250b [cmake] Don't create installation directories that already exist
fish's cmake install routines were attempting to create system
directories that already existed, an operation for which the permissions
to do so may not be available (e.g. /usr/local/share/pkgconfig)

This commit first checks if a directory exists before creating it.
2018-03-04 15:46:29 -06:00
Mahmoud Al-Qudsi
9502ea8de3 Add tests for jobs -q 2018-03-04 15:33:36 -06:00
Mahmoud Al-Qudsi
7242c40b5c Document new -q/--quiet flags to jobs builtin 2018-03-04 15:21:31 -06:00
Mahmoud Al-Qudsi
6814f29cd7 Add a -/--quiet option to jobs for silent evaluation 2018-03-04 15:20:14 -06:00
David Adam
99a34fe841 debian packaging: switch to CMake builds 2018-03-04 23:07:33 +08:00
David Adam
5beeb5280f license.hdr: update MIT license for Angular but not MuParser
[ci skip]
2018-03-04 19:41:30 +08:00
Fabian Homborg
0da8022081 [math] Fail without arguments
See #4768.
2018-03-01 22:27:24 +01:00
ridiculousfish
b49e1d7703 Minor cleanup
Mark a function as static and use a std::string instead of malloc.
2018-03-01 21:35:49 +01:00
Fabian Homborg
fd6a1a436b Merge branch 'tinyexpr-rebase'
This replaces muparser with tinyexpr, which

- Saves about 4000 lines
- Removes functionality we do not use, making it so we can document _all_ of it
- Should be more palatable to distributions
2018-03-01 13:10:08 +01:00
Fabian Homborg
84043e425d [math] Keep LC_NUMERIC=C for output as well
Otherwise, we'd have issues with people putting math's output back
into math because of "," vs ".".
2018-03-01 13:09:35 +01:00
Fabian Homborg
f20b6a1e8f [math] Document scientific notation 2018-03-01 13:09:35 +01:00
Fabian Homborg
642a1db4fc [math] Add two error strings as fallback 2018-03-01 13:09:35 +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
Fabian Homborg
0d9123ec91 [math] Return STATUS_CMD_ERROR when an error occured 2018-03-01 13:09:35 +01:00
Fabian Homborg
18bc2b0f4a Add tinyexpr to autotools build 2018-03-01 13:09:35 +01:00
Fabian Homborg
d90d0ee08e [tinyexpr] Let specific errors take precedence over generic ones
Fixes the case where `sin()` reported the generic "bogus" error
instead of "too few arguments".

Also rename the constant to "TE_ERROR_UNKNOWN".
2018-03-01 13:09:35 +01:00
Fabian Homborg
4f39cc4d82 [tinyexpr] Remove closures
These are only available as a customization point. Since we don't use
that, it's dead code.
2018-03-01 13:09:35 +01:00
Fabian Homborg
4f56ce6d33 [math] Improve error formatting
This looked like

    math: Error in expression
    'sin(5,4)'
          ^
    Too many arguments

Now it looks like

    math: Too many arguments
    'sin(5,4)'
          ^
2018-03-01 13:09:35 +01:00
Fabian Homborg
0fa0b620b3 [tinyexpr] Remove list()
This just read comma-separated expressions and returned the last of
them, which is useless and confusing.
2018-03-01 13:09:35 +01:00
Fabian Homborg
ea2934e644 [tinyexpr] Make unary functions fail with too many arguments
As it turns out, this was, for some reason, actual wanted behavior.

We _don't_ want it, so just remove the code.
2018-03-01 13:09:35 +01:00
Fabian Homborg
7b9c75094c [tinyexpr] Add error handling
This turns a bunch of ifs on their heads.

We often see this pattern in te:

```c
if (s->type != SOME_TYPE) {
   // error handling
}  else {
   // normal code
}
```

Only, since we want to return the first error, we do

```c
if (s->type == SOME_TYPE) {
    // normal code
} else if (s->type != TOK_ERROR) {
    // Add a new error - if it already has type error
    // this should already be handled.
}
```

One big issue is the comma operator, that means arity-1 functions can
take an arbitrary number of arguments. E.g.

```fish
math "sin(5,9)"
```

will return the value of sin for _9_, since this is read as "5 COMMA
9".
2018-03-01 13:09:35 +01:00
Fabian Homborg
b9a3938a2b [tinyexpr] Add change notice 2018-03-01 13:09:35 +01:00
Fabian Homborg
2ab1466c8f [tinyexpr] Remove #ifdefs
We don't use them, so we don't need them.
2018-03-01 13:09:35 +01:00
Fabian Homborg
ce28891c76 [math] Set LC_NUMERIC to C
This allows us to always use "." as radix character, so e.g.

    math 2.5 - 2

is always valid, regardless of locale.
2018-03-01 13:09:35 +01:00
Fabian Homborg
234ebb5d7b [math] Fix docs
We no longer use muparser, but tinyexpr.

tinyexpr does not have:

- "Statistical functions" like min, max, avg

- Multiple expressions separated with ","

[ci skip]
2018-03-01 13:09:35 +01:00
Fabian Homborg
b75c3b968c Replace muparser with tinyexpr 2018-03-01 13:09:35 +01:00
George Christou
6f1ae79a13 alias: Fix string args being parsed as options 2018-02-28 11:17:00 +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