logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git/
commit: 27fd2bbbe5ef3c4139ff34422e9f24c96c5c3ba6
parent e8e526bdb58ea53fafea5fd82e3535b7fe218b23
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Sat,  8 Nov 2025 19:13:35 +0100

cmd/chmod: handle -X/-s/-t as non-options

Diffstat:

Mcmd/chmod.c2+-
Mtest-cmd/chmod.sh9++++++++-
2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/cmd/chmod.c b/cmd/chmod.c @@ -344,7 +344,7 @@ main(int argc, char *argv[]) { if(optind >= argc || !argv[optind]) break; - if(argv[optind][0] == '-' && strchr("rwxugoa", argv[optind][1])) + if(argv[optind][0] == '-' && strchr("ugoarwxXst", argv[optind][1])) { fprintf(stderr, "%s: warning: (portability) Pass -- before a mode with a leading dash(-) to " diff --git a/test-cmd/chmod.sh b/test-cmd/chmod.sh @@ -2,9 +2,9 @@ # SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me> # SPDX-License-Identifier: MPL-2.0 +plans=15 WD="$(dirname "$0")/../" target="${WD}/cmd/chmod" -plans=13 . "${WD}/test-cmd/tap.sh" tmpfile="${TMPDIR-/tmp}/test_chmod_$(date +%s)" @@ -39,6 +39,13 @@ t 'mode:-r' "-v -r $tmpfile" "chmod: warning: (portability) Pass -- before a mod chmod: Permissions changed from 00577/-r-xrwxrwx to 00133/---x-wx-wx for '${tmpfile}' " +t 'mode:+t' "-v +t $tmpfile" "chmod: Permissions changed from 00133/---x-wx-wx to 01133/---x-wx-wt for '${tmpfile}' +" + +t 'mode:-t' "-v -t $tmpfile" "chmod: warning: (portability) Pass -- before a mode with a leading dash(-) to separate it from options +chmod: Permissions changed from 01133/---x-wx-wt to 00133/---x-wx-wx for '${tmpfile}' +" + t '__mode:-x,+w' "-v -- -x,+w $tmpfile" "chmod: Permissions changed from 00133/---x-wx-wx to 00222/--w--w--w- for '${tmpfile}' "