diff cmd2.py @ 31:5e2f6ec2e383

load so close!
author devlinjs@FA7CZA6N1254998.wrightpatterson.afmc.ds.af.mil
date Fri, 21 Dec 2007 15:06:13 -0500
parents 2739250177ed
children ebefe2d57e3b
line wrap: on
line diff
--- a/cmd2.py	Fri Dec 21 14:00:11 2007 -0500
+++ b/cmd2.py	Fri Dec 21 15:06:13 2007 -0500
@@ -12,7 +12,7 @@
 run
 >
 """
-import cmd, re, os
+import cmd, re, os, sys
 
 class Cmd(cmd.Cmd):
     caseInsensitive = True
@@ -22,7 +22,10 @@
     excludeFromHistory = '''run r list l history hi ed li eof'''.split()   
     defaultExtension = 'txt'
     defaultFileName = 'command.txt'
-    editor = os.environ.get('EDITOR') or ''
+    editor = os.environ.get('EDITOR')
+    if not editor:
+	if sys.platform[:3] == 'win':
+	    editor = 'notepad'
     settable = ['prompt', 'continuationPrompt', 'defaultFileName', 'editor', 'caseInsensitive']
     terminators = ';\n'
     def do_cmdenvironment(self, args):
@@ -201,11 +204,8 @@
 	    print "please use 'set editor' to specify your text editing program of choice."
 	    return
         buffer = self.last_matching(arg)
-        if not buffer:
-            print 'Nothing appropriate in buffer to edit.'
-            return
         f = open(self.defaultFileName, 'w')
-        f.write(buffer)
+        f.write(buffer or '')
         f.close()
 	os.system('%s %s' % (self.editor, self.defaultFileName))
         self.do_load(self.defaultFileName)