tabbed

my build of tabbed
git clone git://git.ckyln.com/~cem/tabbed.git
Log | Files | Refs | README | LICENSE

commit c6b1f05d151e74197ca80c9b6363ebc28ced4951
parent c79e3392413da488eecb2769473989d0c2c861c9
Author: Christoph Lohmann <20h@r-36.net>
Date:   Thu,  9 Feb 2012 18:03:50 +0100

Add '--' and concatenated parameter support.
Diffstat:
Mtabbed.c | 54++++++++++++++++++++++++++++++++++++++----------------
1 file changed, 38 insertions(+), 16 deletions(-)

diff --git a/tabbed.c b/tabbed.c @@ -863,30 +863,52 @@ xerror(Display *dpy, XErrorEvent *ee) { return xerrorxlib(dpy, ee); /* may call exit */ } +char *argv0; + void -usage(char *argv0) +usage(void) { die("usage: %s [-dhsv] command...\n", argv0); } int main(int argc, char *argv[]) { - int i, detach = 0; - - for(i = 1; i < argc && !cmd; i++) { - if(!strcmp("-v", argv[i])) - die("tabbed-"VERSION", © 2009-2011 tabbed engineers, see LICENSE for details\n"); - else if(!strcmp("-d", argv[i])) - detach = 1; - else if(!strcmp("-s", argv[i])) - doinitspawn = False; - else if(!strcmp("-h", argv[i])) - usage(argv[0]); - else - setcmd(argc-i, argv+i); + int detach = 0; + char _argc; + char **_argv; + + for(argv0 = *argv, argv++, argc--; + argv[0] && argv[0][1] && argv[0][0] == '-'; + argc--, argv++) { + if(argv[0][1] == '-' && argv[0][2] == '\0') { + argv++; + argc--; + break; + } + for(argv[0]++, _argv = argv; argv[0][0]; argv[0]++) { + if(_argv != argv) + break; + _argc = argv[0][0]; + switch(_argc) { + case 'v': + die("tabbed-"VERSION", © 2009-2011" + " tabbed engineers, see LICENSE" + " for details.\n"); + case 's': + doinitspawn = False; + break; + case 'h': + usage(); + case 'd': + detach = 1; + break; + } + } } - if(!cmd) - usage(argv[0]); + if(argc < 1) + usage(); + setcmd(argc, argv); + if(!setlocale(LC_CTYPE, "") || !XSupportsLocale()) fprintf(stderr, "tabbed: no locale support\n"); if(!(dpy = XOpenDisplay(NULL)))