about summary refs log tree commit homepage
path: root/bin
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
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')
-rwxr-xr-xbin/dtas-console1
-rwxr-xr-xbin/dtas-ctl3
-rwxr-xr-xbin/dtas-cueedit11
-rwxr-xr-xbin/dtas-enq1
-rwxr-xr-xbin/dtas-msinkctl1
-rwxr-xr-xbin/dtas-player1
-rwxr-xr-xbin/dtas-sinkedit1
-rwxr-xr-xbin/dtas-sourceedit1
-rwxr-xr-xbin/dtas-xdelay1
9 files changed, 5 insertions, 16 deletions
diff --git a/bin/dtas-console b/bin/dtas-console
index 3b246bd..6d5672b 100755
--- a/bin/dtas-console
+++ b/bin/dtas-console
@@ -1,5 +1,4 @@
 #!/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)
 #
diff --git a/bin/dtas-ctl b/bin/dtas-ctl
index 1c0a242..267a873 100755
--- a/bin/dtas-ctl
+++ b/bin/dtas-ctl
@@ -1,10 +1,7 @@
 #!/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 'dtas/unix_client'
 
-# Unix paths are encoding agnostic
-ARGV.map! { |arg| arg.b }
 c = DTAS::UNIXClient.new
 puts c.req(ARGV)
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
diff --git a/bin/dtas-enq b/bin/dtas-enq
index 287c3f7..78829a4 100755
--- a/bin/dtas-enq
+++ b/bin/dtas-enq
@@ -1,5 +1,4 @@
 #!/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 'dtas/unix_client'
diff --git a/bin/dtas-msinkctl b/bin/dtas-msinkctl
index 00d8540..b417d0f 100755
--- a/bin/dtas-msinkctl
+++ b/bin/dtas-msinkctl
@@ -1,5 +1,4 @@
 #!/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 'yaml'
diff --git a/bin/dtas-player b/bin/dtas-player
index 75ec6a6..640d31c 100755
--- a/bin/dtas-player
+++ b/bin/dtas-player
@@ -1,5 +1,4 @@
 #!/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)
 Thread.abort_on_exception = $stderr.sync = $stdout.sync = true
diff --git a/bin/dtas-sinkedit b/bin/dtas-sinkedit
index 3e12415..93a4fe9 100755
--- a/bin/dtas-sinkedit
+++ b/bin/dtas-sinkedit
@@ -1,5 +1,4 @@
 #!/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 'dtas/edit_client'
diff --git a/bin/dtas-sourceedit b/bin/dtas-sourceedit
index 3de1c11..a511793 100755
--- a/bin/dtas-sourceedit
+++ b/bin/dtas-sourceedit
@@ -1,5 +1,4 @@
 #!/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 'dtas/edit_client'
diff --git a/bin/dtas-xdelay b/bin/dtas-xdelay
index 5ac63ae..3b57f44 100755
--- a/bin/dtas-xdelay
+++ b/bin/dtas-xdelay
@@ -1,5 +1,4 @@
 #!/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)
 USAGE = "Usage: #$0 [-x FREQ] [-l] /dev/fd/LO /dev/fd/HI DELAY [DELAY ...]"