nushell: `cp` cannot find source file in the `cd`ed directory in script
Describe the bug
def main [stem: string] {
let in_dir = $env.PWD
cd '~/Templates/dev'
# let template = ^ls -1
# | sk -i --ansi -c 'fd {}' --preview 'bat -pp --color=always {}'
# | str trim -r
let template = 'foo.rs'
echo $template
let extension = $template | path parse | get extension
let dest = $in_dir | path join $"($stem).($extension)"
cp $template $dest
}
This is a script to copy my template file to the specified location. I’m sure that the file $template exists. But I got an $template not found error when running the script.
Strangely, it works fine under interactive mode via typing line by line.
How to reproduce
# 1.
$ mkdir -p ~/Templates/dev
# 2.
$ touch ~/Templates/dev/foo.rs
# 3.
$ script bar
Then you will get an file not found error.
Expected behavior
It should create an file named bar.rs with the content of foo.rs in the current directory.
Screenshots
Configuration
| key | value |
|---|---|
| version | 0.86.1 |
| branch | makepkg |
| commit_hash | cb754befe91d6ba3e853004fe90ff3a1af7caa9b |
| build_os | linux-x86_64 |
| build_target | x86_64-unknown-linux-gnu |
| rust_version | rustc 1.75.0-nightly (1c05d50c8 2023-10-21) |
| cargo_version | cargo 1.75.0-nightly (8eb8acbb1 2023-10-17) |
| build_time | 2023-10-24 21:55:19 +00:00 |
| build_rust_channel | release |
| allocator | mimalloc |
| features | default, sqlite, trash, which, zip |
| installed_plugins |
Additional context
No response
About this issue
- Original URL
- State: closed
- Created 8 months ago
- Comments: 21 (9 by maintainers)
Commits related to this issue
- Send only absolute paths to uu_cp (#11080) # Description Fixes https://github.com/nushell/nushell/issues/10832 Replaces: https://github.com/nushell/nushell/pull/10843 — committed to nushell/nushell by kubouch 7 months ago
- Send only absolute paths to uu_cp (#11080) # Description Fixes https://github.com/nushell/nushell/issues/10832 Replaces: https://github.com/nushell/nushell/pull/10843 — committed to nushell/nushell by kubouch 7 months ago
- Send only absolute paths to uu_cp (#11080) # Description Fixes https://github.com/nushell/nushell/issues/10832 Replaces: https://github.com/nushell/nushell/pull/10843 — committed to hardfau1t/nushell by kubouch 7 months ago
- Send only absolute paths to uu_cp (#11080) # Description Fixes https://github.com/nushell/nushell/issues/10832 Replaces: https://github.com/nushell/nushell/pull/10843 — committed to dmatos2012/nushell by kubouch 7 months ago
After the team meeting yesterday, @kubouch volunteered to fix this by passing fully qualified paths to uu_cp. We hope to have this resolved soon.