From 6818a692d27b09a13f0bca9177450c94c67ade1e Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Fri, 14 Mar 2008 18:12:33 +0100 Subject: [PATCH] Rewrite uicb_exec --- uicb.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/uicb.c b/uicb.c index fc8b1a1a..b08a0cc0 100644 --- a/uicb.c +++ b/uicb.c @@ -52,7 +52,6 @@ void uicb_exec(int screen __attribute__ ((unused)), char *cmd) { Client *c; - int args_pos; char *args, *path; /* remap all clients since some WM won't handle them otherwise */ @@ -61,23 +60,20 @@ uicb_exec(int screen __attribute__ ((unused)), char *cmd) XSync(globalconf.display, False); - if(globalconf.display) - close(ConnectionNumber(globalconf.display)); - /* Ignore the leading spaces if any */ - for(args_pos = 0; - args_pos < a_strlen(cmd) && cmd[args_pos] == ' '; - ++args_pos); + while(cmd[0] && cmd[0] == ' ') + cmd++; /* Get the beginning of the arguments */ - if((args = strchr(cmd + args_pos, ' ')) == NULL) - { - warn("invalid command %s\n", cmd); - return; - } + args = strchr(cmd, ' '); + + if(args) + path = strndup(cmd, args - cmd); + else + path = strndup(cmd, a_strlen(cmd)); - path = strndup(cmd + args_pos, args - (cmd + args_pos)); execlp(path, cmd, NULL); + p_delete(&path); } -- 2.11.4.GIT