diff options
| -rw-r--r-- | Makefile | 4 | ||||
| -rw-r--r-- | bb.c | 8 | ||||
| -rw-r--r-- | config.def.h | 8 |
3 files changed, 14 insertions, 6 deletions
@@ -13,6 +13,10 @@ ifeq ($(shell uname),Darwin) -Wno-missing-noreturn -Wno-cast-qual endif +ifneq (, $(SH)) + CFLAGS += -D'SH="$(SH)"' +endif + PICKER_FLAG= ifeq (, $(PICKER)) PICKER=$(shell sh -c "(which fzy >/dev/null 2>/dev/null && echo 'fzy') || (which fzf >/dev/null 2>/dev/null && echo 'fzf') || (which pick >/dev/null 2>/dev/null && echo 'pick') || (which ask >/dev/null 2>/dev/null && echo 'ask')") @@ -307,7 +307,7 @@ int run_script(bb_t *bb, const char *cmd) size_t space = 32; char **args = memcheck(calloc(space, sizeof(char*))); size_t i = 0; - args[i++] = "sh"; + args[i++] = SH; args[i++] = "-c"; char *fullcmd = calloc(strlen(cmd) + strlen(bbcmdfn) + 1, sizeof(char)); strcpy(fullcmd, bbcmdfn); @@ -332,7 +332,7 @@ int run_script(bb_t *bb, const char *cmd) ttyin = open("/dev/tty", O_RDONLY); dup2(ttyout, STDOUT_FILENO); dup2(ttyin, STDIN_FILENO); - execvp("sh", args); + execvp(SH, args); err("Failed to execute command: '%s'", cmd); return -1; } @@ -1074,8 +1074,8 @@ bb_result_t process_cmd(bb_t *bb, const char *cmd) } else { close(fds[1]); dup2(fds[0], STDIN_FILENO); - char *args[] = {"sh", "-c", "$PAGER -rX", NULL}; - execvp("sh", args); + char *args[] = {SH, "-c", "$PAGER -rX", NULL}; + execvp(SH, args); } init_term(); signal(SIGINT, old_handler); diff --git a/config.def.h b/config.def.h index e8d1d3e..498f03c 100644 --- a/config.def.h +++ b/config.def.h @@ -91,6 +91,10 @@ typedef struct { #define DIR_COLOR "\033[34m" #define EXECUTABLE_COLOR "\033[31m" +#ifndef SH +#define SH "sh" +#endif + // Some handy macros for common shell script behaviors: #define PAUSE " read -n1 -p '\033[2mPress any key to continue...\033[0m\033[?25l' >/dev/tty </dev/tty" @@ -249,9 +253,9 @@ binding_t bindings[] = { "{ if [ $type = File ]; then touch \"$name\"; else mkdir \"$name\"; fi " "&& bb \"+goto:$name\" +r || "PAUSE"; }", B("New")" file/directory"}, {{'p'}, "$PAGER \"$@\"", B("Page")" through a file in $PAGER"}, - {{'|'}, ASK("cmd", "|", "") " && printf '%s\\n' \"$@\" | sh -c \"$BBSHELLFUNC$cmd\"; " PAUSE "; bb +r", + {{'|'}, ASK("cmd", "|", "") " && printf '%s\\n' \"$@\" | "SH" -c \"$BBSHELLFUNC$cmd\"; " PAUSE "; bb +r", B("Pipe")" selected files to a command"}, - {{':'}, ASK("cmd", ":", "")" && sh -c \"$BBSHELLFUNC$cmd\" -- \"$@\"; " PAUSE "; bb +refresh", + {{':'}, ASK("cmd", ":", "")" && "SH" -c \"$BBSHELLFUNC$cmd\" -- \"$@\"; " PAUSE "; bb +refresh", B("Run")" a command"}, {{'>'}, "tput rmcup >/dev/tty; $SHELL; bb +r", "Open a "B("shell")}, {{'r', KEY_F2}, |
