no more stderr
This commit is contained in:
+2
-1
@@ -641,6 +641,7 @@ function parse_options {
|
|||||||
builtin exit
|
builtin exit
|
||||||
;;
|
;;
|
||||||
--initiate)
|
--initiate)
|
||||||
|
#TODO: remove, self_upgrade does it anyway
|
||||||
initiate
|
initiate
|
||||||
builtin exit
|
builtin exit
|
||||||
;;
|
;;
|
||||||
@@ -694,7 +695,7 @@ else
|
|||||||
[[ -t 2 ]] && MAIN_FD_STDERR=false || MAIN_FD_STDERR=true
|
[[ -t 2 ]] && MAIN_FD_STDERR=false || MAIN_FD_STDERR=true
|
||||||
exec 4>/dev/tty
|
exec 4>/dev/tty
|
||||||
fi
|
fi
|
||||||
exec 3>/dev/stderr 2>"$MIAOU_BASH_ERROR"
|
exec 3>&2 2>"$MIAOU_BASH_ERROR"
|
||||||
miaou_debug "<main file=$BASH_ARGV0 pid=${BASHPID}/>"
|
miaou_debug "<main file=$BASH_ARGV0 pid=${BASHPID}/>"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
+2
-5
@@ -152,8 +152,8 @@ function __vte_urlencode {
|
|||||||
### MAIN
|
### MAIN
|
||||||
###------
|
###------
|
||||||
|
|
||||||
MIAOU_BASH_DIR=/opt/miaou-bash
|
# If not running interactively, don't do anything
|
||||||
export MIAOU_BASH_DIR
|
[[ $- != *i* ]] && return
|
||||||
|
|
||||||
## Add path for TOOLBOX if any
|
## Add path for TOOLBOX if any
|
||||||
[[ -d "/TOOLBOX" ]] && PATH=$PATH:/TOOLBOX || true
|
[[ -d "/TOOLBOX" ]] && PATH=$PATH:/TOOLBOX || true
|
||||||
@@ -161,9 +161,6 @@ export MIAOU_BASH_DIR
|
|||||||
# Add path to any tools folder in /opt/miaou-*
|
# Add path to any tools folder in /opt/miaou-*
|
||||||
for i in {/opt,$HOME}/miaou-*/tools; do [[ -d "$i" ]] && PATH=$PATH:$i; done || true
|
for i in {/opt,$HOME}/miaou-*/tools; do [[ -d "$i" ]] && PATH=$PATH:$i; done || true
|
||||||
|
|
||||||
# If not running interactively, don't do anything
|
|
||||||
[[ $- != *i* ]] && return
|
|
||||||
|
|
||||||
HOSTNAME=$(hostname -f)
|
HOSTNAME=$(hostname -f)
|
||||||
|
|
||||||
# don't put duplicate lines or lines starting with space in the history.
|
# don't put duplicate lines or lines starting with space in the history.
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
MIAOU_BASH_DIR=/opt/miaou-bash
|
||||||
|
export MIAOU_BASH_DIR
|
||||||
|
|
||||||
|
PATH=$PATH:$MIAOU_BASH_DIR/bin
|
||||||
+5
-2
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
## CONSTANTS
|
## CONSTANTS
|
||||||
|
|
||||||
MIAOU_BASH_DIR=/opt/miaou-bash
|
|
||||||
MAIN_TAR_GZ_URL="https://git.artcode.re/miaou/miaou-bash/archive/main.tar.gz"
|
MAIN_TAR_GZ_URL="https://git.artcode.re/miaou/miaou-bash/archive/main.tar.gz"
|
||||||
|
|
||||||
## FUNCTIONS
|
## FUNCTIONS
|
||||||
@@ -27,7 +26,11 @@ deployment_type_adjective="${1:-installed}"
|
|||||||
[[ "$UID" -ne 0 ]] && echo 'root privilege required' && exit 1
|
[[ "$UID" -ne 0 ]] && echo 'root privilege required' && exit 1
|
||||||
! assert_supported_distro && echo 'unsupported distro: debian-like OR arch-like expected' && exit 2
|
! assert_supported_distro && echo 'unsupported distro: debian-like OR arch-like expected' && exit 2
|
||||||
|
|
||||||
export MIAOU_BASH_DIR
|
if [[ ! -v MIAOU_BASH_DIR ]]; then
|
||||||
|
MIAOU_BASH_DIR=/opt/miaou-bash
|
||||||
|
export MIAOU_BASH_DIR
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -d "$MIAOU_BASH_DIR" && -L /etc/inputrc && "$(readlink /etc/inputrc)" == "$MIAOU_BASH_DIR"/etc/inputrc ]]; then
|
if [[ -d "$MIAOU_BASH_DIR" && -L /etc/inputrc && "$(readlink /etc/inputrc)" == "$MIAOU_BASH_DIR"/etc/inputrc ]]; then
|
||||||
. "$MIAOU_BASH_DIR"/bin/miaou-bash "$MIAOU_BASH_DIR/lib/self-upgrade.bash"
|
. "$MIAOU_BASH_DIR"/bin/miaou-bash "$MIAOU_BASH_DIR/lib/self-upgrade.bash"
|
||||||
else
|
else
|
||||||
|
|||||||
+11
-2
@@ -68,8 +68,16 @@ EOF
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function is_arch_like {
|
||||||
|
[[ "$DISTRO_LIKE" == 'arch' ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
function is_debian_like {
|
||||||
|
[[ "$DISTRO_LIKE" == 'debian' ]]
|
||||||
|
}
|
||||||
|
|
||||||
function link_config_files {
|
function link_config_files {
|
||||||
[[ "$DISTRO_LIKE" == 'arch' ]] && arch_vimrc
|
is_arch_like && arch_vimrc
|
||||||
|
|
||||||
link_etc vimrc.core vim
|
link_etc vimrc.core vim
|
||||||
link_etc vimrc.miaou vim
|
link_etc vimrc.miaou vim
|
||||||
@@ -81,6 +89,7 @@ function link_config_files {
|
|||||||
else
|
else
|
||||||
link_etc vimrc.local vim
|
link_etc vimrc.local vim
|
||||||
fi
|
fi
|
||||||
|
link_etc 20-miaou-bash.sh profile.d
|
||||||
link_etc bash.bashrc
|
link_etc bash.bashrc
|
||||||
link_etc inputrc # last command required to detect successful installation
|
link_etc inputrc # last command required to detect successful installation
|
||||||
}
|
}
|
||||||
@@ -157,7 +166,7 @@ function ghostty_global_config {
|
|||||||
|
|
||||||
source "$MIAOU_BASH_DIR/lib/functions.bash"
|
source "$MIAOU_BASH_DIR/lib/functions.bash"
|
||||||
assert_root
|
assert_root
|
||||||
usr_bin_miaou_bash
|
|
||||||
DISTRO_LIKE=$(fetch_distro_like)
|
DISTRO_LIKE=$(fetch_distro_like)
|
||||||
install_required_packages
|
install_required_packages
|
||||||
rm_bashrc_skeleton
|
rm_bashrc_skeleton
|
||||||
|
|||||||
@@ -2,21 +2,19 @@
|
|||||||
|
|
||||||
# CONSTANTS
|
# CONSTANTS
|
||||||
|
|
||||||
[[ ! -v MAIN_TAR_GZ_URL ]] &&
|
|
||||||
readonly MAIN_TAR_GZ_URL="https://git.artcode.re/miaou/miaou-bash/archive/main.tar.gz"
|
|
||||||
|
|
||||||
# FUNCTIONS
|
# FUNCTIONS
|
||||||
|
|
||||||
function self_upgrade {
|
function self_upgrade {
|
||||||
mv "$MIAOU_BASH_DIR" "$MIAOU_BASH_DIR".before_upgrade
|
local backup="$MIAOU_BASH_DIR".before_upgrade
|
||||||
if "$MIAOU_BASH_DIR".before_upgrade/install.sh upgraded; then
|
mv "$MIAOU_BASH_DIR" "$backup"
|
||||||
rm -rf "$MIAOU_BASH_DIR".before_upgrade
|
if "$backup"/install.sh upgraded; then
|
||||||
|
rm -rf "$backup"
|
||||||
echo -n "version: "
|
echo -n "version: "
|
||||||
. "$MIAOU_BASH_DIR"/bin/miaou-bash --version
|
. "$MIAOU_BASH_DIR"/bin/miaou-bash --version
|
||||||
else
|
else
|
||||||
echo "ERROR: trouble during self-upgrade: revert back"
|
echo "ERROR: trouble during self-upgrade: revert back"
|
||||||
rm -rf "$MIAOU_BASH_DIR"
|
rm -rf "$MIAOU_BASH_DIR"
|
||||||
mv "$MIAOU_BASH_DIR".before_upgrade "$MIAOU_BASH_DIR"
|
mv "$backup" "$MIAOU_BASH_DIR"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,6 +27,7 @@ assert_root
|
|||||||
current=$(miaou-bash --version)
|
current=$(miaou-bash --version)
|
||||||
latest=$("$MIAOU_BASH_DIR/tools/wget_semver" artcode miaou/miaou-bash)
|
latest=$("$MIAOU_BASH_DIR/tools/wget_semver" artcode miaou/miaou-bash)
|
||||||
if [[ "$current" == "$latest" ]]; then
|
if [[ "$current" == "$latest" ]]; then
|
||||||
|
. "$MIAOU_BASH_DIR"/bin/miaou-bash --initiate
|
||||||
echo "up-to-date version: $current"
|
echo "up-to-date version: $current"
|
||||||
else
|
else
|
||||||
self_upgrade
|
self_upgrade
|
||||||
|
|||||||
@@ -10,6 +10,17 @@ readonly TMP_DIRECTORY TMP_OUT TMP_ERR TMP_MIAOU
|
|||||||
|
|
||||||
# functions
|
# functions
|
||||||
|
|
||||||
|
function assert_stderr {
|
||||||
|
((test_count++))
|
||||||
|
if [[ -w /dev/stderr ]]; then
|
||||||
|
echo -n .
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
echo -n F
|
||||||
|
failures+=("test -w /dev/stderr")
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
function assert {
|
function assert {
|
||||||
((test_count++))
|
((test_count++))
|
||||||
cmd="$MIAOU_BASH_DIR/test/stub/scenario.bash $1"
|
cmd="$MIAOU_BASH_DIR/test/stub/scenario.bash $1"
|
||||||
@@ -113,7 +124,6 @@ function fail_miaou_count {
|
|||||||
local regex count="$2"
|
local regex count="$2"
|
||||||
|
|
||||||
cmd="$MIAOU_BASH_DIR/test/stub/scenario.bash $1"
|
cmd="$MIAOU_BASH_DIR/test/stub/scenario.bash $1"
|
||||||
# mapfile -t stderr <<<"$(miaou-bash ./test/stub/scenario.bash "$1" 2>&1 >/dev/null 3>/dev/null)"
|
|
||||||
if ! $cmd >/dev/null 2>/dev/null 3>"$TMP_MIAOU"; then
|
if ! $cmd >/dev/null 2>/dev/null 3>"$TMP_MIAOU"; then
|
||||||
mapfile -t miaou <"$TMP_MIAOU"
|
mapfile -t miaou <"$TMP_MIAOU"
|
||||||
if [[ "${#miaou[@]}" == "$count" ]]; then
|
if [[ "${#miaou[@]}" == "$count" ]]; then
|
||||||
@@ -138,6 +148,8 @@ mkdir -p "$TMP_DIRECTORY"
|
|||||||
TIMEFORMAT=$'\nelapsed: %Rs'
|
TIMEFORMAT=$'\nelapsed: %Rs'
|
||||||
|
|
||||||
time {
|
time {
|
||||||
|
assert_stderr
|
||||||
|
|
||||||
assert success
|
assert success
|
||||||
assert exit_0
|
assert exit_0
|
||||||
assert return_conditional
|
assert return_conditional
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ function show_error {
|
|||||||
>&2 printf '\r'
|
>&2 printf '\r'
|
||||||
>&2 ansi_block_error "$failure_type" "$failure_payload" "$code"
|
>&2 ansi_block_error "$failure_type" "$failure_payload" "$code"
|
||||||
>&2 ansi_traces stack_sources stack_lines stack_functions
|
>&2 ansi_traces stack_sources stack_lines stack_functions
|
||||||
# [[ -p /dev/stdout ]] && kill -TERM $$
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function echo_return {
|
function echo_return {
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
# CONSTANTS
|
# CONSTANTS
|
||||||
|
|
||||||
[[ ! -v MIAOU_BASH_DIR ]] && readonly MIAOU_BASH_DIR=/opt/miaou-bash && export MIAOU_BASH_DIR
|
|
||||||
|
|
||||||
# functions
|
# functions
|
||||||
|
|
||||||
function usage {
|
function usage {
|
||||||
|
|||||||
Reference in New Issue
Block a user