![]() Examples to Implement of Eval in Shell Script One can also type eval –help in the command line to get quick help on the eval documentation. The eval statements find a lot of use cases in times when we want to access the index variable of an argument. Now in another process, the $var_2 will be executed first and the corresponding value will be an output, which can be a string and along with an escape character, var_1 will attain the value stored in the variable $var_2 output, which would be a string. What it will eventually do is take the var_1=’$’$var_2 as a string itself and then try to execute that in another child process. If the command is as follows: eval var_1='$'$var_2 The argument is converted like a single string and that acts as an input to another child process of the shell where the resulting commands are executed. If we want to get deeper on what exactly is performed. The syntax goes on as: eval Īlthough the syntax looks pretty plain, but the power lies in the simplicity itself. ![]() Now let us come to the syntax part of eval command. The reason for being a benchmark or being a standard system is simply because of Unix being neutral from a manufacturer’s perspective. Web development, programming languages, Software testing & othersĪnother important concept is that eval is a part of POSIXwhich is nothing, but a standard maintained by IEEE for keeping compatibility between operating systems. Hence you would see a different process id of the eval command itself. ![]() But in case of eval, a child process is created, and the commands are executed there and not in the process id of the shell itself. In layman terms, it simply means that the process id of exec inside a shell script is the same as the process id of the shell script itself. In the case of exec, the execution of the command doesn’t fork and just replaces the shell. Both are completely different genres of beasts. In quite a number of instances, we have seen people using the concept of exec and eval interchangeably. We combine all the command and as soon as we execute the script, we execute the command in the same chronological order. This though of execution can be write related to the execution of a script. At the end, the execution returns an exit status of the command. This command enables us in a combination of all the arguments together into a combined expression and then executes that. This is one of the most powerful commands and besides being powerful, it provides flexibility as well. Eval command is like any other command responsible for getting the popularity shell script is enjoying today.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |