From 895be08b27e53b212e221297d22559994f50de23 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Mon, 10 Oct 2016 03:43:08 +0300 Subject: don't create database during dry runs --- update.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/update.sh b/update.sh index 2950599..f9b5724 100644 --- a/update.sh +++ b/update.sh @@ -17,7 +17,7 @@ # `CYGWIN` Windows environment variable value **must** include either # `winsymlinks:native` or `winsymlinks:nativestrict`! -# usage: ./update.sh [-d|--database PATH] [-c|--config-dir DIR] [-n|--dry-run] [-h|--help] +# usage: ./update.sh [-h|--help] [-d|--database PATH] [-c|--config-dir DIR] [-n|--dry-run] set -o errexit set -o nounset @@ -190,10 +190,12 @@ update_database_path() { } ensure_database_exists() { - [ -f "$db_path" ] || touch "$db_path" + [ -f "$db_path" ] || [ -n "${dry_run+x}" ] || touch "$db_path" } read_database() { + [ ! -f "$db_path" ] && [ -n "${dry_run+x}" ] && return 0 + local entry while IFS= read -d '' -r entry; do database[$entry]=1 @@ -369,7 +371,7 @@ discover_new_entries() { exit_with_usage() { local msg IFS= read -d '' -r msg <