Fix #12391: mkdir uses process startup directory instead of current script directory (#12394)

# Description

This fixes #12391.

nushell/nushell@87c5f6e455 accidentally introduced a bug where the path
was not being properly
expanded according to the cwd. This makes both 'touch' and 'mkdir' use
globs just like the rest of
the commands to preserve tilde behavior while still expanding the paths
properly.

This doesn't actually expand the globs. Should it?

# User-Facing Changes

- Restore behavior of `mkdir`, `touch`
- Help text now says they can take globs, but they won't actually expand
them, maybe this should be changed

# Tests + Formatting

Regression tests added.


# After Submitting

This is severe enough and should be included in the point release.
This commit is contained in:
Devyn Cairns
2024-04-04 05:23:10 -07:00
committed by GitHub
parent 25b90744b7
commit 51aa66fef7
4 changed files with 52 additions and 14 deletions

View File

@ -502,3 +502,16 @@ fn create_a_file_with_tilde() {
assert!(files_exist_at(vec![Path::new("~tilde2")], dirs.test()));
})
}
#[test]
fn respects_cwd() {
Playground::setup("touch_respects_cwd", |dirs, _sandbox| {
nu!(
cwd: dirs.test(),
"mkdir 'dir'; cd 'dir'; touch 'i_will_be_created.txt'"
);
let path = dirs.test().join("dir/i_will_be_created.txt");
assert!(path.exists());
})
}

View File

@ -123,6 +123,20 @@ fn creates_directory_three_dots_quotation_marks() {
})
}
#[test]
fn respects_cwd() {
Playground::setup("mkdir_respects_cwd", |dirs, _| {
nu!(
cwd: dirs.test(),
"mkdir 'some_folder'; cd 'some_folder'; mkdir 'another/deeper_one'"
);
let expected = dirs.test().join("some_folder/another/deeper_one");
assert!(expected.exists());
})
}
#[cfg(not(windows))]
#[test]
fn mkdir_umask_permission() {