-
Notifications
You must be signed in to change notification settings - Fork 0
/
aproname
88 lines (73 loc) · 1.84 KB
/
aproname
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/sh
# Detect invalid and problematic pathname lengths and patterns,
# accounting for both unix-like and Microsoft OSes.
# Only include ASCII characters in bracket expressions,
# and count length by bytes rather than characters.
export LC_COLLATE=C
export LC_CTYPE=C
# Propagate the value of LC_ALL to the environment
# without affecting the values of LC_COLLATE or LC_CTYPE.
if test -n "$LC_ALL"
then
for i in LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME
do
export "$i=$LC_ALL"
done
unset LC_ALL
fi
awk '
BEGIN {
FS = "/"
status = 0
format = "%s: %s: \47%s\47\n"
filter = "sort"
byte[byte_pref = 156] = \
"exceeds ustar prefix byte limit"
byte[byte_name = 100] = \
"exceeds ustar filename byte limit"
spec[leading2slashes = "^//[^/]"] = \
"POSIX non-portable leading pathname pattern"
patt["[^0-9A-Za-z._-]"] = \
"POSIX non-portable character"
patt["^-"] = \
"POSIX non-portable leading filename character"
patt["[ .]$"] = \
"Microsoft non-portable trailing filename character"
patt["^(aux|con|nul|prn|(com|lpt)[0-9])([.].*)?$"] = \
"reserved MS-DOS filename"
patt["^[.]lock$|_vti_|^desktop[.]ini$"] = \
"restricted Microsoft OneDrive filename"
++omit[""]
++omit["."]
++omit[".."]
for (i = 1; i < ARGC; ++i) {
$0 = ARGV[i]
if (NF > 1 && length() - length($NF) > byte_pref) {
flag[byte_pref] = byte[byte_pref]
}
if ($0 ~ leading2slashes) {
flag[leading2slashes] = spec[leading2slashes]
}
for (j = 1; j <= NF; ++j) {
if ($j in omit) {
continue
}
if (length($j) > byte_name) {
flag[byte_name] = byte[byte_name]
}
for (k in patt) {
if (tolower($j) ~ k) {
flag[k] = patt[k]
}
}
}
for (j in flag) {
printf format, $0, flag[j], j | filter
status = 1
}
close(filter)
split("", flag)
}
exit status
}
' "$@"