Fix exception on a command line without a command, like:

PATH=.


git-svn-id: https://kippo.googlecode.com/svn/trunk@174 951d7100-d841-11de-b865-b3884708a8e2
This commit is contained in:
desaster 2010-10-25 14:11:55 +00:00
parent b4a2e04d99
commit 34a99b876f
1 changed files with 16 additions and 7 deletions

View File

@ -69,6 +69,12 @@ class HoneyPotShell(object):
self.showPrompt()
def runCommand(self):
def runOrPrompt():
if len(self.cmdpending):
self.runCommand()
else:
self.showPrompt()
if not len(self.cmdpending):
self.showPrompt()
return
@ -85,15 +91,21 @@ class HoneyPotShell(object):
# probably no reason to be this comprehensive for just PATH...
envvars = copy(self.envvars)
cmd = None
while len(cmdAndArgs):
cmd = cmdAndArgs.pop(0)
if cmd.count('='):
key, value = cmd.split('=', 1)
piece = cmdAndArgs.pop(0)
if piece.count('='):
key, value = piece.split('=', 1)
envvars[key] = value
continue
cmd = piece
break
args = cmdAndArgs
if not cmd:
runOrPrompt()
return
rargs = []
for arg in args:
matches = self.honeypot.fs.resolve_path_wc(arg, self.honeypot.cwd)
@ -109,10 +121,7 @@ class HoneyPotShell(object):
print 'Command not found: %s' % (line,)
if len(line):
self.honeypot.writeln('bash: %s: command not found' % cmd)
if len(self.cmdpending):
self.runCommand()
else:
self.showPrompt()
runOrPrompt()
def resume(self):
self.honeypot.setInsertMode()