about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2022-01-23 20:37:35 +0000
committerEric Wong <e@80x24.org>2022-01-23 20:46:00 +0000
commit7c433348820908fbf4d723ec1cff605ae5ea06a8 (patch)
tree039cb010f32b8f962bba6cab3513abf3040d2d3b
parent9f69299e2abb6624d9ccb18099a9504cd03deba0 (diff)
downloaddtas-7c433348820908fbf4d723ec1cff605ae5ea06a8.tar.gz
Try to consistently treat pathnames as binary blobs everywhere,
since POSIX FSes allow everything but "\0" in pathnames.
-rwxr-xr-xbin/dtas-tl10
1 files changed, 2 insertions, 8 deletions
diff --git a/bin/dtas-tl b/bin/dtas-tl
index 767b02d..e58ee31 100755
--- a/bin/dtas-tl
+++ b/bin/dtas-tl
@@ -7,6 +7,8 @@
 # itself is also unstable, but better than this one probably).
 require 'dtas/unix_client'
 require 'shellwords'
+$stdout.binmode
+$stderr.binmode
 
 def get_track_ids(c)
   track_ids = c.req("tl tracks")
@@ -16,18 +18,11 @@ def get_track_ids(c)
   track_ids
 end
 
-def fix_enc!(str, enc)
-  str.force_encoding(enc)
-  str.force_encoding(Encoding::ASCII_8BIT) unless str.valid_encoding?
-end
-
 def each_track(c)
-  enc = Encoding.default_external
   get_track_ids(c).each_slice(128) do |track_ids|
     res = c.req("tl get #{track_ids.join(' ')}")
     res = Shellwords.split(res.sub!(/\A\d+ /, ''))
     while line = res.shift
-      fix_enc!(line, enc)
       yield line
     end
   end
@@ -109,7 +104,6 @@ def do_edit(c)
     path = File.expand_path(path)
     unless File.exist?(path)
       path = orig.dup
-      fix_enc!(path, enc)
       path = Shellwords.split(path)[0]
       path = File.expand_path(path)
     end