Bash how is C lib?

I have a project in which I want to do some things that would be trivial in bash, but where I want / need a binary, with zero external dependencies. So, did anyone write a standalone lib (i.e. Not a wrapper around system ()) that allows you to do bash as material from within C?

By hand, the things that I expect will be as follows: cp, rm, wget, tftp, ar, tar, guzipand, perhaps dpkg, but I think I can make a side step.


To answer the comments: I'm looking for something in the lines of a statically linked boot window, but where I do not need a shell file as a program for it, and where things that I do not use automatically, t even connect.

+3
source share
3 answers

You need busybox .

+6
source

I totally agree with Busybox . In addition, if you get the source code for dpkg, you will find a small library inside that will give you access to most of its functions.

+2
source

, , , , ", , [ting]", .

, ( , , , ), , main().

In fact, for the dependencies, you might even just rename them main(), and you have a tool as if you would call it from the command line yourself, packing them with argc / argv, although this will most likely have some overhead rather than calling separate functions independently.

The above busyboxalready offers all the features you need (even tarand wget), except dpkg, and since there is already a lib, I would say that you are well on your way.

+1
source

Source: https://habr.com/ru/post/1787067/


All Articles