aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/update.sh
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2016-10-05 20:47:07 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2016-10-05 20:47:07 +0300
commit2bc6960919fb73bbfd6461f5f1024fd9ad19bf9c (patch)
treef61070f080d79c396a898014c7f4fe67411400f4 /update.sh
parentadd command line options to update.sh (diff)
downloadconfig-links-2bc6960919fb73bbfd6461f5f1024fd9ad19bf9c.tar.gz
config-links-2bc6960919fb73bbfd6461f5f1024fd9ad19bf9c.zip
add -s|--source to update.sh
Diffstat (limited to '')
-rw-r--r--update.sh25
1 files changed, 16 insertions, 9 deletions
diff --git a/update.sh b/update.sh
index 351996b..0e460d9 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] [-n|--dry-run] [-h|--help]
+# usage: ./update.sh [-d|--database PATH] [-s|--source DIR] [-n|--dry-run] [-h|--help]
set -o errexit
set -o nounset
@@ -26,6 +26,8 @@ set -o pipefail
script_argv0="${BASH_SOURCE[0]}"
script_dir="$( cd "$( dirname "$script_argv0" )" && pwd )"
+src_dir="$script_dir"
+
dump() {
local prefix="${FUNCNAME[0]}"
@@ -45,13 +47,13 @@ ensure_symlinks_enabled() {
*winsymlinks:nativestrict*) ;;
*)
- dump 'native Windows symbolic links aren'"'"'t enabled in Cygwin' >&2
+ dump 'native Windows symlinks aren'"'"'t enabled in Cygwin' >&2
return 1
;;
esac
}
-database_path="$script_dir/db.bin"
+database_path="$src_dir/db.bin"
declare -A database
ensure_database_exists() {
@@ -168,7 +170,7 @@ delete_obsolete_entries() {
fi
if [ ! -L "$dest_path" ]; then
- dump " not a symbolic link: $dest_path" >&2
+ dump " not a symlink: $dest_path" >&2
unset database["$entry"]
continue
fi
@@ -231,15 +233,16 @@ discover_new_entries() {
database[$entry]=1
done < <( find "$src_var_dir" -type f -print0 )
- done < <( find "$script_dir" -regextype posix-basic -mindepth 1 -maxdepth 1 -type d -regex ".*/$var_name_regex\$" -print0 )
+ done < <( find "$src_dir" -regextype posix-basic -mindepth 1 -maxdepth 1 -type d -regex ".*/$var_name_regex\$" -print0 )
}
exit_with_usage() {
- dump "usage: $script_argv0 [-d|--database PATH] [-n|--dry-run] [-h|--help]"
+ dump "usage: $script_argv0 [-d|--database PATH] [-s|--source DIR] [-n|--dry-run] [-h|--help]"
dump 'optional parameters:'
+ dump ' -h,--help show this message and exit'
dump ' -d,--database set database file path'
+ dump ' -s,--source set source directory path (script directory by default)'
dump ' -n,--dry-run don'"'"'t actually do anything intrusive'
- dump ' -h,--help show this message and exit'
exit "${exit_with_usage:-0}"
}
@@ -259,7 +262,7 @@ parse_script_options() {
continue
;;
- -d|--database)
+ -d|--database|-s|--source)
;;
*)
@@ -280,7 +283,11 @@ parse_script_options() {
case "$key" in
-d|--database)
- database_path="$value"
+ database_path="$( readlink -f "$value" )"
+ ;;
+
+ -s|--source)
+ src_dir="$( readlink -e "$value" )"
;;
esac
done