From 871a23afb022e57fbf8950422674ea0a6fdbfc4d Mon Sep 17 00:00:00 2001 From: Ben Bowers Date: Sat, 27 Apr 2024 10:58:27 -0400 Subject: [PATCH] Enable frozen_string_literal for future-ruby support plus minimal edits to fix errors --- lib/optimist.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/optimist.rb b/lib/optimist.rb index 73ef909..3df68a6 100644 --- a/lib/optimist.rb +++ b/lib/optimist.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # lib/optimist.rb -- optimist command-line processing library # Copyright (c) 2008-2014 William Morgan. # Copyright (c) 2014 Red Hat, Inc. @@ -483,7 +485,7 @@ def each_arg(args) end i += 1 when /^-(\S+)$/ # one or more short arguments - short_remaining = "" + short_remaining = [] shortargs = $1.split(//) shortargs.each_with_index do |a, j| if j == (shortargs.length - 1) @@ -493,7 +495,7 @@ def each_arg(args) unless num_params_taken short_remaining << a if @stop_on_unknown - remains << "-#{short_remaining}" + remains << "-#{short_remaining.join}" return remains += args[i + 1..-1] end else @@ -503,8 +505,8 @@ def each_arg(args) unless yield "-#{a}", [] short_remaining << a if @stop_on_unknown - short_remaining += shortargs[j + 1..-1].join - remains << "-#{short_remaining}" + short_remaining << shortargs[j + 1..-1].join + remains << "-#{short_remaining.join}" return remains += args[i + 1..-1] end end @@ -512,7 +514,7 @@ def each_arg(args) end unless short_remaining.empty? - remains << "-#{short_remaining}" + remains << "-#{short_remaining.join}" end i += 1 else