Commit Graph

45 Commits

Author SHA1 Message Date
79182db587 Clean up which/which-support Cargo feature ()
* Rename "which" feature to "which-support"

* Ignore currently broken environment tests
2022-03-29 06:10:43 -05:00
a64e0956cd Support binary data to stdin of run-external ()
* Add test for passing binary data through externals

This change adds an ignored test to confirm that binary data is passed
correctly between externals to be enabled in a later commit along with
the fix.

To assist in platform agnostic testing of binary data a couple of
additional testbins were added to allow testing on `Value::Binary` inside
`ExternalStream`.

* Support binary data to stdin of run-external

Prior to this change, any pipeline producing binary data (not detected
as string) then feed into an external would be ignored due to
run-external only supporting `Value::String` on stdin.

This change adds binary stdin support for externals allowing something
like this for example:

  〉^cat /dev/urandom | ^head -c 1MiB | ^pv -b | ignore
  1.00MiB

This would previously output `0.00 B [0.00 B/s]` due to the data not
being pushed to stdin at each stage.
2022-03-27 15:35:59 +13:00
JT
7773c4cd4d Fix single quote external interpolation () 2022-03-18 19:59:28 +13:00
dfffd45bcd Streaming support for lines with raw streams () 2022-03-13 04:52:55 -07:00
JT
6e733f49bc Require block params ()
* Require block params

* Improve errors
2022-02-17 06:40:24 -05:00
JT
f9e1c4ef50 Use 'table' on scripts and -c commands ()
* Use 'table' on scripts and -c commands

* Fix tests

* Oops, missed a spot
2022-02-09 05:58:54 -05:00
JT
d70d91e559 Remove old nushell/merge engine-q 2022-02-07 14:54:06 -05:00
fdce6c49ab engine-q merge 2022-02-07 19:11:34 +00:00
JT
cc1b784e3d Add initial nu-test-support port ()
* Add initial nu-test-support port

* finish changing binary name

* Oops, these aren't Windows-safe tests
2022-02-02 15:59:01 -05:00
1794ad51bd Sanitize arguments to external commands a bit better ()
* fix 

We are passing commands into a shell underneath but we were not
escaping arguments correctly. This new version of the code also takes
into consideration the ";" and "&" characters, which have special
meaning in shells.

We would probably benefit from a more robust way to join arguments to
shell programs. Python's stdlib has shlex.join, and perhaps we can
take that implementation as a reference.

* clean up escaping of posix shell args

I believe the right place to do escaping of arguments was in the
spawn_sh_command function. Note that this change prevents things like:

^echo "$(ls)"

from executing the ls command. Instead, this will just print

$(ls)

The regex has been taken from the python stdlib implementation of shlex.quote

* fix non-literal parameters and single quotes

* address clippy's comments

* fixup! address clippy's comments

* test that subshell commands are sanitized properly
2021-11-29 09:46:42 -06:00
b32979bc84 ^ls doesn't exist on windows () 2021-07-06 13:14:48 -05:00
7cb9fddc11 Add Test Case for Special Character Paths ()
Added test cases that ensure that special characters in path names are passed
to external commands correctly. These cases have been implemented with rstest
to reuse existing test code.
2021-06-28 22:16:03 +12:00
6cdd8a2b07 Fix string interpolation is not working with external command () 2021-06-26 08:14:54 +12:00
JT
d9d956e54f Fix issue in external subexpression paths ()
* Fix issue in external subexpression paths

* new clippy dropped

* clippy
2021-06-18 07:59:58 +12:00
721f704260 Add support to run external command with string evaluation () 2021-06-14 12:20:07 +12:00
JT
a021b99614 Improve external quoting logic ()
* Add tests and improve quoting logic

* fmt

* Fix clippy ling

* Fix clippy ling
2021-06-09 08:59:53 +12:00
JT
25a8caa9b0 Simplify expressions ()
* WIP: experiment with simpler expressions

* fix simple invoke

* update tests

* fix a few tests

* Make paren parsing more robust

* fix external args

* Remove old invocation

* Update tests

* Update tests
2021-05-12 13:01:48 +12:00
JT
3ad4e0348f Fix external redirect ()
* Fix external redirection

* Fix external redirection
2021-04-22 08:54:34 +12:00
7e184b58b2 Fix warnings for Rust 1.51 ()
* Fix warnings for Rust 1.51

* More fixes

* More fixes
2021-03-26 21:26:57 +13:00
c13fe83784 Rename count to length ()
* update docs to refer to length instead of count

* rename count to length

* change all occurrences of 'count' to 'length' in tests

* format length command
2021-03-14 10:46:40 +13:00
0d305d7c3e Lines no longer treats a text buffer as a line () 2021-03-11 11:35:15 +13:00
6951fb440c Remove it expansion ()
* Remove it-expansion, take 2

* Cleanup

* silly update to test CI
2020-10-26 19:55:52 +13:00
6b4634b293 Convert table of primitives to positional arguments for external cmd ()
* Convert table of primitives to positional arguments for external cmd

* Multiple file test, fix for cococo
2020-07-23 09:41:34 +12:00
d8594a62c2 Add wasm support ()
* Working towards a PoC for wasm

