Skip to content

Commit d0b8f51

Browse files
committed
fix: Dynamic box sizing, three-way merge, upgrade error detection, and bug fixes (v6)
1 parent dd2d956 commit d0b8f51

2 files changed

Lines changed: 37 additions & 22 deletions

File tree

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5
1+
6

update.sh

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -89,29 +89,37 @@ get_system_info() {
8989
show_system_status() {
9090
get_system_info
9191

92-
# Box width (inner content width = 49 chars)
93-
local box_width=49
92+
# Calculate dynamic box width based on content
93+
local header="System Information"
94+
local fedora_text="Fedora Version: $FEDORA_VERSION"
95+
local kernel_text="Kernel: $KERNEL_VERSION"
96+
local update_text="Last Package Change: $LAST_UPDATE"
9497

95-
echo -e " ┌─────────────────────────────────────────────────┐"
96-
echo -e "${BOLD}System Information${NC}"
97-
echo -e " ├─────────────────────────────────────────────────┤"
98+
# Find the longest line (add 4 for " " padding on each side)
99+
local max_len=${#header}
100+
[ ${#fedora_text} -gt $max_len ] && max_len=${#fedora_text}
101+
[ ${#kernel_text} -gt $max_len ] && max_len=${#kernel_text}
102+
[ ${#update_text} -gt $max_len ] && max_len=${#update_text}
98103

99-
# Fedora Version line
100-
local fedora_text="Fedora Version: $FEDORA_VERSION"
101-
local fedora_pad=$((box_width - ${#fedora_text} - 2))
102-
printf " │ Fedora Version: ${GREEN}%s${NC}%*s│\n" "$FEDORA_VERSION" "$fedora_pad" ""
104+
# Box width = max content + 4 (2 spaces padding each side)
105+
local box_width=$((max_len + 4))
106+
# Minimum width of 49 for aesthetics
107+
[ $box_width -lt 49 ] && box_width=49
103108

104-
# Kernel line
105-
local kernel_text="Kernel: $KERNEL_VERSION"
106-
local kernel_pad=$((box_width - ${#kernel_text} - 2))
107-
printf " │ Kernel: ${CYAN}%s${NC}%*s│\n" "$KERNEL_VERSION" "$kernel_pad" ""
109+
# Generate horizontal border
110+
local border=""
111+
for ((i=0; i<box_width; i++)); do border+=""; done
108112

109-
# Last Package Change line
110-
local update_text="Last Package Change: $LAST_UPDATE"
111-
local update_pad=$((box_width - ${#update_text} - 2))
112-
printf " │ Last Package Change: ${YELLOW}%s${NC}%*s│\n" "$LAST_UPDATE" "$update_pad" ""
113+
echo -e "${border}"
114+
printf "${BOLD}%-$((box_width - 4))s${NC} │\n" "$header"
115+
echo -e "${border}"
116+
117+
# Content lines with dynamic padding
118+
printf " │ Fedora Version: ${GREEN}%-$((box_width - 22))s${NC} │\n" "$FEDORA_VERSION"
119+
printf " │ Kernel: ${CYAN}%-$((box_width - 14))s${NC} │\n" "$KERNEL_VERSION"
120+
printf " │ Last Package Change: ${YELLOW}%-$((box_width - 28))s${NC} │\n" "$LAST_UPDATE"
113121

114-
echo -e "─────────────────────────────────────────────────"
122+
echo -e "${border}"
115123
echo ""
116124
}
117125

@@ -847,9 +855,16 @@ handle_config_conflict() {
847855
# Use loop instead of recursion to avoid stack depth issues
848856
while true; do
849857
echo ""
850-
echo -e " ${YELLOW}╔═══════════════════════════════════════════════════════════╗${NC}"
851-
printf " ${YELLOW}${NC} Conflict in: ${BOLD}%-43s${NC}${YELLOW}${NC}\n" "$config_name"
852-
echo -e " ${YELLOW}╚═══════════════════════════════════════════════════════════╝${NC}"
858+
# Dynamic box width based on config name length
859+
local label="Conflict in: $config_name"
860+
local box_width=${#label}
861+
[ $box_width -lt 55 ] && box_width=55 # Minimum width
862+
box_width=$((box_width + 4)) # Add padding
863+
local border=""
864+
for ((i=0; i<box_width; i++)); do border+=""; done
865+
echo -e " ${YELLOW}${border}${NC}"
866+
printf " ${YELLOW}${NC} Conflict in: ${BOLD}%-$((box_width - 18))s${NC} ${YELLOW}${NC}\n" "$config_name"
867+
echo -e " ${YELLOW}${border}${NC}"
853868
echo ""
854869

855870
# Show diff summary (your version vs new version)

0 commit comments

Comments
 (0)