From a8916274bb3386c3ae913ccccd25757cb62b9126 Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Thu, 4 Jul 2019 17:03:29 -0700 Subject: [PATCH] Created SC2253 (markdown) --- SC2253.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 SC2253.md diff --git a/SC2253.md b/SC2253.md new file mode 100644 index 0000000..09d1754 --- /dev/null +++ b/SC2253.md @@ -0,0 +1,29 @@ +## Use -R to recurse, or explicitly a-r to remove read permissions. + +### Problematic code: + +```sh +chmod -r 0700 dir +chmod -r file +``` + +### Correct code: + +```sh +chmod -R 0700 dir +chmod a-r file +``` + +### Rationale: + +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. + +### Exceptions: + +If you're using it correctly and don't mind the potential for confusion, you can save a single character by ignoring this warning. + +### Related resources: + +* Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc! \ No newline at end of file