Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 12-03-2010
Member
 
Join Date: Oct 2009
Posts: 82
Eval in bash shell

hi everyone!

I have been studying and learning the bash and there is something associated with the command line argument which is not acceptable for me and I want to know the reason.what does eval do and what is the effect on the shell after executing it.

could somebody explain this to me.
Reply With Quote
  #2  
Old 12-03-2010
Member
 
Join Date: May 2008
Posts: 4,080
Eval in bash shell

Eval in bash shell

Eval is used to evaluate more than one commands/arguments.

Syntax:

eval [arguments]

The eval is used to make the group of arguments which are concatenated with each other into a single command then after is executed by the bash, and its exit status returned as the exit status of eval. If the argument is not specified then the status would be returned as zero.
Reply With Quote
  #3  
Old 12-03-2010
Member
 
Join Date: Apr 2008
Posts: 1,948
Eval in bash shell

Before execution of any command by the shell the eval performs the following operations -

1- Syntax analysis means Parsing.
2- Brace expansion
3- Tilde expansion
4- Parameter and variable expansion
5- Command substitution
6- Arithmetic expansion
7- Word splitting
8- Filename expansion
9- Quote removal

It is necessary to feel that parsing takes place before parameter and command substitution.
Reply With Quote
  #4  
Old 12-03-2010
Member
 
Join Date: May 2008
Posts: 2,008
Eval in bash shell

The 'eval' doesn't return the values in double quotations or after backslash, but it destroys the quotations and backslashes tagged in the statement !

One thing should be considered ,the shell parses the whole line one time before "eval" gets to interpret it.The actual lines would be as :

Code:
eval dn="$"$nn; echo $dn
After that the shell will parse it one time and would be converted as -

Code:
eval dn=$aa; echo final
Reply With Quote
  #5  
Old 12-03-2010
Member
 
Join Date: Apr 2008
Posts: 2,001
Eval in bash shell

eval is capable to "translates" a value buried under a variable and then applied the execution of the command -

for i in 1 2 3
do
eval myvar="$i"
echo "$myvar"
done

# this gives
1
2
3

This is because,no any metavalue or special meaning to 1 or 2 or 3.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Eval in bash shell"
Thread Thread Starter Forum Replies Last Post
How Eval() and Bind() methods differs in ASP Chillam Software Development 3 26-02-2011 08:44 AM
The eval() method in Java Isabella Software Development 6 11-08-2010 05:05 PM
Eval function in javascript Solaris Software Development 5 02-03-2010 05:59 PM
Creating array with Bash shell Carnie Operating Systems 5 19-02-2010 07:54 PM
Eval encoded file decoder Tungesh Software Development 1 30-07-2009 07:01 PM


All times are GMT +5.5. The time now is 02:10 PM.