From: Simon Ruderich Date: Sun, 3 Jun 2018 16:14:06 +0000 (+0200) Subject: Use command grouping to reduce number of redirects X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=2add0d25a030ae29da75d19a958643466f25b8ab;p=config%2Fdotfiles.git Use command grouping to reduce number of redirects Suggested by shellcheck and makes the code more readable. --- diff --git a/lib.sh b/lib.sh index bb60c52..1ce0c33 100644 --- a/lib.sh +++ b/lib.sh @@ -196,13 +196,15 @@ generate() { printf '%s: generating from "%s" (%s)\n' \ "$file" "$file$extension" "$1" - echo '###################################' >"$file" - echo '# WARNING! DO NOT EDIT THIS FILE! #' >>"$file" - echo '###################################' >>"$file" - echo >>"$file" - printf '# It was generated from "%s" on %s.\n' \ - "$file$extension" "`date`" >>"$file" - echo >>"$file" + { + echo '###################################' + echo '# WARNING! DO NOT EDIT THIS FILE! #' + echo '###################################' + echo + printf '# It was generated from "%s" on %s.\n' \ + "$file$extension" "`date`" + echo + } > "$file" file_tmp="$file" fi diff --git a/shell/crontab.d/setup.sh b/shell/crontab.d/setup.sh index 603e301..0abf260 100755 --- a/shell/crontab.d/setup.sh +++ b/shell/crontab.d/setup.sh @@ -46,12 +46,14 @@ fi # `set -e` aborts when `mktemp` fails. CRONTAB=`mktemp --tmpdir="$DIRECTORY" update-crontab.XXXXXXXXXXXX` -echo '###################################' >"$CRONTAB" -echo "$HEADER_WARNING" >>"$CRONTAB" -echo '###################################' >>"$CRONTAB" -echo >>"$CRONTAB" -printf '# It was generated from "%s/*" on %s.' \ - "$DIRECTORY" "`LANG=C date '+%a, %d %b %Y %H:%M:%S %z'`" >>"$CRONTAB" +{ + echo '###################################' + echo "$HEADER_WARNING" + echo '###################################' + echo + printf '# It was generated from "%s/*" on %s.' \ + "$DIRECTORY" "`LANG=C date '+%a, %d %b %Y %H:%M:%S %z'`" +} > "$CRONTAB" # Enforce C sort order. LC_ALL=C