zsh-workers
 help / color / mirror / code / Atom feed
* adding mkdir to _store_cache
@ 2002-09-09 14:43 Felix Rosencrantz
  2002-09-09 16:23 ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: Felix Rosencrantz @ 2002-09-09 14:43 UTC (permalink / raw)
  To: zsh-workers

Would anyone object to adding an additional mkdir to the _store_cache function.

This would allow a cache identifier to contain slashes, basically a simple
attempt at having caches that can be per file.

Here is the suggested patch.

-FR.
Index: Completion/Base/Utility/_store_cache
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Utility/_store_cache,v
retrieving revision 1.2
diff -u -r1.2 _store_cache
--- Completion/Base/Utility/_store_cache	16 Apr 2002 07:48:45 -0000	1.2
+++ Completion/Base/Utility/_store_cache	9 Sep 2002 02:19:26 -0000
@@ -2,7 +2,7 @@
 #
 # Storage component of completions caching layer
 
-local _cache_ident
+local _cache_ident _cache_ident_dir
 _cache_ident="$1"
 
 if zstyle -t ":completion:${curcontext}:" use-cache; then
@@ -20,6 +20,21 @@
       fi
     fi
   fi
+  _cache_ident_dir="$_cache_dir/$_cache_ident"
+  _cache_ident_dir="$_cache_ident_dir:h"
+  
+  if [[ ! -d "$_cache_ident_dir" ]]; then
+    if [[ -e "$_cache_ident_dir" ]]; then
+      _message "cache ident dir points to a non-directory:$_cache_ident_dir"
+    else
+      mkdir -p "$_cache_ident_dir"
+      if [[ ! -d "$_cache_ident_dir" ]]; then
+        _message "couldn't create cache-ident_dir $_cache_ident_dir"
+        return 1
+      fi
+    fi
+  fi
+  
 
   shift
   for var; do



__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: adding mkdir to _store_cache
  2002-09-09 14:43 adding mkdir to _store_cache Felix Rosencrantz
@ 2002-09-09 16:23 ` Bart Schaefer
  2002-09-11 10:16   ` Felix Rosencrantz
  0 siblings, 1 reply; 6+ messages in thread
From: Bart Schaefer @ 2002-09-09 16:23 UTC (permalink / raw)
  To: Felix Rosencrantz, zsh-workers

On Sep 9,  7:43am, Felix Rosencrantz wrote:
} Subject: adding mkdir to _store_cache
}
} Would anyone object to adding an additional mkdir to the _store_cache
} function.

"mkdir -p" is not universally supported.

Other than that, no.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: adding mkdir to _store_cache
  2002-09-09 16:23 ` Bart Schaefer
@ 2002-09-11 10:16   ` Felix Rosencrantz
  2002-09-11 13:14     ` DervishD
  0 siblings, 1 reply; 6+ messages in thread
From: Felix Rosencrantz @ 2002-09-11 10:16 UTC (permalink / raw)
  To: Bart Schaefer, zsh-workers

--- Bart Schaefer <schaefer@brasslantern.com> wrote:
> "mkdir -p" is not universally supported.

I thought modern versions of *nix had the "-p" flag.  Is there something that
is portable?  Basically that code was copied from the existing code, we already
do a "-p" to create the cache directory if it doesn't exist.  So that needs to
be fixed also.

-FR.

__________________________________________________
Yahoo! - We Remember
9-11: A tribute to the more than 3,000 lives lost
http://dir.remember.yahoo.com/tribute


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: adding mkdir to _store_cache
  2002-09-11 13:14     ` DervishD
@ 2002-09-11 13:13       ` Peter Stephenson
  2002-09-11 14:15       ` Bart Schaefer
  1 sibling, 0 replies; 6+ messages in thread
From: Peter Stephenson @ 2002-09-11 13:13 UTC (permalink / raw)
  To: Zsh hackers list

In practice, mkdirhier is likely to be at least as portable as mkdir -p
since the vast majority of versions of UNIX over the last decade have
X11.  It may not be in the current path, however.

pws


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: adding mkdir to _store_cache
  2002-09-11 10:16   ` Felix Rosencrantz
@ 2002-09-11 13:14     ` DervishD
  2002-09-11 13:13       ` Peter Stephenson
  2002-09-11 14:15       ` Bart Schaefer
  0 siblings, 2 replies; 6+ messages in thread
From: DervishD @ 2002-09-11 13:14 UTC (permalink / raw)
  To: f_rosencrantz, zsh-workers, schaefer

    Hi Felix :)

>> "mkdir -p" is not universally supported.
>I thought modern versions of *nix had the "-p" flag.

    The Single Unix Specification v3 specify it, and GNU fileutils
(version 4.1, which is what I have) supports it.

>Is there something that is portable?

    Well, you can use parameter expansion and use the '##' and '%%'
expansions for getting each component of the path and make
directories simulating '-p', but IMHO it doesn't worth the effort.

>Basically that code was copied from the existing code, we already
>do a "-p" to create the cache directory if it doesn't exist.  
>So that needs to be fixed also.

    Autoconf uses '-p' too, if I remember well :? Anyway, if you want
to make something portable, you must assume that you cannot do it
*universally* portable. Just make it portable among 'current
practice unixes'. IMHO it doesn't make sense to make a thing work for
a couple of systems in a difficult way just for not using a feature
that the rest 98% systems have O:))
 
    Raúl


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: adding mkdir to _store_cache
  2002-09-11 13:14     ` DervishD
  2002-09-11 13:13       ` Peter Stephenson
@ 2002-09-11 14:15       ` Bart Schaefer
  1 sibling, 0 replies; 6+ messages in thread
From: Bart Schaefer @ 2002-09-11 14:15 UTC (permalink / raw)
  To: zsh-workers

On Sep 11,  3:14pm, DervishD wrote:
} Subject: Re: adding mkdir to _store_cache
} 
} >> "mkdir -p" is not universally supported.
} >I thought modern versions of *nix had the "-p" flag.
} 
}     The Single Unix Specification v3 specify it, and GNU fileutils
} (version 4.1, which is what I have) supports it.

It occurs to me that possibly the most obvious solution is

    (zmodload zsh/files 2>/dev/null; mkdir -p ...)

[Directed to /dev/null rather than used -i because "already loaded" is
not the only possible error to be ignored.]

Now that module builtins are not automatically loaded when the module is
compiled into the binary, we could change the default config.modules line
for the files (and possibly also stat, net/socket, and zftp) modules to
cause them to be linked to static builds.  Then the above subshell trick
would give us nearly-guaranteed access to necessary functionality.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2002-09-11 14:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-09 14:43 adding mkdir to _store_cache Felix Rosencrantz
2002-09-09 16:23 ` Bart Schaefer
2002-09-11 10:16   ` Felix Rosencrantz
2002-09-11 13:14     ` DervishD
2002-09-11 13:13       ` Peter Stephenson
2002-09-11 14:15       ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).