Skip to content

Commit def5ac8

Browse files
committed
sg: Properly document synopsis and options
The usage message of sg and synopsis of its manual page diverged. The difference was even noted in a comment, instead of fixing it. Synchronize both, add information about hidden options and document what they do (wording taken from su's manual page). Signed-off-by: Tobias Stoeckmann <[email protected]>
1 parent 6fa85ec commit def5ac8

File tree

2 files changed

+45
-9
lines changed

2 files changed

+45
-9
lines changed

man/sg.1.xml

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,15 @@
4545
<refsynopsisdiv id='synopsis'>
4646
<cmdsynopsis>
4747
<command>sg</command>
48-
<arg choice='opt'>- </arg>
49-
<arg choice='opt'>group
50-
<arg choice='opt'>-c </arg>
51-
command
48+
<arg choice='opt'>
49+
<replaceable>-</replaceable>
50+
</arg>
51+
<arg choice='plain'>
52+
<replaceable>group</replaceable>
53+
</arg>
54+
<arg choice='opt'>
55+
<arg choice='opt'><replaceable>-c</replaceable></arg>
56+
<replaceable>command</replaceable>
5257
</arg>
5358
</cmdsynopsis>
5459
</refsynopsisdiv>
@@ -70,6 +75,38 @@
7075
</para>
7176
</refsect1>
7277

78+
<refsect1 id='options'>
79+
<title>OPTIONS</title>
80+
<para>
81+
The options which apply to the <command>sg</command> command are:
82+
</para>
83+
<variablelist remap='IP'>
84+
<varlistentry>
85+
<term><option>-</option>, <option>-l</option></term>
86+
<listitem>
87+
<para>
88+
Provide an environment similar to what the user would expect had
89+
the user logged in directly.
90+
</para>
91+
</listitem>
92+
</varlistentry>
93+
<varlistentry>
94+
<term>
95+
<option>-c</option>
96+
</term>
97+
<listitem>
98+
<para>
99+
Specify a command that will be invoked by the shell using its
100+
<option>-c</option>.
101+
</para>
102+
<para>
103+
This is the default. For backward compatibility.
104+
</para>
105+
</listitem>
106+
</varlistentry>
107+
</variablelist>
108+
</refsect1>
109+
73110
<refsect1 id='configuration'>
74111
<title>CONFIGURATION</title>
75112
<para>

src/newgrp.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ static void usage (void)
7272
if (is_newgrp) {
7373
(void) fputs (_("Usage: newgrp [-] [group]\n"), stderr);
7474
} else {
75-
(void) fputs (_("Usage: sg group [[-c] command]\n"), stderr);
75+
(void) fputs (_("Usage: sg [-] group [[-c] command]\n"), stderr);
7676
}
7777
}
7878

@@ -465,8 +465,8 @@ int main (int argc, char **argv)
465465
* The valid syntax are
466466
* newgrp [-] [groupid]
467467
* newgrp [-l] [groupid]
468-
* sg [-]
469-
* sg [-] groupid [[-c command]
468+
* sg [-] groupid [[-c] command]
469+
* sg [-l] groupid [[-c] command]
470470
*/
471471
if ( (argc > 0)
472472
&& ( streq(argv[0], "-")
@@ -499,8 +499,7 @@ int main (int argc, char **argv)
499499

500500
/*
501501
* Skip -c if specified so both forms work:
502-
* "sg group -c command" (as in the man page) or
503-
* "sg group command" (as in the usage message).
502+
* "sg group -c command" or "sg group command".
504503
*/
505504
if ((argc > 1) && streq(argv[0], "-c")) {
506505
command = argv[1];

0 commit comments

Comments
 (0)