Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Oh, great. Except uhh... they are.

Shell variables are inextricably tied to environment variables and frankly, making them uninheritable would make them less useful, not more.



They're not. Here's proof:

   $ unset x
   $ x=1
   $ env | grep '^x='
It's perfectly valid and common to create variables that aren't environment variables. Variables silently dropping off characters causes problems for these use cases. For that reason, inextricably tying normal variables to environment variables would make them less useful, not more.


> It's perfectly valid

Yes.

> and common

Not even remotely.

> Variables silently dropping off characters causes problems for these use cases.

Sure, you should just silently drop it off when you export it instead, because that makes far more sense.


> > and common

> Not even remotely.

Real world code from numerous prominent open source projects begs to differ. Almost every random script I've opened in random open source projects made use of unexported shell variables. Take a look at the source repositories of the Linux kernel, Git, coreutils, GCC, LLVM, CMake, GDB, cURL, OpenSSL, Firefox, Chromium, Vim, and tmux. It's so prevalent that I don't even know why I have to point this out.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: