logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git
commit: 3ade2ff3c0d3f603f0b92ba72fc6b2d44a63ac92
parent 5f710b994abe117862214072869e78f54ee950b7
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Tue, 15 Oct 2024 13:45:49 +0200

cmd/chmod: detail the symbolic operations grammar in BNF-style

Diffstat:

Mcmd/chmod.173++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------
1 file changed, 54 insertions(+), 19 deletions(-)

diff --git a/cmd/chmod.1 b/cmd/chmod.1 @@ -44,27 +44,60 @@ Verbose, print both changes and retained modes .Ar file .El .Sh SYMBOLIC OPERATIONS -Roughly corresponds to the following regex: -.Ql ((^|,)[ugoa]*([+-=][ugo]|[+-=][rwxXst]+)+)+ -.Bl -tag -width Ds -.It , -Separator between each operation, +Uses the following grammar: +.Bd -literal +mode ::= clause [',' clause]* +clause ::= who* action+ +action ::= [op | op perm+ | op permcopy] + +who ::= 'u' | 'g' | 'o' | 'a' +op ::= '+' | '-' | '=' +perm ::= 'r' | 'w' | 'x' | 'X' | 's' | 't' + +permcopy ::= 'u' | 'g' | 'o' +.Ed +.Pp +Which corresponds to: +.Bl -tag -width permcopy +.It mode +List of +.Ql clause +to apply, each separated by a comma. +.Pp +For example .Ql g+r,o=g -sets read for group and copies to other the resulting permissions of group. -.It [ugoa] -who: Sets who to assign permissions to. -.It [+-=] -op: Respectively add(+), del(-), set(=). +sets read permission for group part and copies to other part the resulting permissions of the group part. +.It clause +Optionally starts with +.Ql who +and contains one or more +.Ql action . .Pp -When who isn't given, +When +.Ql who +isn't given, .Xr umask 3 is followed similarly to file creation. -When neither permcopy nor permlist is given, set(=) clears all permissions. -.It [ugo] -permcopy: Sets who to copy permissions from. -.It [rwxXst]+ -permlist: Sets which permissions to assign, respectively: -.Bl -tag -width X +.It action +Always starts with +.Ql op , +optionally followed by either one or more +.Ql perm , +or a single +.Ql permcopy +.It who +user(u), group(g), other(o), all(a) +.It op +Operation to apply: add(+), del(-), set(=) +.Pp +When neither +.Ql perm +nor +.Ql permcopy +were given, set(=) clears all permissions. +.It perm +which permissions to assign: +.Bl -tag -width X -compact .It r Read .It w @@ -74,10 +107,12 @@ Execute/Search .It X Search (directories-only) .It s -Setuid when assigned to user, setgid when assigned to group. +Setuid when assigned to user, setgid when assigned to group .It t -Sticky bit. +Sticky bit .El +.It permcopy +who to copy permissions from: user(u), group(g), other(o) .El .Sh EXIT STATUS .Ex -std