1
0
Fork 0
mirror of synced 2024-12-21 22:21:08 -05:00

Format yadm and bootstrap with shfmt

Command: shfmt -w -ln bash -i 2 -ci <file>
This commit is contained in:
Erik Flodin 2024-12-11 20:05:16 +01:00
parent bb21c9a267
commit f5dfc7ab01
No known key found for this signature in database
GPG key ID: 420A7C865EE3F85F
2 changed files with 218 additions and 221 deletions

View file

@ -40,13 +40,15 @@ function _private_yadm() {
unset -f _private_yadm
command yadm "$@"
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.
curl -fsSL "$YADM_REPO/raw/$YADM_RELEASE/yadm" | bash -s -- "$@"
fi
}
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
return 2>/dev/null

27
yadm
View file

@ -162,7 +162,6 @@ function main() {
}
# ****** Alternate Processing ******
function score_file() {
@ -1337,7 +1336,7 @@ function upgrade() {
local -a submodules
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"
# choose a legacy repo, the version 2 location will be favored
@ -1407,9 +1406,7 @@ function upgrade() {
"$YADM_LEGACY_DIR/config" \
"$YADM_LEGACY_DIR/encrypt" \
"$YADM_LEGACY_DIR/bootstrap" \
"$YADM_LEGACY_DIR"/hooks/{pre,post}_* \
;
do
"$YADM_LEGACY_DIR"/hooks/{pre,post}_*; do
if [ -e "$legacy_path" ]; then
new_filename="${legacy_path#"$YADM_LEGACY_DIR/"}"
new_filename="$YADM_DIR/$new_filename"
@ -1430,10 +1427,10 @@ function upgrade() {
"$GIT_PROGRAM" -C "$YADM_WORK" submodule update --init --recursive -- "$submodule"
done
[ "$actions_performed" -eq 0 ] && \
[ "$actions_performed" -eq 0 ] &&
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."
exit 0
@ -1443,7 +1440,8 @@ function upgrade() {
function version() {
echo "bash version $BASH_VERSION"
printf " "; "$GIT_PROGRAM" --version
printf " "
"$GIT_PROGRAM" --version
echo "yadm version $VERSION"
exit_with_hook 0
@ -1507,7 +1505,7 @@ function query_distro() {
while IFS='' read -r line || [ -n "$line" ]; do
if [[ "$line" = ID=* ]]; then
distro="${line#ID=}"
distro="${distro//\"}"
distro="${distro//\"/}"
break
fi
done <"$OS_RELEASE"
@ -1528,7 +1526,7 @@ function query_distro_family() {
fi
done <"$OS_RELEASE"
fi
echo "${family//\"}"
echo "${family//\"/}"
}
function process_global_args() {
@ -1635,9 +1633,7 @@ function issue_legacy_path_warning() {
"$YADM_LEGACY_DIR/$YADM_CONFIG" \
"$YADM_LEGACY_DIR/$YADM_ENCRYPT" \
"$YADM_LEGACY_DIR/$YADM_HOOKS"/{pre,post}_* \
"$YADM_LEGACY_DIR/$YADM_LEGACY_ARCHIVE" \
;
do
"$YADM_LEGACY_DIR/$YADM_LEGACY_ARCHIVE"; do
[ -e "$legacy_path" ] && legacy_found+=("$legacy_path")
done
@ -1763,8 +1759,7 @@ function set_operating_system() {
fi
OPERATING_SYSTEM=$(uname -o)
;;
*)
;;
*) ;;
esac
}
@ -1802,7 +1797,7 @@ function invoke_hook() {
exit_status="$2"
hook_command="${YADM_HOOKS}/${mode}_$HOOK_COMMAND"
if [ -x "$hook_command" ] || \
if [ -x "$hook_command" ] ||
{ [[ $OPERATING_SYSTEM == MINGW* ]] && [ -f "$hook_command" ]; }; then
debug "Invoking hook: $hook_command"