|
|
|
|
|
by chubot
2733 days ago
|
|
Yeah, I think there is a stark difference in how we're thinking about it. I can't imagine dissuading someone from using local variables "with a straight face". I didn't get your solution below because "local_variable" is actually a global. I could see that perhaps low level scripts need to be portable to different Unixes. But again I would say that's maybe 5% of what shell is good for. Also, someone once said "it's easier to port a shell than a shell script". So that's why I'm paying careful attention to Oil build dependencies. For example, Rust and Go are significantly less portable than C, and Oil is self-contained C if you look at it the right way :) ---- EDIT: Also I think there's no problem adding local variables to POSIX, since all shells implement the same way as far as I can tell. That would be the much better solution, rather than trying to convince people to use only globals. There are many useful / real shell scripts that are thousands of lines long, so you really need locals. |
|
A global in a subshell, so the caller's globals aren't affected.
>Also, someone once said "it's easier to port a shell than a shell script".
Yeah, but it's pretty damn presumptuous to make someone install some random shell on my machine to build your code, imo. The same goes double for e.g. GNU coreutils extensions, since I have to set up some kind of separate root for you where true --version works (ditto for assuming /bin/sh is bash, or even dash so you can use 'local'). It's like encouraging people to use a fucked up version of libc where the args to strcat are reversed. Fuck that. The standard exists to define the environment. Sometimes it's within reason to have dependencies outside of that - but the shell is a good example of where the case for it is very weak.
For the record, my motivations for working on Simon's mrsh project is basically 50:50 between "I want to support POSIX-compatible shell scripts" and "I want a POSIX shell whose interactive mode isn't dogshit". Both are equally important to me.
>EDIT: Also I think there's no problem adding local variables to POSIX, since all shells implement the same way as far as I can tell. That would be the much better solution, rather than trying to convince people to use only globals.
That's all well and good. The Austin Group has public meetings, a public bug tracker, and a public mailing list. Go there and make a case for it! But be prepared for "all shells" to include more than dash, bash, ksh, and zsh.
>There are many useful / real shell scripts that are thousands of lines long, so you really need locals.
Length of shell script is not directly correleated for need for locals.