diff options
author | Patrick Simianer <p@simianer.de> | 2015-11-12 13:57:07 +0100 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2015-11-12 13:57:07 +0100 |
commit | 5c2833c505dda0d1646b8f8c1e62abd391f0401e (patch) | |
tree | 0259c7c2bdb531c09587a744869848d87f4bbd9e /split_pipes | |
parent | ef282dbe4fef1b0ae0c8544f0bb84ba674c68de7 (diff) | |
parent | 8151031373c08ccd714a99f50783eafcb54d2010 (diff) |
Merge branch 'master' of github.com:pks/scripts
Diffstat (limited to 'split_pipes')
-rwxr-xr-x | split_pipes | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/split_pipes b/split_pipes index a1a0128..ce8f018 100755 --- a/split_pipes +++ b/split_pipes @@ -5,7 +5,7 @@ require 'trollop' STDIN.set_encoding 'utf-8' STDOUT.set_encoding 'utf-8' -cfg = Trollop::options do +conf = Trollop::options do banner "splitpipes -f <n> < <input>" opt :field, "field", :type => :int, :required => true opt :to, "to", :type => :int, :default => nil @@ -14,18 +14,18 @@ end a = [] range = false -if cfg[:to] +if conf[:to] range = true end if range - if cfg[:field] >= cfg[:to] + if conf[:field] >= conf[:to] STDERR.write "field >= to, exiting\n" exit end end -if cfg[:field]<=0 || (range && cfg[:to]<=0) +if conf[:field]<=0 || (range && conf[:to]<=0) STDERR.write "field or to <= 0, exiting" exit end @@ -33,9 +33,9 @@ end while line = STDIN.gets j = 1 line.strip.split(' ||| ').each { |i| - if range && (cfg[:field]..cfg[:to]).include?(j) + if range && (conf[:field]..conf[:to]).include?(j) a << i.strip - elsif j == cfg[:field] + elsif j == conf[:field] puts i.strip break end |