mirror of
https://github.com/ivuorinen/dotfiles.git
synced 2026-03-04 03:00:07 +00:00
chore: cr fixes
This commit is contained in:
@@ -13,7 +13,6 @@
|
|||||||
# License: MIT
|
# License: MIT
|
||||||
#
|
#
|
||||||
# vim: set ft=sh ts=2 sw=2 et: ft=sh
|
# vim: set ft=sh ts=2 sw=2 et: ft=sh
|
||||||
#set -euo pipefail
|
|
||||||
set -u
|
set -u
|
||||||
|
|
||||||
VERSION="1.0.0"
|
VERSION="1.0.0"
|
||||||
@@ -41,7 +40,7 @@ readonly TMPFILE=$(mktemp)
|
|||||||
|
|
||||||
# Signal handling and cleanup
|
# Signal handling and cleanup
|
||||||
trap 'cleanup' INT TERM
|
trap 'cleanup' INT TERM
|
||||||
#trap 'error_handler $?' ERR
|
trap 'error_handler $?' ERR
|
||||||
trap 'error_occurred $? $LINENO $BASH_LINENO "$BASH_COMMAND" $(printf "::%s" ${FUNCNAME[@]:-})' ERR
|
trap 'error_occurred $? $LINENO $BASH_LINENO "$BASH_COMMAND" $(printf "::%s" ${FUNCNAME[@]:-})' ERR
|
||||||
trap 'rm -f "$TMPFILE"' EXIT
|
trap 'rm -f "$TMPFILE"' EXIT
|
||||||
|
|
||||||
@@ -135,7 +134,7 @@ error_occurred()
|
|||||||
|
|
||||||
echo "Error occurred in:"
|
echo "Error occurred in:"
|
||||||
echo " Exit code: $exit_code"
|
echo " Exit code: $exit_code"
|
||||||
echo " Line number: $line_no"
|
echo " Line number: $line_no ($bash_lineno)"
|
||||||
echo " Command: $last_command"
|
echo " Command: $last_command"
|
||||||
echo " Function trace: $func_trace"
|
echo " Function trace: $func_trace"
|
||||||
}
|
}
|
||||||
@@ -856,10 +855,23 @@ create_backup()
|
|||||||
local tool_path
|
local tool_path
|
||||||
tool_path=$(asdf where "$tool" "$version")
|
tool_path=$(asdf where "$tool" "$version")
|
||||||
|
|
||||||
|
# Check backup directory permissions
|
||||||
|
if [[ ! -w $BACKUP_DIR ]]; then
|
||||||
|
debug "Backup directory not writable: $BACKUP_DIR"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -d $tool_path ]]; then
|
if [[ -d $tool_path ]]; then
|
||||||
debug "Creating backup of $tool $version"
|
debug "Creating backup of $tool $version"
|
||||||
log_to_file "INFO" "Creating backup of $tool $version"
|
log_to_file "INFO" "Creating backup of $tool $version"
|
||||||
if tar czf "$backup_path.tar.gz" -C "$(dirname "$tool_path")" "$(basename "$tool_path")"; then
|
if tar czf "$backup_path.tar.gz" -C "$(dirname "$tool_path")" "$(basename "$tool_path")"; then
|
||||||
|
# Verify backup integrity
|
||||||
|
if ! tar tzf "$backup_path.tar.gz" > /dev/null 2>&1; then
|
||||||
|
debug "Backup verification failed"
|
||||||
|
rm -f "$backup_path.tar.gz"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
echo "$tool $version" > "$LAST_OP_FILE"
|
echo "$tool $version" > "$LAST_OP_FILE"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
@@ -904,7 +916,15 @@ read_installed_versions()
|
|||||||
local line
|
local line
|
||||||
debug "Reading installed versions from asdf"
|
debug "Reading installed versions from asdf"
|
||||||
|
|
||||||
while IFS= read -r line; do
|
# Capture asdf output and check for errors
|
||||||
|
local asdf_output
|
||||||
|
if ! asdf_output=$(asdf list 2>&1); then
|
||||||
|
print_error "Failed to read installed versions: $asdf_output"
|
||||||
|
log_to_file "ERROR" "Failed to read installed versions: $asdf_output"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
while IFS= read -r line || [[ -n $line ]]; do
|
||||||
if [[ $line =~ ^[^[:space:]] ]]; then
|
if [[ $line =~ ^[^[:space:]] ]]; then
|
||||||
current_tool=$(trim_whitespace "$line")
|
current_tool=$(trim_whitespace "$line")
|
||||||
continue
|
continue
|
||||||
@@ -930,7 +950,7 @@ read_installed_versions()
|
|||||||
installed_versions["$current_tool $version"]=1
|
installed_versions["$current_tool $version"]=1
|
||||||
debug "Added installed version: $current_tool $version"
|
debug "Added installed version: $current_tool $version"
|
||||||
|
|
||||||
done < <(asdf list)
|
done <<< "$asdf_output"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Group and sort versions by tool
|
# Group and sort versions by tool
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ A tool to clean up unused asdf tool versions from your system.
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
mkdir -p ~/.local/bin
|
mkdir -p ~/.local/bin
|
||||||
curl -o ~/.local/bin/x-asdf-cleanup https://raw.githubusercontent.com/yourusername/dotfiles/main/.dotfiles/local/bin/x-asdf-cleanup
|
curl -o ~/.local/bin/x-asdf-cleanup https://raw.githubusercontent.com/ivuorinen/dotfiles/main/.dotfiles/local/bin/x-asdf-cleanup
|
||||||
chmod +x ~/.local/bin/x-asdf-cleanup
|
chmod +x ~/.local/bin/x-asdf-cleanup
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user