diff options
author | Aurélien Aptel <aurelien.aptel@gmail.com> | 2010-11-30 22:55:44 +0100 |
---|---|---|
committer | Aurélien Aptel <aurelien.aptel@gmail.com> | 2010-11-30 22:55:44 +0100 |
commit | 5dd76fab8b4772adb10a0ba37c7bce8d3ca06b7c (patch) | |
tree | c2e0b837ea9437f8ac9c2f5a5e0aeaf4b6ae3a7f | |
parent | 191e59e4389cc0d235c14be5a53554267a81c0a6 (diff) | |
download | st-patched-5dd76fab8b4772adb10a0ba37c7bce8d3ca06b7c.tar.bz2 st-patched-5dd76fab8b4772adb10a0ba37c7bce8d3ca06b7c.tar.xz st-patched-5dd76fab8b4772adb10a0ba37c7bce8d3ca06b7c.zip |
change -e behaviour and update man page.
-rw-r--r-- | st.1 | 25 | ||||
-rw-r--r-- | st.c | 16 |
2 files changed, 24 insertions, 17 deletions
@@ -3,23 +3,30 @@ | |||
3 | st \- simple terminal | 3 | st \- 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 |
12 | is a simple terminal emulator. | 15 | is a simple terminal emulator. |
13 | .SH OPTIONS | 16 | .SH OPTIONS |
14 | .TP | 17 | .TP |
15 | .B \-e <cmd> | 18 | .B \-t title |
16 | Execute cmd instead of the shell | ||
17 | .TP | ||
18 | .B \-t <title> | ||
19 | Overrides the default title (st) | 19 | Overrides the default title (st) |
20 | .TP | 20 | .TP |
21 | .B \-c <class> | 21 | .B \-c class |
22 | Overrides the default class ($TERM) | 22 | Overrides the default class ($TERM) |
23 | .TP | 23 | .TP |
24 | .BI \-v | 24 | .B \-v |
25 | Prints version information to standard output, then exits. | 25 | Prints version information to standard output, then exits. |
26 | .TP | ||
27 | .B \-e cmd [arguments] | ||
28 | Execute cmd instead of the shell. Type your command as you would on your | ||
29 | shell. If this option is used, it | ||
30 | .BI "must be the last" | ||
31 | on the command-line. This is the same behaviour as xterm/rxvt. | ||
32 | |||
@@ -247,7 +247,7 @@ static CSIEscape escseq; | |||
247 | static int cmdfd; | 247 | static int cmdfd; |
248 | static pid_t pid; | 248 | static pid_t pid; |
249 | static Selection sel; | 249 | static Selection sel; |
250 | static char *opt_cmd = NULL; | 250 | static char **opt_cmd = NULL; |
251 | static char *opt_title = NULL; | 251 | static char *opt_title = NULL; |
252 | static char *opt_class = NULL; | 252 | static char *opt_class = NULL; |
253 | 253 | ||
@@ -547,15 +547,12 @@ void | |||
547 | execsh(void) { | 547 | execsh(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 | ||
561 | void | 558 | void |
@@ -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); |