- Регистрация
- 1 Мар 2015
- Сообщения
- 1,481
- Баллы
- 155
1. Hardcoding Values
- Using fixed paths, IPs, or credentials inside the script.
Use variables or config files instead.
- Assuming user input or arguments are always correct.
Always check for type, format, and range.
- Ignoring exceptions or command failures.
Use try/catch, if [ $? -ne 0 ], or similar.
- Leaving behind unused logs, temp data, or cache.
Add cleanup functions or use trap in shell scripts.
- Continuing the script even when a step fails.
Always check exit codes before moving forward.
- Using vague variable or function names (x, temp, data1).
Use descriptive and consistent naming.
- Forgetting loop conditions or exit criteria.
Always define clear limits and break conditions.
- No comments, no usage instructions.
Add inline comments and a help section (--help flag).
- Writing credentials directly in the code.
Use environment variables or secure vaults.
- Running scripts directly in production without testing.
Always test in a sandbox or staging environment first.