* unfunction fix
@ 1995-08-19 23:48 Zoltan Hidvegi
1995-08-21 16:42 ` Richard Coleman
0 siblings, 1 reply; 2+ messages in thread
From: Zoltan Hidvegi @ 1995-08-19 23:48 UTC (permalink / raw)
To: zsh-workers
unfunction was the same as unhash so far. This means that for example
unfunction -m '*' removed everything from the command hash table not
only the functions. The simple patch below fixes it. It adds a new -f
optino to unhash, and unfunction is the same as unhash -f.
When a function is removed unhash will check if there is a command in the
path with the same name and if it finds one, it puts it into the hash table
if the HASH_CMDS option is set.
Zoltan
*** 1.27 1995/07/24 17:07:11
--- Src/builtin.c 1995/08/19 21:04:16
***************
*** 187,194 ****
{"ulimit", bin_ulimit, 0, 1, 0, 0, "HSacdflmnopstv", NULL},
{"umask", bin_umask, 0, 1, 0, 0, NULL, NULL},
{"unalias", bin_unalias, 1, -1, 0, 0, "m", NULL},
! {"unfunction", bin_unhash, 1, -1, 0, 0, "m", NULL},
! {"unhash", bin_unhash, 1, -1, 0, 0, "m", NULL},
{"unlimit", bin_unlimit, 0, -1, 0, 0, "h", NULL},
{"unset", bin_unset, 1, -1, 0, 0, "m", NULL},
{"unsetopt", bin_setopt, 0, -1, BINF_PLUSOPTS, 1, "0123456789BCDEFGHIJKLMNOPQRSTUWXYZabefghjklmnopsuvwxy", NULL},
--- 187,194 ----
{"ulimit", bin_ulimit, 0, 1, 0, 0, "HSacdflmnopstv", NULL},
{"umask", bin_umask, 0, 1, 0, 0, NULL, NULL},
{"unalias", bin_unalias, 1, -1, 0, 0, "m", NULL},
! {"unfunction", bin_unhash, 1, -1, 0, 0, "m", "f"},
! {"unhash", bin_unhash, 1, -1, 0, 0, "mf", NULL},
{"unlimit", bin_unlimit, 0, -1, 0, 0, "h", NULL},
{"unset", bin_unset, 1, -1, 0, 0, "m", NULL},
{"unsetopt", bin_setopt, 0, -1, BINF_PLUSOPTS, 1, "0123456789BCDEFGHIJKLMNOPQRSTUWXYZabefghjklmnopsuvwxy", NULL},
***************
*** 3784,3791 ****
for (t = 0; t < n; t++)
for (chn = (Cmdnam) cmdnamtab->nodes[t]; chn; chn = nchn) {
nchn = (Cmdnam) chn->next;
! if (domatch(chn->nam, com, 0) && !(chn->flags & BUILTIN))
! cmdnamtab->freenode(cmdnamtab->removenode(cmdnamtab, chn->nam));
}
}
}
--- 3784,3797 ----
for (t = 0; t < n; t++)
for (chn = (Cmdnam) cmdnamtab->nodes[t]; chn; chn = nchn) {
nchn = (Cmdnam) chn->next;
! if (domatch(chn->nam, com, 0) &&
! !(chn->flags & BUILTIN) &&
! (!ops['f'] || chn->flags & SHFUNC)) {
! dat = cmdnamtab->removenode(cmdnamtab, chn->nam);
! if (ops['f'] && isset(HASHCMDS))
! hashcmd(chn->nam, path);
! cmdnamtab->freenode(dat);
! }
}
}
}
***************
*** 3794,3800 ****
while (*argv) {
if (!strncmp(*argv, "TRAP", 4))
unsettrap(getsignum(*argv + 4));
! if ((dat = cmdnamtab->removenode(cmdnamtab, *argv++)))
cmdnamtab->freenode(dat);
}
}
--- 3800,3815 ----
while (*argv) {
if (!strncmp(*argv, "TRAP", 4))
unsettrap(getsignum(*argv + 4));
! if (ops['f']) {
! Cmdnam chn = (Cmdnam) cmdnamtab->getnode(cmdnamtab, *argv);
!
! if (chn->flags & SHFUNC) {
! cmdnamtab->freenode(cmdnamtab->removenode(cmdnamtab, *argv));
! if (isset(HASHCMDS))
! hashcmd(*argv, path);
! argv++;
! }
! } else if ((dat = cmdnamtab->removenode(cmdnamtab, *argv++)))
cmdnamtab->freenode(dat);
}
}
*** 1.10 1995/07/10 18:27:53
--- Doc/zshbuiltins.1 1995/08/19 21:28:48
***************
*** 228,234 ****
\-\fBm\fP flag the arguments are taken as patterns (should be quoted
to preserve them from being taken as glob patterns) and all builtins
matching these patterns are disabled.
- Actually the same as \fBunhash\fP.
Builtins can be enabled with the \fBenable\fP command.
.TP
.PD 0
--- 228,233 ----
***************
*** 1010,1024 ****
quoted) and all aliases with matching names are removed.
.TP
\fBunfunction\fP [ \-\fBm\fP ] \fIname\fP ...
! The function definition, if any, for each \fIname\fP is removed.
! If the \-\fBm\fP flag is specified the arguments are taken as patterns
! (should be quoted) and all functions with matching names are removed.
.TP
! \fBunhash\fP [ \-\fBm\fP ] \fIname\fP ...
The entry in the command hash table, if any, for each \fIname\fP
is removed. If the \-\fBm\fP flag is given the arguments are taken as
patterns (should be quoted) and all entries for commands with matching
! names will be removed.
.TP
\fBunlimit\fP [ \-\fBh\fP ] \fIresource\fP ...
The resource limit for each \fIresource\fP is set to the hard limit.
--- 1009,1022 ----
quoted) and all aliases with matching names are removed.
.TP
\fBunfunction\fP [ \-\fBm\fP ] \fIname\fP ...
! Same as \fBunhash \-f\fP.
.TP
! \fBunhash\fP [ \-\fBfm\fP ] \fIname\fP ...
The entry in the command hash table, if any, for each \fIname\fP
is removed. If the \-\fBm\fP flag is given the arguments are taken as
patterns (should be quoted) and all entries for commands with matching
! names will be removed. With the \-\fBf\fP flag only function definitions
! are removed.
.TP
\fBunlimit\fP [ \-\fBh\fP ] \fIresource\fP ...
The resource limit for each \fIresource\fP is set to the hard limit.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: unfunction fix
1995-08-19 23:48 unfunction fix Zoltan Hidvegi
@ 1995-08-21 16:42 ` Richard Coleman
0 siblings, 0 replies; 2+ messages in thread
From: Richard Coleman @ 1995-08-21 16:42 UTC (permalink / raw)
To: zsh-workers
> unfunction was the same as unhash so far. This means that for example
> unfunction -m '*' removed everything from the command hash table not
> only the functions. The simple patch below fixes it. It adds a new -f
> optino to unhash, and unfunction is the same as unhash -f.
>
> When a function is removed unhash will check if there is a command in the
> path with the same name and if it finds one, it puts it into the hash table
> if the HASH_CMDS option is set.
In beta11, shell functions, buitlins, and external commands are in
separate hash tables, so this will no longer be a problem. I made
good progress on beta11 last week, so I will probably start making
test releases later in the week, with a real beta11 in about two weeks.
Richard Coleman
coleman@math.gatech.edu
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1995-08-21 17:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-08-19 23:48 unfunction fix Zoltan Hidvegi
1995-08-21 16:42 ` Richard Coleman
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).