2021-01-12 04:59:53 +00:00
|
|
|
[package]
|
2022-03-22 20:25:38 +00:00
|
|
|
authors = ["The Nushell Project Developers"]
|
2022-04-11 18:17:06 +00:00
|
|
|
description = "Nushell's built-in commands"
|
2022-03-22 20:25:38 +00:00
|
|
|
edition = "2021"
|
|
|
|
license = "MIT"
|
2021-01-12 04:59:53 +00:00
|
|
|
name = "nu-command"
|
2023-02-11 18:59:11 +00:00
|
|
|
repository = "https://github.com/nushell/nushell/tree/main/crates/nu-command"
|
2024-11-14 09:04:39 +00:00
|
|
|
version = "0.100.1"
|
2021-12-11 20:08:17 +00:00
|
|
|
|
2021-09-02 01:29:43 +00:00
|
|
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
|
|
|
2023-02-12 22:22:00 +00:00
|
|
|
[lib]
|
|
|
|
bench = false
|
|
|
|
|
2024-08-28 21:37:17 +00:00
|
|
|
[lints]
|
|
|
|
workspace = true
|
|
|
|
|
2021-09-02 01:29:43 +00:00
|
|
|
[dependencies]
|
2024-11-14 09:04:39 +00:00
|
|
|
nu-cmd-base = { path = "../nu-cmd-base", version = "0.100.1" }
|
|
|
|
nu-color-config = { path = "../nu-color-config", version = "0.100.1" }
|
|
|
|
nu-engine = { path = "../nu-engine", version = "0.100.1" }
|
|
|
|
nu-glob = { path = "../nu-glob", version = "0.100.1" }
|
|
|
|
nu-json = { path = "../nu-json", version = "0.100.1" }
|
|
|
|
nu-parser = { path = "../nu-parser", version = "0.100.1" }
|
|
|
|
nu-path = { path = "../nu-path", version = "0.100.1" }
|
|
|
|
nu-pretty-hex = { path = "../nu-pretty-hex", version = "0.100.1" }
|
|
|
|
nu-protocol = { path = "../nu-protocol", version = "0.100.1" }
|
|
|
|
nu-system = { path = "../nu-system", version = "0.100.1" }
|
|
|
|
nu-table = { path = "../nu-table", version = "0.100.1" }
|
|
|
|
nu-term-grid = { path = "../nu-term-grid", version = "0.100.1" }
|
|
|
|
nu-utils = { path = "../nu-utils", version = "0.100.1" }
|
2024-03-07 22:40:31 +00:00
|
|
|
nu-ansi-term = { workspace = true }
|
2024-11-14 09:04:39 +00:00
|
|
|
nuon = { path = "../nuon", version = "0.100.1" }
|
2023-03-14 18:46:42 +00:00
|
|
|
|
2024-03-23 23:46:02 +00:00
|
|
|
alphanumeric-sort = { workspace = true }
|
|
|
|
base64 = { workspace = true }
|
|
|
|
bracoxide = { workspace = true }
|
2024-04-26 11:23:16 +00:00
|
|
|
brotli = { workspace = true }
|
2024-03-23 23:46:02 +00:00
|
|
|
byteorder = { workspace = true }
|
|
|
|
bytesize = { workspace = true }
|
|
|
|
calamine = { workspace = true, features = ["dates"] }
|
|
|
|
chardetng = { workspace = true }
|
2024-03-07 22:40:31 +00:00
|
|
|
chrono = { workspace = true, features = ["std", "unstable-locales", "clock"], default-features = false }
|
2024-03-23 23:46:02 +00:00
|
|
|
chrono-humanize = { workspace = true }
|
|
|
|
chrono-tz = { workspace = true }
|
2024-03-07 22:40:31 +00:00
|
|
|
crossterm = { workspace = true }
|
2024-03-23 23:46:02 +00:00
|
|
|
csv = { workspace = true }
|
|
|
|
dialoguer = { workspace = true, default-features = false, features = ["fuzzy-select"] }
|
|
|
|
digest = { workspace = true, default-features = false }
|
|
|
|
dtparse = { workspace = true }
|
|
|
|
encoding_rs = { workspace = true }
|
2024-03-07 22:40:31 +00:00
|
|
|
fancy-regex = { workspace = true }
|
2024-03-23 23:46:02 +00:00
|
|
|
filesize = { workspace = true }
|
|
|
|
filetime = { workspace = true }
|
|
|
|
human-date-parser = { workspace = true }
|
|
|
|
indexmap = { workspace = true }
|
|
|
|
indicatif = { workspace = true }
|
|
|
|
itertools = { workspace = true }
|
2024-03-07 22:40:31 +00:00
|
|
|
log = { workspace = true }
|
2024-03-23 23:46:02 +00:00
|
|
|
lscolors = { workspace = true, default-features = false, features = ["nu-ansi-term"] }
|
|
|
|
md5 = { workspace = true }
|
|
|
|
mime = { workspace = true }
|
|
|
|
mime_guess = { workspace = true }
|
2024-08-06 20:28:38 +00:00
|
|
|
multipart-rs = { workspace = true }
|
2024-03-23 23:46:02 +00:00
|
|
|
native-tls = { workspace = true }
|
|
|
|
notify-debouncer-full = { workspace = true, default-features = false }
|
|
|
|
num-format = { workspace = true }
|
|
|
|
num-traits = { workspace = true }
|
2024-10-29 11:32:35 +00:00
|
|
|
oem_cp = { workspace = true }
|
2024-03-23 23:46:02 +00:00
|
|
|
open = { workspace = true }
|
|
|
|
os_pipe = { workspace = true }
|
2024-03-07 22:40:31 +00:00
|
|
|
pathdiff = { workspace = true }
|
|
|
|
percent-encoding = { workspace = true }
|
2024-03-23 23:46:02 +00:00
|
|
|
print-positions = { workspace = true }
|
|
|
|
quick-xml = { workspace = true }
|
|
|
|
rand = { workspace = true }
|
|
|
|
rayon = { workspace = true }
|
|
|
|
regex = { workspace = true }
|
|
|
|
roxmltree = { workspace = true }
|
|
|
|
rusqlite = { workspace = true, features = ["bundled", "backup", "chrono"], optional = true }
|
2024-04-26 11:23:16 +00:00
|
|
|
rmp = { workspace = true }
|
2024-03-23 23:46:02 +00:00
|
|
|
serde = { workspace = true, features = ["derive"] }
|
2024-03-07 22:40:31 +00:00
|
|
|
serde_json = { workspace = true, features = ["preserve_order"] }
|
2024-03-23 23:46:02 +00:00
|
|
|
serde_urlencoded = { workspace = true }
|
|
|
|
serde_yaml = { workspace = true }
|
|
|
|
sha2 = { workspace = true }
|
2024-03-07 22:40:31 +00:00
|
|
|
sysinfo = { workspace = true }
|
2024-08-23 22:35:42 +00:00
|
|
|
tabled = { workspace = true, features = ["ansi"], default-features = false }
|
2024-03-23 23:46:02 +00:00
|
|
|
titlecase = { workspace = true }
|
2024-08-13 19:27:28 +00:00
|
|
|
toml = { workspace = true, features = ["preserve_order"] }
|
2024-03-07 22:40:31 +00:00
|
|
|
unicode-segmentation = { workspace = true }
|
2024-03-23 23:46:02 +00:00
|
|
|
ureq = { workspace = true, default-features = false, features = ["charset", "gzip", "json", "native-tls"] }
|
|
|
|
url = { workspace = true }
|
|
|
|
uu_cp = { workspace = true }
|
|
|
|
uu_mkdir = { workspace = true }
|
|
|
|
uu_mktemp = { workspace = true }
|
|
|
|
uu_mv = { workspace = true }
|
2024-11-18 00:03:21 +00:00
|
|
|
uu_touch = { workspace = true }
|
2024-03-25 21:51:50 +00:00
|
|
|
uu_uname = { workspace = true }
|
2024-03-23 23:46:02 +00:00
|
|
|
uu_whoami = { workspace = true }
|
2024-03-07 22:40:31 +00:00
|
|
|
uuid = { workspace = true, features = ["v4"] }
|
2024-03-23 23:46:02 +00:00
|
|
|
v_htmlescape = { workspace = true }
|
|
|
|
wax = { workspace = true }
|
Rewrite run_external.rs (#12921)
This PR is a complete rewrite of `run_external.rs`. The main goal of the
rewrite is improving readability, but it also fixes some bugs related to
argument handling and the PATH variable (fixes
https://github.com/nushell/nushell/issues/6011).
I'll discuss some technical details to make reviewing easier.
## Argument handling
Quoting arguments for external commands is hard. Like, *really* hard.
We've had more than a dozen issues and PRs dedicated to quoting
arguments (see Appendix) but the current implementation is still buggy.
Here's a demonstration of the buggy behavior:
```nu
let foo = "'bar'"
^touch $foo # This creates a file named `bar`, but it should be `'bar'`
^touch ...[ "'bar'" ] # Same
```
I'll describe how this PR deals with argument handling.
First, we'll introduce the concept of **bare strings**. Bare strings are
**string literals** that are either **unquoted** or **quoted by
backticks** [^1]. Strings within a list literal are NOT considered bare
strings, even if they are unquoted or quoted by backticks.
When a bare string is used as an argument to external process, we need
to perform tilde-expansion, glob-expansion, and inner-quotes-removal, in
that order. "Inner-quotes-removal" means transforming from
`--option="value"` into `--option=value`.
## `.bat` files and CMD built-ins
On Windows, `.bat` files and `.cmd` files are considered executable, but
they need `CMD.exe` as the interpreter. The Rust standard library
supports running `.bat` files directly and will spawn `CMD.exe` under
the hood (see
[documentation](https://doc.rust-lang.org/std/process/index.html#windows-argument-splitting)).
However, other extensions are not supported [^2].
Nushell also supports a selected number of CMD built-ins. The problem
with CMD is that it uses a different set of quoting rules. Correctly
quoting for CMD requires using
[Command::raw_arg()](https://doc.rust-lang.org/std/os/windows/process/trait.CommandExt.html#tymethod.raw_arg)
and manually quoting CMD special characters, on top of quoting from the
Nushell side. ~~I decided that this is too complex and chose to reject
special characters in CMD built-ins instead [^3]. Hopefully this will
not affact real-world use cases.~~ I've implemented escaping that works
reasonably well.
## `which-support` feature
The `which` crate is now a hard dependency of `nu-command`, making the
`which-support` feature essentially useless. The `which` crate is
already a hard dependency of `nu-cli`, and we should consider removing
the `which-support` feature entirely.
## Appendix
Here's a list of quoting-related issues and PRs in rough chronological
order.
* https://github.com/nushell/nushell/issues/4609
* https://github.com/nushell/nushell/issues/4631
* https://github.com/nushell/nushell/issues/4601
* https://github.com/nushell/nushell/pull/5846
* https://github.com/nushell/nushell/issues/5978
* https://github.com/nushell/nushell/pull/6014
* https://github.com/nushell/nushell/issues/6154
* https://github.com/nushell/nushell/pull/6161
* https://github.com/nushell/nushell/issues/6399
* https://github.com/nushell/nushell/pull/6420
* https://github.com/nushell/nushell/pull/6426
* https://github.com/nushell/nushell/issues/6465
* https://github.com/nushell/nushell/issues/6559
* https://github.com/nushell/nushell/pull/6560
[^1]: The idea that backtick-quoted strings act like bare strings was
introduced by Kubouch and briefly mentioned in [the language
reference](https://www.nushell.sh/lang-guide/chapters/strings_and_text.html#backtick-quotes).
[^2]: The documentation also said "running .bat scripts in this way may
be removed in the future and so should not be relied upon", which is
another reason to move away from this. But again, quoting for CMD is
hard.
[^3]: If anyone wants to try, the best resource I found on the topic is
[this](https://daviddeley.com/autohotkey/parameters/parameters.htm).
2024-05-23 02:05:27 +00:00
|
|
|
which = { workspace = true }
|
2024-03-26 05:57:55 +00:00
|
|
|
unicode-width = { workspace = true }
|
2024-08-23 16:18:51 +00:00
|
|
|
data-encoding = { version = "2.6.0", features = ["alloc"] }
|
2021-05-12 01:01:31 +00:00
|
|
|
|
2022-10-07 18:54:36 +00:00
|
|
|
[target.'cfg(windows)'.dependencies]
|
2024-03-23 23:46:02 +00:00
|
|
|
winreg = { workspace = true }
|
2022-10-07 18:54:36 +00:00
|
|
|
|
2024-03-14 21:43:42 +00:00
|
|
|
[target.'cfg(not(windows))'.dependencies]
|
2024-03-23 23:46:02 +00:00
|
|
|
uucore = { workspace = true, features = ["mode"] }
|
2024-03-14 21:43:42 +00:00
|
|
|
|
2021-01-12 04:59:53 +00:00
|
|
|
[target.'cfg(unix)'.dependencies]
|
2024-03-23 23:46:02 +00:00
|
|
|
umask = { workspace = true }
|
2024-03-30 13:49:54 +00:00
|
|
|
nix = { workspace = true, default-features = false, features = ["user", "resource", "pthread"] }
|
2021-01-12 04:59:53 +00:00
|
|
|
|
Fix build for BSDs (#11372)
# Description
This PR fixes build for BSD variants (including FreeBSD and NetBSD).
Currently, `procfs` only support linux, android and l4re, and
0cba269d80953bc391070bdc8e878d276ecd1180 only adds support for NetBSD,
this PR should work on all BSD variants.
https://github.com/eminence/procfs/blob/b153b782a5957aa619ed744d0ac8bbe4734601ed/procfs/build.rs#L4-L8
Fixes #11373
# User-Facing Changes
* before
```console
nibon7@fbsd /d/s/nushell ((70f7db14))> cargo build
Compiling tempfile v3.8.1
Compiling procfs v0.16.0
Compiling toml_edit v0.21.0
Compiling native-tls v0.2.11
error: failed to run custom build command for `procfs v0.16.0`
Caused by:
process didn't exit successfully: `/data/source/nushell/target/debug/build/procfs-d59599f40f32f0d5/build-script-build` (exit status: 1)
--- stderr
Building procfs on an for a unsupported platform. Currently only linux and android are supported
(Your current target_os is freebsd)
warning: build failed, waiting for other jobs to finish...
```
* after
```console
nushell on bsd [✘!?] is 📦 v0.88.2 via 🦀 v1.74.1
❯ version
╭────────────────────┬───────────────────────────────────────────╮
│ version │ 0.88.2 │
│ branch │ bsd │
│ commit_hash │ 151edef186470e454367ac6e4b2178188062c1f9 │
│ build_os │ freebsd-x86_64 │
│ build_target │ x86_64-unknown-freebsd │
│ rust_version │ rustc 1.74.1 (a28077b28 2023-12-04) │
│ rust_channel │ stable-x86_64-unknown-freebsd │
│ cargo_version │ cargo 1.74.1 (ecb9851af 2023-10-18) │
│ build_time │ 2023-12-19 10:12:15 +00:00 │
│ build_rust_channel │ debug │
│ allocator │ mimalloc │
│ features │ default, extra, sqlite, trash, which, zip │
│ installed_plugins │ │
╰────────────────────┴───────────────────────────────────────────╯
nushell on bsd [✘!?] is 📦 v0.88.2 via 🦀 v1.74.1
❯ cargo test --workspace commands::ulimit e>> /dev/null | rg ulimit
test commands::ulimit::limit_set_filesize2 ... ok
test commands::ulimit::limit_set_filesize1 ... ok
test commands::ulimit::limit_set_hard1 ... ok
test commands::ulimit::limit_set_hard2 ... ok
test commands::ulimit::limit_set_invalid1 ... ok
test commands::ulimit::limit_set_invalid3 ... ok
test commands::ulimit::limit_set_invalid4 ... ok
test commands::ulimit::limit_set_invalid5 ... ok
test commands::ulimit::limit_set_soft2 ... ok
test commands::ulimit::limit_set_soft1 ... ok
nushell on bsd [✘!?] is 📦 v0.88.2 via 🦀 v1.74.1
```
# Tests + Formatting
<!--
Don't forget to add tests that cover your changes.
Make sure you've run and fixed any issues with these commands:
- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to
check that you're using the standard code style
- `cargo test --workspace` to check that all tests pass (on Windows make
sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- `cargo run -- -c "use std testing; testing run-tests --path
crates/nu-std"` to run the tests for the standard library
> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->
# After Submitting
<!-- If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
-->
2023-12-19 14:58:45 +00:00
|
|
|
[target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies]
|
2024-03-23 23:46:02 +00:00
|
|
|
procfs = { workspace = true }
|
2023-11-20 20:22:35 +00:00
|
|
|
|
2022-03-26 18:21:19 +00:00
|
|
|
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies.trash]
|
|
|
|
optional = true
|
2024-03-23 23:46:02 +00:00
|
|
|
workspace = true
|
2022-03-26 18:21:19 +00:00
|
|
|
|
2022-06-03 16:37:27 +00:00
|
|
|
[target.'cfg(windows)'.dependencies.windows]
|
2023-07-18 13:36:54 +00:00
|
|
|
features = [
|
|
|
|
"Win32_Foundation",
|
|
|
|
"Win32_Storage_FileSystem",
|
Improve `registry value` return types (#10806)
r? @fdncred
Last one, I hope. At least short of completely redesigning `registry
query`'s interface. (Which I wouldn't implement without asking around
first.)
# Description
User-Facing Changes has the general overview. Inline comments provide a
lot of justification on specific choices. Most of the type conversions
should be reasonably noncontroversial, but expanding `REG_EXPAND_SZ`
needs some justification. First, an example of the behavior there:
```shell
> # release nushell:
> version | select version commit_hash | to md --pretty
| version | commit_hash |
| ------- | ---------------------------------------- |
| 0.85.0 | a6f62e05ae5b4e9ba4027fbfffd21025a898783e |
> registry query --hkcu Environment TEMP | get value
%USERPROFILE%\AppData\Local\Temp
> # with this patch:
> version | select version commit_hash | to md --pretty
| version | commit_hash |
| ------- | ---------------------------------------- |
| 0.86.1 | 0c5a4c991f1a77bcbe5a86bc8f4469ecf1218fe9 |
> registry query --hkcu Environment TEMP | get value
C:\Users\CAD\AppData\Local\Temp
> # Microsoft CLI tooling behavior:
> ^pwsh -c `(Get-ItemProperty HKCU:\Environment).TEMP`
C:\Users\CAD\AppData\Local\Temp
> ^reg query HKCU\Environment /v TEMP
HKEY_CURRENT_USER\Environment
TEMP REG_EXPAND_SZ %USERPROFILE%\AppData\Local\Temp
```
As noted in the inline comments, I'm arguing that it makes more sense to
eagerly expand the %EnvironmentString% placeholders, as none of
Nushell's path functionality will interpret these placeholders. This
makes the behavior of `registry query` match the behavior of pwsh's
`Get-ItemProperty` registry access, and means that paths (the most
common use of `REG_EXPAND_SZ`) are actually usable.
This does *not* break nu_script's
[`update-path`](https://github.com/nushell/nu_scripts/blob/main/sourced/update-path.nu);
it will just be slightly inefficient as it will not find any
`%Placeholder%`s to manually expand anymore. But also, note that
`update-path` is currently *wrong*, as a path including
`%LocalAppData%Low` is perfectly valid and sometimes used (to go to
`Appdata\LocalLow`); expansion isn't done solely on a path segment
basis, as is implemented by `update-path`.
I believe that the type conversions implemented by this patch are
essentially always desired. But if we want to keep `registry query`
"pure", we could easily introduce a `registry get`[^get] which does the
more complete interpretation of registry types, and leave `registry
query` alone as doing the bare minimum. Or we could teach `path expand`
to do `ExpandEnvironmentStringsW`. But REG_EXPAND_SZ being the odd one
out of not getting its registry type semantics decoded by `registry
query` seems wrong.
[^get]: This is the potential redesign I alluded to at the top. One
potential change could be to make `registry get Environment` produce
`record<Path: string, TEMP: string, TMP: string>` instead of `registry
query`'s `table<name: string, value: string, type: string>`, the idea
being to make it feel as native as possible. We could even translate
between Nu's cell-path and registry paths -- cell paths with spaces do
actually work, if a bit awkwardly -- or even introduce lazy records so
the registry can be traversed with normal data manipulation ... but that
all seems a bit much.
# User-Facing Changes
- `registry query`'s produced `value` has changed. Specifically:
- ❗ Rows `where type == REG_EXPAND_SZ` now expand `%EnvironmentVarable%`
placeholders for you. For example, `registry query --hkcu Environment
TEMP | get value` returns `C:\Users\CAD\AppData\Local\Temp` instead of
`%USERPROFILE%\AppData\Local\Temp`.
- You can restore the old behavior and preserve the placeholders by
passing a new `--no-expand` switch.
- Rows `where type == REG_MULTI_SZ` now provide a `list<string>` value.
They previously had that same list, but `| str join "\n"`.
- Rows `where type == REG_DWORD_BIG_ENDIAN` now provide the correct
numeric value instead of a byte-swapped value.
- Rows `where type == REG_QWORD` now provide the correct numeric
value[^sign] instead of the value modulo 2<sup>32</sup>.
- Rows `where type == REG_LINK` now provide a string value of the link
target registry path instead of an internal debug string representation.
(This should never be visible, as links should be transparently
followed.)
- Rows `where type =~ RESOURCE` now provide a binary value instead of an
internal debug string representation.
[^sign]: Nu's `int` is a signed 64-bit integer. As such, values >=
2<sup>63</sup> will be reported as their negative two's compliment
value. This might sometimes be the correct interpretation -- the
registry does not distinguish between signed and unsigned integer values
-- but regedit and pwsh display all values as unsigned.
2023-10-23 12:21:27 +00:00
|
|
|
"Win32_System_Environment",
|
2023-07-18 13:36:54 +00:00
|
|
|
"Win32_System_SystemServices",
|
|
|
|
"Win32_Security",
|
2023-08-23 20:23:27 +00:00
|
|
|
"Win32_System_Threading",
|
2023-07-18 13:36:54 +00:00
|
|
|
]
|
2024-03-23 23:46:02 +00:00
|
|
|
workspace = true
|
2022-06-03 16:37:27 +00:00
|
|
|
|
2021-10-10 04:13:15 +00:00
|
|
|
[features]
|
2021-11-02 20:56:00 +00:00
|
|
|
plugin = ["nu-parser/plugin"]
|
2023-06-14 21:12:55 +00:00
|
|
|
sqlite = ["rusqlite"]
|
2023-02-11 18:59:11 +00:00
|
|
|
trash-support = ["trash"]
|
2021-01-12 04:59:53 +00:00
|
|
|
|
|
|
|
[dev-dependencies]
|
2024-11-14 09:04:39 +00:00
|
|
|
nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.100.1" }
|
|
|
|
nu-test-support = { path = "../nu-test-support", version = "0.100.1" }
|
2023-06-14 21:12:55 +00:00
|
|
|
|
2024-07-16 12:16:26 +00:00
|
|
|
dirs = { workspace = true }
|
2024-03-23 23:46:02 +00:00
|
|
|
mockito = { workspace = true, default-features = false }
|
|
|
|
quickcheck = { workspace = true }
|
|
|
|
quickcheck_macros = { workspace = true }
|
2024-03-07 22:40:31 +00:00
|
|
|
rstest = { workspace = true, default-features = false }
|
2024-04-26 11:23:16 +00:00
|
|
|
pretty_assertions = { workspace = true }
|
2024-08-23 16:18:51 +00:00
|
|
|
tempfile = { workspace = true }
|
2024-10-15 19:01:08 +00:00
|
|
|
rand_chacha = { workspace = true }
|