@@ -240,44 +240,108 @@ case "$1" in
240
240
original_cmd=" "
241
241
shift
242
242
while [ $# -gt 0 ]; do
243
- # check if the argument is the short option
244
- # (starting with "-" instead of "--"):
245
- if [ " ${1# --} " = " $1 " -a " ${1# -} " != " $1 " ]; then
246
- option=" ${1# -} "
247
- value=" "
248
- # check that the option value follows the name,
249
- # without a space:
250
- if [ ${# option} -gt 1 ]; then
251
- # let's separate the first character as the option name,
252
- # and the subsequent characters consider its value:
253
- value=" ${1# -?} "
254
- option=" ${1% $value } "
255
- # check that the option name consists of one letter
256
- # and there are the following arguments:
257
- elif [ ${# option} -eq 1 -a $# -gt 1 ]; then
258
- # if the next argument does not start with a "-" character,
259
- # then this is the value of the current option:
260
- if [ " ${2# -} " = " $2 " ]; then
261
- value=" $2 "
243
+ lname=" ${1# --} "
244
+ # "--" is interpreted as the end of the list of options:
245
+ if [ -z " $lname " ]; then
246
+ shift
247
+ if [ $# -gt 0 ]; then
248
+ # copy "--" to the output string:
249
+ original_cmd=" $original_cmd --"
250
+ # All other arguments must be copied unchanged:
251
+ while [ $# -gt 0 ]; do
252
+ original_cmd=" $original_cmd '$1 '"
262
253
shift
263
- fi
254
+ done
264
255
fi
265
- shift
266
- if [ " $option " = ' h' ]; then
267
- if [ -z " $WSREP_SST_OPT_DATA " ]; then
268
- MYSQLD_OPT_DATADIR=" ${value%/ } "
269
- fi
270
- elif [ " $option " != ' u' -a \
271
- " $option " != ' P' ]; then
272
- if [ -z " $original_cmd " ]; then
273
- original_cmd=" '-$option$value '"
274
- else
275
- original_cmd=" $original_cmd '-$option$value '"
256
+ break ;
257
+ fi
258
+ # Make sure the argument does not start with "--", otherwise it
259
+ # is a long option, which is processed after this "if":
260
+ if [ " $lname " = " $1 " ]; then
261
+ # Check if the argument is the short option or the short
262
+ # options list, starting with "-":
263
+ options=" ${1# -} "
264
+ if [ " $options " != " $1 " -a -n " $options " ]; then
265
+ slist=" "
266
+ while [ -n " $options " ]; do
267
+ # Let's separate the first character as the current
268
+ # option name:
269
+ if [ -n " $BASH_VERSION " ]; then
270
+ option=" ${options: 0: 1} "
271
+ else
272
+ # If it's not bash, then we need to use slow
273
+ # external utilities:
274
+ option=$( echo " $options " | cut -c1-1)
275
+ fi
276
+ # And the subsequent characters consider option value:
277
+ value=" "
278
+ if [ ${# options} -gt 0 ]; then
279
+ value=" ${options# ?} "
280
+ fi
281
+ # Check for options without argument:
282
+ if [ " $option " != ' ?' -a \
283
+ " $option " != ' a' -a \
284
+ " $option " != ' s' -a \
285
+ " $option " != ' v' ]
286
+ then
287
+ # If the option value is absent, then check
288
+ # the following argument:
289
+ if [ -z " $value " -a $# -gt 1 ]; then
290
+ # if the next argument does not start with
291
+ # the "-" character, then next argument is
292
+ # the current option value:
293
+ if [ " ${2# -} " = " $2 " ]; then
294
+ shift
295
+ value=" $1 "
296
+ fi
297
+ fi
298
+ if [ $option == ' h' ]; then
299
+ if [ -z " $WSREP_SST_OPT_DATA " ]; then
300
+ MYSQLD_OPT_DATADIR=" ${value%/ } "
301
+ fi
302
+ elif [ $option != ' u' -a \
303
+ $option != ' P' ]
304
+ then
305
+ if [ -z " $value " ]; then
306
+ slist=" $slist$option "
307
+ elif [ -z " $slist " ]; then
308
+ slist=" $option '$value '"
309
+ else
310
+ slist=" $slist -$option '$value '"
311
+ fi
312
+ fi
313
+ break
314
+
315
+ else
316
+ slist=" $slist$option "
317
+ fi
318
+ options=" $value "
319
+ done
320
+ if [ -n " $slist " ]; then
321
+ original_cmd=" $original_cmd -$slist "
276
322
fi
323
+ elif [ -z " $options " ]; then
324
+ # We found an equal sign without any characters after it:
325
+ original_cmd=" $original_cmd -"
326
+ else
327
+ # We found a value that does not start with a minus -
328
+ # it is a positional argument or the value of previous
329
+ # option. Copy it to output string (as is):
330
+ original_cmd=" $original_cmd '$1 '"
277
331
fi
332
+ shift
278
333
continue ;
279
334
fi
335
+ # Now we are sure that we are working with an option
336
+ # that has a "long" name, so remove all characters after
337
+ # the first equal sign:
280
338
option=" ${1%% =* } "
339
+ # The "--loose-" prefix should not affect the recognition
340
+ # of the option name:
341
+ if [ " ${option# --loose-} " != " $option " ]; then
342
+ option=" --${option# --loose-} "
343
+ fi
344
+ # Some options just need to be removed from the list:
281
345
if [ " $option " != ' --defaults-file' -a \
282
346
" $option " != ' --defaults-extra-file' -a \
283
347
" $option " != ' --defaults-group-suffix' -a \
@@ -340,22 +404,17 @@ case "$1" in
340
404
;;
341
405
esac
342
406
if [ $skip_mysqld_arg -eq 0 ]; then
343
- if [ -z " $original_cmd " ]; then
344
- original_cmd=" '$1 '"
345
- else
346
- original_cmd=" $original_cmd '$1 '"
347
- fi
407
+ original_cmd=" $original_cmd '$1 '"
348
408
fi
349
- fi
350
- shift
409
+ fi
410
+ shift
351
411
done
352
- WSREP_SST_OPT_MYSQLD=" $original_cmd "
412
+ WSREP_SST_OPT_MYSQLD=" ${ original_cmd# * } "
353
413
break
354
414
;;
355
- * ) # must be command
356
- # usage
357
- # exit 1
358
- ;;
415
+ * ) # Must be command usage
416
+ # exit 1
417
+ ;;
359
418
esac
360
419
shift
361
420
done
@@ -601,9 +660,9 @@ parse_cnf()
601
660
# of the groups list (as if it were a prefix):
602
661
groups=" ${groups# $group } "
603
662
groups=" ${groups# \| } "
604
- # if the group name is the same as the "[--]mysqld", then
605
- # try to use it together with the group suffix:
606
- if [ " ${ group# --} " = ' mysqld' -a -n " $WSREP_SST_OPT_SUFFIX_VALUE " ]; then
663
+ # If the group name is the same as the "mysqld" without "--" prefix,
664
+ # then try to use it together with the group suffix:
665
+ if [ " $group " = ' mysqld' -a -n " $WSREP_SST_OPT_SUFFIX_VALUE " ]; then
607
666
reval=$( $MY_PRINT_DEFAULTS " mysqld$WSREP_SST_OPT_SUFFIX_VALUE " | awk " $pattern " )
608
667
if [ -n " $reval " ]; then
609
668
break
@@ -616,7 +675,7 @@ parse_cnf()
616
675
fi
617
676
done
618
677
619
- # use default if we haven't found a value:
678
+ # Use default if we haven't found a value:
620
679
if [ -z " $reval " ]; then
621
680
[ -n " ${3:- } " ] && reval=" $3 "
622
681
fi
@@ -648,9 +707,9 @@ in_config()
648
707
# of the groups list (as if it were a prefix):
649
708
groups=" ${groups# $group } "
650
709
groups=" ${groups# \| } "
651
- # if the group name is the same as the "[--]mysqld", then
652
- # try to use it together with the group suffix:
653
- if [ " ${ group# --} " = ' mysqld' -a -n " $WSREP_SST_OPT_SUFFIX_VALUE " ]; then
710
+ # If the group name is the same as the "mysqld" without "--" prefix,
711
+ # then try to use it together with the group suffix:
712
+ if [ " $group " = ' mysqld' -a -n " $WSREP_SST_OPT_SUFFIX_VALUE " ]; then
654
713
found=$( $MY_PRINT_DEFAULTS " mysqld$WSREP_SST_OPT_SUFFIX_VALUE " | awk " $pattern " )
655
714
if [ $found -ne 0 ]; then
656
715
break
0 commit comments