Skip to content

Commit 01c3953

Browse files
committed
- Make getopt stop processing as soon as the first non-option argument is
found. This should improve command chaining: previously required: xdotool search ... -- windowsize --usehints 80 24 now : xdotool search ... windowsize --usehints 80 24 The -- is no longer required to mark end of arguments for each command if a future command uses flags. From gnu's getopt_long(3): """If the first character of optstring is '+' or the environment variable POSIXLY_CORRECT is set, then option processing stops as soon as a non-option argument is encountered.""" Done with: sed -i -e '/getopt_long/ { s/"/"+/ }' *.c git-svn-id: https://semicomplete.googlecode.com/svn/xdotool@2940 66067f73-fe4c-0410-82e9-b9c6d0c95a22
1 parent 0b2f7dc commit 01c3953

27 files changed

+27
-27
lines changed

cmd_click.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ int cmd_click(context_t *context) {
2525
"right = 3, wheel up = 4, wheel down = 5\n";
2626
int option_index;
2727

28-
while ((c = getopt_long_only(context->argc, context->argv, "cw:h",
28+
while ((c = getopt_long_only(context->argc, context->argv, "+cw:h",
2929
longopts, &option_index)) != -1) {
3030
switch (c) {
3131
case 'h':

cmd_get_desktop.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ int cmd_get_desktop(context_t *context) {
1313
static const char *usage = "Usage: %s\n";
1414
int option_index;
1515

16-
while ((c = getopt_long_only(context->argc, context->argv, "h",
16+
while ((c = getopt_long_only(context->argc, context->argv, "+h",
1717
longopts, &option_index)) != -1) {
1818
switch (c) {
1919
case 'h':

cmd_get_desktop_for_window.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ int cmd_get_desktop_for_window(context_t *context) {
1515
HELP_SEE_WINDOW_STACK;
1616
int option_index;
1717

18-
while ((c = getopt_long_only(context->argc, context->argv, "h",
18+
while ((c = getopt_long_only(context->argc, context->argv, "+h",
1919
longopts, &option_index)) != -1) {
2020
switch (c) {
2121
case 'h':

cmd_get_num_desktops.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ int cmd_get_num_desktops(context_t *context) {
1313
static const char *usage = "Usage: %s\n";
1414
int option_index;
1515

16-
while ((c = getopt_long_only(context->argc, context->argv, "h",
16+
while ((c = getopt_long_only(context->argc, context->argv, "+h",
1717
longopts, &option_index)) != -1) {
1818
switch (c) {
1919
case 'h':

cmd_getactivewindow.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ int cmd_getactivewindow(context_t *context) {
1313
static const char *usage = "Usage: %s\n";
1414
int option_index;
1515

16-
while ((c = getopt_long_only(context->argc, context->argv, "h",
16+
while ((c = getopt_long_only(context->argc, context->argv, "+h",
1717
longopts, &option_index)) != -1) {
1818
switch (c) {
1919
case 'h':

cmd_getmouselocation.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ int cmd_getmouselocation(context_t *context) {
1717
int option_index;
1818
int output_shell = 0;
1919

20-
while ((c = getopt_long_only(context->argc, context->argv, "h",
20+
while ((c = getopt_long_only(context->argc, context->argv, "+h",
2121
longopts, &option_index)) != -1) {
2222
switch (c) {
2323
case 'h':

cmd_getwindowfocus.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ int cmd_getwindowfocus(context_t *context) {
2020
" that has focus.\n";
2121
int option_index;
2222

23-
while ((c = getopt_long_only(context->argc, context->argv, "fh",
23+
while ((c = getopt_long_only(context->argc, context->argv, "+fh",
2424
longopts, &option_index)) != -1) {
2525
switch (c) {
2626
case 'h':

cmd_getwindowpid.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ int cmd_getwindowpid(context_t *context) {
1212
static const char *usage = "Usage: %s <window id>\n";
1313
int option_index;
1414

15-
while ((c = getopt_long_only(context->argc, context->argv, "h",
15+
while ((c = getopt_long_only(context->argc, context->argv, "+h",
1616
longopts, &option_index)) != -1) {
1717
switch (c) {
1818
case 'h':

cmd_key.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ int cmd_key(context_t *context) {
4444
HELP_CHAINING_ENDS;
4545
int option_index;
4646

47-
while ((c = getopt_long_only(context->argc, context->argv, "d:hcw:",
47+
while ((c = getopt_long_only(context->argc, context->argv, "+d:hcw:",
4848
longopts, &option_index)) != -1) {
4949
switch (c) {
5050
case 'w':

cmd_mousedown.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ int cmd_mousedown(context_t *context) {
2222
"--clearmodifiers - reset active modifiers (alt, etc) while typing\n";
2323
int option_index;
2424

25-
while ((c = getopt_long_only(context->argc, context->argv, "chw:",
25+
while ((c = getopt_long_only(context->argc, context->argv, "+chw:",
2626
longopts, &option_index)) != -1) {
2727
switch (c) {
2828
case 'c':

cmd_mousemove.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ int cmd_mousemove(context_t *context) {
5757
"-w, --window <windowid> - specify a window to move relative to.\n";
5858
int option_index;
5959

60-
while ((c = getopt_long_only(context->argc, context->argv, "chw:pd:",
60+
while ((c = getopt_long_only(context->argc, context->argv, "+chw:pd:",
6161
longopts, &option_index)) != -1) {
6262
switch (c) {
6363
case 'c':

cmd_mousemove_relative.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ int cmd_mousemove_relative(context_t *context) {
3838
" %s 100 140\n";
3939
int option_index;
4040

41-
while ((c = getopt_long_only(context->argc, context->argv, "cph",
41+
while ((c = getopt_long_only(context->argc, context->argv, "+cph",
4242
longopts, &option_index)) != -1) {
4343
switch (c) {
4444
case 'h':

cmd_mouseup.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ int cmd_mouseup(context_t *context) {
2222
"--clearmodifiers - reset active modifiers (alt, etc) while typing\n";
2323
int option_index;
2424

25-
while ((c = getopt_long_only(context->argc, context->argv, "cw:h",
25+
while ((c = getopt_long_only(context->argc, context->argv, "+cw:h",
2626
longopts, &option_index)) != -1) {
2727
switch (c) {
2828
case 'h':

cmd_search.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ int cmd_search(context_t *context) {
5757
char *cmd = *context->argv;
5858
int option_index;
5959

60-
while ((c = getopt_long_only(context->argc, context->argv, "h",
60+
while ((c = getopt_long_only(context->argc, context->argv, "+h",
6161
longopts, &option_index)) != -1) {
6262
switch (c) {
6363
case 0:

cmd_set_desktop.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ int cmd_set_desktop(context_t *context) {
1212
static const char *usage = "Usage: %s desktop\n";
1313
int option_index;
1414

15-
while ((c = getopt_long_only(context->argc, context->argv, "h",
15+
while ((c = getopt_long_only(context->argc, context->argv, "+h",
1616
longopts, &option_index)) != -1) {
1717
switch (c) {
1818
case 'h':

cmd_set_desktop_for_window.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ int cmd_set_desktop_for_window(context_t *context) {
1313
static const char *usage = "Usage: %s <window> <desktop>\n";
1414
int option_index;
1515

16-
while ((c = getopt_long_only(context->argc, context->argv, "h",
16+
while ((c = getopt_long_only(context->argc, context->argv, "+h",
1717
longopts, &option_index)) != -1) {
1818
switch (c) {
1919
case 'h':

cmd_set_num_desktops.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ int cmd_set_num_desktops(context_t *context) {
1212
static const char *usage = "Usage: %s num_desktops\n";
1313
int option_index;
1414

15-
while ((c = getopt_long_only(context->argc, context->argv, "h",
15+
while ((c = getopt_long_only(context->argc, context->argv, "+h",
1616
longopts, &option_index)) != -1) {
1717
switch (c) {
1818
case 'h':

cmd_set_window.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ int cmd_set_window(context_t *context) {
2525
static const char *usage = "Usage: %s [--name name] [--icon-name name] "
2626
"[--role role] [--classname classname] [--class class] window\n";
2727

28-
while ((c = getopt_long_only(context->argc, context->argv, "hn:i:r:C:N:",
28+
while ((c = getopt_long_only(context->argc, context->argv, "+hn:i:r:C:N:",
2929
longopts, &option_index)) != -1) {
3030
switch(c) {
3131
case 'n':

cmd_type.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ int cmd_type(context_t *context) {
3030
"-h, --help - show this help output\n";
3131
int option_index;
3232

33-
while ((c = getopt_long_only(context->argc, context->argv, "w:d:ch",
33+
while ((c = getopt_long_only(context->argc, context->argv, "+w:d:ch",
3434
longopts, &option_index)) != -1) {
3535
switch (c) {
3636
case 'w':

cmd_windowactivate.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ int cmd_windowactivate(context_t *context) {
2020
"--sync - only exit once the window is active (is visible + active)\n";
2121

2222
int option_index;
23-
while ((c = getopt_long_only(context->argc, context->argv, "h",
23+
while ((c = getopt_long_only(context->argc, context->argv, "+h",
2424
longopts, &option_index)) != -1) {
2525
switch (c) {
2626
case 'h':

cmd_windowfocus.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ int cmd_windowfocus(context_t *context) {
2020
"--sync - only exit once the window has focus\n";
2121

2222
int option_index;
23-
while ((c = getopt_long_only(context->argc, context->argv, "h",
23+
while ((c = getopt_long_only(context->argc, context->argv, "+h",
2424
longopts, &option_index)) != -1) {
2525
switch (c) {
2626
case 'h':

cmd_windowmap.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ int cmd_windowmap(context_t *context) {
2121
"--sync - only exit once the window has been mapped (is visible)\n";
2222

2323
int option_index;
24-
while ((c = getopt_long_only(context->argc, context->argv, "h",
24+
while ((c = getopt_long_only(context->argc, context->argv, "+h",
2525
longopts, &option_index)) != -1) {
2626
switch (c) {
2727
case 'h':

cmd_windowmove.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ int cmd_windowmove(context_t *context) {
3333
"--sync - only exit once the window has moved\n";
3434

3535
int option_index;
36-
while ((c = getopt_long_only(context->argc, context->argv, "h",
36+
while ((c = getopt_long_only(context->argc, context->argv, "+h",
3737
longopts, &option_index)) != -1) {
3838
switch (c) {
3939
case 'h':

cmd_windowraise.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ int cmd_windowraise(context_t *context) {
1212
static const char *usage = "Usage: %s window\n";
1313
int option_index;
1414

15-
while ((c = getopt_long_only(context->argc, context->argv, "h",
15+
while ((c = getopt_long_only(context->argc, context->argv, "+h",
1616
longopts, &option_index)) != -1) {
1717
switch (c) {
1818
case 'h':

cmd_windowsize.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ int cmd_windowsize(context_t *context) {
2727
"--sync - only exit once the window has resized\n";
2828

2929

30-
while ((c = getopt_long_only(context->argc, context->argv, "uh",
30+
while ((c = getopt_long_only(context->argc, context->argv, "+uh",
3131
longopts, &option_index)) != -1) {
3232
switch (c) {
3333
case 'h':

cmd_windowunmap.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ int cmd_windowunmap(context_t *context) {
2121
"--sync - only exit once the window has been unmapped (is hidden)\n";
2222

2323
int option_index;
24-
while ((c = getopt_long_only(context->argc, context->argv, "h",
24+
while ((c = getopt_long_only(context->argc, context->argv, "+h",
2525
longopts, &option_index)) != -1) {
2626
switch (c) {
2727
case 'h':

xdotool.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ int args_main(int argc, char **argv) {
332332
exit(1);
333333
}
334334

335-
while ((opt = getopt_long_only(argc, argv, "+hv", long_options, &option_index)) != -1) {
335+
while ((opt = getopt_long_only(argc, argv, "++hv", long_options, &option_index)) != -1) {
336336
switch (opt) {
337337
case 'h':
338338
cmd_help(NULL);

0 commit comments

Comments
 (0)