3 ms·
> NUL bytes aren’t that uncommon, think of e.g. find -print0, xargs -0, etc. That all works grand, right up to the point you try to assign it to a variable. We
by jfrunyon 5y ago
> NUL bytes aren’t that uncommon, think of e.g. find -print0, xargs -0, etc. That all works grand, right up to the point you try to assign it to a variable.
Well, duh. Environment variables are NUL-terminated.
I don't understand arguments like this. "Learn something new so that you can avoid learning something old". None of the arguments on this page show me that zsh has a shallower learning curve than bash - only that zsh makes "more sense", once you've learned it, to you.
- soraminazuki 5y ago> Well, duh. Environment variables are NUL-terminated. Shell variables aren't the same thing as environment variables.
- jfrunyon 5y agoOh, 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.
- soraminazuki 5y agoThey'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.
- jfrunyon 5y ago> 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.
- soraminazuki 5y ago> > 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.