Re: [dev] [st] [PATCH 2/2] Make -e behave as -- for compatibility.

From: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
Date: Mon, 13 Apr 2015 21:58:16 +0200

> + case 'e':
> + /* xterm/rxvt compatibility */
> + *argv[0] = '-';
> + argc++, argv--;
> + break;
> case 'f':
> opt_font = EARGF(usage());
> break;


Ha,ha, ha. Good hack, but it fails. Think in something like
st -e -sh. I also don't understand why to remove -e from
the man page. If the patch is only because you want to
remove the goto, then you are wrong. This goto is a perfect
example of a correct goto and it is even beatiful. If you agree
I will apply this version of your patch:


diff --git a/st.1 b/st.1
index a9fec15..56dfa3a 100644
--- a/st.1
+++ b/st.1
_AT_@ -20,6 +20,7 @@ st \- simple terminal
 .RB [ \-v ]
 .RB [ \-e
 .IR command ...]
+.RI [ command ...]
 .SH DESCRIPTION
 .B st
 is a simple terminal emulator.
diff --git a/st.c b/st.c
index 7051a4a..c5120d0 100644
--- a/st.c
+++ b/st.c
_AT_@ -4022,12 +4022,12 @@ void
 usage(void) {
         die("%s " VERSION " (c) 2010-2015 st engineers\n" \
         "usage: st [-a] [-v] [-c class] [-f font] [-g geometry] [-o file]\n"
- " [-i] [-t title] [-w windowid] [-e command ...]\n", argv0);
+ " [-i] [-t title] [-w windowid] [-e command ...][command ...]\n",
+ argv0);
 }
 
 int
 main(int argc, char *argv[]) {
- char *titles;
         uint cols = 80, rows = 24;
 
         xw.l = xw.t = 0;
_AT_@ -4042,14 +4042,8 @@ main(int argc, char *argv[]) {
                 opt_class = EARGF(usage());
                 break;
         case 'e':
- /* eat all remaining arguments */
- if(argc > 1) {
- opt_cmd = &argv[1];
- if(argv[1] != NULL && opt_title == NULL) {
- titles = xstrdup(argv[1]);
- opt_title = basename(titles);
- }
- }
+ if (argc > 1)
+ --argc, ++argv;
                 goto run;
         case 'f':
                 opt_font = EARGF(usage());
_AT_@ -4076,6 +4070,12 @@ main(int argc, char *argv[]) {
         } ARGEND;
 
 run:
+ if(argc > 0) {
+ /* eat all remaining arguments */
+ opt_cmd = argv;
+ if(!opt_title)
+ opt_title = basename(xstrdup(argv[0]));
+ }
         setlocale(LC_CTYPE, "");
         XSetLocaleModifiers("");
         tnew(cols? cols : 1, rows? rows : 1);
Received on Mon Apr 13 2015 - 21:58:16 CEST

This archive was generated by hypermail 2.3.0 : Mon Apr 13 2015 - 22:00:13 CEST