Related to question 3451993, is it possible to call a function which is internal to subst.c (in the Bash source code) in a Bash script?
+1
A:
The simplest way to do this is to write a simple program that collects the input, feeds it to the function, then prints the result. Why don't you tell us what you are attempting to accomplish and perhaps we can suggest an easier way to "skin this cat".
Jay
2010-08-10 20:28:12
I'm trying to call a function which is internal to Bash, but it looks like it's not compiled into a separate shell command. Please see the link for more info.
l0b0
2010-08-10 20:51:10
It's very difficult to do this and is usually very unreliable. You're better off trying to get what you want a different way.
Jay
2010-08-10 20:57:10
@l0b0: restating the question is not equivalent to saying what you are trying to accomplish.
msw
2010-08-10 20:57:12
+3
A:
No.
You can't access a function internal to the shell binary from the shell if it is not exported as a shell function.
msw
2010-08-10 20:58:32
A:
No, you'll have to write a short C program, compile it and call it from the shell.
tomlogic
2010-08-10 21:15:29
+2
A:
Bash supports loadable builtins. You might be able to make use of this to do what you want. See the files in your /usr/share/doc/bash/examples/loadables
(or similar) directory.
Dennis Williamson
2010-08-10 22:58:12
Good idea. Unfortunately `grep subst /usr/share/doc/bash/examples/loadables/*` returned nothing.
l0b0
2010-08-11 14:19:41
@l0b0: That just means you have to write your own. Also, `grep subst /usr/include/bash/*` gives `/usr/include/bash/shell.h:#include "subst.h"`, `grep shell.h /usr/share/doc/bash/examples/loadables/*` gives a bunch. Unfortunately, `grep prompt /usr/share/doc/bash/examples/loadables/*` gives nothing, but `grep prompt /usr/include/bash/subst.h` does look interesting.
Dennis Williamson
2010-08-11 14:49:09