summaryrefslogtreecommitdiff
path: root/content/posts/coding_standards.md
blob: 728b7dd6faeae36ec988e988f84645ed1a606518 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
---
title: "Post Title"
slug: post-title
created: 2024-12-31
updated: 2025-06-23
description: "A brief summary of what this page is about."
tags: [linux, self-hosting, minimalism]
draft: true
---


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
``