Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have been reading about how ssh-agent works and how it relates to the shell environment. I understand why we do eval ssh-agent now (usually in /etc/profile), it makes logical sense. However the output of ssh-agent seems a little unnatural to me

# The bad way just (env dont get set, just printed) so i can see its output
[matt@laparchie rc.d]$ ssh-agent
SSH_AUTH_SOCK=/tmp/ssh-EQUsXLxh4103/agent.4103; export SSH_AUTH_SOCK;
echo Agent pid 4104;

Why doesnt ssh-agent just output

export SSH_AUTH_SOCK=/tmp/ssh-EQUsXLxh4103/agent.4103;
export SSH_AGENT_PID=4104;
echo Agent pid 4104;

When pumped to eval both do the same (i.e. setting env variables), but the latter is less verbose and more clear to me, is it just a style (the verbosity of the first)? and if so does the style have a history/reason? or is there something technically different?

share|improve this question
BASH is not the only shell. People using other shells want to use SSH too. – Zoredache Sep 15 '11 at 4:44

What ssh-agent outputs is sh syntax. The export varname=value construct is valid in bash but is not recognized by many implementations of sh whereas the varname=value; export varname construct is.

share|improve this answer

Technically, X=Y; export X is the right way.

But because it's unnecessary verbose, bash (as well as sh and zsh) provides shortcut export X=Y, which does exactly the same.

Actually, I don't know any shell, which uses export X to set environment variables, but does not understand export X=Y, but still using more verbose way is considered more portable.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .