Pattern: Use of -r
in chmod
Issue: -
Many tools use -r
for recursive operation, but in chmod
this removes read permissions.
If you wanted to change permissions recursively, change the flag to -R
. If you wanted to remove read permissions, consider using a-r
explicitly to make this more obvious.
Example of incorrect code:
chmod -r 0700 dir
chmod -r file
Example of correct code:
chmod -R 0700 dir
chmod a-r file