aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xlinks-chmod5
-rwxr-xr-xlinks-remove5
-rwxr-xr-xlinks-update5
-rw-r--r--src/db.sh19
-rw-r--r--src/path.sh4
-rwxr-xr-xtest/test.sh3
6 files changed, 23 insertions, 18 deletions
diff --git a/links-chmod b/links-chmod
index 9810cf6..f722b95 100755
--- a/links-chmod
+++ b/links-chmod
@@ -7,9 +7,8 @@
# usage: ./links-chmod [-h|--help] [-d|--database PATH] [-s|--shared-dir DIR] [-n|--dry-run] MODE
-set -o errexit
-set -o nounset
-set -o pipefail
+set -o errexit -o nounset -o pipefail
+shopt -s inherit_errexit lastpipe
script_name="$( basename -- "${BASH_SOURCE[0]}" )"
readonly script_name
diff --git a/links-remove b/links-remove
index ea79596..c378485 100755
--- a/links-remove
+++ b/links-remove
@@ -7,9 +7,8 @@
# usage: ./links-remove [-h|--help] [-d|--database PATH] [-s|--shared-dir DIR] [-n|--dry-run]
-set -o errexit
-set -o nounset
-set -o pipefail
+set -o errexit -o nounset -o pipefail
+shopt -s inherit_errexit lastpipe
script_name="$( basename -- "${BASH_SOURCE[0]}" )"
readonly script_name
diff --git a/links-update b/links-update
index 6a802bc..5b15f1b 100755
--- a/links-update
+++ b/links-update
@@ -19,9 +19,8 @@
# usage: ./links-update [-h|--help] [-d|--database PATH] [-s|--shared-dir DIR] [-m|--mode MODE] [-n|--dry-run]
-set -o errexit
-set -o nounset
-set -o pipefail
+set -o errexit -o nounset -o pipefail
+shopt -s inherit_errexit lastpipe
script_name="$( basename -- "${BASH_SOURCE[0]}" )"
readonly script_name
diff --git a/src/db.sh b/src/db.sh
index b057202..201ad25 100644
--- a/src/db.sh
+++ b/src/db.sh
@@ -57,7 +57,7 @@ add_entry() {
local shared_var_dir="$shared_root_dir%$var_name%"
local symlink_var_dir
symlink_var_dir="$( resolve_variable "$var_name" )"
- local subpath="${entry#%$var_name%/}"
+ local subpath="${entry#%"$var_name"%/}"
local shared_path="$shared_var_dir"
[ "$shared_var_dir" != / ] && shared_path="$shared_path/"
@@ -134,7 +134,7 @@ delete_obsolete_dirs() {
[ "$base_dir" = "$dir" ] && return 0
- local subpath="${dir##$base_dir/}"
+ local subpath="${dir##"$base_dir"/}"
if [ "$subpath" = "$dir" ]; then
dump "base directory: $base_dir" >&2
@@ -193,10 +193,18 @@ shared_file_present() {
link_all_entries() {
local shared_var_dir
+
+ find "$shared_root_dir" \
+ -mindepth 1 -maxdepth 1 \
+ -\( -type d -o -type l -\) \
+ -regextype posix-basic \
+ -regex ".*/$var_name_regex\$" \
+ -printf '%P\0' |
while IFS= read -d '' -r shared_var_dir; do
dump "shared directory: $shared_root_dir$shared_var_dir"
-
local shared_path
+
+ find "$shared_root_dir$shared_var_dir/" -\( -type f -o -type l -\) -print0 |
while IFS= read -d '' -r shared_path; do
dump " shared file path: $shared_path"
local entry="${shared_path:${#shared_root_dir}}"
@@ -214,9 +222,8 @@ link_all_entries() {
dump ' ... adding a symlink'
is_dry_run || link_entry "$entry"
fi
-
- done < <( find "$shared_root_dir$shared_var_dir/" -\( -type f -o -type l -\) -print0 )
- done < <( find "$shared_root_dir" -regextype posix-basic -mindepth 1 -maxdepth 1 -\( -type d -o -type l -\) -regex ".*/$var_name_regex\$" -printf '%P\0' )
+ done
+ done
}
unlink_all_entries() {
diff --git a/src/path.sh b/src/path.sh
index bf52a6f..8ac71a9 100644
--- a/src/path.sh
+++ b/src/path.sh
@@ -76,7 +76,7 @@ traverse_path() {
local -a abs_paths=()
local path
- while IFS= read -d '' -r path; do
+ readlink -z --canonicalize-missing -- ${paths[@]+"${paths[@]}"} | while IFS= read -d '' -r path; do
if [ -n "$must_exist" ] && [ ! -e "$path" ]; then
dump "must exist: $path" >&2
return 1
@@ -88,7 +88,7 @@ traverse_path() {
fi
abs_paths+=("$path")
- done < <( readlink -z --canonicalize-missing -- ${paths[@]+"${paths[@]}"} )
+ done
printf -- "$fmt" ${abs_paths[@]+"${abs_paths[@]}"}
}
diff --git a/test/test.sh b/test/test.sh
index f2920b5..9a9ff33 100755
--- a/test/test.sh
+++ b/test/test.sh
@@ -1,6 +1,7 @@
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail
+shopt -s inherit_errexit lastpipe
script_dir="$( dirname -- "${BASH_SOURCE[0]}" )"
script_dir="$( cd -- "$script_dir" && pwd )"
@@ -55,7 +56,7 @@ call_bin_script() {
printf -- '\n'
echo
- DEST="$test_dest_dir" ALT_DEST="$test_alt_dest_dir" eval "$@" --shared-dir "$test_src_dir" --database "$test_root_dir/links.bin"
+ DEST="$test_dest_dir" ALT_DEST="$test_alt_dest_dir" "$@" --shared-dir "$test_src_dir" --database "$test_root_dir/links.bin"
}
call_update() {