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