summaryrefslogtreecommitdiff
path: root/perms
diff options
context:
space:
mode:
Diffstat (limited to 'perms')
-rwxr-xr-xperms26
1 files changed, 24 insertions, 2 deletions
diff --git a/perms b/perms
index d806173..d38548b 100755
--- a/perms
+++ b/perms
@@ -1,3 +1,25 @@
#!/usr/bin/env bash
-echo $(realpath $1)
-stat --printf "octal: %a\nhuman: %A\nowner: %U (%u)\ngroup: %G (%g)\n" "$@"
+
+if [[ $1 == "-v" ]]; then
+ export verbose=1
+ shift
+fi
+file="$1"
+echo $(realpath "$file")
+
+if [[ -n "$verbose" ]]; then
+ perm=$(stat --printf "%a" "$file")
+ declare -A permMap=( [0]="no perms" [1]="execute" [2]="write" [3]="write, execute"
+ [4]="read" [5]="read, execute" [6]="read, write" [7]="read, write, execute" )
+
+ owner="${permMap[${perm:0:1}]}"
+ group="${permMap[${perm:1:1}]}"
+ other="other:\t\t\t${permMap[${perm:2:1}]}"
+else
+ owner=""
+ group=""
+ other=""
+fi
+
+
+stat --printf "octal: %a\nhuman: %A\nowner: %U (%u)\t$owner\ngroup: %G (%g)\t$group\n$other" "$file"