give correct error when starting with && || or ;

This commit is contained in:
Michel Oosterhof 2016-06-01 20:09:51 +04:00
parent 8916d728b8
commit d1402b9298
1 changed files with 11 additions and 11 deletions

View File

@ -161,22 +161,22 @@ class HoneyPotShell(object):
try:
tok = self.lexer.get_token()
#log.msg( "tok: %s" % (repr(tok)) )
# for now, execute all after &&
if tok == self.lexer.eof:
if len(tokens):
self.cmdpending.append((tokens))
tokens = []
break
if tok == ';' or tok == '&&' or tok == '||':
# For now, execute all after &&
elif tok == ';' or tok == '&&' or tok == '||':
if len(tokens):
self.cmdpending.append((tokens))
tokens = []
if tok == ';':
continue
if tok == '&&':
continue
if tok == '||':
continue
if tok == '$?':
else:
self.protocol.terminal.write(
'-bash: syntax error near unexpected token `{}\'\n'.format(tok))
break
elif tok == '$?':
tok = "0"
elif tok[0] == '$':
env_rex = re.compile('^\$([_a-zA-Z0-9]+)$')