OPP - Other Process’ Property
Sunday, February 25th, 2007For those who use linux and /bin/bash… did you know that you can export both variables -and- functions?
The story– if you use Linux and the shell “GNU Bash” (echo $SHELL), you may know that you can create custom environment variables to modify your local runtime. Some executed programs may optionally look for env variables to condition how they run. It’s important to know that when you execute a program, a new process is forked and an exact copy of your environment at-that-time (including variables) defines the new environment. Any new env changes are local to that forked process. When you execute those programs, you may need to let them “see” your custom variables. In Bash, you do that with the command ‘export’. If you have a group of commands, you can envelope them within a function. Guess what? If you want that executed program to see your custom function… you can ‘export’ it!
$ function resolveln {
for link in $(find . -type l) {
echo "readlink -e ${link}";
}
}
$ export resolveln
$ ./myprogram # new process; has access to shell function





