q[SET]^q[EXPORT]^plain assignment #no-arg SET

(Not sure about csh. Let’s focus on /bin/sh and bash for now. I bet everything here also applies to ksh.)

“set” is mostly used to set options. I see it less often used to manipulate variables, which is possible but unnecessarily complicated. In fact

set a=1; echo $a # shows nothing

  • “set” alone displays variables, but “set” doesn’t modify/create variables. [1]
  • “export” has a single meaning and you see it used consistently (whereas “set” isn’t).

Are you managing variables in bash? A simple “binary” advice is
– use export for ENV variables
– use “nothing” to manage shell variable — Nothing but “a=1”

How about “let”? Only needed for arithmetic. I would say don’t let this stranger join the club and confuse yourself.

[1] In DOS, “set” command creates variables (http://www.easydos.com/set.html)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s