This repository was archived by the owner on Aug 12, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0002-use-stateless-paths.patch
More file actions
105 lines (97 loc) · 4.47 KB
/
0002-use-stateless-paths.patch
File metadata and controls
105 lines (97 loc) · 4.47 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Lucius Hu <orctarorga@gmail.com>
Date: Mon, 10 Jun 2019 23:44:31 -0400
Subject: [PATCH] use stateless paths
The following completion functions are modified so that it will try to
read configurations from `/etc` directory, where system admin may overrides
stateless defaults. And if there's no such system overrieds, they will
read the stateless defaults from `/usr/share/defaults/etc` directory:
- Completion/Unix/Command/_chsh
- Completion/Unix/Command/_mount
- Completion/Unix/Command/_su
- Completion/Unix/Command/_user_admin
- Completion/Unix/Type/_bpf_filters
- Completion/Unix/Type/_ports
On a system with Clear Linux and `zsh` installed, these files can be found
under `/usr/share/zsh/<ZSH_VERSION>/functions` directory.
---
Completion/Unix/Command/_chsh | 2 +-
Completion/Unix/Command/_mount | 2 +-
Completion/Unix/Command/_su | 2 +-
Completion/Unix/Command/_user_admin | 2 +-
Completion/Unix/Type/_bpf_filters | 2 +-
Completion/Unix/Type/_ports | 3 +--
6 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/Completion/Unix/Command/_chsh b/Completion/Unix/Command/_chsh
index 8023698..2b05aae 100644
--- a/Completion/Unix/Command/_chsh
+++ b/Completion/Unix/Command/_chsh
@@ -63,5 +63,5 @@ case $OSTYPE in
;;
esac
-(( $#shells )) || shells=( ${(Z+Cn+)"$(</etc/shells)"} )
+(( $#shells )) || shells=( ${(Z+Cn+)"$([ -r /etc/shells ] && </etc/shells || </usr/share/defaults/etc/shells)"} )
_arguments $args '1:user name:_users'
diff --git a/Completion/Unix/Command/_mount b/Completion/Unix/Command/_mount
index 301b9e5..db6ddac 100644
--- a/Completion/Unix/Command/_mount
+++ b/Completion/Unix/Command/_mount
@@ -256,7 +256,7 @@ if (( ! $+_fs_any )); then
'noac[no attribute caching]'
'port[server IP port number]:port'
'posix[posix semantics]'
- 'proto[specify protocol]:protocol:'\("$(grep -v '^#' /etc/netconfig 2> /dev/null | cut -d ' ' -f 1)"\)
+ 'proto[specify protocol]:protocol:'\("$(grep -v '^#' "$([ -r /etc/netconfig ] && </etc/netconfig || </usr/share/defaults/etc/netconfig)" | cut -d ' ' -f 1)"\)
'public[force public file handle]'
'(noquota)quota[enable quotas]'
'(quota)noquota[disable quotas]'
diff --git a/Completion/Unix/Command/_su b/Completion/Unix/Command/_su
index 1af751a..1f58c4d 100644
--- a/Completion/Unix/Command/_su
+++ b/Completion/Unix/Command/_su
@@ -95,7 +95,7 @@ fi
case $state in
shells)
- _wanted -C $context shells expl shell compadd ${(f)^"$(</etc/shells)"}(N)
+ _wanted -C $context shells expl shell compadd ${(f)^"$([ -r /etc/shells ] && </etc/shells || </usr/share/defaults/etc/shells)"}(N)
return
;;
rest)
diff --git a/Completion/Unix/Command/_user_admin b/Completion/Unix/Command/_user_admin
index db1c977..5494059 100644
--- a/Completion/Unix/Command/_user_admin
+++ b/Completion/Unix/Command/_user_admin
@@ -9,7 +9,7 @@ case ${service%???}:${(M)service%???}:$OSTYPE in
if [[ -r /etc/shells ]]; then
shells=( ${${(f)"$(</etc/shells)"}:#\#*} )
else
- shells=( ${(M)commands:#*/(|[abckz]|tc|ba)sh} )
+ shells=( ${${(f)"$(</usr/share/defaults/etc/shells)"}:#\#*} )
fi
args+=(
'(-D -c --commend)'{-c+,--comment=}'[comment]:comment'
diff --git a/Completion/Unix/Type/_bpf_filters b/Completion/Unix/Type/_bpf_filters
index b744b1a..48f11a9 100644
--- a/Completion/Unix/Type/_bpf_filters
+++ b/Completion/Unix/Type/_bpf_filters
@@ -174,7 +174,7 @@ _regex_arguments _bpf /$'[^\0]#\0'/ \( \
\|\
/$'rpc[ \0]'/ \
\(\
- /$'[^, \0]##[ \0]'/ ':programs:rpc program:compadd -qS, - ${${(f)"$(</etc/rpc)"}%%[[:blank:]#]*}' \
+ /$'[^, \0]##[ \0]'/ ':programs:rpc program:compadd -qS, - ${${(f)"$([ -r /etc/rpc ] && </etc/rpc || </usr/share/defaults/etc/rpc)"}%%[[:blank:]#]*}' \
\|\
/$'[^, \0]##,[^, \0]##,'/ /$'[^, \0]##[ \0]'/ ':procedures:procedure:' \
\|\
diff --git a/Completion/Unix/Type/_ports b/Completion/Unix/Type/_ports
index 8c8da53..59e17be 100644
--- a/Completion/Unix/Type/_ports
+++ b/Completion/Unix/Type/_ports
@@ -4,8 +4,7 @@ local expl ports
if ! zstyle -a ":completion:${curcontext}:" ports ports; then
(( $+_cache_ports )) ||
- : ${(A)_cache_ports:=${${(M)${${(f)"$(</etc/services)"}:#\#*}#*/tcp}%%[ ]*}}
-
+ : ${(A)_cache_ports:=${${(M)${${(f)"$([ -r /etc/services ] && </etc/services || </usr/share/defaults/etc/services)"}:#\#*}#*/tcp}%%[ ]*}}
ports=( "$_cache_ports[@]" )
fi