I am trying to learn some Bash to maybe get a job working with computers one day.
To improve my clarity and disciple writing my self-learning code, I am trying to adhere to a set of consistent "guiding principles".
As I roll my own "guidelines" I obviously ask myself: should I not be using an established standard instead?
I could not find one such "authoritative" reference for Bash, similar to what these other languages have:
- Java (http://www.oracle.com/technetwork/java/javase/documentation/index-137868.html) How to Write Doc Comments for the Javadoc Tool
- Java (http://www.oracle.com/technetwork/java/javase/documentation/codeconvtoc-136057.html) Code Conventions for the Java Programming Language
- Java (https://code.google.com/p/java-coding-standards/wiki/Introduction) Google Java coding standards
- Python (http://www.python.org/dev/peps/pep-0008/) PEP 8 -- Style Guide for Python Code
- Python (http://google-styleguide.googlecode.com/svn/trunk/pyguide.html) Google Python Style Guide
Is there a link with a similar document for Bash which has good reason for being used?
Here is the type of stuff I was putting together on my own... but I think, especially as a beginner, I should be using guidelines written by experts rather than trying to come up with my own, as they would not be based on much experience, insight, practicality, knowledge of common patterns/anti-patterns, etc.
You may dispute the validity of such documents in general, but some people must like them for the web to have such prominent examples online as the ones I mention in the bullet-list above..
################################################################################
# Coding conventions
#
# - Prefer lines of 80 characters of length or less
#
# - Perform arithmetic operations and numeric comparisons within "(( ))" blocks
# e.g. if ((42<=24+24)), ((3**3==27))
#
# - Reference variables by name, not expansion, within arithmetic evaluation
# e.g. ((i++)) rather than (($i++)), ((v+=42)) rathern than v=$(($v+42))
#
# - Prefer "[[" to "[" for conditional expressions
#
# - Prefer "[[ $s ]]" to "[[ -n $s ]]" when checking for empty strings
#
# - Document each function with at least a summary sentence. This should not
# exceed the preferred line length, be written in third person, end with a
# period and concisely describe the general utility of the function
#
# ...
# ...
# ...
#
################################################################################
bashprogramming, you seem to be placing an undue importance on the topic. I doubt you are going to find a job where shell programming is your primary duty; an in-depth knowledge ofbashcan make everyday tasks easier, but it's not going to be the primary reason you are hired. Style guides for Python exist to provide consistency for projects with many contributors or projects whose long lifetime suggests they will be maintained by people not involved with earlier development. Similar projects written inbashare rare.bashto be fast and accurate on the command line, learnpythonto write my scripts, learnjavato do my GUIs (SWT), learnandroidto do my mobile apps, learnlinuxto do my sysadmin, learn machine learning to do my back-end stuff (I have ideas), learn html5/css/jscript to do some, probably very little web presentation, as in "a little web site for myself", learn algorithms and compete in a few TopCoder tournaments to get some interviewing practice. Bash is just my 1st step: foundations and not looking silly @ CLI