-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstat2assoc
More file actions
executable file
·56 lines (51 loc) · 939 Bytes
/
stat2assoc
File metadata and controls
executable file
·56 lines (51 loc) · 939 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env bash
#
# Stat a file and build an associative bash array.
if [[ $1 == -f ]]; then
shift 1
{ exec -- stat --file-system --printf="$(</dev/fd/0)\n" "$1"; } <<'SEQ'
STAT[|]=%n
STAT[|%n|]='a b c d f i l s S t T'
STAT[|%n|a]=%a
STAT[|%n|b]=%b
STAT[|%n|c]=%c
STAT[|%n|d]=%d
STAT[|%n|f]=%f
STAT[|%n|i]=%i
STAT[|%n|l]=%l
STAT[|%n|s]=%s
STAT[|%n|S]=%S
STAT[|%n|t]=%t
STAT[|%n|T]=%T
SEQ
else
{ exec -- stat --printf="$(</dev/fd/0)\n" "$1"; } <<'SEQ'
STAT[|]=%n
STAT[|%n|]='a A b B d D f F g G h i m o s t T u U w W X Y Z'
STAT[|%n|a]=%a
STAT[|%n|A]=%A
STAT[|%n|b]=%b
STAT[|%n|B]=%B
STAT[|%n|d]=%d
STAT[|%n|D]=%D
STAT[|%n|f]=%f
STAT[|%n|F]='%F'
STAT[|%n|g]=%g
STAT[|%n|G]='%G'
STAT[|%n|h]=%h
STAT[|%n|i]=%i
STAT[|%n|m]='%m'
STAT[|%n|o]=%o
STAT[|%n|s]=%s
STAT[|%n|t]=%t
STAT[|%n|T]=%T
STAT[|%n|u]=%u
STAT[|%n|U]='%U'
STAT[|%n|w]=%w
STAT[|%n|W]=%W
STAT[|%n|X]=%X
STAT[|%n|Y]=%Y
STAT[|%n|Z]=%Z
SEQ
fi
# vim: set ft=zsh :