5 ms·
> The double quotes are of course technically correct, but when you're writing a shell script in a subdir 8 levels deep in the repo that only operates on 3 file
by jonahx 7y ago
> The double quotes are of course technically correct, but when you're writing a shell script in a subdir 8 levels deep in the repo that only operates on 3 files in that subdir, it's overkill and makes everything ugly.
Once it becomes habit the cost is zero, though.
And the alternative you're implicitly suggesting is: "Follow shellcheck except you are allowed to make an expert judgement and ignore it when you know it won't be dangerous and have determined that the code is unlikely to change in the future so that this exception will be safe going forward too."
I think it's clear that this isn't a practical rule on a team with many people -- especially where they are not all experts in shell, which is 100% of teams of many people.
Making the experts "add those annoying double quotes they don't really need in this case" is the far lesser of the two sins.
- acqq 7y agoExactly. If one "expert" is developing only for himself he can allow himself not to bother writing a script "clearly" (i.e. failing the programs that perform source checks). But as soon as the script is something that should be potentially sooner or later maintained by anybody else than the original author (and in any successful project that's practically sure) the only right policy is to produce the source code that's obvious and passes the source checks. An "expert" would have no problem to in no time adjust his three-line code to fulfill all the expectations of ShellCheck. If it takes more than that, that only proves that the checks are actually beneficial and even more important than the "expert" tells to himself: it proves that writing that specific code "cleanly" is actually hard for everybody.
- chubot 7y agoYeah I don't disagree with that. If you're working in a big group with some shell scripts, and want to get stuff done, use ShellCheck. I just find it annoying, hence the new shell :) There's a lot more to Oil, but that's definitely one of the surface annoyances I want to fix. Although zsh actually does fix that, and for some reason I've almost never seen a zsh script.
- fctorial 7y agoMany oh-my-zsh plugins are just collection of functions, which I think could be considered scripts. https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins
- chubot 7y agoYes sorry I should have said "I rarely see a batch program in zsh". zsh is customized with zsh scripts for sure, and they are very extensive. I guess it's because zsh is not POSIX compatible by default.