Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[templates] add bash template and style guide #1

Open
budRich opened this issue Sep 20, 2018 · 0 comments
Open

[templates] add bash template and style guide #1

budRich opened this issue Sep 20, 2018 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@budRich
Copy link
Contributor

budRich commented Sep 20, 2018

Rules of bash:

All scripts should at least have long and short options for help and version.
Help always contains Short and long description, synopsis, options descriptions.

Environment variables are always ALL_CAPS.
global variables and arrays are prefixed with __two_underscores
all other variables are declared local.
functions are all lowercase(){ : ;}

informative mandatory globals always at the top of the scripts after shebang (#!/bin/env bash)

three mandatory functions: main() and init() printinfo()

special optional global variables are __lastarg and __stdin. __lastarg is defined after options are parsed, __stdin` is defined before entering main function.

maybe add mandatory function deticated for option parsing.

options are defined like this:

__optargs[longoption]=ARGNAME
__opttext[longoption]=description
__options[longoption]= followed by optional shortoption, colons, and +.
one colon means that the option have a mandatory argument, two colons are optional argument, + will automaticly add the argument to a global variable named __LONGOPTION, if no argument is given set the variable to 1.

@budRich budRich added the enhancement New feature or request label Sep 20, 2018
@budRich budRich self-assigned this Sep 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant