Format yadm and bootstrap with shfmt
Command: shfmt -w -ln bash -i 2 -ci <file>
This commit is contained in:
parent
bb21c9a267
commit
f5dfc7ab01
2 changed files with 218 additions and 221 deletions
|
@ -40,13 +40,15 @@ function _private_yadm() {
|
||||||
unset -f _private_yadm
|
unset -f _private_yadm
|
||||||
command yadm "$@"
|
command yadm "$@"
|
||||||
else
|
else
|
||||||
function yadm() { _private_yadm "$@"; }; export -f yadm
|
function yadm() { _private_yadm "$@"; }
|
||||||
|
export -f yadm
|
||||||
echo WARNING: Using yadm remotely. You should install yadm locally.
|
echo WARNING: Using yadm remotely. You should install yadm locally.
|
||||||
curl -fsSL "$YADM_REPO/raw/$YADM_RELEASE/yadm" | bash -s -- "$@"
|
curl -fsSL "$YADM_REPO/raw/$YADM_RELEASE/yadm" | bash -s -- "$@"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
export -f _private_yadm
|
export -f _private_yadm
|
||||||
function yadm() { _private_yadm "$@"; }; export -f yadm
|
function yadm() { _private_yadm "$@"; }
|
||||||
|
export -f yadm
|
||||||
|
|
||||||
# if being sourced, return here, otherwise continue processing
|
# if being sourced, return here, otherwise continue processing
|
||||||
return 2>/dev/null
|
return 2>/dev/null
|
||||||
|
|
27
yadm
27
yadm
|
@ -162,7 +162,6 @@ function main() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# ****** Alternate Processing ******
|
# ****** Alternate Processing ******
|
||||||
|
|
||||||
function score_file() {
|
function score_file() {
|
||||||
|
@ -1337,7 +1336,7 @@ function upgrade() {
|
||||||
local -a submodules
|
local -a submodules
|
||||||
local repo_updates=0
|
local repo_updates=0
|
||||||
|
|
||||||
[[ -n "${YADM_OVERRIDE_REPO}${YADM_OVERRIDE_ARCHIVE}" || "$YADM_DATA" = "$YADM_DIR" ]] && \
|
[[ -n "${YADM_OVERRIDE_REPO}${YADM_OVERRIDE_ARCHIVE}" || "$YADM_DATA" = "$YADM_DIR" ]] &&
|
||||||
error_out "Unable to upgrade. Paths have been overridden with command line options"
|
error_out "Unable to upgrade. Paths have been overridden with command line options"
|
||||||
|
|
||||||
# choose a legacy repo, the version 2 location will be favored
|
# choose a legacy repo, the version 2 location will be favored
|
||||||
|
@ -1407,9 +1406,7 @@ function upgrade() {
|
||||||
"$YADM_LEGACY_DIR/config" \
|
"$YADM_LEGACY_DIR/config" \
|
||||||
"$YADM_LEGACY_DIR/encrypt" \
|
"$YADM_LEGACY_DIR/encrypt" \
|
||||||
"$YADM_LEGACY_DIR/bootstrap" \
|
"$YADM_LEGACY_DIR/bootstrap" \
|
||||||
"$YADM_LEGACY_DIR"/hooks/{pre,post}_* \
|
"$YADM_LEGACY_DIR"/hooks/{pre,post}_*; do
|
||||||
;
|
|
||||||
do
|
|
||||||
if [ -e "$legacy_path" ]; then
|
if [ -e "$legacy_path" ]; then
|
||||||
new_filename="${legacy_path#"$YADM_LEGACY_DIR/"}"
|
new_filename="${legacy_path#"$YADM_LEGACY_DIR/"}"
|
||||||
new_filename="$YADM_DIR/$new_filename"
|
new_filename="$YADM_DIR/$new_filename"
|
||||||
|
@ -1430,10 +1427,10 @@ function upgrade() {
|
||||||
"$GIT_PROGRAM" -C "$YADM_WORK" submodule update --init --recursive -- "$submodule"
|
"$GIT_PROGRAM" -C "$YADM_WORK" submodule update --init --recursive -- "$submodule"
|
||||||
done
|
done
|
||||||
|
|
||||||
[ "$actions_performed" -eq 0 ] && \
|
[ "$actions_performed" -eq 0 ] &&
|
||||||
echo "No legacy paths found. Upgrade is not necessary"
|
echo "No legacy paths found. Upgrade is not necessary"
|
||||||
|
|
||||||
[ "$repo_updates" -eq 1 ] && \
|
[ "$repo_updates" -eq 1 ] &&
|
||||||
echo "Some files tracked by yadm have been renamed. These changes should probably be commited now."
|
echo "Some files tracked by yadm have been renamed. These changes should probably be commited now."
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -1443,7 +1440,8 @@ function upgrade() {
|
||||||
function version() {
|
function version() {
|
||||||
|
|
||||||
echo "bash version $BASH_VERSION"
|
echo "bash version $BASH_VERSION"
|
||||||
printf " "; "$GIT_PROGRAM" --version
|
printf " "
|
||||||
|
"$GIT_PROGRAM" --version
|
||||||
echo "yadm version $VERSION"
|
echo "yadm version $VERSION"
|
||||||
exit_with_hook 0
|
exit_with_hook 0
|
||||||
|
|
||||||
|
@ -1507,7 +1505,7 @@ function query_distro() {
|
||||||
while IFS='' read -r line || [ -n "$line" ]; do
|
while IFS='' read -r line || [ -n "$line" ]; do
|
||||||
if [[ "$line" = ID=* ]]; then
|
if [[ "$line" = ID=* ]]; then
|
||||||
distro="${line#ID=}"
|
distro="${line#ID=}"
|
||||||
distro="${distro//\"}"
|
distro="${distro//\"/}"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done <"$OS_RELEASE"
|
done <"$OS_RELEASE"
|
||||||
|
@ -1528,7 +1526,7 @@ function query_distro_family() {
|
||||||
fi
|
fi
|
||||||
done <"$OS_RELEASE"
|
done <"$OS_RELEASE"
|
||||||
fi
|
fi
|
||||||
echo "${family//\"}"
|
echo "${family//\"/}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function process_global_args() {
|
function process_global_args() {
|
||||||
|
@ -1635,9 +1633,7 @@ function issue_legacy_path_warning() {
|
||||||
"$YADM_LEGACY_DIR/$YADM_CONFIG" \
|
"$YADM_LEGACY_DIR/$YADM_CONFIG" \
|
||||||
"$YADM_LEGACY_DIR/$YADM_ENCRYPT" \
|
"$YADM_LEGACY_DIR/$YADM_ENCRYPT" \
|
||||||
"$YADM_LEGACY_DIR/$YADM_HOOKS"/{pre,post}_* \
|
"$YADM_LEGACY_DIR/$YADM_HOOKS"/{pre,post}_* \
|
||||||
"$YADM_LEGACY_DIR/$YADM_LEGACY_ARCHIVE" \
|
"$YADM_LEGACY_DIR/$YADM_LEGACY_ARCHIVE"; do
|
||||||
;
|
|
||||||
do
|
|
||||||
[ -e "$legacy_path" ] && legacy_found+=("$legacy_path")
|
[ -e "$legacy_path" ] && legacy_found+=("$legacy_path")
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -1763,8 +1759,7 @@ function set_operating_system() {
|
||||||
fi
|
fi
|
||||||
OPERATING_SYSTEM=$(uname -o)
|
OPERATING_SYSTEM=$(uname -o)
|
||||||
;;
|
;;
|
||||||
*)
|
*) ;;
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1802,7 +1797,7 @@ function invoke_hook() {
|
||||||
exit_status="$2"
|
exit_status="$2"
|
||||||
hook_command="${YADM_HOOKS}/${mode}_$HOOK_COMMAND"
|
hook_command="${YADM_HOOKS}/${mode}_$HOOK_COMMAND"
|
||||||
|
|
||||||
if [ -x "$hook_command" ] || \
|
if [ -x "$hook_command" ] ||
|
||||||
{ [[ $OPERATING_SYSTEM == MINGW* ]] && [ -f "$hook_command" ]; }; then
|
{ [[ $OPERATING_SYSTEM == MINGW* ]] && [ -f "$hook_command" ]; }; then
|
||||||
debug "Invoking hook: $hook_command"
|
debug "Invoking hook: $hook_command"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue