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