about summary refs log tree commit homepage
path: root/bin/dtas-sourceedit
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-08-24 20:48:31 +0000
committerEric Wong <normalperson@yhbt.net>2013-08-24 20:48:31 +0000
commitef70b5de358a728caa105b91016433ad2e9eeece (patch)
treee49157474b345efd6f53f75a5ccaa86a520573ce /bin/dtas-sourceedit
parent3e09ac0c10c95bb24a08af62393b4f761e2743d0 (diff)
downloaddtas-ef70b5de358a728caa105b91016433ad2e9eeece.tar.gz
Omitting a command: entry or an entry inside env: should delete
it from the player
Diffstat (limited to 'bin/dtas-sourceedit')
-rwxr-xr-xbin/dtas-sourceedit11
1 files changed, 10 insertions, 1 deletions
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)