logo

utils

~/.local/bin tools and git-hooks git clone https://hacktivis.me/git/utils.git
commit: 1f07ed293d92e6df6d43dc5ae7e08240373391c2
parent 25d16de6f4c594c2a074fd2307144b68f8105209
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Sat,  3 Jun 2023 06:18:23 +0200

cmd/touch: Add -h for Busybox compatibility

Diffstat:

Mcmd/touch.110+++++++---
Mcmd/touch.c5++++-
2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/cmd/touch.1 b/cmd/touch.1 @@ -9,7 +9,7 @@ .Nd change file access and modification times .Sh SYNOPSIS .Nm -.Op Fl acm +.Op Fl achm .Op Fl d Ar datetime | Fl r Ar ref_file .Ar file... .Sh DESCRIPTION @@ -25,6 +25,8 @@ is also given. .It Fl c Do not create .Ar file . +.It Fl h +Do not follow symlinks. .It Fl m Change the modification time, no changes to access time unless .Fl a @@ -74,10 +76,12 @@ is given but the file doesn't exists. .Nm is mostly compliant with the .St -p1003.1-2008 -specification ( +specification. .Fl t is intentionally missing and .Xr futimens 3 -is always used) +is always used. +.Fl h +is an extension. .Sh AUTHORS .An Haelwenn (lanodan) Monnier Aq Mt contact@hacktivis.me diff --git a/cmd/touch.c b/cmd/touch.c @@ -75,7 +75,7 @@ main(int argc, char *argv[]) int open_flags = O_WRONLY | O_CREAT | O_NOCTTY; int c = 0; - while((c = getopt(argc, argv, ":acmr:t:d:")) != -1) + while((c = getopt(argc, argv, ":achmr:t:d:")) != -1) { switch(c) { @@ -85,6 +85,9 @@ main(int argc, char *argv[]) case 'c': open_flags ^= O_CREAT; break; + case 'h': + open_flags |= O_NOFOLLOW; + break; case 'm': ch_mtime = true; break;