aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/links-chmod
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2022-01-06 17:31:48 +0000
committerEgor Tensin <Egor.Tensin@gmail.com>2022-01-06 17:31:48 +0000
commit1b0e7de26eac6cee94dc1c15c8fb91e6a925bd2d (patch)
tree50781b37ab78421cb2aba62703a4fd019207e8bf /links-chmod
parentdebian: 1.1-2 (diff)
parentlinks-chmod: mode parameter is mandatory (diff)
downloadconfig-links-1b0e7de26eac6cee94dc1c15c8fb91e6a925bd2d.tar.gz
config-links-1b0e7de26eac6cee94dc1c15c8fb91e6a925bd2d.zip
Merge tag 'v2.0' into debian
Diffstat (limited to 'links-chmod')
-rwxr-xr-xlinks-chmod33
1 files changed, 25 insertions, 8 deletions
diff --git a/links-chmod b/links-chmod
index 9c7a427..9810cf6 100755
--- a/links-chmod
+++ b/links-chmod
@@ -5,7 +5,7 @@
# For details, see https://github.com/egor-tensin/config-links.
# Distributed under the MIT License.
-# usage: ./links-chmod [-h|--help] [-d|--database PATH] [-s|--shared-dir DIR] [-m|--mode MODE] [-n|--dry-run]
+# usage: ./links-chmod [-h|--help] [-d|--database PATH] [-s|--shared-dir DIR] [-n|--dry-run] MODE
set -o errexit
set -o nounset
@@ -32,16 +32,18 @@ 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] [-n|--dry-run] MODE
+ MODE shared files mode (as in chmod)
-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"
}
parse_script_options() {
+ local -a args=()
+
while [ "$#" -gt 0 ]; do
local key="$1"
shift
@@ -55,12 +57,19 @@ parse_script_options() {
set_dry_run
continue
;;
- -d|--database|-s|--shared-dir|-m|--mode)
+ -d|--database|-s|--shared-dir)
;;
- *)
+ --)
+ break
+ ;;
+ -*)
script_usage "unrecognized parameter: $key" >&2
exit 1
;;
+ *)
+ args+=("$key")
+ continue
+ ;;
esac
if [ "$#" -eq 0 ]; then
@@ -78,17 +87,25 @@ parse_script_options() {
-s|--shared-dir)
update_shared_dir "$value"
;;
- -m|--mode)
- mode="$value"
- ;;
*)
script_usage "unrecognized parameter: $key" >&2
exit 1
;;
esac
done
+
+ args+=("$@")
+
+ if [ "${#args[@]}" -ne 1 ]; then
+ script_usage "missing parameter MODE" >&2
+ exit 1
+ fi
+
+ mode="$( parse_mode "${args[0]}" )"
}
+mode=''
+
main() {
parse_script_options "$@"
read_database