]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
sg: Properly document synopsis and options
authorTobias Stoeckmann <tobias@stoeckmann.org>
Sun, 28 Dec 2025 15:36:19 +0000 (16:36 +0100)
committerAlejandro Colomar <foss+github@alejandro-colomar.es>
Mon, 29 Dec 2025 22:49:00 +0000 (23:49 +0100)
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.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
man/sg.1.xml
src/newgrp.c

index 2423f1097f58f4ada8f4b9a2e08529d779b0c756..54d9023b773ed16b65a1fc8275c07b2436c32065 100644 (file)
   <refsynopsisdiv id='synopsis'>
     <cmdsynopsis>
       <command>sg</command>
-      <arg choice='opt'>- </arg>
+      <arg choice='opt'>
+        <replaceable>-</replaceable>
+      </arg>
       <arg choice='plain'>
         <replaceable>group</replaceable>
       </arg>
       <arg choice='opt'>
-       <arg choice='opt'>-c </arg>
-       command
+        <arg choice='opt'><replaceable>-c</replaceable></arg>
+        <replaceable>command</replaceable>
       </arg>
     </cmdsynopsis>
   </refsynopsisdiv>
     </para>
   </refsect1>
 
+  <refsect1 id='options'>
+    <title>OPTIONS</title>
+    <para>
+      The options which apply to the <command>sg</command> command are:
+    </para>
+    <variablelist remap='IP'>
+      <varlistentry>
+       <term><option>-</option>, <option>-l</option></term>
+       <listitem>
+         <para>
+           Start the shell as a login shell.
+         </para>
+       </listitem>
+      </varlistentry>
+      <varlistentry>
+       <term>
+         <option>-c</option>
+       </term>
+       <listitem>
+         <para>
+           Specify a command that will be invoked by the shell using its
+           <option>-c</option>.
+         </para>
+         <para>
+           This is the default; for backward compatibility.
+         </para>
+       </listitem>
+      </varlistentry>
+    </variablelist>
+  </refsect1>
+
   <refsect1 id='configuration'>
     <title>CONFIGURATION</title>
     <para>
index e48b4d36606de37d60a02b8b895b3aca001b0229..5c4cc07b15cdbf11611deb4fff6101f499e6481f 100644 (file)
@@ -72,7 +72,7 @@ static void usage (void)
        if (is_newgrp) {
                (void) fputs (_("Usage: newgrp [-] [group]\n"), stderr);
        } else {
-               (void) fputs (_("Usage: sg group [[-c] command]\n"), stderr);
+               (void) fputs (_("Usage: sg [-] group [[-c] command]\n"), stderr);
        }
 }
 
@@ -465,8 +465,8 @@ int main (int argc, char **argv)
         * The valid syntax are
         *      newgrp [-] [groupid]
         *      newgrp [-l] [groupid]
-        *      sg [-]
-        *      sg [-] groupid [[-c command]
+        *      sg [-] groupid [[-c] command]
+        *      sg [-l] groupid [[-c] command]
         */
        if (   (argc > 0)
            && (   streq(argv[0], "-")
@@ -499,8 +499,7 @@ int main (int argc, char **argv)
 
                        /*
                         * Skip -c if specified so both forms work:
-                        * "sg group -c command" (as in the man page) or
-                        * "sg group command" (as in the usage message).
+                        * "sg group -c command" or "sg group command".
                         */
                        if ((argc > 1) && streq(argv[0], "-c")) {
                                command = argv[1];