From 400a886af2703438d7acf748618bb833895a9cf8 Mon Sep 17 00:00:00 2001 From: Julien Caillon Date: Sat, 11 Jan 2025 19:08:20 +0100 Subject: [PATCH] :sparkles: working on compat with bash 5.0 --- commands.d/self-install.sh | 2 +- docs/content/docs/800.roadmap/_index.md | 2 +- libraries.d/core | 8 ++++++-- libraries.d/lib-prompt | 1 + .../docker-valet-test/Dockerfile | 16 ++++++++++++++-- 5 files changed, 23 insertions(+), 6 deletions(-) diff --git a/commands.d/self-install.sh b/commands.d/self-install.sh index 45414053..9dbe42d5 100644 --- a/commands.d/self-install.sh +++ b/commands.d/self-install.sh @@ -610,7 +610,7 @@ function selfUpdate_createShim() { local valetBin="${binDirectory}/valet" log::info "Creating a shim ⌜${valetBin}⌝ → ⌜${GLOBAL_VALET_HOME}/valet⌝." - ${_SUDO} bash -c "printf '#%s\n%s \"\$@\"' \"!/usr/bin/env bash\" \"'${GLOBAL_VALET_HOME}/valet'\" 1> \"${valetBin}\"" + ${_SUDO} bash -c "printf '#%s\nsource %s \"\$@\"' \"!/usr/bin/env bash\" \"'${GLOBAL_VALET_HOME}/valet'\" 1> \"${valetBin}\"" ${_SUDO} chmod +x "${valetBin}" } diff --git a/docs/content/docs/800.roadmap/_index.md b/docs/content/docs/800.roadmap/_index.md index 9424bbab..84d0cca5 100644 --- a/docs/content/docs/800.roadmap/_index.md +++ b/docs/content/docs/800.roadmap/_index.md @@ -8,7 +8,7 @@ url: /docs/roadmap This page lists the features that I would like to implement in Valet. They come in addition to new features described in the [issues][valet-issues]. -- Refactor the logging functions to be more readable, see if we really need to precalculate them or if we can just compute on the fly. +- Refactor the logging functions to be more readable, see if we really need to precalculate them or if we can just compute on the fly. Remove createPrintFunction on SIGWINCH. - Finish prompt and interactive functions: prompt user for multiline text. Prompt user for multi select. - core::checkParseResults typo... - Add a full screen view with the keyboard shortcuts in edit mode (new interactive::showFullScreenHelp ?). diff --git a/libraries.d/core b/libraries.d/core index 997ea38b..f120970d 100644 --- a/libraries.d/core +++ b/libraries.d/core @@ -23,8 +23,12 @@ set -o pipefail -o braceexpand -o errexit -o errtrace -o functrace -o nounset -o # +dotglob: disable inclusion of hidden files in filename expansion # +expand_aliases: disable alias expansion # +nocasematch: disable case-insensitive matching -shopt -s extquote globasciiranges globskipdots huponexit interactive_comments patsub_replacement progcomp -shopt -u assoc_expand_once cdable_vars checkhash checkjobs checkwinsize compat31 compat32 compat40 compat41 compat42 compat43 compat44 globstar localvar_inherit localvar_unset nocaseglob nocasematch noexpand_translation progcomp_alias shift_verbose varredir_close xpg_echo nullglob direxpand dirspell dotglob extglob failglob execfail expand_aliases inherit_errexit +shopt -s extquote globasciiranges huponexit interactive_comments progcomp +shopt -u assoc_expand_once cdable_vars checkhash checkjobs checkwinsize compat31 compat32 compat40 compat41 compat42 compat43 compat44 globstar localvar_inherit localvar_unset nocaseglob nocasematch progcomp_alias shift_verbose xpg_echo nullglob direxpand dirspell dotglob extglob failglob execfail expand_aliases inherit_errexit +if (( ${BASH_VERSINFO[1]} >= 2)); then + shopt -s globskipdots patsub_replacement + shopt -u varredir_close +fi # we check for this variable to know if this script has already been included GLOBAL_CORE_INCLUDED=1 diff --git a/libraries.d/lib-prompt b/libraries.d/lib-prompt index 77afaf4f..2a44464a 100644 --- a/libraries.d/lib-prompt +++ b/libraries.d/lib-prompt @@ -960,6 +960,7 @@ function prompt_filterItems() { rm -f "${_PROMPT_ITEMS_BOX_ASYNC_FILTERED_ITEMS_FILE}" &>/dev/null || : prompt_filterItemsAsync 1>&2 & GLOBAL_BACKGROUND_JOB1_PID="$!" + fi } diff --git a/tests.d/1106-self-install/docker-valet-test/Dockerfile b/tests.d/1106-self-install/docker-valet-test/Dockerfile index 3db401c3..094b8c44 100644 --- a/tests.d/1106-self-install/docker-valet-test/Dockerfile +++ b/tests.d/1106-self-install/docker-valet-test/Dockerfile @@ -8,11 +8,23 @@ ARG LOCALE=en_US ENV LANG=${LOCALE}.UTF-8 RUN \ apt-get update -qq; \ -apt-get install -qq -y curl sudo makepasswd uidmap git xonsh fish zsh csh tcsh ksh 1>/dev/null; \ +apt-get install -qq -y curl sudo makepasswd uidmap git xonsh fish zsh csh tcsh ksh build-essential wget 1>/dev/null; \ echo 'me' > /tmp/pw; \ useradd -m -u 1000 -U -p "$(makepasswd --crypt-md5 --clearfrom=/tmp/pw)" me; \ echo "me ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers.d/me-sudo; \ chsh -s /bin/bash me; \ curl -fsSL https://github.com/nushell/nushell/releases/download/0.100.0/nu-0.100.0-x86_64-unknown-linux-gnu.tar.gz -o nu.tar.gz; \ tar -xvf nu.tar.gz; \ -mv nu-0.100.0-x86_64-unknown-linux-gnu/nu /usr/local/bin/nu; \ No newline at end of file +mv nu-0.100.0-x86_64-unknown-linux-gnu/nu /usr/local/bin/nu; + +# now install bash 5.0 +SHELL ["/bin/sh", "-o", "errexit", "-o", "nounset", "-x", "-c"] + +RUN \ +cd /tmp; \ +wget http://ftp.gnu.org/gnu/bash/bash-5.0.tar.gz; \ +tar xf bash-5.0.tar.gz; \ +cd bash-5.0; \ +./configure; \ +make; \ +sudo make install; \ No newline at end of file