/usr/bin/ascii85 is in ruby-ascii85 1.0.2-3.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | #!/usr/bin/ruby
# encoding: utf-8
#
# A simple command-line tool to de- and encode Ascii85, modeled after `base64`
# from the GNU Coreutils.
#
require "optparse"
require "ascii85"
@options = {
:wrap => 80,
:decode => false
}
ARGV.options do |opts|
opts.banner = "Usage: #{File.basename($PROGRAM_NAME)} [OPTIONS] [FILE]\n" +
"Encodes or decodes FILE or STDIN using Ascii85 and writes to STDOUT."
opts.on( "-w", "--wrap COLUMN", Integer,
"Wrap lines at COLUMN. Default is 80, use 0 for no wrapping") do |opt|
@options[:wrap] = opt.abs
@options[:wrap] = false if opt.zero?
end
opts.on( "-d", "--decode", "Decode the input") do
@options[:decode] = true
end
opts.on( "-h", "--help", "Display this help and exit") do
puts opts
exit
end
opts.on( "--version", "Output version information") do |opt|
puts "Ascii85 v#{Ascii85::VERSION},\nwritten by Johannes HolzfuĆ"
exit
end
remaining_args = opts.parse!
case remaining_args.size
when 0
@options[:file] = '-'
when 1
@options[:file] = remaining_args.first
else
abort "Superfluous operand(s): \"#{remaining_args.join('", "')}\""
end
end
if @options[:file] == '-'
@input = $stdin.binmode.read
else
unless File.exists?(@options[:file])
abort "File not found: \"#{@options[:file]}\""
end
unless File.readable_real?(@options[:file])
abort "File is not readable: \"#{@options[:file]}\""
end
File.open(@options[:file], 'rb') do |f|
@input = f.read
end
end
if @options[:decode]
begin
print Ascii85.decode(@input)
rescue Ascii85::DecodingError => error
abort "Decoding Error: #{error.message.to_s}"
end
else
print Ascii85.encode(@input, @options[:wrap])
end
|