st-option-20250404-98610fc.diff - sites - public wiki contents of suckless.org
 (HTM) git clone git://git.suckless.org/sites
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
       st-option-20250404-98610fc.diff (1452B)
       ---
            1 From de46184d9175c67e3fc45aed997118dad0d6bb3d Mon Sep 17 00:00:00 2001
            2 From: Mertoalex Ashley <mertoalex+git@disroot.org>
            3 Date: Fri, 4 Apr 2025 21:27:03 +0300
            4 Subject: [PATCH] adding variable `option` to config.def.h so you can call
            5  shell with argument.
            6 
            7 ---
            8  config.def.h | 6 ++++++
            9  st.c         | 3 +++
           10  st.h         | 1 +
           11  3 files changed, 10 insertions(+)
           12 
           13 diff --git a/config.def.h b/config.def.h
           14 index 2cd740a..c314e98 100644
           15 --- a/config.def.h
           16 +++ b/config.def.h
           17 @@ -17,6 +17,12 @@ static int borderpx = 2;
           18   * 5: value of shell in config.h
           19   */
           20  static char *shell = "/bin/sh";
           21 +/*
           22 + * argument that should be used to call shell with,
           23 + * like  "-l" to make st open shell as login shell.
           24 + * (needed on shells like busybox-ash.)
           25 + */
           26 +char *option = NULL;
           27  char *utmp = NULL;
           28  /* scroll program: to enable use a string like "scroll" */
           29  char *scroll = NULL;
           30 diff --git a/st.c b/st.c
           31 index 03b9bc8..03d3100 100644
           32 --- a/st.c
           33 +++ b/st.c
           34 @@ -677,6 +677,9 @@ execsh(char *cmd, char **args)
           35          if (args) {
           36                  prog = args[0];
           37                  arg = NULL;
           38 +        } else if (option) {
           39 +                prog = sh;
           40 +                arg = option;
           41          } else if (scroll) {
           42                  prog = scroll;
           43                  arg = utmp ? utmp : sh;
           44 diff --git a/st.h b/st.h
           45 index fd3b0d8..b7a0237 100644
           46 --- a/st.h
           47 +++ b/st.h
           48 @@ -112,6 +112,7 @@ void *xrealloc(void *, size_t);
           49  char *xstrdup(const char *);
           50  
           51  /* config.h globals */
           52 +extern char *option;
           53  extern char *utmp;
           54  extern char *scroll;
           55  extern char *stty_args;
           56 -- 
           57 2.48.1
           58