tags:

views:

89

answers:

4

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
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
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
@l0b0: restating the question is not equivalent to saying what you are trying to accomplish.
msw
+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
A: 

No, you'll have to write a short C program, compile it and call it from the shell.

tomlogic
+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
Good idea. Unfortunately `grep subst /usr/share/doc/bash/examples/loadables/*` returned nothing.
l0b0
@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