aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/links-update
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2021-11-25 21:57:57 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2021-11-25 21:59:09 +0300
commita556264de6ddab9bcd47023b1d3daa2e2b683505 (patch)
tree4c50bce86d153b4ccd3ab6f77f36b6222b332814 /links-update
parenttest/test.sh: best practices (diff)
downloadconfig-links-a556264de6ddab9bcd47023b1d3daa2e2b683505.tar.gz
config-links-a556264de6ddab9bcd47023b1d3daa2e2b683505.zip
links-update: add --mode parameter
Diffstat (limited to '')
-rwxr-xr-xlinks-update13
1 files changed, 10 insertions, 3 deletions
diff --git a/links-update b/links-update
index b195305..1e1c829 100755
--- a/links-update
+++ b/links-update
@@ -17,7 +17,7 @@
# `CYGWIN` Windows environment variable value **must** include either
# `winsymlinks:native` or `winsymlinks:nativestrict`!
-# usage: ./links-update [-h|--help] [-d|--database PATH] [-s|--shared-dir DIR] [-n|--dry-run]
+# usage: ./links-update [-h|--help] [-d|--database PATH] [-s|--shared-dir DIR] [-m|--mode MODE] [-n|--dry-run]
set -o errexit
set -o nounset
@@ -32,6 +32,8 @@ readonly script_dir
src_dir="$( cd -- "$script_dir/src" && pwd )"
readonly src_dir
+mode=''
+
. "$src_dir/common.sh"
. "$src_dir/os.sh"
. "$src_dir/path.sh"
@@ -44,11 +46,12 @@ script_usage() {
echo "$script_name: $msg"
done
- echo "usage: $script_name [-h|--help] [-d|--database PATH] [-s|--shared-dir DIR] [-n|--dry-run]
+ echo "usage: $script_name [-h|--help] [-d|--database PATH] [-s|--shared-dir DIR] [-m|--mode MODE] [-n|--dry-run]
-h,--help show this message and exit
-d,--database set database file path
-s,--shared-dir set top-level shared directory path
(current working directory by default)
+ -m,--mode shared files mode (as in chmod)
-n,--dry-run don't actually do anything intrusive"
}
@@ -66,7 +69,7 @@ parse_script_options() {
set_dry_run
continue
;;
- -d|--database|-s|--shared-dir)
+ -d|--database|-s|--shared-dir|-m|--mode)
;;
*)
script_usage "unrecognized parameter: $key" >&2
@@ -89,6 +92,9 @@ parse_script_options() {
-s|--shared-dir)
update_shared_dir "$value"
;;
+ -m|--mode)
+ mode="$value"
+ ;;
*)
script_usage "unrecognized parameter: $key" >&2
exit 1
@@ -103,6 +109,7 @@ main() {
read_database
unlink_obsolete_entries
link_all_entries
+ test -n "$mode" && chmod_entries "$mode"
write_database
}