mirror of
https://github.com/notwa/rc
synced 2024-11-05 06:39:02 -08:00
avoid non-standard local keyword in install script
This commit is contained in:
parent
c0b0cf78ed
commit
c11d384c1b
1 changed files with 17 additions and 14 deletions
31
install
31
install
|
@ -61,15 +61,15 @@ list_files() {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
softlink_pseudo() {
|
softlink_pseudo() (
|
||||||
: "${1:?missing argument}"
|
: "${1:?missing argument}"
|
||||||
: "${2:?missing argument}"
|
: "${2:?missing argument}"
|
||||||
[ -d "$2" ] || die "$1 is not a directory to softlink"
|
[ -d "$2" ] || die "$1 is not a directory to softlink"
|
||||||
[ -d "$1" ] || mkdir "$1" || die "failed to mkdir $1"
|
[ -d "$1" ] || mkdir "$1" || die "failed to mkdir $1"
|
||||||
|
|
||||||
list_files "$2" | while read -r f; do
|
list_files "$2" | while read -r f; do
|
||||||
local d1="$1/$f"
|
d1="$1/$f"
|
||||||
local d2="$2/$f"
|
d2="$2/$f"
|
||||||
|
|
||||||
if [ -d "$d2" ]; then
|
if [ -d "$d2" ]; then
|
||||||
if [ "$d1" != ".vim/bundle" ]; then # buggy on Windows
|
if [ "$d1" != ".vim/bundle" ]; then # buggy on Windows
|
||||||
|
@ -83,23 +83,25 @@ softlink_pseudo() {
|
||||||
die "i don't know how to pseudo-symlink $d2"
|
die "i don't know how to pseudo-symlink $d2"
|
||||||
fi
|
fi
|
||||||
done || exit
|
done || exit
|
||||||
}
|
)
|
||||||
|
|
||||||
find_new_files() {
|
find_new_files() (
|
||||||
: "${1:?missing argument}"
|
: "${1:?missing argument}"
|
||||||
: "${2:?missing argument}"
|
: "${2:?missing argument}"
|
||||||
|
|
||||||
list_files "$1" | while read -r f; do
|
list_files "$1" | while read -r f; do
|
||||||
local d1="$1/$f"
|
d1="$1/$f"
|
||||||
local d2="$2/$f"
|
d2="$2/$f"
|
||||||
[ "$d1" != ".vim/.netrwhist" ] || continue
|
[ "$d1" != ".vim/.netrwhist" ] || continue
|
||||||
[ "$d1" != ".vim/backup" ] || continue
|
[ "$d1" != ".vim/backup" ] || continue
|
||||||
[ "$d1" != ".vim/bundle" ] || continue
|
[ "$d1" != ".vim/bundle" ] || continue
|
||||||
[ "$d1" != ".vim/swp" ] || continue
|
[ "$d1" != ".vim/swp" ] || continue
|
||||||
[ "$d1" != ".vim/undo" ] || continue
|
[ "$d1" != ".vim/undo" ] || continue
|
||||||
|
|
||||||
if [ -d "$d2" ]; then
|
if [ -d "$d2" ]; then
|
||||||
find_new_files "$d1" "$d2"
|
find_new_files "$d1" "$d2" || exit
|
||||||
elif [ ! "$d1" -ef "$d2" ]; then
|
elif [ ! "$d1" -ef "$d2" ]; then
|
||||||
local ind=
|
ind=
|
||||||
[ ! -d "$d1" ] || ind=/
|
[ ! -d "$d1" ] || ind=/
|
||||||
if [ "$VERBOSE" -lt 1 ]; then
|
if [ "$VERBOSE" -lt 1 ]; then
|
||||||
printf ' + %s%s\n' "$d1" "$ind" >&2
|
printf ' + %s%s\n' "$d1" "$ind" >&2
|
||||||
|
@ -109,13 +111,14 @@ find_new_files() {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
)
|
||||||
|
|
||||||
softlink() {
|
softlink() {
|
||||||
if [ -n "$MSYSTEM" ]; then
|
if [ -n "$MSYSTEM" ]; then
|
||||||
# MSYS2 does not have nor emulate symbolic links.
|
# MSYS2 does not have nor emulate symbolic links.
|
||||||
softlink_pseudo "$@"
|
softlink_pseudo "$@" || exit
|
||||||
find_new_files "$@" # to make up for git status not seeing new files
|
# to make up for git status not seeing new files:
|
||||||
|
find_new_files "$@" || exit
|
||||||
else
|
else
|
||||||
softlink_nix "$@"
|
softlink_nix "$@"
|
||||||
fi
|
fi
|
||||||
|
@ -146,8 +149,8 @@ if [ ! -e .bash_profile ] || ! grep -qF .bashrc .bash_profile; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
is_empty() {
|
is_empty() {
|
||||||
local f="${1:?is_empty requires an argument}"
|
set -- "${1:?is_empty requires an argument}"
|
||||||
find "$f" -type f | while read -r f; do
|
find "$1" -type f | while read -r dummy; do
|
||||||
return 1
|
return 1
|
||||||
done || return 1 # just in case pipes mess things up
|
done || return 1 # just in case pipes mess things up
|
||||||
return 0
|
return 0
|
||||||
|
|
Loading…
Reference in a new issue