Skip to content

Commit a3f1029

Browse files
committed
Use \A instead of ^ as the beginning of string
1 parent 61b4ea0 commit a3f1029

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/optparse.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ def compsys(sdone, ldone) # :nodoc:
668668

669669
(sopts+lopts).each do |opt|
670670
# "(-x -c -r)-l[left justify]"
671-
if /^--\[no-\](.+)$/ =~ opt
671+
if /\A--\[no-\](.+)$/ =~ opt
672672
o = $1
673673
yield("--#{o}", desc.join(""))
674674
yield("--no-#{o}", desc.join(""))
@@ -1508,7 +1508,7 @@ def make_switch(opts, block = nil)
15081508
raise ArgumentError, "unsupported argument type: #{o}", ParseError.filter_backtrace(caller(4))
15091509
when *ArgumentStyle.keys
15101510
style = notwice(ArgumentStyle[o], style, 'style')
1511-
when /^--no-([^\[\]=\s]*)(.+)?/
1511+
when /\A--no-([^\[\]=\s]*)(.+)?/
15121512
q, a = $1, $2
15131513
o = notwice(a ? Object : TrueClass, klass, 'type')
15141514
not_pattern, not_conv = search(:atype, o) unless not_style
@@ -1519,7 +1519,7 @@ def make_switch(opts, block = nil)
15191519
(q = q.downcase).tr!('_', '-')
15201520
long << "no-#{q}"
15211521
nolong << q
1522-
when /^--\[no-\]([^\[\]=\s]*)(.+)?/
1522+
when /\A--\[no-\]([^\[\]=\s]*)(.+)?/
15231523
q, a = $1, $2
15241524
o = notwice(a ? Object : TrueClass, klass, 'type')
15251525
if a
@@ -1532,7 +1532,7 @@ def make_switch(opts, block = nil)
15321532
not_pattern, not_conv = search(:atype, FalseClass) unless not_style
15331533
not_style = Switch::NoArgument
15341534
nolong << "no-#{o}"
1535-
when /^--([^\[\]=\s]*)(.+)?/
1535+
when /\A--([^\[\]=\s]*)(.+)?/
15361536
q, a = $1, $2
15371537
if a
15381538
o = notwice(NilClass, klass, 'type')
@@ -1542,7 +1542,7 @@ def make_switch(opts, block = nil)
15421542
ldesc << "--#{q}"
15431543
(o = q.downcase).tr!('_', '-')
15441544
long << o
1545-
when /^-(\[\^?\]?(?:[^\\\]]|\\.)*\])(.+)?/
1545+
when /\A-(\[\^?\]?(?:[^\\\]]|\\.)*\])(.+)?/
15461546
q, a = $1, $2
15471547
o = notwice(Object, klass, 'type')
15481548
if a
@@ -1553,7 +1553,7 @@ def make_switch(opts, block = nil)
15531553
end
15541554
sdesc << "-#{q}"
15551555
short << Regexp.new(q)
1556-
when /^-(.)(.+)?/
1556+
when /\A-(.)(.+)?/
15571557
q, a = $1, $2
15581558
if a
15591559
o = notwice(NilClass, klass, 'type')
@@ -1562,7 +1562,7 @@ def make_switch(opts, block = nil)
15621562
end
15631563
sdesc << "-#{q}"
15641564
short << q
1565-
when /^=/
1565+
when /\A=/
15661566
style = notwice(default_style.guess(arg = o), style, 'style')
15671567
default_pattern, conv = search(:atype, Object) unless default_pattern
15681568
else

0 commit comments

Comments
 (0)