[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] dtas-tl edit: do not shell-escape text file
From: |
Eric Wong |
Subject: |
[PATCH] dtas-tl edit: do not shell-escape text file |
Date: |
Sun, 13 Nov 2022 21:23:50 +0000 |
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})
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] dtas-tl edit: do not shell-escape text file,
Eric Wong <=