diff options
author | Roberto E. Vargas Caballero <k0ga@shike2.com> | 2020-04-10 22:06:32 +0200 |
---|---|---|
committer | Hiltjo Posthuma <hiltjo@codemadness.org> | 2020-04-11 15:23:20 +0200 |
commit | 21e0d6e8b8d20903494386e7e6f43201b3761154 (patch) | |
tree | 5b05d14922679f2560855d5734314336c16cade2 /st.c | |
parent | 5703aa0390484dd7da4bd9c388c85708d8fcd339 (diff) | |
download | st-patched-21e0d6e8b8d20903494386e7e6f43201b3761154.tar.bz2 st-patched-21e0d6e8b8d20903494386e7e6f43201b3761154.tar.xz st-patched-21e0d6e8b8d20903494386e7e6f43201b3761154.zip |
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.c | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -664,7 +664,7 @@ die(const char *errstr, ...) | |||
664 | void | 664 | void |
665 | execsh(char *cmd, char **args) | 665 | execsh(char *cmd, char **args) |
666 | { | 666 | { |
667 | char *sh, *prog; | 667 | char *sh, *prog, *arg; |
668 | const struct passwd *pw; | 668 | const struct passwd *pw; |
669 | 669 | ||
670 | errno = 0; | 670 | errno = 0; |
@@ -678,13 +678,17 @@ execsh(char *cmd, char **args) | |||
678 | if ((sh = getenv("SHELL")) == NULL) | 678 | if ((sh = getenv("SHELL")) == NULL) |
679 | sh = (pw->pw_shell[0]) ? pw->pw_shell : cmd; | 679 | sh = (pw->pw_shell[0]) ? pw->pw_shell : cmd; |
680 | 680 | ||
681 | if (args) | 681 | if (args) { |
682 | prog = args[0]; | 682 | prog = args[0]; |
683 | else if (utmp) | 683 | arg = NULL; |
684 | prog = utmp; | 684 | } else if (scroll || utmp) { |
685 | else | 685 | prog = scroll ? scroll : utmp; |
686 | arg = scroll ? utmp : NULL; | ||
687 | } else { | ||
686 | prog = sh; | 688 | prog = sh; |
687 | DEFAULT(args, ((char *[]) {prog, NULL})); | 689 | arg = NULL; |
690 | } | ||
691 | DEFAULT(args, ((char *[]) {prog, arg, NULL})); | ||
688 | 692 | ||
689 | unsetenv("COLUMNS"); | 693 | unsetenv("COLUMNS"); |
690 | unsetenv("LINES"); | 694 | unsetenv("LINES"); |