linux - Set a Bash function on the environment -


I need to define the Bash function in the Bash environment with the C / C ++ program I shellshock Before the bug, I can define a function like this:

  my_func = '() {echo "this is my work";}'   

or equivalent to C program:

  setenv ("my_func", "() {echo" This is my work ";)", 1);   

or

  putenv ("my_func = () {echo" This is my work ";););   

But using a Bash version with shellshock , I can not manage to define my actions in the environment.

The strange thing is that if I run env , then I can define my work in the environment, but if I call it, then Bash says that it does not exist.

thanks advance

If you type bash Starting with code> execv> > (so that you are only implementing it once), you can (use execl for clarification):

  execl ("/ bin / bash", "Bash", "file_to_run", "arg1", "arg2", 0);   

  execl ("/ bin / bash", "bash", "-c", "f () {...} With () {...} \ n. $ 0 "," file_to_run "," arg1 "," arg2 ", 0);   

And then you do not need to play the game with the internal bad interface to define the function. (If the script is running, then the function is also required to export, for whatever reason, after the code -c in the logic, export -f & lt; func & gt; ; Add line.)

It has the advantage of working with both patch and unread bases.

(I have to make patch similar to several programs, so I share your pain.)

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -