Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: completion cache mkdir & startup stat/zstat
- X-seq: zsh-workers 25275
- From: Phil Pennock <zsh-workers+phil.pennock@xxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: PATCH: completion cache mkdir & startup stat/zstat
- Date: Thu, 10 Jul 2008 23:47:09 -0700
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=d200803; d=spodhuis.org; h=Received:Date:From:To:Subject:Message-ID:Mail-Followup-To:MIME-Version:Content-Type:Content-Disposition; b=Dcbf9eASni9eERpKLvJ1dVwWbOhpD99RP/FdhX/5rEIYPTf+pNkM8lGkQynKLrKCZ5YtwQI1v2nTh/Vu788YCxTJ3huvzoHPaWIti1+PMHlUW8v5L4UDb61Hn75NDG5H1WeoIw4253oqHoCsrsuvaT7SVMDBa1Q42GwLLcWXoQw=;
- Mail-followup-to: zsh-workers@xxxxxxxxxx
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
I noticed that the ~/.zcompcache is being created with normal umask,
which seems a bit odd for something that might be used for caching data
from private areas; a cache should typically be private IMO. Best way
to test if MO differs from the norm is to throw the patch out there.
I initially switched to using zf_mkdir but then realised why that was
not the right thing to do. There were a couple of things which I had to
think over; so I added explanatory comments. A disturbing trend, this.
More arguably, I also changed StartupFiles/zshrc to only load zstat, not
stat. Hopefully, this really is always used as an example (as warned in
BIG CAPS at the start) and never automatically deployed to new user
accounts by an environment which depends on stat being the zsh built-in
for aforesaid new user accounts. It seems unlikely that we'd break
anything and we really do need to make the switch at some point. So I'm
doing so. I claim bonus points for demonstrating Peter's cool features
work in the demo file.
----------------------------8< cut here >8------------------------------
Index: Completion/Base/Utility/_store_cache
===================================================================
RCS file: /home/cvsroot/zsh/Completion/Base/Utility/_store_cache,v
retrieving revision 1.3
diff -p -u -r1.3 _store_cache
--- Completion/Base/Utility/_store_cache 9 Oct 2002 20:38:28 -0000 1.3
+++ Completion/Base/Utility/_store_cache 11 Jul 2008 06:38:24 -0000
@@ -13,7 +13,11 @@ if zstyle -t ":completion:${curcontext}:
if [[ -e "$_cache_dir" ]]; then
_message "cache-dir style points to a non-directory\!"
else
- (zmodload zsh/files 2>/dev/null; mkdir -p "$_cache_dir" )
+ # if module load fails, we *should* be okay using normal mkdir so
+ # we load feature b:mkdir instead of b:zf_mkdir; note that modules
+ # loaded in a sub-shell don't affect the parent.
+ ( zmodload -F zsh/files b:mkdir; mkdir -m 0700 -p "$_cache_dir"
+ ) 2>/dev/null
if [[ ! -d "$_cache_dir" ]]; then
_message "couldn't create cache-dir $_cache_dir"
return 1
@@ -27,7 +31,9 @@ if zstyle -t ":completion:${curcontext}:
if [[ -e "$_cache_ident_dir" ]]; then
_message "cache ident dir points to a non-directory:$_cache_ident_dir"
else
- (zmodload zsh/files 2>/dev/null; mkdir -p "$_cache_ident_dir")
+ # See also rationale in zmodload above
+ ( zmodload -F zsh/files b:mkdir; mkdir -m 0700 -p "$_cache_ident_dir"
+ ) 2>/dev/null
if [[ ! -d "$_cache_ident_dir" ]]; then
_message "couldn't create cache-ident_dir $_cache_ident_dir"
return 1
Index: StartupFiles/zshrc
===================================================================
RCS file: /home/cvsroot/zsh/StartupFiles/zshrc,v
retrieving revision 1.3
diff -p -u -r1.3 zshrc
--- StartupFiles/zshrc 9 May 2001 16:57:31 -0000 1.3
+++ StartupFiles/zshrc 11 Jul 2008 06:25:45 -0000
@@ -95,10 +95,11 @@ setopt autopushd pushdminus extendedgl
unsetopt bgnice autoparamslash
# Autoload zsh modules when they are referenced
-zmodload -a zsh/stat stat
zmodload -a zsh/zpty zpty
zmodload -a zsh/zprof zprof
zmodload -ap zsh/mapfile mapfile
+# stat(1) is now commonly an external command, so just load zstat
+zmodload -aF zsh/stat b:zstat
# Some nice key bindings
#bindkey '^X^Z' universal-argument ' ' magic-space
Messages sorted by:
Reverse Date,
Date,
Thread,
Author