[enh] #17: check 'set -(e)u' usage on scripts.

This commit is contained in:
Moul 2017-01-28 11:52:22 +01:00
parent 7806446235
commit be1f2b2eb5
2 changed files with 20 additions and 0 deletions

View file

@ -23,6 +23,7 @@ git clone https://github.com/<account>/<app>_ynh
* warn missing sudo before commands * warn missing sudo before commands
* make sure verifications are done before modifications on the system * make sure verifications are done before modifications on the system
* check non usage of helpers and propose them * check non usage of helpers and propose them
- check 'set -eu' usage
## License ## License

View file

@ -171,6 +171,7 @@ def check_script(path, script_name, script_nbr):
return_code = check_non_helpers_usage(script) or return_code return_code = check_non_helpers_usage(script) or return_code
if script_nbr < 5: if script_nbr < 5:
return_code = check_verifications_done_before_modifying_system(script) or return_code return_code = check_verifications_done_before_modifying_system(script) or return_code
return_code = check_set_usage(script_name, script) or return_code
return return_code return return_code
@ -268,6 +269,24 @@ def check_non_helpers_usage(script):
return return_code return return_code
def check_set_usage(script_name, script):
return_code = 0
present = False
set_val = "set -u" if script_name == "remove" else "set -eu"
for line in script:
if set_val in line:
present = True
break
if present:
print_right(set_val + " is present")
else:
print_wrong(set_val + " is missing. For details, look at https://dev.yunohost.org/issues/419")
return_code = 1
return return_code
if __name__ == '__main__': if __name__ == '__main__':
os.system("clear") os.system("clear")