nushell/crates/nu-command/src
kik4444 38a42905ae
Fix touch to allow changing timestamps on directories, remake from #11760 (#12005)
<!--
if this PR closes one or more issues, you can automatically link the PR
with
them by using one of the [*linking
keywords*](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword),
e.g.
- this PR should close #xxxx
- fixes #xxxx

you can also mention related issues, PRs or discussions!
-->

Based off of #11760 to be mergable without conflicts.

# Description
<!--
Thank you for improving Nushell. Please, check our [contributing
guide](../CONTRIBUTING.md) and talk to the core team before making major
changes.

Description of your pull request goes here. **Provide examples and/or
screenshots** if your changes affect the user experience.
-->
Fix for #11757.
The main issue in #11757 is I tried to copy the timestamp from one
directory to another only to realize that did not work whereas the
coreutils `^touch` had no problems. I thought `--reference` just did not
work, but apparently the whole `touch` command could not work on
directories because
`OpenOptions::new().write(true).create(true).open(&item)` tries to
create `touch`'s target in advance and then modify its timestamps. But
if the target is a directory that already exists then this would fail
even though the crate used for working with timestamps, `filetime`,
already works on directories.

# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->
I don't believe this should change any existing valid behaviors. It just
changes a non-working behavior.

# 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
> ```
-->
~~I only could not run `cargo test` because I get compilation errors on
the latest main branch~~
All tests pass with `cargo test --features=sqlite`

# 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.
-->
2024-03-01 07:23:03 -06:00
..
bytes adjust some commansd input_output type (#11436) 2024-01-15 16:58:26 +08:00
charting Remove Record::from_raw_cols_vals_unchecked (#11810) 2024-02-18 14:20:22 +02:00
conversions Glob: don't allow implicit casting between glob and string (#11992) 2024-02-28 23:05:35 +08:00
database open, rm, umv, cp, rm and du: Don't globs if inputs are variables or string interpolation (#11886) 2024-02-23 09:17:09 +08:00
date Remove some unnecessary static Vecs (#11947) 2024-02-24 20:58:01 +01:00
debug open, rm, umv, cp, rm and du: Don't globs if inputs are variables or string interpolation (#11886) 2024-02-23 09:17:09 +08:00
env Add ConfigDirNotFound error (#11849) 2024-02-26 15:42:20 +08:00
experimental Bump windows from 0.48.0 to 0.52.0 (#11325) 2023-12-21 18:49:15 +01:00
filesystem Fix touch to allow changing timestamps on directories, remake from #11760 (#12005) 2024-03-01 07:23:03 -06:00
filters add is-not-empty command as a QOL improvement (#11991) 2024-02-28 17:11:44 -06:00
formats Fix: string_to_table in ssv.rs now filters comments. (issue #11997) (#12035) 2024-03-01 07:11:13 -06:00
generators allow current day to be highlighted (#11954) 2024-02-26 08:31:46 -06:00
hash adjust some commansd input_output type (#11436) 2024-01-15 16:58:26 +08:00
help adjust some commansd input_output type (#11436) 2024-01-15 16:58:26 +08:00
math allow math avg to work with durations (#11598) 2024-01-21 08:41:23 -06:00
misc wrapping run_repl with catch_unwind and restarting the repl on panic (#11860) 2024-02-22 12:14:10 -06:00
network Add Value::coerce_str (#11885) 2024-02-18 17:47:10 +01:00
path Add Value::coerce_str (#11885) 2024-02-18 17:47:10 +01:00
platform Allow clear command to clear terminal's history (#12008) 2024-02-28 07:49:41 -06:00
random Name the Value conversion functions more clearly (#11851) 2024-02-17 18:14:16 +00:00
removed Enforce required, optional, and rest positional arguments start with an uppercase and end with a period. (#11285) 2023-12-15 14:32:37 +08:00
shells Enforce required, optional, and rest positional arguments start with an uppercase and end with a period. (#11285) 2023-12-15 14:32:37 +08:00
stor Add Value::coerce_str (#11885) 2024-02-18 17:47:10 +01:00
strings deprecate str escape-glob command (#12018) 2024-02-29 20:29:56 +08:00
system Don't expanding globs if user pass variables. (#11946) 2024-02-28 23:05:09 +08:00
viewers nu-table: Improve table -a (#11905) 2024-02-23 19:12:10 -06:00
default_context.rs remove old mv command in favor of umv (renamed to mv) (#12022) 2024-03-01 09:37:23 +08:00
example_test.rs Add tee command for operating on copies of streams (#11928) 2024-02-28 17:08:31 -06:00
lib.rs Simplify the feature gates for stor commands (#11416) 2023-12-24 13:31:46 +01:00
progress_bar.rs remove cp-old (#11622) 2024-01-24 07:38:15 +08:00
sort_utils.rs Add Value::coerce_str (#11885) 2024-02-18 17:47:10 +01:00