Xinqi Bao's Git
projects
/
st.git
/ commitdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
patch
|
inline
| side by side (parent:
732b960
)
change -e behaviour and update man page.
author
Aurélien Aptel <
[email protected]
>
Tue, 30 Nov 2010 21:55:44 +0000
(22:55 +0100)
committer
Aurélien Aptel <
[email protected]
>
Tue, 30 Nov 2010 21:55:44 +0000
(22:55 +0100)
st.1
patch
|
blob
|
history
st.c
patch
|
blob
|
history
diff --git
a/st.1
b/st.1
index
29bdda6
..
f1f41a7
100644
(file)
--- a/
st.1
+++ b/
st.1
@@
-3,23
+3,30
@@
st \- simple terminal
.SH SYNOPSIS
.B st
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 [ \-v ]
+.RB [ \-e
+.IR cmd ]
.SH DESCRIPTION
.B st
is a simple terminal emulator.
.SH OPTIONS
.TP
.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
Overrides the default title (st)
.TP
-.B \-c
<class>
+.B \-c
class
Overrides the default class ($TERM)
.TP
Overrides the default class ($TERM)
.TP
-.B
I
\-v
+.B \-v
Prints version information to standard output, then exits.
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 --git
a/st.c
b/st.c
index
d43c30c
..
2be6772
100644
(file)
--- a/
st.c
+++ b/
st.c
@@
-247,7
+247,7
@@
static CSIEscape escseq;
static int cmdfd;
static pid_t pid;
static Selection sel;
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;
static char *opt_title = NULL;
static char *opt_class = NULL;
@@
-547,15
+547,12
@@
void
execsh(void) {
char **args;
char *envshell = getenv("SHELL");
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};
-
+ DEFAULT(envshell, "sh");
putenv("TERM="TNAME);
putenv("TERM="TNAME);
+ args = opt_cmd ? opt_cmd : (char*[]){envshell, "-i", NULL};
execvp(args[0], args);
execvp(args[0], args);
+ exit(EXIT_FAILURE);
}
void
}
void
@@
-1855,12
+1852,15
@@
main(int argc, char *argv[]) {
if(++i < argc) opt_class = argv[i];
break;
case 'e':
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);
}
break;
case 'v':
default:
die(USAGE);
}
+ /* -e eats every remaining arguments */
+ if(opt_cmd)
+ break;
}
setlocale(LC_CTYPE, "");
tnew(80, 24);
}
setlocale(LC_CTYPE, "");
tnew(80, 24);