diff --git a/builtin.cpp b/builtin.cpp index 861d355dc..890784a37 100644 --- a/builtin.cpp +++ b/builtin.cpp @@ -2904,28 +2904,17 @@ static int builtin_contains(parser_t &parser, wchar_t ** argv) { int argc; argc = builtin_count_args(argv); - int i; wchar_t *needle; - int index=0; + bool should_output_index = false; woptind=0; - const struct woption - long_options[] = + const struct woption long_options[] = { - { - L"help", no_argument, 0, 'h' - } - , - { - L"index", no_argument, 0, 'i' - } - , - { - 0, 0, 0, 0 - } - } - ; + { L"help", no_argument, 0, 'h' } , + { L"index", no_argument, 0, 'i' }, + { 0, 0, 0, 0 } + }; while (1) { @@ -2967,14 +2956,12 @@ static int builtin_contains(parser_t &parser, wchar_t ** argv) return STATUS_BUILTIN_ERROR; case 'i': - index=1; + should_output_index = true; break; } } - - needle = argv[woptind]; if (!needle) { @@ -2982,12 +2969,12 @@ static int builtin_contains(parser_t &parser, wchar_t ** argv) } - for (i=woptind+1; i