From 12bea39e635a7617a7ef88487262f58aa7de6789 Mon Sep 17 00:00:00 2001 From: Suleyman Farajli Date: Wed, 26 Feb 2025 01:19:54 +0400 Subject: markdown updated to follow a consistent style --- posts/coding_standards.md | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 posts/coding_standards.md (limited to 'posts/coding_standards.md') diff --git a/posts/coding_standards.md b/posts/coding_standards.md new file mode 100644 index 0000000..aa2e1fd --- /dev/null +++ b/posts/coding_standards.md @@ -0,0 +1,43 @@ +Here are my **personal** coding standards for some languages. + +## Interpreted languages +#### Never put the file extension to the source file instead use a shebang. +`` + #!/bin/sh + #!/bin/python3 + #!/bin/perl +`` + +## Posix shell +#### Always wrap variables with `"${}"` to prevent globbing. +`` + echo "${var}" + echo "${1}" + echo "${@}" +`` + +## Makefiles +#### If Makefile is fully posix complient and doesn't have anything extra add +`.POSIX:` to the beginning of the file + +## C +#### Use K&R style `if`s +`` + if (condition) { + do this; + do that; + do another; + } +`` +#### if only one line don't use curly braces. +`` + while (condition) + do this +`` + +`` + if (condition) + do this + else + do that +`` -- cgit v1.2.3