tests/functional/test-restore-corrupted-dumps-missing-files.sh
Don't use ls | grep. Use a glob or a for loop with a condition to allow non-alphanumeric filenames. Open
Open
ls -A | grep -v var | xargs rm -rf
- Read upRead up
- Exclude checks
Don't use ls | grep. Use a glob or a for loop with a condition to allow non-alphanumeric filenames.
Problematic code:
ls /directory | grep target_file_pattern
Correct code:
ls /directory/target_file_pattern
Rationale:
Matching non-alphanumeric characters with grep may require escaping. Typically it is cleaner to use the built in pattern matching or another command like find
Exceptions:
None
Notice
Original content from the ShellCheck https://github.com/koalaman/shellcheck/wiki.