* Move bson and sqlite to plugins

* proof of concept now working

* tests are green

* Add CI test for --no-default-features

* Fix some tests

* Fix clippy and windows build

* More fixes

* Fix the windows build

* Fix the windows test
2020-07-18 13:59:23 +12:00
180290f3a8 Remove custom escaping for external args. ()
Our own custom escaping unfortunately is far too simple to cover all cases.
Instead, the parser will now do no transforms on the args passed to an external
command, letting the process spawning library deal with doing the appropriate
escaping.
2020-07-03 11:29:28 +12:00
ed10aafa6f Bubble errors even if pipeline isn't used () 2020-06-30 05:39:11 +12:00
6ec6eb5199 Call external correctly. 2020-05-17 23:32:55 -05:00
f18424a6f6 Remove test-bins feature. 2020-05-17 23:32:55 -05:00
96e5fc05a3 Pick->Select rename. Integration tests changes. ()
Pick->Select rename. Integration tests changes.
2020-05-07 06:03:43 -05:00
a9968046ed Add subcommands. Switch from-* and to-* to them () 2020-05-04 20:44:33 +12:00
7d403a6cc7 Escape some symbols in external args ()
* Escape some symbols in external args

* Don't escape on Windows, which does its own

* fix warning
2020-04-30 16:54:07 +12:00
db8219e798 extend it-expansion to externals ()
* extend it-expansion to externals

* trim the carriage return for external strings
2020-04-30 07:09:14 +12:00
6f2ef05195 Resolves https://github.com/nushell/nushell/issues/1658 ()
For example, when running the following:

    crates/nu-cli/src

nushell currently parses this as an external command. Before running the command, we check to see if
it's a directory. If it is, we "auto cd" into that directory, otherwise we go through normal
external processing.

If we put a trailing slash on it though, shells typically interpret that as "user is explicitly
referencing directory". So

    crates/nu-cli/src/

should not be interpreted as "run an external command". We intercept a trailing slash in the head
position of a command in a pipeline as such, and inject a `cd` internal command.
2020-04-27 13:22:01 +12:00
1ec2ec72b5 Add automatic change directory ()
* Allow automatic cd in cli mode

* Set correct priority for auto-cd and add test
2020-03-18 07:13:38 +13:00
8925ca5da3 Move to bytes/string hybrid codec ()
* WIP: move to bytes codec

* Progress on adding collect helpers

* Progress on adding collect helpers

* Add in line splitting back to lines

* Lines outputting line primitives

* Close to ready?

* Finish fixing lines

* clippy fixes

* fmt fixes

* removed unused code

* Cleanup a few bits

* Cleanup a few bits

* Cleanup a few more bits

* Fix failing test with corrected test case
2020-03-07 05:06:39 +13:00
7304d06c0b Use threads to avoid blocking reads/writes in externals. ()
In particular, one thing that we can't (properly) do before this commit
is consuming an infinite input stream. For example:

```
yes | grep y | head -n10
```

will give 10 "y"s in most shells, but blocks indefinitely in nu. This PR
resolves that by doing blocking I/O in threads, and reducing the `await`
calls we currently have in our pipeline code.
2020-03-02 06:19:09 +13:00
8ae8ebd107 Add support for multiline script files ()
* Add support for multiline script files

* clippy
2020-02-13 21:24:18 -08:00
2ab8d035e6 External it and nu variable column path fetch support. () 2020-02-11 18:25:56 -05:00
fb532f3f4e Prototype shebang support ()
* Add shebang support to nu.

* Move test file

* Add test for scripts

Co-authored-by: Jason Gedge <jason.gedge@shopify.com>
2020-02-10 08:49:45 -08:00
a29d52158e Do not panic when failing to decode lines from external stdout () 2020-02-10 07:37:48 -08:00
dc50e61f26 Switch stdin redirect to manual. Add test () 2020-02-09 22:55:07 -08:00
798a24eda5 Soften restrictions for external parameters ()
* Soften restrictions for external parameters

* Add test
2020-01-25 08:14:49 +13:00
d38a63473b Improve shelling out ()
Improvements to shelling out
2020-01-24 08:24:31 +13:00
2b37ae3e81 Switch to using subprocess::shell ()
* Switch to using `shell`

Switch to using the shell for subprocess to enable more natural shelling out.

* Update external.rs

* This is a test with .shell() for external

* El pollo loco's PR

* co co co

* Attempt to fix windows

* Fmt

* Less is more?

Co-authored-by: Andrés N. Robalino <andres@androbtech.com>
2020-01-24 05:21:05 +13:00
29431e73c2 Externals now spawn independently. ()
This commit changes the way we shell out externals when using the `"$it"` argument. Also pipes per row to an external's stdin if no `"$it"` argument is present for external commands. 

Further separation of logic (preparing the external's command arguments, getting the data for piping, emitting values, spawning processes) will give us a better idea for lower level details regarding external commands until we can find the right abstractions for making them more generic and unify within the pipeline calling logic of Nu internal's and external's.
2020-01-16 04:05:53 -05:00