From 79f580c97ab046d978b64494ef31164d8d2c56ff Mon Sep 17 00:00:00 2001 From: jkool702 <107448833+jkool702@users.noreply.github.com> Date: Mon, 5 Aug 2024 11:03:27 -0400 Subject: [PATCH] Update forkrun.bash --- forkrun.bash | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/forkrun.bash b/forkrun.bash index 4e7884e..18a6f1c 100644 --- a/forkrun.bash +++ b/forkrun.bash @@ -1603,21 +1603,23 @@ EOF forkrun_lseek_setup() { ## sets up a "lseek" bash builtin for x86_64 machines + local lseekPreFlag=false type uname &>/dev/null && { [[ $(uname -m) == 'x86_64' ]] || return 1; } [[ -f /proc/sys/kernel/arch ]] && { [[ "$(/dev/null || { + [[ -f /usr/local/lib/bash/lseek ]] && lseekPreFlag=true case "${USER}" in root) mkdir -p /usr/local/lib/bash - [[ -f /usr/local/lib/bash/lseek ]] && mv /usr/local/lib/bash/lseek /usr/local/lib/bash/lseek.old + ${lseekPreFlag} && \mv /usr/local/lib/bash/lseek /usr/local/lib/bash/lseek.old [[ "${BASH_LOADABLES_PATH}" == */usr/local/lib/bash* ]] || export BASH_LOADABLES_PATH=/usr/local/lib/bash:${BASH_LOADABLES_PATH} curl -o /usr/local/lib/bash/lseek 'https://raw.githubusercontent.com/jkool702/forkrun/main/lseek_builtin/lseek' ;; *) mkdir -p /dev/shm/.forkrun.lseek - [[ -f /dev/shm/.forkrun.lseek/lseek ]] && mv /dev/shm/.forkrun.lseek/lseek /dev/shm/.forkrun.lseek/lseek.old + ${lseekPreFlag} && \mv /dev/shm/.forkrun.lseek/lseek /dev/shm/.forkrun.lseek/lseek.old [[ "${BASH_LOADABLES_PATH}" == */dev/shm/.forkrun.lseek* ]] || export BASH_LOADABLES_PATH=/dev/shm/.forkrun.lseek:${BASH_LOADABLES_PATH} curl -o /dev/shm/.forkrun.lseek/lseek 'https://raw.githubusercontent.com/jkool702/forkrun/main/lseek_builtin/lseek' ;; @@ -1644,8 +1646,10 @@ forkrun_lseek_setup() { printf '\nWARNING: lseek functionality has not been enabled due to an unknown runtime error.\nIf you are on x86_64 and are using bash 4.0 or later, please file a github issue in the forkrun repo describing this error.\n' >&2 if [[ "${USER}" == 'root' ]]; then \rm -f /usr/local/lib/bash/lseek + ${lseekPreFlag} && mv /usr/local/lib/bash/lseek.old /usr/local/lib/bash/lseek else \rm -f /dev/shm/.forkrun.lseek/lseek + ${lseekPreFlag} && mv /dev/shm/.forkrun.lseek/lseek.old /dev/shm/.forkrun.lseek/lseek fi return 1 ;;