aboutsummaryrefslogtreecommitdiff
path: root/st.c
diff options
context:
space:
mode:
authorRoberto E. Vargas Caballero <k0ga@shike2.com>2020-04-10 22:06:32 +0200
committerHiltjo Posthuma <hiltjo@codemadness.org>2020-04-11 15:23:20 +0200
commit21e0d6e8b8d20903494386e7e6f43201b3761154 (patch)
tree5b05d14922679f2560855d5734314336c16cade2 /st.c
parent5703aa0390484dd7da4bd9c388c85708d8fcd339 (diff)
downloadst-21e0d6e8b8d20903494386e7e6f43201b3761154.tar.gz
st-21e0d6e8b8d20903494386e7e6f43201b3761154.tar.bz2
Add support for scroll(1)
Scroll is a program that stores all the lines of its child and be used in st as a way of implementing scrollback. This solution is much better than implementing the scrollback in st itself because having a different program allows to use it in any other program without doing modifications to those programs.
Diffstat (limited to 'st.c')
-rw-r--r--st.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/st.c b/st.c
index 3e48410..5f2352a 100644
--- a/st.c
+++ b/st.c
@@ -664,7 +664,7 @@ die(const char *errstr, ...)
void
execsh(char *cmd, char **args)
{
- char *sh, *prog;
+ char *sh, *prog, *arg;
const struct passwd *pw;
errno = 0;
@@ -678,13 +678,17 @@ execsh(char *cmd, char **args)
if ((sh = getenv("SHELL")) == NULL)
sh = (pw->pw_shell[0]) ? pw->pw_shell : cmd;
- if (args)
+ if (args) {
prog = args[0];
- else if (utmp)
- prog = utmp;
- else
+ arg = NULL;
+ } else if (scroll || utmp) {
+ prog = scroll ? scroll : utmp;
+ arg = scroll ? utmp : NULL;
+ } else {
prog = sh;
- DEFAULT(args, ((char *[]) {prog, NULL}));
+ arg = NULL;
+ }
+ DEFAULT(args, ((char *[]) {prog, arg, NULL}));
unsetenv("COLUMNS");
unsetenv("LINES");