From bd997ea8d727d70df7e246595e55afa45902fb49 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sun, 3 Jun 2018 18:08:25 +0200 Subject: [PATCH] Always use single quotes for printf format string "\n" is literal, but causes a warning in shellcheck. As single quotes are better suited for the format string (they interpolate nothing) switch to single quotes. --- lib.sh | 10 +++++----- shell/crontab.d/setup.sh | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib.sh b/lib.sh index 6df5311..6a61902 100644 --- a/lib.sh +++ b/lib.sh @@ -151,19 +151,19 @@ link() { # Abort if the target file exists and is no symbolic link. Prevents # overwriting real files. if test -e "$target" && test ! -h "$target"; then - printf "link(): target '%s' exists already and is no symbolic link!\n" \ + printf 'link(): target "%s" exists already and is no symbolic link!\n' \ "$target" >&2 exit 1 fi # Make sure the source exists. if test ! -e "$source"; then - printf "link(): source '%s' doesn't exist!\n" "$source" >&2 + printf 'link(): source "%s" does not exist!\n' "$source" >&2 exit 1 fi # Create the new symbolic link; remove the old one if necessary. - printf "link(): linking '%s' to '%s'\n" "$source" "$target" + printf 'link(): linking "%s" to "%s"\n' "$source" "$target" rm -f "$target" ln -s "$source" "$target" @@ -193,14 +193,14 @@ generate() { file_tmp="$file.tmp" else # We only need this message if we generate a new file. - printf "%s: generating from '%s' (%s)\n" \ + 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" \ + printf '# It was generated from "%s" on %s.\n' \ "$file$extension" "`date`" >>"$file" echo >>"$file" diff --git a/shell/crontab.d/setup.sh b/shell/crontab.d/setup.sh index 46ebb56..603e301 100755 --- a/shell/crontab.d/setup.sh +++ b/shell/crontab.d/setup.sh @@ -50,7 +50,7 @@ echo '###################################' >"$CRONTAB" echo "$HEADER_WARNING" >>"$CRONTAB" echo '###################################' >>"$CRONTAB" echo >>"$CRONTAB" -printf "# It was generated from '%s/*' on %s." \ +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. @@ -64,7 +64,7 @@ for file in "$DIRECTORY"/crontab.*; do break fi - printf "Found '%s'.\n" "$file" + printf 'Found "%s".\n' "$file" printf '\n\n## %s:\n' "$file" >>"$CRONTAB" -- 2.43.2