simplify for shellcheck
[log-quiet] / logq-function
index 2ae5dae47fb8ff3e14890e34760473b220837b47..410e683beb9b6ac360725c1c208ba4e4ac6c6297 100644 (file)
@@ -1,5 +1,12 @@
 #!/bin/bash
-# Copyright (C) 2014-2016 Ian Kelling
+# I, Ian Kelling, follow the GNU license recommendations at
+# https://www.gnu.org/licenses/license-recommendations.en.html. They
+# recommend that small programs, < 300 lines, be licensed under the
+# Apache License 2.0. This file contains or is part of one or more small
+# programs. If a small program grows beyond 300 lines, I plan to switch
+# its license to GPL.
+
+# Copyright 2024 Ian Kelling
 
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -12,6 +19,7 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
+
 logq () {
   local help="Usage: logq [-h|--help] COMMAND [ARG...]
 
@@ -45,16 +53,13 @@ $help"
   printf "%s\n%s\n\n" "Log of $prettycommand" "$(date)" >"$file"
 
   if [[ $- != *x* ]]; then
-    echo "log $file = $@"
+    echo "log $file = $*"
   fi
 
   # we will propagate any errors
-  local logq_ret=$(
-    set +e
-    trap ERR
-    "$@" &>> "$file"
-    echo $?
-        )
+  local logq_ret
+  logq_ret=0
+  "$@" &>> "$file" || logq_ret=$?
   printf "\n%s\n%s\n" "$(date)" "----------------" >> "$file"
 
   if [[ $logq_ret != 0 ]]; then