From c3b96b220c7abb624de848399a72593fc83621b2 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 10 Dec 2023 17:12:14 +0200 Subject: Update content for html --- ...021-05-16-personal-bash-coding-style-guide.html | 341 ++++++++++++-------- gemfeed/atom.xml | 343 ++++++++++++--------- index.html | 2 +- uptime-stats.html | 2 +- 4 files changed, 411 insertions(+), 277 deletions(-) diff --git a/gemfeed/2021-05-16-personal-bash-coding-style-guide.html b/gemfeed/2021-05-16-personal-bash-coding-style-guide.html index 9a43b775..bb7e2e8f 100644 --- a/gemfeed/2021-05-16-personal-bash-coding-style-guide.html +++ b/gemfeed/2021-05-16-personal-bash-coding-style-guide.html @@ -37,14 +37,20 @@
Google recommends using always...

-
-#!/bin/bash 
+
+
#!/bin/bash 
 

... as the shebang line, but that does not work on all Unix and Unix-like operating systems (e.g., the *BSDs don't have Bash installed to /bin/bash). Better is:

-
-#!/usr/bin/env bash
+
+
#!/usr/bin/env bash
 

Two space soft-tabs indentation


@@ -61,55 +67,72 @@
Google recommends breaking up long pipes like this:

-
-# All fits on one line
-command1 | command2
+
+
# All fits on one line
+command1 | command2
 
-# Long commands
-command1 \
-  | command2 \
-  | command3 \
-  | command4
+# Long commands
+command1 \
+  | command2 \
+  | command3 \
+  | command4
 

I think there is a better way like the following, which is less noisy. The pipe | already indicates the Bash that another command is expected, thus making the explicit line breaks with \ obsolete:

-
-# Long commands
-command1 |
-    command2 |
-    command3 |
+
+
# Long commands
+command1 |
+    command2 |
+    command3 |
     command4
 

+Update: It's 2023 now, and I have changed my mind. I think Google's way is the better one. It may be a bit more to type, but the leading | are a nice eye catcher, so you know immediately what is going on!
+

Quoting your variables



Google recommends always quote your variables. Generally, it would be best if you did that only for variables where you are unsure about the content/values of the variables (e.g., content is from an external input source and may contain whitespace or other special characters). In my opinion, the code will become quite noisy when you always quote your variables like this:

-
-greet () {
-    local -r greeting="${1}"
-    local -r name="${2}"
-    echo "${greeting} ${name}!"
+
+
greet () {
+    local -r greeting="${1}"
+    local -r name="${2}"
+    echo "${greeting} ${name}!"
 }
 

In this particular example, I agree that you should quote them as you don't know the input (are there, for example, whitespace characters?). But if you are sure that you are only using simple bare words, then I think that the code looks much cleaner when you do this instead:

-
-say_hello_to_paul () {
-    local -r greeting=Hello
-    local -r name=Paul
-    echo "$greeting $name!"
+
+
say_hello_to_paul () {
+    local -r greeting=Hello
+    local -r name=Paul
+    echo "$greeting $name!"
 }
 

You see, I also omitted the curly braces { } around the variables. I only use the curly braces around variables when it makes the code either easier/clearer to read or if it is necessary to use them:

-
-declare FOO=bar
-# Curly braces around FOO are necessary
-echo "foo${FOO}baz"
+
+
declare FOO=bar
+# Curly braces around FOO are necessary
+echo "foo${FOO}baz"
 

A few more words on always quoting the variables: For the sake of consistency (and for making ShellCheck happy), I am not against quoting everything I encounter. I also think that the larger the Bash script becomes, the more critical it becomes always to quote variables. That's because it will be more likely that you might not remember that some of the functions don't work on values with spaces in them, for example. It's just that I won't quote everything in every small script I write.
@@ -118,14 +141,17 @@ echo "foo${FOO}baz"
Google recommends using the built-in commands over available external commands where possible:

-
-# Prefer this:
-addition=$(( X + Y ))
-substitution="${string/#foo/bar}"
+
+
# Prefer this:
+addition=$(( X + Y ))
+substitution="${string/#foo/bar}"
 
-# Instead of this:
-addition="$(expr "${X}" + "${Y}")"
-substitution="$(echo "${string}" | sed -e 's/^foo/bar/')"
+# Instead of this:
+addition="$(expr "${X}" + "${Y}")"
+substitution="$(echo "${string}" | sed -e 's/^foo/bar/')"
 

I can't entirely agree here. The external commands (especially sed) are much more sophisticated and powerful than the built-in Bash versions. Sed can do much more than the Bash can ever do by itself when it comes to text manipulation (the name "sed" stands for streaming editor, after all).
@@ -142,35 +168,40 @@ substitution="$(echo "${string}" | sed -e 's/^foo/bar/')"
Bash does not support a boolean type. I tend just to use the strings 'yes' and 'no' here. I used 0 for false and 1 for true for some time, but I think that the yes/no strings are easier to read. Yes, the Bash script would need to perform string comparisons on every check, but if performance is crucial to you, you wouldn't want to use a Bash script anyway, correct?

-
-declare -r SUGAR_FREE=yes
-declare -r I_NEED_THE_BUZZ=no
+
+
declare -r SUGAR_FREE=yes
+declare -r I_NEED_THE_BUZZ=no
 
-buy_soda () {
-    local -r sugar_free=$1
+buy_soda () {
+    local -r sugar_free=$1
 
-    if [[ $sugar_free == yes ]]; then
-        echo 'Diet Dr. Pepper'
-    else
-        echo 'Pepsi Coke'
-    fi
+    if [[ $sugar_free == yes ]]; then
+        echo 'Diet Dr. Pepper'
+    else
+        echo 'Pepsi Coke'
+    fi
 }
 
-buy_soda $I_NEED_THE_BUZZ
+buy_soda $I_NEED_THE_BUZZ
 

Non-evil alternative to variable assignments via eval



Google is in the opinion that eval should be avoided. I think so too. They list these examples in their guide:

-
-# What does this set?
-# Did it succeed? In part or whole?
-eval $(set_my_variables)
-
-# What happens if one of the returned values has a space in it?
-variable="$(eval some_function)"
+
+
# What does this set?
+# Did it succeed? In part or whole?
+eval $(set_my_variables)
 
+# What happens if one of the returned values has a space in it?
+variable="$(eval some_function)"
 

However, if I want to read variables from another file, I don't have to use eval here. I only have to source the file:
@@ -205,36 +236,39 @@ Hello paul, it is Sat 15 May 19:21:12 BST 2021
When I do list processing in Bash, I prefer to use pipes. You can chain them through Bash functions as well, which is pretty neat. Usually, my list processing scripts are of a structure like this:

-
-filter_lines () {
-    echo 'Start filtering lines in a fancy way!' >&2
-    grep ... | sed ....
+
+
filter_lines () {
+    echo 'Start filtering lines in a fancy way!' >&2
+    grep ... | sed ....
 }
 
-process_lines () {
-    echo 'Start processing line by line!' >&2
-    while read -r line; do
-        ... do something and produce a result...
-        echo "$result"
-    done 
+process_lines () {
+    echo 'Start processing line by line!' >&2
+    while read -r line; do
+        ... do something and produce a result...
+        echo "$result"
+    done 
 }
 
-# Do some post-processing of the data
-postprocess_lines () {
-    echo 'Start removing duplicates!' >&2
+# Do some post-processing of the data
+postprocess_lines () {
+    echo 'Start removing duplicates!' >&2
     sort -u
 }
 
-genreate_report () {
-    echo 'My boss wants to have a report!' >&2
-    tee outfile.txt
-    wc -l outfile.txt
+genreate_report () {
+    echo 'My boss wants to have a report!' >&2
+    tee outfile.txt
+    wc -l outfile.txt
 }
 
-main () {
-    filter_lines |
-        process_lines |
-        postprocess_lines |
+main () {
+    filter_lines |
+        process_lines |
+        postprocess_lines |
         generate_report
 }
 
@@ -249,35 +283,47 @@ main
 
The solution is to use of the "assign-then-shift"-method, which goes like this: "local -r var1=$1; shift; local -r var2=$1; shift". The idea is that you only use "$1" to assign function arguments to named (better readable) local function variables. You will never have to bother about "$2" or above. That is very useful when you constantly refactor your code and remove or add function arguments. It's something that I picked up from a colleague (a pure Bash wizard) some time ago:

-
-some_function () {
-    local -r param_foo="$1"; shift
-    local -r param_baz="$1"; shift
-    local -r param_bay="$1"; shift
-    ...
+
+
some_function () {
+    local -r param_foo="$1"; shift
+    local -r param_baz="$1"; shift
+    local -r param_bay="$1"; shift
+
+    # ...
 }
 

Want to add a param_baz? Just do this:

-
-some_function () {
-    local -r param_foo="$1"; shift
-    local -r param_bar="$1"; shift
-    local -r param_baz="$1"; shift
-    local -r param_bay="$1"; shift
-    ...
+
+
some_function () {
+    local -r param_foo="$1"; shift
+    local -r param_bar="$1"; shift
+    local -r param_baz="$1"; shift
+    local -r param_bay="$1"; shift
+
+    # ...
 }
 

Want to remove param_foo? Nothing easier than that:

-
-some_function () {
-    local -r param_bar="$1"; shift
-    local -r param_baz="$1"; shift
-    local -r param_bay="$1"; shift
-    ...
+
+
some_function () {
+    local -r param_bar="$1"; shift
+    local -r param_baz="$1"; shift
+    local -r param_bay="$1"; shift
+    
+    # ...
 }
 

@@ -287,34 +333,40 @@ some_function () {
I call this the paranoid mode. The Bash will stop executing when a command exits with a status not equal to 0:

-
-set -e
-grep -q foo <<< bar
+
+
set -e
+grep -q foo <<< bar
 echo Jo
 

Here 'Jo' will never be printed out as the grep didn't find any match. It's unrealistic for most scripts to run in paranoid mode purely, so there must be a way to add exceptions. Critical Bash scripts of mine tend to look like this:

-
-#!/usr/bin/env bash
+
+
#!/usr/bin/env bash
 
-set -e
+set -e
 
-some_function () {
-    .. some critical code
-    ...
+some_function () {
+    # .. some critical code
+    # ...
 
-    set +e
-    # Grep might fail, but that's OK now
-    grep ....
-    local -i ec=$?
-    set -e
+    set +e
+    # Grep might fail, but that's OK now
+    grep ....
+    local -i ec=$?
+    set -e
 
-    .. critical code continues ...
-    if [[ $ec -ne 0 ]]; then
-        ...
-    fi
-    ...
+    # .. critical code continues ...
+    if [[ $ec -ne 0 ]]; then
+        : # ...
+    fi
+    # ...
 }
 

@@ -326,27 +378,36 @@ some_function () {
The following looks like a valid Bash code:

-
-if [[ "${my_var}" > 3 ]]; then
-    # True for 4, false for 22.
+
+
if [[ "${my_var}" > 3 ]]; then
+    # True for 4, false for 22.
     do_something
-fi
+fi
 

... but it is probably an unintended lexicographical comparison. A correct way would be:

-
-if (( my_var > 3 )); then
+
+
if (( my_var > 3 )); then
     do_something
-fi
+fi
 

or

-
-if [[ "${my_var}" -gt 3 ]]; then
+
+
if [[ "${my_var}" -gt 3 ]]; then
     do_something
-fi
+fi
 

PIPESTATUS


@@ -355,24 +416,30 @@ fi
The PIPESTATUS variable in Bash allows checking of the return code from all parts of a pipe. If it's only necessary to check the success or failure of the whole pipe, then the following is acceptable:

-
-tar -cf - ./* | ( cd "${dir}" && tar -xf - )
-if (( PIPESTATUS[0] != 0 || PIPESTATUS[1] != 0 )); then
-    echo "Unable to tar files to ${dir}" >&2
-fi
+
+
tar -cf - ./* | ( cd "${dir}" && tar -xf - )
+if (( PIPESTATUS[0] != 0 || PIPESTATUS[1] != 0 )); then
+    echo "Unable to tar files to ${dir}" >&2
+fi
 

However, as PIPESTATUS will be overwritten as soon as you do any other command, if you need to act differently on errors based on where it happened in the pipe, you'll need to assign PIPESTATUS to another variable immediately after running the command (don't forget that [ is a command and will wipe out PIPESTATUS).

-
-tar -cf - ./* | ( cd "${DIR}" && tar -xf - )
-return_codes=( "${PIPESTATUS[@]}" )
-if (( return_codes[0] != 0 )); then
+
+
tar -cf - ./* | ( cd "${DIR}" && tar -xf - )
+return_codes=( "${PIPESTATUS[@]}" )
+if (( return_codes[0] != 0 )); then
     do_something
-fi
-if (( return_codes[1] != 0 )); then
+fi
+if (( return_codes[1] != 0 )); then
     do_something_else
-fi
+fi
 

Use common sense and BE CONSISTENT.


diff --git a/gemfeed/atom.xml b/gemfeed/atom.xml index f6a2a318..f38c9ff6 100644 --- a/gemfeed/atom.xml +++ b/gemfeed/atom.xml @@ -1,6 +1,6 @@ - 2023-12-10T11:46:05+02:00 + 2023-12-10T17:11:56+02:00 foo.zone feed To be in the .zone! @@ -8105,14 +8105,20 @@ assert::equals "$(generate::m
Google recommends using always...

-
-#!/bin/bash 
+
+
#!/bin/bash 
 

... as the shebang line, but that does not work on all Unix and Unix-like operating systems (e.g., the *BSDs don't have Bash installed to /bin/bash). Better is:

-
-#!/usr/bin/env bash
+
+
#!/usr/bin/env bash
 

Two space soft-tabs indentation


@@ -8129,55 +8135,72 @@ assert::equals "$(generate::m
Google recommends breaking up long pipes like this:

-
-# All fits on one line
-command1 | command2
+
+
# All fits on one line
+command1 | command2
 
-# Long commands
-command1 \
-  | command2 \
-  | command3 \
-  | command4
+# Long commands
+command1 \
+  | command2 \
+  | command3 \
+  | command4
 

I think there is a better way like the following, which is less noisy. The pipe | already indicates the Bash that another command is expected, thus making the explicit line breaks with \ obsolete:

-
-# Long commands
-command1 |
-    command2 |
-    command3 |
+
+
# Long commands
+command1 |
+    command2 |
+    command3 |
     command4
 

+Update: It's 2023 now, and I have changed my mind. I think Google's way is the better one. It may be a bit more to type, but the leading | are a nice eye catcher, so you know immediately what is going on!
+

Quoting your variables



Google recommends always quote your variables. Generally, it would be best if you did that only for variables where you are unsure about the content/values of the variables (e.g., content is from an external input source and may contain whitespace or other special characters). In my opinion, the code will become quite noisy when you always quote your variables like this:

-
-greet () {
-    local -r greeting="${1}"
-    local -r name="${2}"
-    echo "${greeting} ${name}!"
+
+
greet () {
+    local -r greeting="${1}"
+    local -r name="${2}"
+    echo "${greeting} ${name}!"
 }
 

In this particular example, I agree that you should quote them as you don't know the input (are there, for example, whitespace characters?). But if you are sure that you are only using simple bare words, then I think that the code looks much cleaner when you do this instead:

-
-say_hello_to_paul () {
-    local -r greeting=Hello
-    local -r name=Paul
-    echo "$greeting $name!"
+
+
say_hello_to_paul () {
+    local -r greeting=Hello
+    local -r name=Paul
+    echo "$greeting $name!"
 }
 

You see, I also omitted the curly braces { } around the variables. I only use the curly braces around variables when it makes the code either easier/clearer to read or if it is necessary to use them:

-
-declare FOO=bar
-# Curly braces around FOO are necessary
-echo "foo${FOO}baz"
+
+
declare FOO=bar
+# Curly braces around FOO are necessary
+echo "foo${FOO}baz"
 

A few more words on always quoting the variables: For the sake of consistency (and for making ShellCheck happy), I am not against quoting everything I encounter. I also think that the larger the Bash script becomes, the more critical it becomes always to quote variables. That's because it will be more likely that you might not remember that some of the functions don't work on values with spaces in them, for example. It's just that I won't quote everything in every small script I write.
@@ -8186,14 +8209,17 @@ echo "foo${FOO}baz"
Google recommends using the built-in commands over available external commands where possible:

-
-# Prefer this:
-addition=$(( X + Y ))
-substitution="${string/#foo/bar}"
+
+
# Prefer this:
+addition=$(( X + Y ))
+substitution="${string/#foo/bar}"
 
-# Instead of this:
-addition="$(expr "${X}" + "${Y}")"
-substitution="$(echo "${string}" | sed -e 's/^foo/bar/')"
+# Instead of this:
+addition="$(expr "${X}" + "${Y}")"
+substitution="$(echo "${string}" | sed -e 's/^foo/bar/')"
 

I can't entirely agree here. The external commands (especially sed) are much more sophisticated and powerful than the built-in Bash versions. Sed can do much more than the Bash can ever do by itself when it comes to text manipulation (the name "sed" stands for streaming editor, after all).
@@ -8210,35 +8236,40 @@ substitution="$(echo "${string}" | sed -e 's/^foo/bar/')"
Bash does not support a boolean type. I tend just to use the strings 'yes' and 'no' here. I used 0 for false and 1 for true for some time, but I think that the yes/no strings are easier to read. Yes, the Bash script would need to perform string comparisons on every check, but if performance is crucial to you, you wouldn't want to use a Bash script anyway, correct?

-
-declare -r SUGAR_FREE=yes
-declare -r I_NEED_THE_BUZZ=no
+
+
declare -r SUGAR_FREE=yes
+declare -r I_NEED_THE_BUZZ=no
 
-buy_soda () {
-    local -r sugar_free=$1
+buy_soda () {
+    local -r sugar_free=$1
 
-    if [[ $sugar_free == yes ]]; then
-        echo 'Diet Dr. Pepper'
-    else
-        echo 'Pepsi Coke'
-    fi
+    if [[ $sugar_free == yes ]]; then
+        echo 'Diet Dr. Pepper'
+    else
+        echo 'Pepsi Coke'
+    fi
 }
 
-buy_soda $I_NEED_THE_BUZZ
+buy_soda $I_NEED_THE_BUZZ
 

Non-evil alternative to variable assignments via eval



Google is in the opinion that eval should be avoided. I think so too. They list these examples in their guide:

-
-# What does this set?
-# Did it succeed? In part or whole?
-eval $(set_my_variables)
-
-# What happens if one of the returned values has a space in it?
-variable="$(eval some_function)"
+
+
# What does this set?
+# Did it succeed? In part or whole?
+eval $(set_my_variables)
 
+# What happens if one of the returned values has a space in it?
+variable="$(eval some_function)"
 

However, if I want to read variables from another file, I don't have to use eval here. I only have to source the file:
@@ -8273,36 +8304,39 @@ Hello paul, it is Sat 15 May 19:21:12 BST 2021
When I do list processing in Bash, I prefer to use pipes. You can chain them through Bash functions as well, which is pretty neat. Usually, my list processing scripts are of a structure like this:

-
-filter_lines () {
-    echo 'Start filtering lines in a fancy way!' >&2
-    grep ... | sed ....
+
+
filter_lines () {
+    echo 'Start filtering lines in a fancy way!' >&2
+    grep ... | sed ....
 }
 
-process_lines () {
-    echo 'Start processing line by line!' >&2
-    while read -r line; do
-        ... do something and produce a result...
-        echo "$result"
-    done 
+process_lines () {
+    echo 'Start processing line by line!' >&2
+    while read -r line; do
+        ... do something and produce a result...
+        echo "$result"
+    done 
 }
 
-# Do some post-processing of the data
-postprocess_lines () {
-    echo 'Start removing duplicates!' >&2
+# Do some post-processing of the data
+postprocess_lines () {
+    echo 'Start removing duplicates!' >&2
     sort -u
 }
 
-genreate_report () {
-    echo 'My boss wants to have a report!' >&2
-    tee outfile.txt
-    wc -l outfile.txt
+genreate_report () {
+    echo 'My boss wants to have a report!' >&2
+    tee outfile.txt
+    wc -l outfile.txt
 }
 
-main () {
-    filter_lines |
-        process_lines |
-        postprocess_lines |
+main () {
+    filter_lines |
+        process_lines |
+        postprocess_lines |
         generate_report
 }
 
@@ -8317,35 +8351,47 @@ main
 
The solution is to use of the "assign-then-shift"-method, which goes like this: "local -r var1=$1; shift; local -r var2=$1; shift". The idea is that you only use "$1" to assign function arguments to named (better readable) local function variables. You will never have to bother about "$2" or above. That is very useful when you constantly refactor your code and remove or add function arguments. It's something that I picked up from a colleague (a pure Bash wizard) some time ago:

-
-some_function () {
-    local -r param_foo="$1"; shift
-    local -r param_baz="$1"; shift
-    local -r param_bay="$1"; shift
-    ...
+
+
some_function () {
+    local -r param_foo="$1"; shift
+    local -r param_baz="$1"; shift
+    local -r param_bay="$1"; shift
+
+    # ...
 }
 

Want to add a param_baz? Just do this:

-
-some_function () {
-    local -r param_foo="$1"; shift
-    local -r param_bar="$1"; shift
-    local -r param_baz="$1"; shift
-    local -r param_bay="$1"; shift
-    ...
+
+
some_function () {
+    local -r param_foo="$1"; shift
+    local -r param_bar="$1"; shift
+    local -r param_baz="$1"; shift
+    local -r param_bay="$1"; shift
+
+    # ...
 }
 

Want to remove param_foo? Nothing easier than that:

-
-some_function () {
-    local -r param_bar="$1"; shift
-    local -r param_baz="$1"; shift
-    local -r param_bay="$1"; shift
-    ...
+
+
some_function () {
+    local -r param_bar="$1"; shift
+    local -r param_baz="$1"; shift
+    local -r param_bay="$1"; shift
+    
+    # ...
 }
 

@@ -8355,34 +8401,40 @@ some_function () {
I call this the paranoid mode. The Bash will stop executing when a command exits with a status not equal to 0:

-
-set -e
-grep -q foo <<< bar
+
+
set -e
+grep -q foo <<< bar
 echo Jo
 

Here 'Jo' will never be printed out as the grep didn't find any match. It's unrealistic for most scripts to run in paranoid mode purely, so there must be a way to add exceptions. Critical Bash scripts of mine tend to look like this:

-
-#!/usr/bin/env bash
+
+
#!/usr/bin/env bash
 
-set -e
+set -e
 
-some_function () {
-    .. some critical code
-    ...
+some_function () {
+    # .. some critical code
+    # ...
 
-    set +e
-    # Grep might fail, but that's OK now
-    grep ....
-    local -i ec=$?
-    set -e
+    set +e
+    # Grep might fail, but that's OK now
+    grep ....
+    local -i ec=$?
+    set -e
 
-    .. critical code continues ...
-    if [[ $ec -ne 0 ]]; then
-        ...
-    fi
-    ...
+    # .. critical code continues ...
+    if [[ $ec -ne 0 ]]; then
+        : # ...
+    fi
+    # ...
 }
 

@@ -8394,27 +8446,36 @@ some_function () {
The following looks like a valid Bash code:

-
-if [[ "${my_var}" > 3 ]]; then
-    # True for 4, false for 22.
+
+
if [[ "${my_var}" > 3 ]]; then
+    # True for 4, false for 22.
     do_something
-fi
+fi
 

... but it is probably an unintended lexicographical comparison. A correct way would be:

-
-if (( my_var > 3 )); then
+
+
if (( my_var > 3 )); then
     do_something
-fi
+fi
 

or

-
-if [[ "${my_var}" -gt 3 ]]; then
+
+
if [[ "${my_var}" -gt 3 ]]; then
     do_something
-fi
+fi
 

PIPESTATUS


@@ -8423,24 +8484,30 @@ fi
The PIPESTATUS variable in Bash allows checking of the return code from all parts of a pipe. If it's only necessary to check the success or failure of the whole pipe, then the following is acceptable:

-
-tar -cf - ./* | ( cd "${dir}" && tar -xf - )
-if (( PIPESTATUS[0] != 0 || PIPESTATUS[1] != 0 )); then
-    echo "Unable to tar files to ${dir}" >&2
-fi
+
+
tar -cf - ./* | ( cd "${dir}" && tar -xf - )
+if (( PIPESTATUS[0] != 0 || PIPESTATUS[1] != 0 )); then
+    echo "Unable to tar files to ${dir}" >&2
+fi
 

However, as PIPESTATUS will be overwritten as soon as you do any other command, if you need to act differently on errors based on where it happened in the pipe, you'll need to assign PIPESTATUS to another variable immediately after running the command (don't forget that [ is a command and will wipe out PIPESTATUS).

-
-tar -cf - ./* | ( cd "${DIR}" && tar -xf - )
-return_codes=( "${PIPESTATUS[@]}" )
-if (( return_codes[0] != 0 )); then
+
+
tar -cf - ./* | ( cd "${DIR}" && tar -xf - )
+return_codes=( "${PIPESTATUS[@]}" )
+if (( return_codes[0] != 0 )); then
     do_something
-fi
-if (( return_codes[1] != 0 )); then
+fi
+if (( return_codes[1] != 0 )); then
     do_something_else
-fi
+fi
 

Use common sense and BE CONSISTENT.


diff --git a/index.html b/index.html index 8e2071f1..dd268ac2 100644 --- a/index.html +++ b/index.html @@ -10,7 +10,7 @@

foo.zone



-This site was generated at 2023-12-10T11:46:05+02:00 by Gemtexter
+This site was generated at 2023-12-10T17:11:56+02:00 by Gemtexter

    |\---/|
diff --git a/uptime-stats.html b/uptime-stats.html
index f259f1dd..3156c703 100644
--- a/uptime-stats.html
+++ b/uptime-stats.html
@@ -10,7 +10,7 @@
 
 

My machine uptime stats



-This site was last updated at 2023-12-10T11:46:05+02:00
+This site was last updated at 2023-12-10T17:11:56+02:00

The following stats were collected via uptimed on all of my personal computers over many years and the output was generated by guprecords, the global uptime records stats analyser of mine.

-- cgit v1.2.3