Programming guidelines and style


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Programming guidelines and style
# 1  
Old 08-09-2017
Programming guidelines and style

Hello all,

I would like to know if there is a generally accepted unix shell programming Guideline?

Do you have any idea where to find this?

There are a lot of programming Guidelines to find over Google, but is there one who is generally accepted?
# 2  
Old 08-09-2017
Hi.

This is a meta-answer for shell coding.

1) Write however you want, then run your code through a semantic and syntax checker:
Code:
shellcheck      analyse shell scripts (man)
Path    : /usr/bin/shellcheck
Version : ShellCheck - shell script analysis tool
Type    : ELF 64-bit LSB executable, x86-64, version 1 (SYSV ...)
Help    : probably available with -h
Repo    : Debian 8.8 (jessie) 
Home    : http://hackage.haskell.org/package/ShellCheck (pm)

As you progress, you can skip this as the first step, and go right to testing, coming back if your code fails.

then through a beautifier (which could easily apply to all languages):
Code:
beautysh        Tidy bash scripts, written in python3. (what)
Path    : ~/bin/beautysh
Version : - ( local: RepRev 1.4, ~/bin/beautysh, 2016-03-31 )
Length  : 174 lines
Type    : Python script, ASCII text executable
Shebang : #!/usr/bin/env python3
Home    : https://github.com/bemeurer/beautysh (doc)
Modules : (for python codes)
  re
  sys

2) Shell (as a programming language for more than trivial scripting) is dead. Perl rules in its place (though it is now being strongly challenged by Python). -- Basic Linux and Unix bibliography , especailly parts:

a) Books on Shell, Script, and Web Development

b) Good Programming Style

Best wishes ... cheers, drl
# 3  
Old 08-10-2017
Hi drl,

thanks for your explanations... Smilie

Shell programming is only for small Problems, for further things I would also take Python... but sometimes it is more comfortable to do some things with the os-shell than to write a Python-Script - sometimes I Need it in an Environment where a lot of People only have know-how it Shell Scripting. Therfor its not possible to take another language...

And my question Targets to the Point, if there is - for UNIX-Shell-Scripting - something like the PEPs in Python?
# 4  
Old 08-10-2017
Hi.

Many people refer to the Linux Documentation Project, tldp, page on bash. In there you will find Unofficial Shell Scripting Stylesheet

However, if:
Quote:
Originally Posted by API
... People only have know-how it Shell Scripting. Therefor its not possible to take another language...
Perhaps you should be asking for advice on that problem.

Best wishes ... cheers, drl
Login or Register to Ask a Question

Previous Thread | Next Thread

4 More Discussions You Might Find Interesting

1. Programming

Building Block style programming Book

Hello to all, Here is my situation. Some time in the mid-80's I stumbled across a small white programming book - can't remember the name but it was unique in that it started right out giving instructions on creating building blocks in code as a foundation for a complete system. The book was... (2 Replies)
Discussion started by: jozefn
2 Replies

2. Shell Programming and Scripting

Unix Shell Scripting Guidelines

Hi, I was wondering if any of you guys have developed shell scripting guidelines for writing unix shell scripts effectively. This includes naming standards, comments, indentation, error handing after unix comands, use of exported variables, sending notifications, functions, logging etc... ... (2 Replies)
Discussion started by: acheepi
2 Replies

3. What is on Your Mind?

Guidelines for Posting Here

This area is not for forum specific technical questions. Please post forum specific technical questions in the best forum, not in the lounge. However, if your idea or question is not covered clearly in a forum, please post it here. Discuss whatever is on your mind. Technical topics welcome... (0 Replies)
Discussion started by: Neo
0 Replies

4. Forum Support Area for Unregistered Users & Account Problems

Guidelines For Posting Here

This area is not for technical questions. It is reserved for unregistered users who have a question or registered users who have trouble with their account. Other posts will be deleted by the moderators. (0 Replies)
Discussion started by: Neo
0 Replies
Login or Register to Ask a Question