[fix] search for "exit" more accurately

Currently, any occurence of the "exit" string is considered as a use of the exit
shell function. While my solution is still clumsy (we should be using a bash
parser), I think it's a bit less clumsy, it triggers less false positives :)
This commit is contained in:
Jocelyn Delalande 2017-03-31 17:43:29 +02:00
parent b9bbb7d93c
commit 1cea3c75f8

View file

@ -222,7 +222,7 @@ def check_verifications_done_before_modifying_system(script):
""" """
ex = 0 ex = 0
for line_number, line in enumerate(script): for line_number, line in enumerate(script):
if "ynh_die" in line or "exit" in line: if "ynh_die" in line or "exit " in line:
ex = line_number ex = line_number
cmds = ("cp", "mkdir", "rm", "chown", "chmod", "apt-get", "apt", "service", cmds = ("cp", "mkdir", "rm", "chown", "chmod", "apt-get", "apt", "service",
@ -273,7 +273,7 @@ def check_non_helpers_usage(script):
ok = True ok = True
for line_nbr, line in enumerate(script): for line_nbr, line in enumerate(script):
if "exit" in line: if "exit " in line:
print_wrong("Line {}: 'exit' command shouldn't be used. Use 'ynh_die' helper instead.".format(line_nbr + 1)) print_wrong("Line {}: 'exit' command shouldn't be used. Use 'ynh_die' helper instead.".format(line_nbr + 1))
ok = False ok = False