bash/every-chmod: generate every combination of rwx for chmod
This commit is contained in:
parent
e056f1eaf5
commit
6d18c17400
|
@ -0,0 +1,24 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
perms=(___ __x _w_ _wx r__ r_x rw_ rwx)
|
||||||
|
|
||||||
|
perms() {
|
||||||
|
local perm perm_str
|
||||||
|
|
||||||
|
for perm do
|
||||||
|
perm_str=$perm_str${perms[$perm]}
|
||||||
|
done
|
||||||
|
|
||||||
|
printf %s "$perm_str"
|
||||||
|
}
|
||||||
|
|
||||||
|
for owner in {0..7}; do
|
||||||
|
for group in {0..7}; do
|
||||||
|
for universe in {0..7}; do
|
||||||
|
printf 'chmod_%s() {\n' "$(perms "$owner" "$group" "$universe")"
|
||||||
|
printf ' chmod %d%d%d "$@"\n' "$owner" "$group" "$universe"
|
||||||
|
printf '}\n'
|
||||||
|
printf '\n'
|
||||||
|
done
|
||||||
|
done
|
||||||
|
done
|
Loading…
Reference in New Issue