-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cp target expansion #11152
Cp target expansion #11152
Conversation
This issue is pretty bad actually. Broke quite a few scripts for me (I skipped a couple of version so just noticed it). Perhaps another minor release may be considered |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i did just
- repro the bug on
0.87.1
- not repro the bug on this PR
so this looks good to me and such a simple change 👌
this sounds like a pretty critical bug as well, at least very confusing...
glad it's not on something like rm
👀
thanks @NotLebedev 🙏
Thanks! |
# Description This PR addresses issue with cp brough up on [discord](https://discord.com/channels/601130461678272522/614593951969574961/1177669443917189130) where target of cp is not correctly expanded. If one has directory `test` with file `file.txt` in it then the following command (in one line or inside a `do` block): ```nu cd test; let file = 'copy.txt'; cp file.txt $file ``` will create a `copy.txt` in `.` not in `test` instead. This happens because target of `cp` is a variable which is not expanded unlike a string literal # User-Facing Changes `cp` will correctly parse realative target paths # 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. -->
# Description This PR addresses issue with cp brough up on [discord](https://discord.com/channels/601130461678272522/614593951969574961/1177669443917189130) where target of cp is not correctly expanded. If one has directory `test` with file `file.txt` in it then the following command (in one line or inside a `do` block): ```nu cd test; let file = 'copy.txt'; cp file.txt $file ``` will create a `copy.txt` in `.` not in `test` instead. This happens because target of `cp` is a variable which is not expanded unlike a string literal # User-Facing Changes `cp` will correctly parse realative target paths # 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. -->
Description
This PR addresses issue with cp brough up on discord where target of cp is not correctly expanded.
If one has directory
test
with filefile.txt
in it then the following command (in one line or inside ado
block):cd test; let file = 'copy.txt'; cp file.txt $file
will create a
copy.txt
in.
not intest
instead. This happens because target ofcp
is a variable which is not expanded unlike a string literalUser-Facing Changes
cp
will correctly parse realative target pathsTests + Formatting
After Submitting