[why] The multi-args is like this "test|nr_threads", if user add it like this "test |nr_threads" or the value like "- shell1 | 1 ". So we need to delete the space
Signed-off-by: Bai Jing 799286817@qq.com --- lib/job.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/job.rb b/lib/job.rb index 2869dcb3..bcf4aa8a 100755 --- a/lib/job.rb +++ b/lib/job.rb @@ -290,11 +290,11 @@ class Job hash.each { |key, value| next unless key =~ /^\w.*|.*\w$/
- key_array = key.split('|') + key_array = key.split('|').map(&:strip) [value].flatten.each do |v| next unless v =~ /^\w.*|.*\w$/
- v_array = v.split('|') + v_array = v.split('|').map(&:strip) next unless key_array.size == v_array.size
hash_job = hash.clone
On Mon, Dec 07, 2020 at 10:44:22AM +0800, Bai Jing wrote:
[why] The multi-args is like this "test|nr_threads", if user add it like this "test |nr_threads" or the value like "- shell1 | 1 ". So we need to delete the space
Signed-off-by: Bai Jing 799286817@qq.com
lib/job.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/job.rb b/lib/job.rb index 2869dcb3..bcf4aa8a 100755 --- a/lib/job.rb +++ b/lib/job.rb @@ -290,11 +290,11 @@ class Job hash.each { |key, value| next unless key =~ /^\w.*|.*\w$/
key_array = key.split('|')
key_array = key.split('|').map(&:strip) [value].flatten.each do |v| next unless v =~ /^\w.*\|.*\w$/
v_array = v.split('|')
v_array = v.split('|').map(&:strip)
for you have limited the format of the key/v you may try to use "key.count '|'" and "v.count '|'" the compare the count value no need to split and then map and then strip
Thanks, Luan Shengde
next unless key_array.size == v_array.size hash_job = hash.clone
-- 2.23.0