1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-05 11:01:13 +02:00

Merge of 23363: fake-files style now takes pattern.

This commit is contained in:
Paul Ackersviller 2007-11-18 19:08:14 +00:00
parent 9894672975
commit d14a675a84
3 changed files with 33 additions and 3 deletions

View file

@ -1340,12 +1340,17 @@ without a tag. Its values are of the form
`var(dir)tt(:)var(names...)'. This will add the var(names) (strings
separated by spaces) as
possible matches when completing in the directory var(dir), even if no
such files really exist.
such files really exist. The dir may be a pattern; pattern characters
or colons in var(dir) should be quote with a backslash to be treated
literally.
This can be useful on systems that support special filesystems whose
top-level pathnames can not be listed or generated with glob patterns.
It can also be used for directories for which one does not have read
permission.
The pattern form can be used to add a certain `magic' entry
to all directories on a particular filing system.
)
kindex(fake-parameters, completion style)
item(tt(fake-parameters))(

16
README
View file

@ -60,6 +60,22 @@ change was necessary because otherwise recursive directories under
hit for anyone not using PINE. The previous default can be restored with:
zstyle ':completion:*' pine-directory ~/mail
The completion style fake-files now allows patterns as directories,
for example the value '/home/*:.snapshot' is now valid. This will
only cause problems in the unlikely event that a directory in the style
has a pattern character in it.
The default maximum function depth (configurable with
--enable-max-function-depth) has been decreased to 1000 from 4096. The
previous value was observed to be large enough that crashes still occurred
on some fairly common PC configurations. This change is only likely to
affect some highly specialised uses of the shell.
The variables HISTCHARS and histchars now reject any attempt to
set non-ASCII characters for history or comments. Multibyte characters
have never worked and the most consistent change was to restrict the
set to portable characters only.
Documentation
-------------

View file

@ -4169,14 +4169,20 @@ cfp_add_sdirs(LinkList final, LinkList orig, char *skipped,
char *m, *f, *p, *t, *a, c;
int sl = strlen(skipped) + 1;
struct stat st1, st2;
Patprog pprog;
for (; (f = *fake); fake++) {
f = dupstring(f);
for (p = t = f; *p; p++) {
if (*p == ':')
break;
else if (*p == '\\' && p[1])
else if (*p == '\\' && p[1] == ':') {
/*
* strip quoted colons here; rely
* on tokenization to strip other backslashes
*/
p++;
}
*t++ = *p;
}
if (*p) {
@ -4184,9 +4190,12 @@ cfp_add_sdirs(LinkList final, LinkList orig, char *skipped,
if (!*p)
continue;
tokenize(f);
pprog = patcompile(f, PAT_STATIC, NULL);
untokenize(f);
for (node = firstnode(orig); node; incnode(node)) {
if ((m = (char *) getdata(node)) &&
(!strcmp(f, m) ||
((pprog ? pattry(pprog, m) : !strcmp(f, m)) ||
(!stat(f, &st1) && !stat((*m ? m : "."), &st2) &&
st1.st_dev == st2.st_dev &&
st1.st_ino == st2.st_ino))) {