nxxd 1.2 → 1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/nxxd +33 -25
- data/lib/nxxd/version.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bbf9ab29dd62c0a7e1f4d08c59fdf54f0e0417b644a4322708a842d2c1f54599
|
|
4
|
+
data.tar.gz: '09993305785a0ef2fe95ceee5d32e0976ce4e96e10e8630d96339e91ad45f1c9'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 58e8a9ba275d34d3f79422060d26b11a5e1d180f24f8c32854eff55607948c37548f063b18e97ffbb3b55665a2199a7a9c93c7348e2b55ef8829982c551e4bd5
|
|
7
|
+
data.tar.gz: 12d11bf3dc4304d1d8abcad03c58211458cb42d6a3eb312be24717cb339fc69d478a398518113986b9dcfca1a3e52471fd36403499919c9e3b9d159335499c81
|
data/bin/nxxd
CHANGED
|
@@ -18,6 +18,7 @@ module Nxxd
|
|
|
18
18
|
"r" => [ :reverse, true, "Reverse operation, pack"],
|
|
19
19
|
"o" => [ :output, :NAME, "Output file (- = stdout)"],
|
|
20
20
|
"output" => "o",
|
|
21
|
+
"n" => [ :noclobber, true, "Don't overwrite existing files"],
|
|
21
22
|
"f" => [ :full, true, "Full output (no squeeze)"],
|
|
22
23
|
"full" => "f",
|
|
23
24
|
"a" => [ :full, false, "Abbreviate (squeeze duplicate lines)"],
|
|
@@ -47,37 +48,38 @@ module Nxxd
|
|
|
47
48
|
attr_reader :opts, :args
|
|
48
49
|
|
|
49
50
|
def initialize params
|
|
50
|
-
@opts
|
|
51
|
+
@opts = {}
|
|
52
|
+
@args = []
|
|
51
53
|
env = ENV[ OPT_ENV]
|
|
52
54
|
if env then
|
|
53
|
-
@params = env.split
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
case p
|
|
57
|
-
when /^--/ then $'.empty? or set $'
|
|
58
|
-
when /^-/ then set_short $'
|
|
59
|
-
else set p
|
|
60
|
-
end
|
|
61
|
-
end
|
|
55
|
+
@params, @args = env.split, []
|
|
56
|
+
parse_params
|
|
57
|
+
@args.empty? or @args.clear
|
|
62
58
|
end
|
|
63
59
|
@params = params
|
|
60
|
+
parse_params
|
|
61
|
+
rescue StandardError
|
|
62
|
+
$stderr.puts $!
|
|
63
|
+
exit 1
|
|
64
|
+
ensure
|
|
65
|
+
@params = nil
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
private
|
|
69
|
+
|
|
70
|
+
def parse_params
|
|
64
71
|
until @params.empty? do
|
|
65
72
|
p = @params.shift
|
|
66
73
|
case p
|
|
67
|
-
when /^--/ then $'.empty?
|
|
68
|
-
when /^-/ then set_short $'
|
|
74
|
+
when /^--/ then if $'.empty? then break else set $' end
|
|
75
|
+
when /^-/ then if $'.empty? then @args.push p else set_short $' end
|
|
69
76
|
else @args.push p
|
|
70
77
|
end
|
|
71
78
|
end
|
|
72
79
|
@args.concat @params
|
|
73
|
-
@params
|
|
74
|
-
rescue StandardError
|
|
75
|
-
$stderr.puts $!
|
|
76
|
-
exit 1
|
|
80
|
+
@params.clear
|
|
77
81
|
end
|
|
78
82
|
|
|
79
|
-
private
|
|
80
|
-
|
|
81
83
|
def set_short cont
|
|
82
84
|
@cont = cont
|
|
83
85
|
until @cont.empty? do
|
|
@@ -131,7 +133,7 @@ module Nxxd
|
|
|
131
133
|
_, arg, text = *defn
|
|
132
134
|
type = type_repr arg if Symbol === arg
|
|
133
135
|
end
|
|
134
|
-
puts " %-
|
|
136
|
+
puts " %-16s %-10s %s" % [(opt_repr opt), type, text]
|
|
135
137
|
}
|
|
136
138
|
end
|
|
137
139
|
|
|
@@ -148,13 +150,11 @@ module Nxxd
|
|
|
148
150
|
def initialize params
|
|
149
151
|
o = Options.new params
|
|
150
152
|
@opts, @args = o.opts, o.args
|
|
151
|
-
@inputs = []
|
|
152
|
-
@inputs.push @args.shift
|
|
153
|
-
@output = (@opts.delete :output) || @args.pop
|
|
154
|
-
@inputs.push @args.shift until @args.empty?
|
|
155
153
|
end
|
|
156
154
|
|
|
157
155
|
def run
|
|
156
|
+
@output = (@opts.delete :output) || last_arg_if_not_existing
|
|
157
|
+
@args.push nil if @args.empty?
|
|
158
158
|
open_output do |o|
|
|
159
159
|
if @opts.delete :reverse then
|
|
160
160
|
open_inputs do |f|
|
|
@@ -189,9 +189,14 @@ module Nxxd
|
|
|
189
189
|
|
|
190
190
|
private
|
|
191
191
|
|
|
192
|
+
def last_arg_if_not_existing
|
|
193
|
+
a = @args.last
|
|
194
|
+
@args.pop unless not a or a == "-" or File.exist? a
|
|
195
|
+
end
|
|
196
|
+
|
|
192
197
|
def open_inputs
|
|
193
198
|
plain = @opts.delete :plain
|
|
194
|
-
@
|
|
199
|
+
@args.each do |i|
|
|
195
200
|
i = nil if i == "-"
|
|
196
201
|
if i then
|
|
197
202
|
@opts[ :input] = i unless plain or @opts[ :reverse]
|
|
@@ -208,9 +213,12 @@ module Nxxd
|
|
|
208
213
|
end
|
|
209
214
|
|
|
210
215
|
def open_output
|
|
216
|
+
nc = @opts.delete :noclobber
|
|
211
217
|
o = @output unless @output == "-"
|
|
212
218
|
if o then
|
|
213
|
-
|
|
219
|
+
mode = "w"
|
|
220
|
+
mode << "x" if nc
|
|
221
|
+
File.open o, mode do |f| yield f end
|
|
214
222
|
else
|
|
215
223
|
yield $stdout
|
|
216
224
|
end
|
data/lib/nxxd/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: nxxd
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: '1.
|
|
4
|
+
version: '1.4'
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Bertram Scharpf
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies: []
|
|
12
12
|
description: 'Yet another Xxd reimplementation.
|
|
13
13
|
|
|
@@ -45,7 +45,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
45
45
|
version: '0'
|
|
46
46
|
requirements:
|
|
47
47
|
- Just Ruby
|
|
48
|
-
rubygems_version: 3.
|
|
48
|
+
rubygems_version: 3.7.1
|
|
49
49
|
specification_version: 4
|
|
50
50
|
summary: Hex Dump Tool
|
|
51
51
|
test_files: []
|