Page MenuHomeFreeBSD

su(1): Add -g flag
AcceptedPublic

Authored by fernape on Aug 1 2025, 4:26 PM.
Tags
None
Referenced Files
F169161768: D51683.id.diff
Mon, Aug 31, 3:33 PM
F169108162: D51683.diff
Mon, Aug 31, 10:46 AM
Unknown Object (File)
Sun, Aug 30, 6:17 AM
Unknown Object (File)
Sat, Aug 29, 11:22 AM
Unknown Object (File)
Thu, Aug 27, 2:29 AM
Unknown Object (File)
Tue, Aug 25, 10:42 AM
Unknown Object (File)
Tue, Aug 25, 1:43 AM
Unknown Object (File)
Mon, Aug 24, 11:31 PM

Details

Reviewers
0mp
bcr
carlavilla
Group Reviewers
manpages
Src Committers
Summary

As an alias to -c to avoid confusion with the flag provided by most shells.

This should avoid confusion when using two -c in one command.

While here improve the manual page a bit

Comes from: https://reviews.freebsd.org/D26941 done by @0mp

Test Plan

Apply patch.

Test commands from the EXAMPLES section.
mandoc -T lint clean.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 65899
Build 62782: arc lint + arc unit

Event Timeline

fernape edited the test plan for this revision. (Show Details)
fernape added reviewers: 0mp, bcr, manpages, Src Committers.
fernape added a subscriber: 0mp.
carlavilla added a subscriber: carlavilla.

Ok for the doc side

This revision is now accepted and ready to land.Aug 1 2025, 10:20 PM

This change seems like it would cause further confusion.
The Linux [coreutils'] version of su uses -g for overriding the primary group and -G to specify the supplementary group: https://www.man7.org/linux/man-pages/man1/su.1.html .
In an ideal world, I honestly think it would be best to rename -c to -C for symmetry with other utilities, but I'm sure that would cause loads of teeth gnashing and complaining from folks since -c has meant "class" since 1997 (renaming the option would break UX for a lot of scripts).
-C seems appropriate here, if nothing else... but I'm not sure this change is necessary. What issue are you ultimately trying to solve and what lead you to this conclusion?

This change seems like it would cause further confusion.
The Linux [coreutils'] version of su uses -g for overriding the primary group and -G to specify the supplementary group: https://www.man7.org/linux/man-pages/man1/su.1.html .
In an ideal world, I honestly think it would be best to rename -c to -C for symmetry with other utilities, but I'm sure that would cause loads of teeth gnashing and complaining from folks since -c has meant "class" since 1997 (renaming the option would break UX for a lot of scripts).
-C seems appropriate here, if nothing else... but I'm not sure this change is necessary. What issue are you ultimately trying to solve and what lead you to this conclusion?

I can't find it, but this was triggered by an email in our lists where someone complained about su not behaving correctly, and took a few mails to actually understand what was going on (basically that -c from su was being subtly being mixed up with -c from the shell in the same invocation). If memory serves, it was des@ the one who finally clarified the issue. The idea to provide an alias keeps compatibility and provides an alternative to disambiguate when necessary.