views:

65

answers:

2

Does anyone know of any tool which can convert shell script '.sh' into a C file '.c' ?

+1  A: 

I doubt that any such tool exists. C and shell files are extremely different languages with completely different purposes, and there is no way to automatically convert one to the other.

JSBangs
Just make a shell implementation in a single .c file with `const char scripttext[] = "` at the end, and the tool is called `( cat shell.c "$1" ; echo '";' )>out.c`.
R..
Thanks for the help but not getting what you want to convey. Can you please explain a little?
hari
I mean find (or write) an implementation of the shell, and then embed your shell script as a constant string for the shell to run.
R..
A: 

you can try shc. Its not a compiler, but it does generate .c files during encoding/encrypting.

Otherwise, do it by hand. Learn to code in C and shell, then translate them yourself. that's the best way to do it.

ghostdog74