Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • 10
    I am not sure you should take any suggestions from that article very seriously. Granted, it has a few good ideas, but it is clearly not someone used to shell scripting. Not a single variable in any of the examples is quoted(!) and it suggests using UPPER CASE variable names which is often a very bad idea since they can conflict with existing env vars. Your points in this answer make sense, but the linked article seems to have been written by someone who is just used to other languages and is trying to force their style onto bash. Commented Feb 10, 2017 at 9:43
  • 2
    @terdon I went back to the article and re-read it. The only place where author mentions upper case variable naming is in "Immutable Global Variables". If you consider global variables as those that have to be within function's environment, then it makes sense to make them capital. On side note, bash's manual doesn't state convention for variable case. Even here accepted answer says "usually" and the only "standard" is by Google, which doesn't represent whole IT industry. Commented Feb 10, 2017 at 16:07
  • @terdon on another note, I do agree 100% that variable quoting should have been mentioned in the article, and it has been pointed out in the comments on the blog,too. Also, I wouldn't judge someone using this style of coding, regardless of whether or not they're used to another language. This whole question and answers clearly show there's advantages to it, and person's degree to which they're used to another language is probably irrelevant here. Commented Feb 10, 2017 at 16:10
  • 1
    @terdon well, the article was posted as part of the "source" material. I could have posted everything as my own opinions, but I just had to give credit that some of the stuff I learned from the article, and that all this came from researching over time. The author's linkedin page shows they have good experience with Linux and IT in general, so I'd guess the article doesn't really show that, but I trust in your experience when it comes to Linux and shell scripting, so you might be right. Commented Feb 10, 2017 at 16:34
  • 2
    That's an excellent answer but I'd also like to add that variable scope in Bash is funky. For that reason, I prefer to declare my variables inside functions using local and calling everything via the main() function. This makes things a lot more manageable and you can avoid a potentially messy situation. Commented Sep 14, 2018 at 11:23