Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call C function in Bash script

Tags:

c

bash

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?

like image 945
l0b0 Avatar asked Aug 10 '10 20:08

l0b0


People also ask

How do you call a function in bash?

To invoke a bash function, simply use the function name. Commands between the curly braces are executed whenever the function is called in the shell script. The function definition must be placed before any calls to the function.

What is C option for bash?

The manual page for Bash (e.g. man bash ) says that the -c option executes the commands from a string; i.e. everything inside the quotes.

What is $() in shell script?

It's called command substitution (posix specification) and it invokes a subshell. The command in the braces of $() or between the backticks ( `…` ) is executed in a subshell and the output is then placed in the original command. Unlike backticks, the $(...) form can be nested.


1 Answers

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.

like image 193
Dennis Williamson Avatar answered Sep 21 '22 16:09

Dennis Williamson