summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Kleine-Budde <mkl@pengutronix.de>2021-07-09 10:45:50 +0200
committerMarc Kleine-Budde <mkl@pengutronix.de>2021-07-09 12:08:05 +0200
commit1c530126810655b645951da50a8f1863312419b0 (patch)
treed80016a565c2f3fdf4c08a68a083992188bde40e
parentc75b6982397afe85f83d8a81d220c3290d5fe60d (diff)
downloadgenimage-1c530126810655b645951da50a8f1863312419b0.tar.gz
genimage-1c530126810655b645951da50a8f1863312419b0.tar.xz
util: systemp(): use shell defined in SHELL rather than /bin/sh
This patch changes systemp() to use the shell defined in the environment variable SHELL rather then hard coded /bin/sh, so that the called programs can use shell functions exported in the calling shell. Use "/bin/sh" as a fall back. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
-rw-r--r--util.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/util.c b/util.c
index 92b4fca..f827ad7 100644
--- a/util.c
+++ b/util.c
@@ -216,6 +216,7 @@ int systemp(struct image *image, const char *fmt, ...)
pid = fork();
if (!pid) {
+ const char *shell;
int fd;
if (loglevel() < 1) {
@@ -230,7 +231,11 @@ int systemp(struct image *image, const char *fmt, ...)
dup2(STDERR_FILENO, STDOUT_FILENO);
}
- ret = execl("/bin/sh", "sh", "-c", buf, NULL);
+ shell = getenv("SHELL");
+ if (!shell || shell[0] == 0x0)
+ shell = "/bin/sh";
+
+ ret = execl(shell, shell, "-c", buf, NULL);
if (ret < 0) {
ret = -errno;
error("Cannot execute %s: %s\n", buf, strerror(errno));