about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2022-11-13 21:23:50 +0000
committerEric Wong <e@80x24.org>2022-11-24 05:10:58 +0000
commit56b5f6bfa937f1b8f274bf65aa9c71eaae7a7bfc (patch)
tree57350110ac8a8b9081baa11c992721c810385471
parentd61b3ee7fde0785839f29a727f37d264ca7ea512 (diff)
downloaddtas-56b5f6bfa937f1b8f274bf65aa9c71eaae7a7bfc.tar.gz
There's no need to shell-escape the text file in most cases, so
make the display of non-ASCII characters more pleasant to users
with UTF-8-capable terminals and editors.
-rwxr-xr-xbin/dtas-tl12
1 files changed, 4 insertions, 8 deletions
diff --git a/bin/dtas-tl b/bin/dtas-tl
index e58ee31..7659570 100755
--- a/bin/dtas-tl
+++ b/bin/dtas-tl
@@ -43,7 +43,8 @@ def do_edit(c)
     track_id = $1.to_i
     orig_idx[track_id] = orig.size
     orig << track_id
-    tmp.write("#{Shellwords.escape(line)} =#{track_id}\n")
+    line = Shellwords.escape(line) if line.include?("\n")
+    tmp.write("#{line} =#{track_id}\n")
   end
   tmp.flush
 
@@ -100,13 +101,8 @@ def do_edit(c)
   non_existent = []
   add.each do |path, after_id|
     orig = path
-    path = Shellwords.split(path)[0]
-    path = File.expand_path(path)
-    unless File.exist?(path)
-      path = orig.dup
-      path = Shellwords.split(path)[0]
-      path = File.expand_path(path)
-    end
+    path = File.expand_path(orig)
+    path = File.expand_path(Shellwords.split(path)[0]) unless File.exist?(path)
 
     if File.exist?(path)
       cmd = %W(tl add #{path})