Use SHELL to find a shell. - sam - An updated version of the sam text editor.
(HTM) git clone git://vernunftzentrum.de/sam.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
(DIR) commit 107d59adec9936d63ab3ca7e508911343473f6da
(DIR) parent 078d234601dbb4122149ad46dbd9b2cf5c67a938
(HTM) Author: Rob King <jking@deadpixi.com>
Date: Fri, 23 Sep 2016 09:26:55 -0500
Use SHELL to find a shell.
Credit for this patch goes to Tommy Pettersson.
Diffstat:
sam/sam.c | 5 +++++
sam/sam.h | 2 ++
sam/shell.c | 3 ++-
3 files changed, 9 insertions(+), 1 deletion(-)
---
(DIR) diff --git a/sam/sam.c b/sam/sam.c
@@ -1,6 +1,7 @@
/* Copyright (c) 1998 Lucent Technologies - All rights reserved. */
#include "sam.h"
+#include <libgen.h>
#include <stdbool.h>
#include <unistd.h>
@@ -31,6 +32,8 @@ int bpipeok;
int termlocked;
char *samterm = "samterm";
char *rsamname = "rsam";
+char *sh = "sh";
+char *shpath = "/bin/sh";
Rune baddir[] = { '<', 'b', 'a', 'd', 'd', 'i', 'r', '>', '\n'};
@@ -99,6 +102,8 @@ main(int argc, char *argv[])
home = getenv("HOME");
if(home == 0)
home = "/";
+ shpath = getenv("SHELL") ? getenv("SHELL") : shpath;
+ sh = basename(shpath);
if(!dflag)
startup(machine, Rflag, arg, ap);
Fstart();
(DIR) diff --git a/sam/sam.h b/sam/sam.h
@@ -346,6 +346,8 @@ extern Rune *right[];
extern char *rsamname; /* globals */
extern char *samterm;
+extern char *sh;
+extern char *shpath;
extern Rune genbuf[];
extern char *genc;
extern int io;
(DIR) diff --git a/sam/shell.c b/sam/shell.c
@@ -95,7 +95,8 @@ plan9(File *f, int type, String *s, int nest)
close(0); /* so it won't read from terminal */
open("/dev/null", 0);
}
- exit(system(Strtoc(&plan9cmd)));
+ execl(shpath, sh, "-c", Strtoc(&plan9cmd), NULL);
+ exits("exec");
}
if(pid == -1)
error(Efork);