Use consistent bash5 style for conditionals and quoting
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# Starting the installer with OMARCHY_CHROOT_INSTALL=1 will put it into chroot mode
|
||||
chrootable_systemctl_enable() {
|
||||
if [ -n "${OMARCHY_CHROOT_INSTALL:-}" ]; then
|
||||
if [[ -n ${OMARCHY_CHROOT_INSTALL:-} ]]; then
|
||||
sudo systemctl enable $1
|
||||
else
|
||||
sudo systemctl enable --now $1
|
||||
|
||||
@@ -25,7 +25,7 @@ show_cursor() {
|
||||
# Display truncated log lines from the install log
|
||||
show_log_tail() {
|
||||
if [[ -f $OMARCHY_INSTALL_LOG_FILE ]]; then
|
||||
local log_lines=$(($TERM_HEIGHT - $LOGO_HEIGHT - 35))
|
||||
local log_lines=$((TERM_HEIGHT - LOGO_HEIGHT - 35))
|
||||
local max_line_width=$((LOGO_WIDTH - 4))
|
||||
|
||||
tail -n $log_lines "$OMARCHY_INSTALL_LOG_FILE" | while IFS= read -r line; do
|
||||
@@ -67,7 +67,7 @@ save_original_outputs() {
|
||||
# Restore stdout and stderr to original (saved in FD 3 and 4)
|
||||
# This ensures output goes to screen, not log file
|
||||
restore_outputs() {
|
||||
if [ -e /proc/self/fd/3 ] && [ -e /proc/self/fd/4 ]; then
|
||||
if [[ -e /proc/self/fd/3 ]] && [[ -e /proc/self/fd/4 ]]; then
|
||||
exec 1>&3 2>&4
|
||||
fi
|
||||
}
|
||||
@@ -75,7 +75,7 @@ restore_outputs() {
|
||||
# Error handler
|
||||
catch_errors() {
|
||||
# Prevent recursive error handling
|
||||
if [[ $ERROR_HANDLING == true ]]; then
|
||||
if [[ $ERROR_HANDLING == "true" ]]; then
|
||||
return
|
||||
else
|
||||
ERROR_HANDLING=true
|
||||
@@ -147,7 +147,7 @@ exit_handler() {
|
||||
local exit_code=$?
|
||||
|
||||
# Only run if we're exiting with an error and haven't already handled it
|
||||
if [[ $exit_code -ne 0 && $ERROR_HANDLING != true ]]; then
|
||||
if (( exit_code != 0 )) && [[ $ERROR_HANDLING != "true" ]]; then
|
||||
catch_errors
|
||||
else
|
||||
stop_log_output
|
||||
|
||||
@@ -24,12 +24,12 @@ start_log_output() {
|
||||
line="${current_lines[i]:-}"
|
||||
|
||||
# Truncate if needed
|
||||
if [ ${#line} -gt $max_line_width ]; then
|
||||
if (( ${#line} > max_line_width )); then
|
||||
line="${line:0:$max_line_width}..."
|
||||
fi
|
||||
|
||||
# Add clear line escape and formatted output for each line
|
||||
if [ -n "$line" ]; then
|
||||
if [[ -n $line ]]; then
|
||||
output+="${ANSI_CLEAR_LINE}${ANSI_GRAY}${PADDING_LEFT_SPACES} → ${line}${ANSI_RESET}\n"
|
||||
else
|
||||
output+="${ANSI_CLEAR_LINE}${PADDING_LEFT_SPACES}\n"
|
||||
@@ -45,7 +45,7 @@ start_log_output() {
|
||||
}
|
||||
|
||||
stop_log_output() {
|
||||
if [ -n "${monitor_pid:-}" ]; then
|
||||
if [[ -n ${monitor_pid:-} ]]; then
|
||||
kill $monitor_pid 2>/dev/null || true
|
||||
wait $monitor_pid 2>/dev/null || true
|
||||
unset monitor_pid
|
||||
@@ -72,11 +72,11 @@ stop_install_log() {
|
||||
echo "" >>"$OMARCHY_INSTALL_LOG_FILE"
|
||||
echo "=== Installation Time Summary ===" >>"$OMARCHY_INSTALL_LOG_FILE"
|
||||
|
||||
if [ -f "/var/log/archinstall/install.log" ]; then
|
||||
if [[ -f "/var/log/archinstall/install.log" ]]; then
|
||||
ARCHINSTALL_START=$(grep -m1 '^\[' /var/log/archinstall/install.log 2>/dev/null | sed 's/^\[\([^]]*\)\].*/\1/' || true)
|
||||
ARCHINSTALL_END=$(grep 'Installation completed without any errors' /var/log/archinstall/install.log 2>/dev/null | sed 's/^\[\([^]]*\)\].*/\1/' || true)
|
||||
|
||||
if [ -n "$ARCHINSTALL_START" ] && [ -n "$ARCHINSTALL_END" ]; then
|
||||
if [[ -n $ARCHINSTALL_START ]] && [[ -n $ARCHINSTALL_END ]]; then
|
||||
ARCH_START_EPOCH=$(date -d "$ARCHINSTALL_START" +%s)
|
||||
ARCH_END_EPOCH=$(date -d "$ARCHINSTALL_END" +%s)
|
||||
ARCH_DURATION=$((ARCH_END_EPOCH - ARCH_START_EPOCH))
|
||||
@@ -88,7 +88,7 @@ stop_install_log() {
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$OMARCHY_START_TIME" ]; then
|
||||
if [[ -n $OMARCHY_START_TIME ]]; then
|
||||
OMARCHY_START_EPOCH=$(date -d "$OMARCHY_START_TIME" +%s)
|
||||
OMARCHY_END_EPOCH=$(date -d "$OMARCHY_END_TIME" +%s)
|
||||
OMARCHY_DURATION=$((OMARCHY_END_EPOCH - OMARCHY_START_EPOCH))
|
||||
@@ -98,7 +98,7 @@ stop_install_log() {
|
||||
|
||||
echo "Omarchy: ${OMARCHY_MINS}m ${OMARCHY_SECS}s" >>"$OMARCHY_INSTALL_LOG_FILE"
|
||||
|
||||
if [ -n "$ARCH_DURATION" ]; then
|
||||
if [[ -n $ARCH_DURATION ]]; then
|
||||
TOTAL_DURATION=$((ARCH_DURATION + OMARCHY_DURATION))
|
||||
TOTAL_MINS=$((TOTAL_DURATION / 60))
|
||||
TOTAL_SECS=$((TOTAL_DURATION % 60))
|
||||
@@ -123,7 +123,7 @@ run_logged() {
|
||||
|
||||
local exit_code=$?
|
||||
|
||||
if [ $exit_code -eq 0 ]; then
|
||||
if (( exit_code == 0 )); then
|
||||
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Completed: $script" >>"$OMARCHY_INSTALL_LOG_FILE"
|
||||
unset CURRENT_SCRIPT
|
||||
else
|
||||
|
||||
@@ -4,10 +4,10 @@ if ! command -v gum &>/dev/null; then
|
||||
fi
|
||||
|
||||
# Get terminal size from /dev/tty (works in all scenarios: direct, sourced, or piped)
|
||||
if [ -e /dev/tty ]; then
|
||||
if [[ -e /dev/tty ]]; then
|
||||
TERM_SIZE=$(stty size 2>/dev/null </dev/tty)
|
||||
|
||||
if [ -n "$TERM_SIZE" ]; then
|
||||
if [[ -n $TERM_SIZE ]]; then
|
||||
export TERM_HEIGHT=$(echo "$TERM_SIZE" | cut -d' ' -f1)
|
||||
export TERM_WIDTH=$(echo "$TERM_SIZE" | cut -d' ' -f2)
|
||||
else
|
||||
@@ -25,7 +25,7 @@ export LOGO_PATH="$OMARCHY_PATH/logo.txt"
|
||||
export LOGO_WIDTH=$(awk '{ if (length > max) max = length } END { print max+0 }' "$LOGO_PATH" 2>/dev/null || echo 0)
|
||||
export LOGO_HEIGHT=$(wc -l <"$LOGO_PATH" 2>/dev/null || echo 0)
|
||||
|
||||
export PADDING_LEFT=$((($TERM_WIDTH - $LOGO_WIDTH) / 2))
|
||||
export PADDING_LEFT=$(((TERM_WIDTH - LOGO_WIDTH) / 2))
|
||||
export PADDING_LEFT_SPACES=$(printf "%*s" $PADDING_LEFT "")
|
||||
|
||||
# Tokyo Night theme for gum confirm
|
||||
|
||||
Reference in New Issue
Block a user