From 56b5f6bfa937f1b8f274bf65aa9c71eaae7a7bfc Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 13 Nov 2022 21:23:50 +0000 Subject: dtas-tl edit: do not shell-escape text file 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. --- bin/dtas-tl | 12 ++++-------- 1 file 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}) -- cgit v1.2.3-24-ge0c7