Project

General

Profile

Feature #8460 ยป 0002-optparse-move-dash-dash-handling-to-a-case.patch

felipec (Felipe Contreras), 05/27/2021 10:07 PM

View differences:

lib/optparse.rb
957 957
  ArgumentStyle.freeze
958 958

  
959 959
  #
960
  # Switches common used such as '--', and also provides default
961
  # argument classes
960
  # Provides default argument classes
962 961
  #
963 962
  DefaultList = List.new
964
  DefaultList.short['-'] = Switch::NoArgument.new {}
965
  DefaultList.long[''] = Switch::NoArgument.new {throw :terminate}
966 963

  
967 964

  
968 965
  COMPSYS_HEADER = <<'XXX'      # :nodoc:
......
1557 1554
    argv.unshift(arg) if arg = catch(:terminate) {
1558 1555
      while arg = argv.shift
1559 1556
        case arg
1557
        # dash dash
1558
        when /\A--\Z/m
1559
          break
1560

  
1560 1561
        # long option
1561
        when /\A--([^=]*)(?:=(.*))?/m
1562
        when /\A--([^=]+)(?:=(.*))?/m
1562 1563
          opt, rest = $1, $2
1563 1564
          opt.tr!('_', '-')
1564 1565
          begin