- if ((*list)->hookee_pre)
- (*list)->hookee_pre->hook_pre = 0; /* Hook slips out of its mouth */
- if ((*list)->hookee_post)
- (*list)->hookee_post->hook_post = 0; /* Hook slips out of its bottom */
- p = (*list)->next;
- xfree (* list);
- *list = p;
+ if (strcmp (iter->name, name) == 0)
+ {
+ if (iter->hookee_pre)
+ iter->hookee_pre->hook_pre = 0;
+ if (iter->hookee_post)
+ iter->hookee_post->hook_post = 0;
+
+ /* Update the link. */
+ *previous_chain_ptr = iter->next;
+
+ aliases = iter->aliases;
+
+ /* If this command was an alias, remove it from the list of
+ aliases. */
+ if (iter->cmd_pointer)
+ {
+ struct cmd_list_element **prevp = &iter->cmd_pointer->aliases;
+ struct cmd_list_element *a = *prevp;
+
+ while (a != iter)
+ {
+ prevp = &a->alias_chain;
+ a = *prevp;
+ }
+ *prevp = iter->alias_chain;
+ }
+
+ xfree (iter);
+
+ /* We won't see another command with the same name. */
+ break;
+ }
+ else
+ previous_chain_ptr = &iter->next;