about summary refs log tree commit homepage
path: root/bin/dtas-cueedit
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-08-29 09:29:40 +0000
committerEric Wong <normalperson@yhbt.net>2013-08-29 09:50:36 +0000
commit0f73acc225656517526b317a05ecab7e1311141b (patch)
tree81a8a8e373df302cfa478a8af706d125dcc1cb1d /bin/dtas-cueedit
parent4bd49cda05b43fc68f9353620e3f018f1c07fcbb (diff)
downloaddtas-0f73acc225656517526b317a05ecab7e1311141b.tar.gz
We don't need it since IO#read(bytes, buf) will convert to
ASCII-8BIT anyways.  Everywhere else, we ensure path names are
already binary.  We do this mainly at the client layer before using
Shellwords to escape the paths.

We also must be careful about parsing output from soxi/avprobe
which can show us metadata in whatever encoding is in the file.
We must still handle data from parsing command output as binary,
as the encoding of file metadata tends to vary.

This also should buy us Syck compatibility for Ruby 1.9.3 users
on Debian systems where Ruby 1.9.3 still uses Syck.
Diffstat (limited to 'bin/dtas-cueedit')
-rwxr-xr-xbin/dtas-cueedit11
1 files changed, 5 insertions, 6 deletions
diff --git a/bin/dtas-cueedit b/bin/dtas-cueedit
index ece4af1..8396cd5 100755
--- a/bin/dtas-cueedit
+++ b/bin/dtas-cueedit
@@ -1,16 +1,15 @@
 #!/usr/bin/env ruby
-# -*- encoding: binary -*-
 # Copyright (C) 2013, Eric Wong <normalperson@yhbt.net> and all contributors
 # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
 require 'tempfile'
-require 'shellwords'
+require 'dtas/xs'
 usage = "Usage: #$0 FILENAME"
 editor = ENV["VISUAL"] || ENV["EDITOR"] || "vi"
 ARGV.size > 0 or abort usage
+include DTAS::XS
 
 def err_msg(cmd, status)
-  err_cmd = cmd.map { |f| Shellwords.escape(f) }.join(' ')
-  "E: #{err_cmd} failed: #{status.inspect}"
+  "E: #{xs(cmd)} failed: #{status.inspect}"
 end
 
 def x!(*cmd)
@@ -52,7 +51,7 @@ ARGV.each do |file|
     # avoid an expensive update if the user didn't change anything
     current = File.binread(tmp.path)
     if current == original
-      $stderr.puts "tags for #{Shellwords.escape(file)} unchanged" if $DEBUG
+      $stderr.puts "tags for #{xs(Array(file))} unchanged" if $DEBUG
       next
     end
 
@@ -68,7 +67,7 @@ ARGV.each do |file|
       warn err_msg(cmd, $?)
       warn "E: restoring original from backup"
       x!(*%W(metaflac --import-cuesheet-from=#{backup.path} #{file}))
-      warn "E: backup cuesheet restored, #{Shellwords.escape(file)} unchanged"
+      warn "E: backup cuesheet restored, #{xs(Array(file))} unchanged"
       exit(false)
     end
   ensure