Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions libexec/erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@ class ERB
when /\A-(.)(.*)/
if $1 == '-'
arg, @maybe_arg = arg.split(/=/, 2)
@maybe_arg_from_short = false
return arg
end
raise 'unknown switch "-"' if $2[0] == ?- and $1 != 'T'
if $2.size > 0
self.unshift "-#{$2}"
@maybe_arg = $2
@maybe_arg_from_short = true
else
@maybe_arg = nil
@maybe_arg_from_short = false
end
"-#{$1}"
when /\A(\w+)=/
Expand All @@ -34,9 +37,17 @@ class ERB
end

def ARGV.req_arg
(@maybe_arg || self.shift || raise('missing argument')).tap {
begin
if @maybe_arg
self.shift if @maybe_arg_from_short
@maybe_arg
else
self.shift || raise('missing argument')
end
ensure
@maybe_arg = nil
}
@maybe_arg_from_short = false
end
end

def trim_mode_opt(trim_mode, disable_percent)
Expand Down