From cbd19301ee92ed4db0c5abae4bb1886ab18d4198 Mon Sep 17 00:00:00 2001 From: Cem Keylan Date: Mon, 14 Sep 2020 20:09:17 +0300 Subject: update --- src/docs/Shell-Conventions.html | 96 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 src/docs/Shell-Conventions.html (limited to 'src/docs/Shell-Conventions.html') diff --git a/src/docs/Shell-Conventions.html b/src/docs/Shell-Conventions.html new file mode 100644 index 0000000..bcaf8b9 --- /dev/null +++ b/src/docs/Shell-Conventions.html @@ -0,0 +1,96 @@ + + + + + + +Shell Conventions (Carbs Linux User Manual) + + + + + + + + + + + + + + + + +
+

+Next: , Previous: , Up: Conventions  

+
+
+

3.1.2 Shell Conventions – 10

+ +

Shell is central to Carbs Linux projects. Most of the tools and packages are +written in POSIX sh. +

+
+
[1010]
+

Use 4 spaces for indentation, don’t use tabs. +

+
[1020]
+

Make sure you don’t use bash-specific code. +

+
[1030]
+

Make sure you lint your code with shellcheck and if you are new to +POSIX sh, use checkbashisms. +

+
[1040]
+

Don’t spawn new processes if you don’t absolutely need to, especially during +string manipulation. +

+
[1041]
+

Never use a program for text manupilation that isn’t defined in the POSIX +standard. This includes gawk and perl. +

+
[1042]
+

Instead of $(basename $file), use ${file##*}. +

+
[1043]
+

Instead of $(dirname $file), use ${file%/*}. +

+
+
+
# This is the same thing as basename /path/to/test.asc .asc
+
+$ file=/path/to/test.asc file=${file##*/} file=${file%.asc}
+$ echo $file
+test
+
+
+
[1050]
+

Instead of backticks, use $(..). +

+
+ + + + + + -- cgit v1.2.3