[gnome-terminal] man: Document the various ways to run a command in a gnome-terminal



commit 61389b21b9306a3fd5d8d45cda36ab029e33f094
Author: Simon McVittie <smcv debian org>
Date:   Thu Sep 3 11:38:14 2020 +0100

    man: Document the various ways to run a command in a gnome-terminal
    
    There are three ways to run a command in a gnome-terminal (using
    "python -q" as my example because it illustrates how argument parsing
    works), of which "-e" was previously the only one listed in the
    man page:
    
    * gnome-terminal [OPTIONS] -- python3 -q
    * gnome-terminal [OPTIONS] -e "python3 -q" [MORE OPTIONS]
    * gnome-terminal [OPTIONS] -x python3 -q
    
    --command is a long form of -e, and --execute is a long form of -x.
    Both the "-e" and "-x" forms are deprecated in favour of the "--" form,
    but previously only the deprecated "-e" form was documented in the
    man page.
    
    Document the preferred form in the synopsis, and document -e and -x in
    terms of their replacements with the preferred form.
    
    Resolves: https://gitlab.gnome.org/GNOME/gnome-terminal/-/issues/296

 man/gnome-terminal.xml | 52 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 51 insertions(+), 1 deletion(-)
---
diff --git a/man/gnome-terminal.xml b/man/gnome-terminal.xml
index abdac002..94f3cc58 100644
--- a/man/gnome-terminal.xml
+++ b/man/gnome-terminal.xml
@@ -48,6 +48,8 @@
   <refsynopsisdiv>
     <cmdsynopsis>
       <command>gnome-terminal</command>
+      <group rep="repeat"><replaceable>OPTION</replaceable></group>
+      <group>-- <replaceable>PROGRAM</replaceable> <group 
rep="repeat"><replaceable>ARG</replaceable></group></group>
     </cmdsynopsis>
   </refsynopsisdiv>
 
@@ -180,7 +182,38 @@
         <term><option>--command, -e=COMMAND</option></term>
         <listitem>
           <para>
-            Execute the argument to this option inside the terminal.
+            Split the argument to this option into a program and arguments
+            in the same way a shell would, and execute the resulting
+            command-line inside the terminal.
+          </para>
+          <para>
+            This option is deprecated. Instead, use <option>--</option>
+            to terminate the options, and put the program and arguments to
+            execute after it: for example, instead of
+            <userinput>gnome-terminal -e "python3 -q"</userinput>, prefer to use
+            <userinput>gnome-terminal -- python3 -q</userinput>.
+          </para>
+          <para>
+            Note that the <replaceable>COMMAND</replaceable> is not run via
+            a shell: it is split into words and executed as a program. If
+            shell syntax is required, use the form
+            <userinput>gnome-terminal -- sh -c '...'</userinput>.
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><option>--execute PROGRAM [ARGS], -x PROGRAM [ARGS]</option></term>
+        <listitem>
+          <para>
+            Stop parsing options at this point, and interpret all
+            subsequent options as a program and arguments to execute
+            inside the terminal.
+          </para>
+          <para>
+            This option is deprecated: use <option>--</option> instead.
+            For example, instead of
+            <userinput>gnome-terminal -x python3 -q</userinput>, prefer to use
+            <userinput>gnome-terminal -- python3 -q</userinput>.
           </para>
         </listitem>
       </varlistentry>
@@ -373,6 +406,23 @@
     </para>
   </refsect1>
 
+  <refsect1>
+    <title>EXAMPLES</title>
+    <para>
+      To run a terminal containing an interactive Python prompt:
+      <literallayout>
+        gnome-terminal --title=Python -- python3 -q
+      </literallayout>
+    </para>
+    <para>
+      To interpret shell syntax in a terminal, either write it in a
+      separate shell script, or use <literal>sh -c</literal>:
+      <literallayout>
+        gnome-terminal -- sh -c 'if [ "$(id -u)" = 0 ]; then ...'
+      </literallayout>
+    </para>
+  </refsect1>
+
   <refsect1>
     <title>SEE ALSO</title>
     <para>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]