fix: unset local variables exported to environment

This commit is contained in:
Ben Grande 2025-02-27 15:25:16 +01:00
parent 6e0fe495cf
commit 11bc58a4dd
No known key found for this signature in database
GPG Key ID: 00C64E14F51F9E56
6 changed files with 44 additions and 13 deletions

View File

@ -124,7 +124,7 @@ if ! shopt -oq posix; then
source_readable /usr/share/bash-completion/bash_completion
fi
unset newline ps1_symbol dircolor reset_color usercolor
unset newline ps1_symbol dircolor usercolor
## }}}
## {{{ Plugins
if has zoxide; then

View File

@ -111,7 +111,8 @@ has qubesctl && {
alias qctlu="qctl --skip-dom0 --targets"
qctlus(){
test -n "${2-}" || return 1
qubesctl --skip-dom0 --targets "${1}" state.apply "${@}"
# shellcheck disable=SC3058
qubesctl --skip-dom0 --targets "${1}" state.apply "${@#"${1}"}"
}
}
has gpg && alias gpgs="gpg --show-keys"
@ -162,16 +163,19 @@ case "${TERM-}" in
iterm|*-truecolor)
export COLORTERM=truecolor; color_prompt=yes
;;
*-color|*-256color|linux*)
*-color|*-256color|linux*|vt100*|vt220*)
color_prompt=yes
;;
""|dumb|vt100*|vt220*)
""|dumb)
color_prompt=no
;;
*)
color_prompt=no
;;
esac
if test -n "${NO_COLOR-}"; then
color_prompt=no
fi
## Colorise "ls" output.
if test "${color_prompt-}" = "yes"; then

View File

@ -99,11 +99,11 @@ _set_title() {
}
case "${TERM-}" in
screen*)
screen*|tmux*)
precmd() {
_set_title "$@"
if [ "${STY:-}" -o "${TMUX:-}" ]; then
# print -Pn "\033]1;\a\033]1;@%m\a"
print -Pn '\033]1;\a\033]1;@%m\a'
print -Pn '\033k@\033\\'
else
print -Pn '\033k@%m\033\\'

View File

@ -1,6 +1,6 @@
#!/bin/sh
## SPDX-FileCopyrightText: 2024 Benjamin Grande M. S. <ben.grande.b@gmail.com>
## SPDX-FileCopyrightText: 2024 - 2025 Benjamin Grande M. S. <ben.grande.b@gmail.com>
##
## SPDX-License-Identifier: GFDL-1.3-or-later
##
@ -46,6 +46,12 @@ if test "${#}" -eq 0; then
unset term_file_active
fi
sc="$(tput sc || printf '%b' '\0337')"
rc="$(tput rc || printf '%b' '\0338')"
cup="$(tput cup 99999 99999 || printf '%b' '\033[99999;99999H')"
csr="$(tput csr || printf '%b' '\033[r')"
gc="$(tput u7 || printf '%b' '\033[6n')"
## POSIX compliant.
# shellcheck disable=SC3045
if ! printf '%s\n' "R" | read -r -t 1 -sd R 2>/dev/null; then
@ -58,7 +64,7 @@ if ! printf '%s\n' "R" | read -r -t 1 -sd R 2>/dev/null; then
## Slow due to heavy stty calls.
termios="$(stty -g)"
stty raw -echo min 0 time 1
printf '\0337\033[r\033[99999;99999H\033[6n\0338' >/dev/tty
printf '%s' "${sc}${csr}${cup}${gc}${rc}" >/dev/tty
IFS='[;R' read -r _ rows cols _ </dev/tty
stty "${termios}" cols "${cols}" rows "${rows}"
unset termios
@ -67,7 +73,7 @@ fi
## Non-POSIX compliant and fast.
stty -echo
printf '\0337\033[r\033[99999;99999H\033[6n\0338' >/dev/tty
printf '%s' "${sc}${csr}${cup}${gc}${rc}" >/dev/tty
# shellcheck disable=3045,SC2034
IFS='[;R' read -r -t 1 -s -d R _ rows cols _ </dev/tty || {
printf '%s\n' "${msg_unsupported}" >&2

View File

@ -17,8 +17,7 @@ set-option -g history-limit 10000
set-option -g repeat-time 2000
set-option -g escape-time 50
set-option -g status-position top
set-option -g default-terminal screen-256color
# set-option -g default-terminal tmux-256color # on newer ncurses
set-option -g default-terminal tmux-256color
set-option -g display-panes-time 2000
set-option -g display-time 2000
set-option -g focus-events on

View File

@ -48,12 +48,34 @@ desktop_autostart(){
for f in "${autostart_etc}"/*.desktop "${autostart_home}"/*.desktop; do
test -r "${f}" || continue
## TODO: check other conditions: (Not|Only)ShowIn
# shellcheck disable=SC2091
autostart_hidden="$(awk -F '=' -- '/^Hidden=/{print $2}' "${f}")"
if test "${autostart_hidden}" = "true"; then
continue
fi
autostart_tryexec="$(awk -F '=' -- '/^TryExec=/{print $2}' "${f}")"
if test -n "${autostart_tryexec}"; then
case "${autostart_tryexec}" in
/*) test -x "${autostart_tryexec}" || continue;;
*) command -v "${autostart_tryexec}" >/dev/null || continue;;
esac
fi
autostart_path="$(awk -F '=' -- '/^Path=/{print $2}' "${f}")"
autostart_exec="$(awk -F '=' -- '/^Exec=/{print $2}' "${f}")"
command -v "${autostart_exec%% *}" >/dev/null || continue
case "${autostart_exec}" in
/*) test -x "${autostart_exec}" || continue;;
*) command -v "${autostart_exec}" >/dev/null || continue;;
esac
if test -n "${autostart_path}"; then
if ! test -d "${autostart_path}"; then
continue
fi
cd "${autostart_path}" || continue
fi
${autostart_exec} &
done
unset f
unset f autostart_hidden autostart_tryexec autostart_exec autostart_path
}
## Source Xorg profiles.