From 6804fd4ca717805c3ed128a18b136b9ff08b04b8 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Wed, 28 Apr 2021 22:02:16 +0000 Subject: bin/*.sh -> *.sh --- .ci/test.sh | 4 +-- README.md | 4 +-- bin/unlink.sh | 95 -------------------------------------------------- bin/update.sh | 109 ---------------------------------------------------------- unlink.sh | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++ update.sh | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 208 insertions(+), 208 deletions(-) delete mode 100755 bin/unlink.sh delete mode 100755 bin/update.sh create mode 100755 unlink.sh create mode 100755 update.sh diff --git a/.ci/test.sh b/.ci/test.sh index e7bcd5a..fffc883 100755 --- a/.ci/test.sh +++ b/.ci/test.sh @@ -58,11 +58,11 @@ call_bin_script() { } call_update() { - call_bin_script "$script_dir/../bin/update.sh" + call_bin_script "$script_dir/../update.sh" } call_unlink() { - call_bin_script "$script_dir/../bin/unlink.sh" + call_bin_script "$script_dir/../unlink.sh" } verify_output() { diff --git a/README.md b/README.md index a687652..c30bb0f 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ This description is obviously confusing; see the complete usage example below. Usage ----- -Symlinks are managed by `bin/update.sh`. +Symlinks are managed by `update.sh`. ``` usage: update.sh [-h|--help] [-d|--database PATH] [-s|--shared-dir DIR] [-n|--dry-run] @@ -36,7 +36,7 @@ In this example, the symlinks to files in "../src" must appear in ``` > pwd -/cygdrive/d/workspace/personal/config-links/bin +/cygdrive/d/workspace/personal/config-links > tree /test/dest/ /test/dest/ diff --git a/bin/unlink.sh b/bin/unlink.sh deleted file mode 100755 index 982e535..0000000 --- a/bin/unlink.sh +++ /dev/null @@ -1,95 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2019 Egor Tensin -# This file is part of the "Configuration file sharing" project. -# For details, see https://github.com/egor-tensin/config-links. -# Distributed under the MIT License. - -# usage: ./unlink.sh [-h|--help] [-d|--database PATH] [-s|--shared-dir DIR] [-n|--dry-run] - -set -o errexit -set -o nounset -set -o pipefail - -script_name="$( basename -- "${BASH_SOURCE[0]}" )" -readonly script_name -script_path="$( realpath --canonicalize-existing -- "${BASH_SOURCE[0]}" )" -readonly script_path -script_dir="$( dirname -- "$script_path" )" -readonly script_dir -src_dir="$( cd -- "$script_dir/../src" && pwd )" -readonly src_dir - -. "$src_dir/common.sh" -. "$src_dir/os.sh" -. "$src_dir/path.sh" -. "$src_dir/vars.sh" -. "$src_dir/db.sh" - -script_usage() { - local msg - for msg; do - echo "$script_name: $msg" - done - - echo "usage: $script_name [-h|--help] [-d|--database PATH] [-s|--shared-dir DIR] [-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) - -n,--dry-run don't actually do anything intrusive" -} - -parse_script_options() { - while [ "$#" -gt 0 ]; do - local key="$1" - shift - - case "$key" in - -h|--help) - script_usage - exit 0 - ;; - -n|--dry-run) - set_dry_run - continue - ;; - -d|--database|-s|--shared-dir) - ;; - *) - script_usage "unrecognized parameter: $key" >&2 - exit 1 - ;; - esac - - if [ "$#" -eq 0 ]; then - script_usage "missing argument for parameter: $key" >&2 - exit 1 - fi - - local value="$1" - shift - - case "$key" in - -d|--database) - update_database_path "$value" - ;; - -s|--shared-dir) - update_shared_dir "$value" - ;; - *) - script_usage "unrecognized parameter: $key" >&2 - exit 1 - ;; - esac - done -} - -main() { - parse_script_options "$@" - read_database - unlink_all_entries - write_database -} - -main "$@" diff --git a/bin/update.sh b/bin/update.sh deleted file mode 100755 index 1b98e9f..0000000 --- a/bin/update.sh +++ /dev/null @@ -1,109 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2016 Egor Tensin -# This file is part of the "Configuration file sharing" project. -# For details, see https://github.com/egor-tensin/config-links. -# Distributed under the MIT License. - -# This script relies on the availability of native symlinks. -# Those are indeed supported by NTFS, but require Administrator privileges for -# creation. -# It likely won't bother you as long as you don't use the functions defined in -# this file. -# In any case, you will see `ln` complaining about some access being denied in -# case something goes wrong. -# -# Remember that in order to force `ln` to use native NTFS symlinks, your -# `CYGWIN` Windows environment variable value **must** include either -# `winsymlinks:native` or `winsymlinks:nativestrict`! - -# usage: ./update.sh [-h|--help] [-d|--database PATH] [-s|--shared-dir DIR] [-n|--dry-run] - -set -o errexit -set -o nounset -set -o pipefail - -script_name="$( basename -- "${BASH_SOURCE[0]}" )" -readonly script_name -script_path="$( realpath --canonicalize-existing -- "${BASH_SOURCE[0]}" )" -readonly script_path -script_dir="$( dirname -- "$script_path" )" -readonly script_dir -src_dir="$( cd -- "$script_dir/../src" && pwd )" -readonly src_dir - -. "$src_dir/common.sh" -. "$src_dir/os.sh" -. "$src_dir/path.sh" -. "$src_dir/vars.sh" -. "$src_dir/db.sh" - -script_usage() { - local msg - for msg; do - echo "$script_name: $msg" - done - - echo "usage: $script_name [-h|--help] [-d|--database PATH] [-s|--shared-dir DIR] [-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) - -n,--dry-run don't actually do anything intrusive" -} - -parse_script_options() { - while [ "$#" -gt 0 ]; do - local key="$1" - shift - - case "$key" in - -h|--help) - script_usage - exit 0 - ;; - -n|--dry-run) - set_dry_run - continue - ;; - -d|--database|-s|--shared-dir) - ;; - *) - script_usage "unrecognized parameter: $key" >&2 - exit 1 - ;; - esac - - if [ "$#" -eq 0 ]; then - script_usage "missing argument for parameter: $key" >&2 - exit 1 - fi - - local value="$1" - shift - - case "$key" in - -d|--database) - update_database_path "$value" - ;; - -s|--shared-dir) - update_shared_dir "$value" - ;; - *) - script_usage "unrecognized parameter: $key" >&2 - exit 1 - ;; - esac - done -} - -main() { - parse_script_options "$@" - check_symlinks_enabled - read_database - unlink_obsolete_entries - link_all_entries - write_database -} - -main "$@" diff --git a/unlink.sh b/unlink.sh new file mode 100755 index 0000000..a44fa3f --- /dev/null +++ b/unlink.sh @@ -0,0 +1,95 @@ +#!/usr/bin/env bash + +# Copyright (c) 2019 Egor Tensin +# This file is part of the "Configuration file sharing" project. +# For details, see https://github.com/egor-tensin/config-links. +# Distributed under the MIT License. + +# usage: ./unlink.sh [-h|--help] [-d|--database PATH] [-s|--shared-dir DIR] [-n|--dry-run] + +set -o errexit +set -o nounset +set -o pipefail + +script_name="$( basename -- "${BASH_SOURCE[0]}" )" +readonly script_name +script_path="$( realpath --canonicalize-existing -- "${BASH_SOURCE[0]}" )" +readonly script_path +script_dir="$( dirname -- "$script_path" )" +readonly script_dir +src_dir="$( cd -- "$script_dir/src" && pwd )" +readonly src_dir + +. "$src_dir/common.sh" +. "$src_dir/os.sh" +. "$src_dir/path.sh" +. "$src_dir/vars.sh" +. "$src_dir/db.sh" + +script_usage() { + local msg + for msg; do + echo "$script_name: $msg" + done + + echo "usage: $script_name [-h|--help] [-d|--database PATH] [-s|--shared-dir DIR] [-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) + -n,--dry-run don't actually do anything intrusive" +} + +parse_script_options() { + while [ "$#" -gt 0 ]; do + local key="$1" + shift + + case "$key" in + -h|--help) + script_usage + exit 0 + ;; + -n|--dry-run) + set_dry_run + continue + ;; + -d|--database|-s|--shared-dir) + ;; + *) + script_usage "unrecognized parameter: $key" >&2 + exit 1 + ;; + esac + + if [ "$#" -eq 0 ]; then + script_usage "missing argument for parameter: $key" >&2 + exit 1 + fi + + local value="$1" + shift + + case "$key" in + -d|--database) + update_database_path "$value" + ;; + -s|--shared-dir) + update_shared_dir "$value" + ;; + *) + script_usage "unrecognized parameter: $key" >&2 + exit 1 + ;; + esac + done +} + +main() { + parse_script_options "$@" + read_database + unlink_all_entries + write_database +} + +main "$@" diff --git a/update.sh b/update.sh new file mode 100755 index 0000000..faea90d --- /dev/null +++ b/update.sh @@ -0,0 +1,109 @@ +#!/usr/bin/env bash + +# Copyright (c) 2016 Egor Tensin +# This file is part of the "Configuration file sharing" project. +# For details, see https://github.com/egor-tensin/config-links. +# Distributed under the MIT License. + +# This script relies on the availability of native symlinks. +# Those are indeed supported by NTFS, but require Administrator privileges for +# creation. +# It likely won't bother you as long as you don't use the functions defined in +# this file. +# In any case, you will see `ln` complaining about some access being denied in +# case something goes wrong. +# +# Remember that in order to force `ln` to use native NTFS symlinks, your +# `CYGWIN` Windows environment variable value **must** include either +# `winsymlinks:native` or `winsymlinks:nativestrict`! + +# usage: ./update.sh [-h|--help] [-d|--database PATH] [-s|--shared-dir DIR] [-n|--dry-run] + +set -o errexit +set -o nounset +set -o pipefail + +script_name="$( basename -- "${BASH_SOURCE[0]}" )" +readonly script_name +script_path="$( realpath --canonicalize-existing -- "${BASH_SOURCE[0]}" )" +readonly script_path +script_dir="$( dirname -- "$script_path" )" +readonly script_dir +src_dir="$( cd -- "$script_dir/src" && pwd )" +readonly src_dir + +. "$src_dir/common.sh" +. "$src_dir/os.sh" +. "$src_dir/path.sh" +. "$src_dir/vars.sh" +. "$src_dir/db.sh" + +script_usage() { + local msg + for msg; do + echo "$script_name: $msg" + done + + echo "usage: $script_name [-h|--help] [-d|--database PATH] [-s|--shared-dir DIR] [-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) + -n,--dry-run don't actually do anything intrusive" +} + +parse_script_options() { + while [ "$#" -gt 0 ]; do + local key="$1" + shift + + case "$key" in + -h|--help) + script_usage + exit 0 + ;; + -n|--dry-run) + set_dry_run + continue + ;; + -d|--database|-s|--shared-dir) + ;; + *) + script_usage "unrecognized parameter: $key" >&2 + exit 1 + ;; + esac + + if [ "$#" -eq 0 ]; then + script_usage "missing argument for parameter: $key" >&2 + exit 1 + fi + + local value="$1" + shift + + case "$key" in + -d|--database) + update_database_path "$value" + ;; + -s|--shared-dir) + update_shared_dir "$value" + ;; + *) + script_usage "unrecognized parameter: $key" >&2 + exit 1 + ;; + esac + done +} + +main() { + parse_script_options "$@" + check_symlinks_enabled + read_database + unlink_obsolete_entries + link_all_entries + write_database +} + +main "$@" -- cgit v1.2.3