diff options
| author | William Casarin <jb55@jb55.com> | 2018-07-09 20:05:58 -0700 |
|---|---|---|
| committer | William Casarin <jb55@jb55.com> | 2018-07-09 20:05:58 -0700 |
| commit | 8a60b03a0119c5ae071952dd5915f2741b3fe4f2 (patch) | |
| tree | 6bf6d2aee186904c51250e964b3c5c185fe9018f | |
| parent | e15c139924df0b56f376ebdeb01c56852de50984 (diff) | |
allow name to be different from command
| -rw-r--r-- | cfg.def.h | 7 | ||||
| -rw-r--r-- | cmdtree.c | 1 | ||||
| -rw-r--r-- | command.c | 3 | ||||
| -rw-r--r-- | command.h | 1 |
4 files changed, 7 insertions, 5 deletions
@@ -45,7 +45,7 @@ static struct command browser_commands[] = { { .bind = "f", .name = "firefox", .nchildren = 0, .children = NULL }, }; -static const struct command commands[] = { +static struct command commands[] = { { .bind = "b", .name = "browsers", .nchildren = LENGTH(browser_commands), @@ -53,8 +53,9 @@ static const struct command commands[] = { }, { .bind = "e", - .name = "emacs-dev", - .children = NULL, + .name = "emacs", + .command = "emacs-dev", + .children = 0, .nchildren = 0 }, }; @@ -41,7 +41,6 @@ static XIC xic; #include "cfg.h" - static int cmdstack_push_(struct command *children, int nchildren) { if (cmdstack_ptr + 1 >= CMDSTACK_SIZE) @@ -17,7 +17,8 @@ command_is_prefix(struct command *cmd) { void command_exec(struct command *cmd) { - execlp("/bin/sh", "sh", "-c", cmd->name, (char *) 0); + const char *cmdname = cmd->command == NULL ? cmd->name : cmd->command; + execlp("/bin/sh", "sh", "-c", cmdname, (char *) 0); err(1, "executing command %s", cmd->name); } @@ -6,6 +6,7 @@ struct command { char *name; + char *command; char *bind; struct command *children; int nchildren; |
