CVSROOT:        /cvs
Module name:    src
Changes by:     [email protected]    2022/10/05 13:30:47

Modified files:
        distrib/miniroot: install.sub 

Log message:
Get rid of useless/confusing subshell

This function's style is a bit off:  it wraps the body in a subshell to
discard all stdout/err at once, but still uses return inside it.

1. A command list (using {}) would be enough here as it groups like a
subshell but avoids spawning another shell;
2. discarding stdout/err at the end of an if block works the same
(effecting both condition and body) and saves one level of indent;
3. return inside a subshell inside a function does NOT return from the
function but merely exits the subshell;  this is easily misread.

Saving a fork and indent and improving readability boils down to this
(cvs diff -wU1):

|@@ -3320,3 +3317,2 @@ check_unattendedupgrade() {
|       _d=${_d%% *}
|-      (
|               if [[ -n $_d ]]; then
|@@ -3331,5 +3327,5 @@ check_unattendedupgrade() {
|                       rm -f /dev/{r,}$_d?
|-              fi
|+      fi >/dev/null 2>&1
|+
|               return $_rc
|-      ) > /dev/null 2>&1
| }

OK halex

Reply via email to