[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#55937: [PATCH] touch: create parent directories if needed

From: Alan Rosenthal
Subject: bug#55937: [PATCH] touch: create parent directories if needed
Date: Wed, 15 Jun 2022 16:31:47 -0400

Thanks for taking the time to review my patch.

I agree with you that this change is not strictly required. It's more of a
nice to have / ergonomic improvement to the existing touch interface.

There are several StackOverflow posts that ask for this very feature:
https://unix.stackexchange.com/q/63098 &

Below is the help text for touch:
> Update the access and modification times of each FILE to the current time.
> A FILE argument that does not exist is created empty, unless -c or -h is

I was surprised to learn there was no existing flag that would allow
directory creation when a file and its directories do not exist. Currently
if directories do not exist, the command fails. I would go as far to argue
that creating a file also implies creating any required directories, since
directories must exist before we can create said file.

I also agree with David Hilton's recommendation that we should not change
the default behavior of touch, like in my first patch, but rather add an
opt-in flag for this behavior.

Thank you for reading my reply and I look forward to your future feedback.

On Tue, Jun 14, 2022 at 10:37 PM Paul Eggert <eggert@cs.ucla.edu> wrote:

> On 6/14/22 19:20, Alan Rosenthal wrote:
> > `touch -p a/b/c/d/e` will now be the same as running:
> > `mkdir -p a/b/c/d && touch a/b/c/d/e`.
> I don't see how this useful enough to merit a change, since one can
> achieve the effect of the proposed "touch -p" with the already-existing
> "mkdir -p" followed by plain "touch". mkdir -p already exists and should
> work everywhere that's POSIX-compatible. We don't need -p for other
> commands that create files (e.g., cp, mv, ln); what's special about
> 'touch'?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]