[hackers] [st] change -e behaviour and update man page. || Aurélien Aptel

From: <hg_AT_suckless.org>
Date: Tue, 30 Nov 2010 20:56:05 +0000 (UTC)

changeset: 175:0fbd5719685a
tag: tip
user: Aurélien Aptel <aurelien.aptel_AT_gmail.com>
date: Tue Nov 30 22:55:44 2010 +0100
files: st.1 st.c
description:
change -e behaviour and update man page.

diff -r bdb4064af341 -r 0fbd5719685a st.1
--- a/st.1 Sun Nov 28 13:17:20 2010 +0100
+++ b/st.1 Tue Nov 30 22:55:44 2010 +0100
@@ -3,23 +3,30 @@
 st \- simple terminal
 .SH SYNOPSIS
 .B st
-.RB [ \-e " <cmd>"]
-.RB [ \-c " <class>"]
-.RB [ \-t " <title>"]
+.RB [ \-c
+.IR class ]
+.RB [ \-t
+.IR title ]
 .RB [ \-v ]
+.RB [ \-e
+.IR cmd ]
 .SH DESCRIPTION
 .B st
 is a simple terminal emulator.
 .SH OPTIONS
 .TP
-.B \-e <cmd>
-Execute cmd instead of the shell
-.TP
-.B \-t <title>
+.B \-t title
 Overrides the default title (st)
 .TP
-.B \-c <class>
+.B \-c class
 Overrides the default class ($TERM)
 .TP
-.BI \-v
+.B \-v
 Prints version information to standard output, then exits.
+.TP
+.B \-e cmd [arguments]
+Execute cmd instead of the shell. Type your command as you would on your
+shell. If this option is used, it
+.BI "must be the last"
+on the command-line. This is the same behaviour as xterm/rxvt.
+
diff -r bdb4064af341 -r 0fbd5719685a st.c
--- a/st.c Sun Nov 28 13:17:20 2010 +0100
+++ b/st.c Tue Nov 30 22:55:44 2010 +0100
@@ -247,7 +247,7 @@
 static int cmdfd;
 static pid_t pid;
 static Selection sel;
-static char *opt_cmd = NULL;
+static char **opt_cmd = NULL;
 static char *opt_title = NULL;
 static char *opt_class = NULL;
 
@@ -547,15 +547,12 @@
 execsh(void) {
         char **args;
         char *envshell = getenv("SHELL");
+
         DEFAULT(envshell, "sh");
-
- if(opt_cmd)
- args = (char*[]){"sh", "-c", opt_cmd, NULL};
- else
- args = (char*[]){envshell, "-i", NULL};
-
         putenv("TERM="TNAME);
+ args = opt_cmd ? opt_cmd : (char*[]){envshell, "-i", NULL};
         execvp(args[0], args);
+ exit(EXIT_FAILURE);
 }
 
 void
@@ -1855,12 +1852,15 @@
                         if(++i < argc) opt_class = argv[i];
                         break;
                 case 'e':
- if(++i < argc) opt_cmd = argv[i];
+ if(++i < argc) opt_cmd = &argv[i];
                         break;
                 case 'v':
                 default:
                         die(USAGE);
                 }
+ /* -e eats every remaining arguments */
+ if(opt_cmd)
+ break;
         }
         setlocale(LC_CTYPE, "");
         tnew(80, 24);
Received on Tue Nov 30 2010 - 21:56:05 CET

This archive was generated by hypermail 2.2.0 : Tue Nov 30 2010 - 22:00:08 CET