made local really local

This commit is contained in:
fatalerrors
2026-05-21 11:17:21 +02:00
parent 19ca7fa905
commit c92ca8a51f
4 changed files with 46 additions and 6 deletions

View File

@@ -44,41 +44,49 @@
# -n, --no-dir Never create a host directory # -n, --no-dir Never create a host directory
utaz() utaz()
{ {
local _ununzip
# shellcheck disable=SC2329 # shellcheck disable=SC2329
_ununzip() _ununzip()
{ {
unzip -o "$1" -d "$2" >/dev/null 2>&1 unzip -o "$1" -d "$2" >/dev/null 2>&1
} }
local _untar
# shellcheck disable=SC2329 # shellcheck disable=SC2329
_untar() _untar()
{ {
tar -xf "$1" -C "$2" tar -xf "$1" -C "$2"
} }
local _ungzip
# shellcheck disable=SC2329 # shellcheck disable=SC2329
_ungzip() _ungzip()
{ {
tar -xzf "$1" -C "$2" tar -xzf "$1" -C "$2"
} }
local _unbzip2
# shellcheck disable=SC2329 # shellcheck disable=SC2329
_unbzip2() _unbzip2()
{ {
tar -xjf "$1" -C "$2" tar -xjf "$1" -C "$2"
} }
local _unxz
# shellcheck disable=SC2329 # shellcheck disable=SC2329
_unxz() _unxz()
{ {
tar -xJf "$1" -C "$2" tar -xJf "$1" -C "$2"
} }
local _unlzop
# shellcheck disable=SC2329 # shellcheck disable=SC2329
_unlzop() _unlzop()
{ {
lzop -d "$1" -o "$2/$(basename "${1%.*}")" lzop -d "$1" -o "$2/$(basename "${1%.*}")"
} }
local _unlzip
# shellcheck disable=SC2329 # shellcheck disable=SC2329
_unlzip() _unlzip()
{ {
@@ -89,18 +97,21 @@ utaz()
fi fi
} }
local _ununrar
# shellcheck disable=SC2329 # shellcheck disable=SC2329
_ununrar() _ununrar()
{ {
unrar x -o+ "$1" "$2/" >/dev/null 2>&1 unrar x -o+ "$1" "$2/" >/dev/null 2>&1
} }
local _ununarj
# shellcheck disable=SC2329 # shellcheck disable=SC2329
_ununarj() _ununarj()
{ {
unarj e "$1" "$2/" >/dev/null 2>&1 unarj e "$1" "$2/" >/dev/null 2>&1
} }
local _unlha
# shellcheck disable=SC2329 # shellcheck disable=SC2329
_unlha() _unlha()
{ {
@@ -109,18 +120,21 @@ utaz()
(cd "$2" && lha -x "../$1") >/dev/null 2>&1 (cd "$2" && lha -x "../$1") >/dev/null 2>&1
} }
local _ununace
# shellcheck disable=SC2329 # shellcheck disable=SC2329
_ununace() _ununace()
{ {
unace x "$1" "$2/" >/dev/null 2>&1 unace x "$1" "$2/" >/dev/null 2>&1
} }
local _un7z
# shellcheck disable=SC2329 # shellcheck disable=SC2329
_un7z() _un7z()
{ {
7z x "$1" -o"$2/" >/dev/null 2>&1 7z x "$1" -o"$2/" >/dev/null 2>&1
} }
local _unzstd
# shellcheck disable=SC2329 # shellcheck disable=SC2329
_unzstd() _unzstd()
{ {
@@ -128,6 +142,7 @@ utaz()
tar --zstd -xf "$1" -C "$2" tar --zstd -xf "$1" -C "$2"
} }
local _uncpio
# shellcheck disable=SC2329 # shellcheck disable=SC2329
_uncpio() _uncpio()
{ {
@@ -135,6 +150,7 @@ utaz()
(cd "$2" && cpio -id < "../$1") >/dev/null 2>&1 (cd "$2" && cpio -id < "../$1") >/dev/null 2>&1
} }
local _uncabextract
# shellcheck disable=SC2329 # shellcheck disable=SC2329
_uncabextract() _uncabextract()
{ {
@@ -142,6 +158,7 @@ utaz()
cabextract "$1" -d "$2/" >/dev/null 2>&1 cabextract "$1" -d "$2/" >/dev/null 2>&1
} }
local _undeb
# shellcheck disable=SC2329 # shellcheck disable=SC2329
_undeb() _undeb()
{ {
@@ -149,6 +166,7 @@ utaz()
dpkg-deb -x "$1" "$2/" >/dev/null 2>&1 dpkg-deb -x "$1" "$2/" >/dev/null 2>&1
} }
local _unrpm
# shellcheck disable=SC2329 # shellcheck disable=SC2329
_unrpm() _unrpm()
{ {
@@ -408,6 +426,7 @@ export -f utaz
taz() taz()
{ {
# Resolve runtime CPU count for --parallel=auto. # Resolve runtime CPU count for --parallel=auto.
local _taz_detect_cpus
_taz_detect_cpus() _taz_detect_cpus()
{ {
local cpus=1 local cpus=1
@@ -421,6 +440,7 @@ taz()
printf "%s\n" "$cpus" printf "%s\n" "$cpus"
} }
local _doxz
# shellcheck disable=SC2329 # shellcheck disable=SC2329
_doxz() _doxz()
{ {
@@ -441,6 +461,7 @@ taz()
return $? return $?
} }
local _dolz
# shellcheck disable=SC2329 # shellcheck disable=SC2329
_dolz() _dolz()
{ {
@@ -468,6 +489,7 @@ taz()
return $? return $?
} }
local _dogz
# shellcheck disable=SC2329 # shellcheck disable=SC2329
_dogz() _dogz()
{ {
@@ -495,6 +517,7 @@ taz()
return $? return $?
} }
local _dobz2
# shellcheck disable=SC2329 # shellcheck disable=SC2329
_dobz2() _dobz2()
{ {
@@ -522,6 +545,7 @@ taz()
return $? return $?
} }
local _dolzo
# shellcheck disable=SC2329 # shellcheck disable=SC2329
_dolzo() _dolzo()
{ {

View File

@@ -128,6 +128,7 @@ export -f set_colors
# D : debug (cyan) # D : debug (cyan)
disp() disp()
{ {
local _disp_print_wrapped
_disp_print_wrapped() _disp_print_wrapped()
{ {
local prefix="$1" local prefix="$1"
@@ -241,6 +242,7 @@ export -f disp
# Usage: mdcat [file] # Usage: mdcat [file]
mdcat() mdcat()
{ {
local _mdcat_style_inline
_mdcat_style_inline() _mdcat_style_inline()
{ {
local text="$1" local text="$1"
@@ -346,6 +348,7 @@ mdcat()
printf "%s\n" "$text" printf "%s\n" "$text"
} }
local _mdcat_print_hr
_mdcat_print_hr() _mdcat_print_hr()
{ {
local cols="${COLUMNS:-}" local cols="${COLUMNS:-}"
@@ -364,6 +367,7 @@ mdcat()
fi fi
} }
local _mdcat_print_code_block
_mdcat_print_code_block() _mdcat_print_code_block()
{ {
local lang="$1" local lang="$1"
@@ -422,14 +426,11 @@ mdcat()
printf "%b%s%b\n" "$frame_on" "$border" "$off" printf "%b%s%b\n" "$frame_on" "$border" "$off"
} }
local _mdcat_print_table
# That function is a bit slow, we need to try to optimize it
_mdcat_print_table() _mdcat_print_table()
{ {
local -a lines=("$@") local _mdcat_parse_table_row
local -a table_rows=()
local -a col_widths=()
local i j ncols=0
local sep=$'\x1f'
_mdcat_parse_table_row() _mdcat_parse_table_row()
{ {
local input="$1" local input="$1"
@@ -466,6 +467,12 @@ mdcat()
printf '%s' "$joined" printf '%s' "$joined"
} }
local -a lines=("$@")
local -a table_rows=()
local -a col_widths=()
local i j ncols=0
local sep=$'\x1f'
# Parse header and data rows, skipping the Markdown separator row. # Parse header and data rows, skipping the Markdown separator row.
# Width is computed from visible text length with ANSI escapes stripped. # Width is computed from visible text length with ANSI escapes stripped.
for ((i=0; i<${#lines[@]}; ++i)); do for ((i=0; i<${#lines[@]}; ++i)); do

View File

@@ -286,6 +286,7 @@ function timer_stop
# command, the elapsed time of the last command, and the current user and host. # command, the elapsed time of the last command, and the current user and host.
set_prompt() set_prompt()
{ {
local _prompt_git_segment
_prompt_git_segment() _prompt_git_segment()
{ {
# Fast path: skip git lookup when feature is disabled. # Fast path: skip git lookup when feature is disabled.
@@ -316,6 +317,7 @@ set_prompt()
printf "%s" "git:${branch}${dirty}${sync}" printf "%s" "git:${branch}${dirty}${sync}"
} }
local _prompt_conda_env
_prompt_conda_env() _prompt_conda_env()
{ {
[[ "${PROMPT_SHOW_CONDA:-1}" == "0" ]] && return 0 [[ "${PROMPT_SHOW_CONDA:-1}" == "0" ]] && return 0
@@ -323,6 +325,7 @@ set_prompt()
printf "%s" "conda:${CONDA_DEFAULT_ENV}" printf "%s" "conda:${CONDA_DEFAULT_ENV}"
} }
local _prompt_venv_env
_prompt_venv_env() _prompt_venv_env()
{ {
[[ "${PROMPT_SHOW_VENV:-1}" == "0" ]] && return 0 [[ "${PROMPT_SHOW_VENV:-1}" == "0" ]] && return 0
@@ -331,6 +334,7 @@ set_prompt()
printf "%s" "venv:${VIRTUAL_ENV##*/}" printf "%s" "venv:${VIRTUAL_ENV##*/}"
} }
local _prompt_session_markers
_prompt_session_markers() _prompt_session_markers()
{ {
[[ "${PROMPT_SHOW_SESSION:-1}" == "0" ]] && return 0 [[ "${PROMPT_SHOW_SESSION:-1}" == "0" ]] && return 0

View File

@@ -152,6 +152,7 @@ _rain_engine()
local term_area=0 local term_area=0
local frame_sleep="$step_duration" local frame_sleep="$step_duration"
local sigwinch
sigwinch() sigwinch()
{ {
term_width=$(tput cols) term_width=$(tput cols)
@@ -193,11 +194,13 @@ _rain_engine()
fi fi
} }
local do_exit
do_exit() do_exit()
{ {
exit_st=1 exit_st=1
} }
local do_render
do_render() do_render()
{ {
local idx=0 y=0 drop_color="" current_char="" render_color="" local idx=0 y=0 drop_color="" current_char="" render_color=""
@@ -293,6 +296,7 @@ _rain_engine()
# Usage: rain [OPTIONS] # Usage: rain [OPTIONS]
rain() rain()
{ {
local _rain_show_usage
_rain_show_usage() _rain_show_usage()
{ {
printf "Usage: rain [OPTIONS]\n" printf "Usage: rain [OPTIONS]\n"
@@ -389,6 +393,7 @@ export -f rain
# Usage: matrix [OPTIONS] # Usage: matrix [OPTIONS]
matrix() matrix()
{ {
local _matrix_show_usage
_matrix_show_usage() _matrix_show_usage()
{ {
printf "Usage: matrix [OPTIONS]\n" printf "Usage: matrix [OPTIONS]\n"