aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAurélien Aptel <aurelien.aptel@gmail.com>2010-11-30 22:55:44 +0100
committerAurélien Aptel <aurelien.aptel@gmail.com>2010-11-30 22:55:44 +0100
commit5dd76fab8b4772adb10a0ba37c7bce8d3ca06b7c (patch)
treec2e0b837ea9437f8ac9c2f5a5e0aeaf4b6ae3a7f
parent191e59e4389cc0d235c14be5a53554267a81c0a6 (diff)
downloadst-patched-5dd76fab8b4772adb10a0ba37c7bce8d3ca06b7c.tar.bz2
st-patched-5dd76fab8b4772adb10a0ba37c7bce8d3ca06b7c.tar.xz
st-patched-5dd76fab8b4772adb10a0ba37c7bce8d3ca06b7c.zip
change -e behaviour and update man page.
-rw-r--r--st.125
-rw-r--r--st.c16
2 files changed, 24 insertions, 17 deletions
diff --git a/st.1 b/st.1
index 29bdda6..f1f41a7 100644
--- a/st.1
+++ b/st.1
@@ -3,23 +3,30 @@
3st \- simple terminal 3st \- simple terminal
4.SH SYNOPSIS 4.SH SYNOPSIS
5.B st 5.B st
6.RB [ \-e " <cmd>"] 6.RB [ \-c
7.RB [ \-c " <class>"] 7.IR class ]
8.RB [ \-t " <title>"] 8.RB [ \-t
9.IR title ]
9.RB [ \-v ] 10.RB [ \-v ]
11.RB [ \-e
12.IR cmd ]
10.SH DESCRIPTION 13.SH DESCRIPTION
11.B st 14.B st
12is a simple terminal emulator. 15is a simple terminal emulator.
13.SH OPTIONS 16.SH OPTIONS
14.TP 17.TP
15.B \-e <cmd> 18.B \-t title
16Execute cmd instead of the shell
17.TP
18.B \-t <title>
19Overrides the default title (st) 19Overrides the default title (st)
20.TP 20.TP
21.B \-c <class> 21.B \-c class
22Overrides the default class ($TERM) 22Overrides the default class ($TERM)
23.TP 23.TP
24.BI \-v 24.B \-v
25Prints version information to standard output, then exits. 25Prints version information to standard output, then exits.
26.TP
27.B \-e cmd [arguments]
28Execute cmd instead of the shell. Type your command as you would on your
29shell. If this option is used, it
30.BI "must be the last"
31on the command-line. This is the same behaviour as xterm/rxvt.
32
diff --git a/st.c b/st.c
index d43c30c..2be6772 100644
--- a/st.c
+++ b/st.c
@@ -247,7 +247,7 @@ static CSIEscape escseq;
247static int cmdfd; 247static int cmdfd;
248static pid_t pid; 248static pid_t pid;
249static Selection sel; 249static Selection sel;
250static char *opt_cmd = NULL; 250static char **opt_cmd = NULL;
251static char *opt_title = NULL; 251static char *opt_title = NULL;
252static char *opt_class = NULL; 252static char *opt_class = NULL;
253 253
@@ -547,15 +547,12 @@ void
547execsh(void) { 547execsh(void) {
548 char **args; 548 char **args;
549 char *envshell = getenv("SHELL"); 549 char *envshell = getenv("SHELL");
550 DEFAULT(envshell, "sh");
551 550
552 if(opt_cmd) 551 DEFAULT(envshell, "sh");
553 args = (char*[]){"sh", "-c", opt_cmd, NULL};
554 else
555 args = (char*[]){envshell, "-i", NULL};
556
557 putenv("TERM="TNAME); 552 putenv("TERM="TNAME);
553 args = opt_cmd ? opt_cmd : (char*[]){envshell, "-i", NULL};
558 execvp(args[0], args); 554 execvp(args[0], args);
555 exit(EXIT_FAILURE);
559} 556}
560 557
561void 558void
@@ -1855,12 +1852,15 @@ main(int argc, char *argv[]) {
1855 if(++i < argc) opt_class = argv[i]; 1852 if(++i < argc) opt_class = argv[i];
1856 break; 1853 break;
1857 case 'e': 1854 case 'e':
1858 if(++i < argc) opt_cmd = argv[i]; 1855 if(++i < argc) opt_cmd = &argv[i];
1859 break; 1856 break;
1860 case 'v': 1857 case 'v':
1861 default: 1858 default:
1862 die(USAGE); 1859 die(USAGE);
1863 } 1860 }
1861 /* -e eats every remaining arguments */
1862 if(opt_cmd)
1863 break;
1864 } 1864 }
1865 setlocale(LC_CTYPE, ""); 1865 setlocale(LC_CTYPE, "");
1866 tnew(80, 24); 1866 tnew(80, 24);