From 34f5066865e69eb92c112532c5ee6bd58e26c31a Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Fri, 21 Dec 2018 10:55:03 -0500 Subject: [PATCH] fixed a bug in fetch and simplified shell-picking logic in term --- config.h | 4 ++-- src/term.c | 48 ++++-------------------------------------------- 2 files changed, 6 insertions(+), 46 deletions(-) diff --git a/config.h b/config.h index 58bff13..ac52cbf 100644 --- a/config.h +++ b/config.h @@ -112,8 +112,8 @@ static Rule* BuiltinRules[] = { }, (Rule[]){ /* Look it up in ctags database */ { ISFILE, "tags", NULL }, - { EXEC, "grep -q '^$data\\s\\+' tags", NULL }, - { LAUNCH, "picktag fetch tags '$data' | xargs -r edit", NULL }, + { EXEC, "grep -q \"^$data\\s\\+\" tags", NULL }, + { LAUNCH, "picktag fetch tags \"$data\" | xargs -r edit", NULL }, { COMPLETE, NULL, NULL } }, (Rule[]){ /* Look up .c or .h files in Code/ */ diff --git a/src/term.c b/src/term.c index 2b415d1..6b27d9c 100644 --- a/src/term.c +++ b/src/term.c @@ -48,7 +48,6 @@ #include #endif - /* XEMBED messages */ #define XEMBED_FOCUS_IN 4 #define XEMBED_FOCUS_OUT 5 @@ -331,16 +330,8 @@ static char font[] = "Liberation Mono:pixelsize=14:antialias=true:autohint=true" static int borderpx = 2; #define histsize 5000 -/* - * What program is execed by st depends of these precedence rules: - * 1: program passed with -e - * 2: utmp option - * 3: SHELL environment variable - * 4: value of shell in /etc/passwd - * 5: value of shell in config.h - */ -static char shell[] = "/bin/sh"; -static char *utmp = NULL; +/* shell */ +static char* shell[] = { "/bin/bash", "-l", 0 }; /* identification sequence returned in DA and DECID */ static char vtiden[] = "\033[?6c"; @@ -378,12 +369,6 @@ static unsigned int blinktimeout = 800; */ static unsigned int cursorthickness = 2; -/* - * bell volume. It must be a value between -100 and 100. Use 0 for disabling - * it - */ -static int bellvolume = 0; - /* default TERM value */ static char termname[] = "st-256color"; @@ -1730,36 +1715,13 @@ die(const char *errstr, ...) void execsh(void) { - char **args, *sh, *prog; - const struct passwd *pw; char buf[sizeof(long) * 8 + 1]; - - errno = 0; - if ((pw = getpwuid(getuid())) == NULL) { - if (errno) - die("getpwuid:%s\n", strerror(errno)); - else - die("who are you?\n"); - } - - if ((sh = getenv("SHELL")) == NULL) - sh = (pw->pw_shell[0]) ? pw->pw_shell : shell; - - if (utmp) - prog = utmp; - else - prog = sh; - args = (char *[]) {prog, NULL}; - snprintf(buf, sizeof(buf), "%lu", xw.win); unsetenv("COLUMNS"); unsetenv("LINES"); unsetenv("TERMCAP"); - setenv("LOGNAME", pw->pw_name, 1); - setenv("USER", pw->pw_name, 1); - setenv("SHELL", sh, 1); - setenv("HOME", pw->pw_dir, 1); + setenv("SHELL", shell[0], 1); setenv("TERM", termname, 1); setenv("WINDOWID", buf, 1); @@ -1770,7 +1732,7 @@ execsh(void) signal(SIGTERM, SIG_DFL); signal(SIGALRM, SIG_DFL); - execvp(prog, args); + execvp(shell[0], shell); _exit(1); } @@ -3092,8 +3054,6 @@ tcontrolcode(uchar ascii) } else { if (!(xw.state & WIN_FOCUSED)) xseturgency(1); - if (bellvolume) - XkbBell(xw.dpy, xw.win, bellvolume, (Atom)NULL); } break; case '\033': /* ESC */ -- 2.52.0