Skip to content

Files

Latest commit

 

History

History
27 lines (17 loc) · 572 Bytes

SC2253.md

File metadata and controls

27 lines (17 loc) · 572 Bytes

Pattern: Use of -r in chmod

Issue: -

Description

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

Further Reading