[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature request. bash builtin autoloading.
From: |
sascha . krissler |
Subject: |
feature request. bash builtin autoloading. |
Date: |
Sat, 3 Apr 2004 13:47:52 +0200 (CEST) |
Configuration Information [Automatically generated, do not change]:
Machine: i386
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i386'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i386-pc-linux-gnu'
-DCONF_VENDOR='pc' -DSHELL -DHAVE_CONFIG_H -I.
-I/home/doko/packages/bash/bash-2.05a
-I/home/doko/packages/bash/bash-2.05a/include
-I/home/doko/packages/bash/bash-2.05a/lib -g -O2
uname output: Linux test 2.6.0 #1 Fri Jan 2 18:54:53 CET 2004 i686 GNU/Linux
Machine Type: i386-pc-linux-gnu
Bash Version: 2.05a
Patch Level: 0
Release Status: release
Description:
I would like to do autoloading of builtins and have problems
implementing it. Maybe it would be a feature worth including
in the next release.
here is a diff which works only with --without-bash-malloc
on my box and then gives segfaults now and then.
Maybe you spot the error. I guess that i do it completly
at the wrong place, but i dont want to study the architecture
of bash.
Thanks in advance for help.
I am not on the list, please send me a CC.
[snip]
diff -r -u bash-2.05b/builtins/common.c
bash-2.05b_autoload/builtins/common.c
--- bash-2.05b/builtins/common.c Fri Jun 28 18:24:31 2002
+++ bash-2.05b_autoload/builtins/common.c Fri Apr 2 12:41:28 2004
@@ -739,7 +739,20 @@
else
lo = mid + 1;
}
- return ((struct builtin *)NULL);
+ if (strcmp(name, "autoload_builtin") != 0) {
+ char buffer[1024];
+ int tmp;
+ void * oldelt = replace_unwind_protect_list(NULL);
+ sprintf(buffer, "autoload_builtin %s 2>/dev/null", name);
+ tmp = parse_and_execute(buffer, NULL, SEVAL_NOHIST);
+ replace_unwind_protect_list(oldelt);
+ //xfree(replace_unwind_protect_list(oldelt));
+ if (tmp == 0)
+ return ((struct builtin *)NULL); /*builtin_address_internal(name,
disabled_okay);*/
+ else
+ return ((struct builtin *)NULL);
+ } else
+ return ((struct builtin *)NULL);
}
/* Return the pointer to the function implementing builtin command NAME. */
diff -r -u bash-2.05b/unwind_prot.c bash-2.05b_autoload/unwind_prot.c
--- bash-2.05b/unwind_prot.c Thu Feb 28 20:34:05 2002
+++ bash-2.05b_autoload/unwind_prot.c Fri Apr 2 22:03:35 2004
@@ -90,6 +90,16 @@
#define uwpalloc(elt) (elt) = (UNWIND_ELT *)xmalloc (sizeof (UNWIND_ELT))
#define uwpfree(elt) free(elt)
+void * replace_unwind_protect_list(void * new) {
+ void * old = (void *) unwind_protect_list;
+ if (new == NULL) {
+ unwind_protect_list = (UNWIND_ELT *)xmalloc(sizeof(UNWIND_ELT));
+ memset(unwind_protect_list, 0, sizeof(UNWIND_ELT));
+ }
+ unwind_protect_list = (UNWIND_ELT *) new;
+ return old;
+}
+
/* Run a function without interrupts. This relies on the fact that the
FUNCTION cannot change the value of interrupt_immediately. (I.e., does
not call QUIT (). */
diff -r -u bash-2.05b/unwind_prot.h bash-2.05b_autoload/unwind_prot.h
--- bash-2.05b/unwind_prot.h Thu Feb 28 18:16:16 2002
+++ bash-2.05b_autoload/unwind_prot.h Fri Apr 2 12:39:06 2004
@@ -31,6 +31,8 @@
extern void clear_unwind_protect_list __P((int));
extern void uwp_init __P((void));
+extern void * replace_unwind_protect_list __P((void *));
+
/* Define for people who like their code to look a certain way. */
#define end_unwind_frame()
[snip]
Repeat-By:
[Describe the sequence of events that causes the problem
to occur.]
Fix:
[Description of how to fix the problem. If you don't know a
fix for the problem, don't include this section.]
- feature request. bash builtin autoloading.,
sascha . krissler <=