[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: OT: Bash: what is eval doing here?



rhkramer@gmail.com writes:

> In my (seemingly unending) quest to understand ssh, I've come across a 
> document that calls for running =eval 'ssh-agent'= from a command line.
>
> I wondered why, as I thought I would get the same result from just running 
> =ssh-agent=, but the results are different -- see below:
>
> $ eval `ssh-agent`
> Agent pid 23929
>
> $ ssh-agent
> SSH_AUTH_SOCK=/tmp/ssh-uLqQ9VWX0RL7/agent.23932; export SSH_AUTH_SOCK;
> SSH_AGENT_PID=23933; export SSH_AGENT_PID;
> echo Agent pid 23933;
>
> Can anybody on here explain what is going on / why?

ssh-agents prints details about its config (i.e. where ssh should search
authentication agent) - and thats all. (these are SSH_AUTH_SOCK et al.)

eval `` in turn takes these statements and try to evaluate them
(i.e. creates these two variables in environment)

as an example try
--8<---------------cut here---------------start------------->8---
$echo "KJONCA_VAR=this_is_test"
$set | grep KJONCA
$eval $(echo "KJONCA_VAR=this_is_test")
$set |grep KJONCA
--8<---------------cut here---------------end--------------->8---

KJ

-- 
http://stopstopnop.pl/stop_stopnop.pl_o_nas.html


Reply to: