From ef70b5de358a728caa105b91016433ad2e9eeece Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 24 Aug 2013 20:48:31 +0000 Subject: dtas-{sink,source}edit: allow unsetting command and env Omitting a command: entry or an entry inside env: should delete it from the player --- bin/dtas-sourceedit | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'bin/dtas-sourceedit') diff --git a/bin/dtas-sourceedit b/bin/dtas-sourceedit index 9d329d7..3ce7945 100755 --- a/bin/dtas-sourceedit +++ b/bin/dtas-sourceedit @@ -18,6 +18,7 @@ tmp.binmode buf = c.req(%W(source cat)) abort(buf) if buf =~ /\AERR/ +orig = YAML.load(buf) tmp.write(buf << DTAS_DISCLAIMER) cmd = "#{editor} #{tmp.path}" @@ -32,8 +33,16 @@ if env = source["env"] end end +# remove deleted env +if orig_env = orig["env"] + env ||= {} + deleted_keys = orig_env.keys - env.keys + deleted_keys.each { |k| cmd << "env##{k}" } +end + %w(command).each do |field| - value = source[field] and cmd << "#{field}=#{value}" + value = source[field] + cmd << "#{field}=#{value}" end c.req_ok(cmd) -- cgit v1.2.3-24-ge0c7