From 8620574a5533695525260fd88df8d249c701217f Mon Sep 17 00:00:00 2001 From: vladislav doster <10052309+vladdoster@users.noreply.github.com> Date: Wed, 18 May 2022 14:36:23 -0500 Subject: [PATCH] fix: account for systems where musl is present (#269) Signed-off-by: Vladislav Doster --- .github/workflows/tests.yaml | 31 +++-- scripts/install.sh | 2 +- scripts/test-scripts/test-excl-id-as | 192 --------------------------- scripts/test-scripts/test-id-as | 182 ------------------------- scripts/zunit-tests.sh | 14 -- tests/_support/bootstrap | 4 +- tests/gh-r.zunit | 152 +++++++++++---------- zinit-autoload.zsh | 4 +- zinit-install.zsh | 176 +++++++++++++----------- 9 files changed, 206 insertions(+), 551 deletions(-) delete mode 100644 scripts/test-scripts/test-excl-id-as delete mode 100644 scripts/test-scripts/test-id-as delete mode 100755 scripts/zunit-tests.sh diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 804013ea1..3ba63363c 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -4,8 +4,8 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true -# env: -# TERM: xterm +env: + TERM: xterm-256color on: pull_request: @@ -15,6 +15,7 @@ on: - 'tests/**' - 'share/**' - 'zinit*.zsh' + - '.github/workflows/tests.yaml' push: branches: - main @@ -27,7 +28,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: ['macos-10.15', 'macos-11', 'macos-12', 'ubuntu-18.04', 'ubuntu-20.04','ubuntu-22.04'] + os: ['macos-10.15','macos-11','macos-12','ubuntu-20.04','ubuntu-22.04'] fail-fast: true steps: @@ -36,25 +37,31 @@ jobs: with: fetch-depth: 0 + - name: "upgrade glibc" + if: runner.os == 'Linux' + run: | + sudo apt-get clean && sudo apt-get update + sudo apt-get install \ + build-essential subversion \ + gcc gcc-multilib \ + glibc-source libc6 libc6-dev \ + musl musl-dev musl-tools + - name: "install ncurses, svn, unzip, and zsh" run: | - brew install ncurses, svn, unzip, and zsh + brew install ncurses svn unzip zsh exec bash echo "eval $(brew shellenv)" > .profile - name: "install revolver" run: | - git clone https://github.com/molovo/revolver revolver - chmod u+x revolver/revolver - mv revolver/revolver /usr/local/bin + git clone --depth 1 https://github.com/molovo/revolver revolver + chmod u+x revolver/revolver; mv revolver/revolver /usr/local/bin; - name: "install zunit" run: | - git clone https://github.com/zdharma-continuum/zunit - cd ./zunit - zsh -c -l './build.zsh' - chmod u+x ./zunit - cp ./zunit /usr/local/bin + git clone --depth 1 https://github.com/zdharma-continuum/zunit; cd ./zunit + zsh -c -l './build.zsh' && cp ./zunit /usr/local/bin && chmod u+x ./zunit - name: 'clean up zunit & revolver' run: rm -rf revolver zunit diff --git a/scripts/install.sh b/scripts/install.sh index c1abecd18..15444fe36 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -106,7 +106,7 @@ download_git_output_processor() { echo_info "Fetching git-process-output.zsh from $url" if command -v curl > /dev/null 2>&1; then - curl -fsSL -o "$script_path" "$url" + curl --tcp-fastopen -fsSL -o "$script_path" "$url" elif command -v wget > /dev/null 2>&1; then wget -q -O "$script_path" "$url" fi diff --git a/scripts/test-scripts/test-excl-id-as b/scripts/test-scripts/test-excl-id-as deleted file mode 100644 index 9675d4a91..000000000 --- a/scripts/test-scripts/test-excl-id-as +++ /dev/null @@ -1,192 +0,0 @@ -# fpath+=( `pwd`/doc ) -# autoload test-id-as -# test-id-as -# -# Introduction of id-as (an ice-mod that allows to nickname -# any snippet or plugin) is a set of so many changes that -# more tests were needed, thus this file was created, real -# tests would took too long. -# -# Creates PLUGINS_DIR and SNIPPETS_DIR in /tmp. Can obtain -# --reuse option, to reuse existing PLUGINS_DIR & SNIPPETS_DIR. - -autoload colors; colors - -setopt localtraps typesetsilent - -typeset -g plg_bkp="${ZPLGM[PLUGINS_DIR]}" snp_bkp="${ZPLGM[SNIPPETS_DIR]}" argv1="$1" argv2="$2" -[[ -z "$plg_bkp" || -z "$snp_bkp" ]] && { print "Zplugin not loaded? (the \$ZPLGM hash is missing fields)"; return 1; } -[[ "$plg_bkp" != /* || $snp_bkp != /* ]] && { print "PLUGINS_DIR and/or SNIPPETS_DIR isn't an absolute path, aborting"; return 1; } - -if [[ "$argv1" != "--reuse" && "$argv2" != "--reuse" ]]; then - command rm -rf /tmp/zplg_plgs /tmp/zplg_snps - command mkdir -p /tmp/zplg_plgs /tmp/zplg_snps - - ZPLGM[PLUGINS_DIR]=/tmp/zplg_plgs ZPLGM[SNIPPETS_DIR]=/tmp/zplg_snps - - trap '[[ $argv1 != "--keep" && $argv2 != "--keep" ]] && { ZPLGM[PLUGINS_DIR]=$plg_bkp; ZPLGM[SNIPPETS_DIR]=$snp_bkp; } || { print; print "Kept ${ZPLGM[PLUGINS_DIR]} :: ${ZPLGM[SNIPPETS_DIR]}"; }; return 0;' EXIT INT TERM QUIT -fi - -local INITIAL_CD="$PWD" -cd /tmp -print; print -- "$fg[green]..........Working dir: $PWD$reset_color.........." - -print -- "Removing test-plugins & snippets from disk ..." - -# This removal is in case of --reuse being passed to this script - -command rm -rf -- ${ZPLGM[PLUGINS_DIR]}/mvdan---sh/ \ - ${ZPLGM[PLUGINS_DIR]}/oz---safe-paste \ - ${ZPLGM[PLUGINS_DIR]}/junegunn---fzf-bin \ - ${ZPLGM[PLUGINS_DIR]}/my---jun---gun \ - ${ZPLGM[PLUGINS_DIR]}/myid \ - ${ZPLGM[PLUGINS_DIR]}/myid---sub---1 \ - ${ZPLGM[PLUGINS_DIR]}/my---pure - -command rm -rf -- ${ZPLGM[SNIPPETS_DIR]}/https--github.com--robbyrussell--oh-my-zsh--trunk--plugins \ - ${ZPLGM[SNIPPETS_DIR]}/MY-UNIQUE \ - ${ZPLGM[SNIPPETS_DIR]}/my \ - ${ZPLGM[SNIPPETS_DIR]}/myid/sub - -print -- "Done." - -print; print -- "\n\n\n$fg[green]----------\nInstalling $fg[red]>\`github-$fg_bold[magenta]binary$fg_no_bold[red]'< $fg[magenta]mvdan$reset_color/$fg[yellow]sh$fg_bold[red] without$fg_no_bold[red] id-as nickname$reset_color" -print zplugin ice from"gh-r" as"command" mv\""shfmt* -> shfmt"\"\; zplugin load mvdan/sh -zplugin ice from"gh-r" as"command" mv"shfmt* -> shfmt"; zplugin load mvdan/sh -zplugin cd mvdan/sh; ls -lthd .*(N) *(N) -cd $OLDPWD -zplugin delete mvdan/sh -zplugin cd mvdan/sh && ls -lthd .*(N) *(N) - -sleep 3 - -print; print -- "\n\n\n$fg[green]----------\nInstalling $fg[red]>\`single-file plugin' $fg[magenta]oz$reset_color/$fg[yellow]safe-paste$fg_bold[red] without$fg_no_bold[red] id-as nickname$reset_color" -print zplugin load oz/safe-paste -zplugin load oz/safe-paste -zplugin cd oz/safe-paste; ls -lthd .*(N) *(N) -cd $OLDPWD -zplugin delete oz/safe-paste -zplugin cd oz/safe-paste && ls -lthd .*(N) *(N) - -sleep 3 - -print; print -- "\n\n\n$fg[green]----------\nInstalling $fg[red]>\`github-$fg_bold[magenta]binary$fg_no_bold[red]'< $fg[magenta]junegunn$reset_color/$fg[yellow]fzf-bin$fg_bold[red] without$fg_no_bold[red] id-as nickname$reset_color" -print zplugin ice from"gh-r" as"command" mv"fzf* -> fzf1" atpull\'"!rm -f fzf2; touch fzf.txt"\'\; zplugin light junegunn/fzf-bin -zplugin ice from"gh-r" as"command" mv"fzf* -> fzf1" atpull'!rm -f fzf2; touch fzf.txt'; zplugin light junegunn/fzf-bin -zplugin cd junegunn/fzf-bin; ls -lthd .*(N) *(N) -cd $OLDPWD -zplugin delete junegunn/fzf-bin -zplugin cd junegunn/fzf-bin && ls -lthd .*(N) *(N) - -sleep 3 - -print; print -- "\n\n\n$fg[green]----------\nInstalling $fg[red]>\`github-$fg_bold[magenta]binary$fg_no_bold[red]'< $fg[magenta]junegunn$reset_color/$fg[yellow]fzf-bin$fg_bold[green] AS ::\`$fg[red]!my/jun/gun$fg_bold[green]'::$reset_color" -print zplugin ice from"gh-r" as"command" mv"fzf* -> fzf2" id-as\"\\\\\!my/jun/gun\"\; zplugin load junegunn/fzf-bin -zplugin ice from"gh-r" as"command" mv"fzf* -> fzf2" id-as"!my/jun/gun"; zplugin load junegunn/fzf-bin -zplugin cd my/jun/gun; ls -lthd .*(N) *(N) -cd $OLDPWD -zplugin delete my/jun/gun -zplugin cd my/jun/gun && ls -lthd .*(N) *(N) - -sleep 3 - -print; print -- "\n\n\n$fg[green]----------\nInstalling $fg[red]>\`theme'< $fg[magenta]agkozak$reset_color/$fg[yellow]agkozak-zsh-theme$fg_bold[green] AS ::\`$fg[red]!myid$fg_bold[green]'::$reset_color" -print zplugin ice id-as\"\\\\\!myid\"\; zplugin load agkozak/agkozak-zsh-theme -zplugin ice id-as"!myid"; zplugin load agkozak/agkozak-zsh-theme -zplugin cd myid; ls -lthd .*(N) *(N) -cd $OLDPWD -zplugin delete myid -zplugin cd myid && ls -lthd .*(N) *(N) - -sleep 3 - -print; print -- "$fg[green]Unloading $fg[red]::\`myid'::$fg[green] (agkozak/agkozak-zsh-theme)$reset_color" -zplugin unload myid > /tmp/myid.unload.txt -head -n 4 /tmp/myid.unload.txt -head -n 17 /tmp/myid.unload.txt | tail -n 4 - -sleep 5 - -print; print -- "\n\n\n$fg[green]----------\nInstalling $fg[red]>\`theme'< $fg[magenta]agkozak$reset_color/$fg[yellow]agkozak-zsh-theme$fg_bold[green] AS ::\`$fg[red]!myid/sub/1$fg_bold[green]'::$reset_color" -print zplugin ice id-as\"\\\\\!myid/sub/1\"\; zplugin load agkozak/agkozak-zsh-theme -zplugin ice id-as"!myid/sub/1"; zplugin load agkozak/agkozak-zsh-theme -zplugin cd myid/sub/1; ls -lthd .*(N) *(N) -cd $OLDPWD -zplugin delete myid/sub/1 -zplugin cd myid/sub/1 && ls -lthd .*(N) *(N) - -sleep 3 - -print; print -- "$green[green]Report of $fg[red]::\`myid/sub/1'::$fg[green] (agkozak/agkozak-zsh-theme)$reset_color" -zplugin report myid/sub/1 > /tmp/myid--sub--1.report.txt -head -n 10 /tmp/myid--sub--1.report.txt | tail -n 8 - -sleep 5 - -print; print -- "$fg[green]Unloading $fg[red]::\`myid/sub/1'::$fg[green] (agkozak/agkozak-zsh-theme)$reset_color" -zplugin unload myid/sub/1 > /tmp/myid--sub--1.unload.txt -head -n 4 /tmp/myid--sub--1.unload.txt -head -n 17 /tmp/myid--sub--1.unload.txt | tail -n 4 - -sleep 5 - -print; print -- "\n\n\n$fg[green]----------\nInstalling $fg[red]>\`theme'< $fg[magenta]sindresorhus$reset_color/$fg[yellow]pure$fg_bold[green] AS ::\`$fg[red]!my/pure$fg_bold[green]'::$reset_color" -print zplugin ice multisrc\"\{async,pure\}.zsh\" pick"/dev/null" id-as\"\\\\\!my/pure\"\; zplugin load sindresorhus/pure -zplugin ice multisrc"{async,pure}.zsh" pick"/dev/null" id-as"!my/pure"; zplugin load sindresorhus/pure -zplugin cd my/pure; ls -lthd .*(N) *(N) -cd $OLDPWD -zplugin delete my/pure -zplugin cd my/pure && ls -lthd .*(N) *(N) - -sleep 3 - -print -print -- "\n\n\n"$fg_bold[red]SNIPPETS START NOW$reset_color - -print; print -- "\n\n\n$fg[green]----------\nInstalling $fg[red]>\`OMZ plugin (svn)'< $fg[magenta]OMZ::plugins$reset_color/$fg[yellow]pip$fg_bold[red] without$fg_no_bold[red] id-as nickname$reset_color" -zplugin ice svn; zplugin snippet OMZ::plugins/pip -zplugin cd OMZ::plugins/pip; ls -lthd .*(N) *(N) -sleep 3 -zplugin creinstall %SNIPPETS/OMZ::plugins/pip -sleep 3 -cd $OLDPWD -zplugin delete OMZ::plugins/pip -zplugin cd OMZ::plugins/pip && ls -lthd .*(N) *(N) -zplugin cclear - -sleep 3 - -print; print -- "\n\n\n$fg[green]----------\nInstalling $fg[red]>\`single-file command-snippet' $fg[magenta]GH::Osse/git-scripts/blob/master/git-unique$fg_bold[green] AS ::\`$fg[red]!MY-UNIQUE$fg_bold[green]'::$reset_color" -zplugin ice as"program" id-as\"\\\\\!MY-UNIQUE\"; zplugin snippet https://github.com/Osse/git-scripts/blob/master/git-unique -zplugin ice as"program" id-as"!MY-UNIQUE"; zplugin snippet https://github.com/Osse/git-scripts/blob/master/git-unique -zplugin cd MY-UNIQUE; ls -lthd .*(N) *(N) -cd $OLDPWD -zplugin delete MY-UNIQUE -zplugin cd MY-UNIQUE && ls -lthd .*(N) *(N) - -sleep 3 - -print; print -- "\n\n\n$fg[green]----------\nInstalling $fg[red]>\`OMZ plugin (svn)'< $fg[magenta]OMZ::plugins$reset_color/$fg[yellow]git$fg_bold[green] AS ::\`$fg[red]!my$fg_bold[green]'::$reset_color" -print zplugin ice svn id-as\"\\\\\!my\"\; zplugin snippet OMZ::plugins/git -zplugin ice svn id-as"!my"; zplugin snippet OMZ::plugins/git -zplugin cd my; ls -lthd .*(N) *(N) -cd $OLDPWD -zplugin delete my -zplugin cd my && ls -lthd .*(N) *(N) - -sleep 3 - -print; print -- "\n\n\n$fg[green]----------\nInstalling $fg[red]>\`OMZ plugin (svn)'< $fg[magenta]OMZ::plugins$reset_color/$fg[yellow]gradle$fg_bold[green] AS ::\`$fg[red]!myid/sub$fg_bold[green]'::$reset_color" -print zplugin ice svn id-as\"\\\\\!myid/sub\"\; zplugin snippet OMZ::plugins/gradle -zplugin ice svn id-as"!myid/sub"; zplugin snippet OMZ::plugins/gradle -zplugin cd myid/sub; ls -lthd .*(N) *(N) -sleep 3 -zplugin creinstall %SNIPPETS/myid/sub -sleep 3 -cd $OLDPWD -zplugin delete myid/sub -zplugin cd myid/sub && ls -lthd .*(N) *(N) -zplugin cclear - -cd $INITIAL_CD -# vim:ft=zsh:sts=4:sw=4:et diff --git a/scripts/test-scripts/test-id-as b/scripts/test-scripts/test-id-as deleted file mode 100644 index 9708001ed..000000000 --- a/scripts/test-scripts/test-id-as +++ /dev/null @@ -1,182 +0,0 @@ -# fpath+=( `pwd`/doc ) -# autoload test-id-as -# test-id-as -# -# Introduction of id-as (an ice-mod that allows to nickname -# any snippet or plugin) is a set of so many changes that -# more tests were needed, thus this file was created, real -# tests would took too long. -# -# Creates PLUGINS_DIR and SNIPPETS_DIR in /tmp. Can obtain -# --reuse option, to reuse existing PLUGINS_DIR & SNIPPETS_DIR. - -autoload colors; colors - -setopt localtraps typesetsilent - -typeset -g plg_bkp="${ZPLGM[PLUGINS_DIR]}" snp_bkp="${ZPLGM[SNIPPETS_DIR]}" argv1="$1" argv2="$2" -[[ -z "$plg_bkp" || -z "$snp_bkp" ]] && { print "Zplugin not loaded? (the \$ZPLGM hash is missing fields)"; return 1; } -[[ "$plg_bkp" != /* || $snp_bkp != /* ]] && { print "PLUGINS_DIR and/or SNIPPETS_DIR isn't an absolute path, aborting"; return 1; } - -if [[ "$argv1" != "--reuse" && "$argv2" != "--reuse" ]]; then - command rm -rf /tmp/zplg_plgs /tmp/zplg_snps - command mkdir -p /tmp/zplg_plgs /tmp/zplg_snps - - ZPLGM[PLUGINS_DIR]=/tmp/zplg_plgs ZPLGM[SNIPPETS_DIR]=/tmp/zplg_snps - - trap '[[ $argv1 != "--keep" && $argv2 != "--keep" ]] && { ZPLGM[PLUGINS_DIR]=$plg_bkp; ZPLGM[SNIPPETS_DIR]=$snp_bkp; } || { print; print "Kept ${ZPLGM[PLUGINS_DIR]} :: ${ZPLGM[SNIPPETS_DIR]}"; }; return 0;' EXIT INT TERM QUIT -fi - -local INITIAL_CD="$PWD" -cd /tmp -print; print -- "$fg[green]..........Working dir: $PWD$reset_color.........." - -print -- "Removing test-plugins & snippets from disk ..." - -# This removal is in case of --reuse being passed to this script - -command rm -rf -- ${ZPLGM[PLUGINS_DIR]}/mvdan---sh/ \ - ${ZPLGM[PLUGINS_DIR]}/oz---safe-paste \ - ${ZPLGM[PLUGINS_DIR]}/junegunn---fzf-bin \ - ${ZPLGM[PLUGINS_DIR]}/my---jun---gun \ - ${ZPLGM[PLUGINS_DIR]}/myid \ - ${ZPLGM[PLUGINS_DIR]}/myid---sub---1 \ - ${ZPLGM[PLUGINS_DIR]}/my---pure - -command rm -rf -- ${ZPLGM[SNIPPETS_DIR]}/https--github.com--robbyrussell--oh-my-zsh--trunk--plugins \ - ${ZPLGM[SNIPPETS_DIR]}/MY-UNIQUE \ - ${ZPLGM[SNIPPETS_DIR]}/my \ - ${ZPLGM[SNIPPETS_DIR]}/myid/sub - -print -- "Done." - -print; print -- "\n\n\n$fg[green]----------\nInstalling $fg[red]>\`github-$fg_bold[magenta]binary$fg_no_bold[red]'< $fg[magenta]mvdan$reset_color/$fg[yellow]sh$fg_bold[red] without$fg_no_bold[red] id-as nickname$reset_color" -zplugin ice from"gh-r" as"command" mv"shfmt* -> shfmt"; zplugin load mvdan/sh -zplugin cd mvdan/sh; ls -lthd .*(N) *(N) -cd $OLDPWD -zplugin delete mvdan/sh -zplugin cd mvdan/sh && ls -lthd .*(N) *(N) - -sleep 3 - -print; print -- "\n\n\n$fg[green]----------\nInstalling $fg[red]>\`single-file plugin' $fg[magenta]oz$reset_color/$fg[yellow]safe-paste$fg_bold[red] without$fg_no_bold[red] id-as nickname$reset_color" -zplugin load oz/safe-paste -zplugin cd oz/safe-paste; ls -lthd .*(N) *(N) -cd $OLDPWD -zplugin delete oz/safe-paste -zplugin cd oz/safe-paste && ls -lthd .*(N) *(N) - -sleep 3 - -print; print -- "\n\n\n$fg[green]----------\nInstalling $fg[red]>\`github-$fg_bold[magenta]binary$fg_no_bold[red]'< $fg[magenta]junegunn$reset_color/$fg[yellow]fzf-bin$fg_bold[red] without$fg_no_bold[red] id-as nickname$reset_color" -zplugin ice from"gh-r" as"command" mv"fzf* -> fzf1" atpull'!rm -f fzf2; touch fzf.txt'; zplugin light junegunn/fzf-bin -zplugin cd junegunn/fzf-bin; ls -lthd .*(N) *(N) -cd $OLDPWD -zplugin delete junegunn/fzf-bin -zplugin cd junegunn/fzf-bin && ls -lthd .*(N) *(N) - -sleep 3 - -print; print -- "\n\n\n$fg[green]----------\nInstalling $fg[red]>\`github-$fg_bold[magenta]binary$fg_no_bold[red]'< $fg[magenta]junegunn$reset_color/$fg[yellow]fzf-bin$fg_bold[green] AS ::\`$fg[red]my/jun/gun$fg_bold[green]'::$reset_color" -zplugin ice from"gh-r" as"command" mv"fzf* -> fzf2" id-as"my/jun/gun"; zplugin load junegunn/fzf-bin -zplugin cd my/jun/gun; ls -lthd .*(N) *(N) -cd $OLDPWD -zplugin delete my/jun/gun -zplugin cd my/jun/gun && ls -lthd .*(N) *(N) - -sleep 3 - -print; print -- "\n\n\n$fg[green]----------\nInstalling $fg[red]>\`theme'< $fg[magenta]agkozak$reset_color/$fg[yellow]agkozak-zsh-theme$fg_bold[green] AS ::\`$fg[red]myid$fg_bold[green]'::$reset_color" -zplugin ice id-as"myid"; zplugin load agkozak/agkozak-zsh-theme -zplugin cd myid; ls -lthd .*(N) *(N) -cd $OLDPWD -zplugin delete myid -zplugin cd myid && ls -lthd .*(N) *(N) - -sleep 3 - -print; print -- "$fg[green]Unloading $fg[red]::\`myid'::$fg[green] (agkozak/agkozak-zsh-theme)$reset_color" -zplugin unload myid > /tmp/myid.unload.txt -head -n 4 /tmp/myid.unload.txt -head -n 17 /tmp/myid.unload.txt | tail -n 4 - -sleep 5 - -print; print -- "\n\n\n$fg[green]----------\nInstalling $fg[red]>\`theme'< $fg[magenta]agkozak$reset_color/$fg[yellow]agkozak-zsh-theme$fg_bold[green] AS ::\`$fg[red]myid/sub/1$fg_bold[green]'::$reset_color" -zplugin ice id-as"myid/sub/1"; zplugin load agkozak/agkozak-zsh-theme -zplugin cd myid/sub/1; ls -lthd .*(N) *(N) -cd $OLDPWD -zplugin delete myid/sub/1 -zplugin cd myid/sub/1 && ls -lthd .*(N) *(N) - -sleep 3 - -print; print -- "$green[green]Report of $fg[red]::\`myid/sub/1'::$fg[green] (agkozak/agkozak-zsh-theme)$reset_color" -zplugin report myid/sub/1 > /tmp/myid--sub--1.report.txt -head -n 10 /tmp/myid--sub--1.report.txt | tail -n 8 - -sleep 5 - -print; print -- "$fg[green]Unloading $fg[red]::\`myid/sub/1'::$fg[green] (agkozak/agkozak-zsh-theme)$reset_color" -zplugin unload myid/sub/1 > /tmp/myid--sub--1.unload.txt -head -n 4 /tmp/myid--sub--1.unload.txt -head -n 17 /tmp/myid--sub--1.unload.txt | tail -n 4 - -sleep 5 - -print; print -- "\n\n\n$fg[green]----------\nInstalling $fg[red]>\`theme'< $fg[magenta]sindresorhus$reset_color/$fg[yellow]pure$fg_bold[green] AS ::\`$fg[red]my/pure$fg_bold[green]'::$reset_color" -zplugin ice multisrc"{async,pure}.zsh" pick"/dev/null" id-as"my/pure"; zplugin load sindresorhus/pure -zplugin cd my/pure; ls -lthd .*(N) *(N) -cd $OLDPWD -zplugin delete my/pure -zplugin cd my/pure && ls -lthd .*(N) *(N) - -sleep 3 - -print -print -- "\n\n\n"$fg_bold[red]SNIPPETS START NOW$reset_color - -print; print -- "\n\n\n$fg[green]----------\nInstalling $fg[red]>\`OMZ plugin (svn)'< $fg[magenta]OMZ::plugins$reset_color/$fg[yellow]pip$fg_bold[red] without$fg_no_bold[red] id-as nickname$reset_color" -zplugin ice svn; zplugin snippet OMZ::plugins/pip -zplugin cd OMZ::plugins/pip; ls -lthd .*(N) *(N) -sleep 3 -zplugin creinstall %SNIPPETS/OMZ::plugins/pip -sleep 3 -cd $OLDPWD -zplugin delete OMZ::plugins/pip -zplugin cd OMZ::plugins/pip && ls -lthd .*(N) *(N) -zplugin cclear - -sleep 3 - -print; print -- "\n\n\n$fg[green]----------\nInstalling $fg[red]>\`single-file command-snippet' $fg[magenta]GH::Osse/git-scripts/blob/master/git-unique$fg_bold[green] AS ::\`$fg[red]MY-UNIQUE$fg_bold[green]'::$reset_color" -zplugin ice as"program" id-as"MY-UNIQUE"; zplugin snippet https://github.com/Osse/git-scripts/blob/master/git-unique -zplugin cd MY-UNIQUE; ls -lthd .*(N) *(N) -cd $OLDPWD -zplugin delete MY-UNIQUE -zplugin cd MY-UNIQUE && ls -lthd .*(N) *(N) - -sleep 3 - -print; print -- "\n\n\n$fg[green]----------\nInstalling $fg[red]>\`OMZ plugin (svn)'< $fg[magenta]OMZ::plugins$reset_color/$fg[yellow]git$fg_bold[green] AS ::\`$fg[red]my$fg_bold[green]'::$reset_color" -zplugin ice svn id-as"my"; zplugin snippet OMZ::plugins/git -zplugin cd my; ls -lthd .*(N) *(N) -cd $OLDPWD -zplugin delete my -zplugin cd my && ls -lthd .*(N) *(N) - -sleep 3 - -print; print -- "\n\n\n$fg[green]----------\nInstalling $fg[red]>\`OMZ plugin (svn)'< $fg[magenta]OMZ::plugins$reset_color/$fg[yellow]gradle$fg_bold[green] AS ::\`$fg[red]myid/sub$fg_bold[green]'::$reset_color" -zplugin ice svn id-as"myid/sub"; zplugin snippet OMZ::plugins/gradle -zplugin cd myid/sub; ls -lthd .*(N) *(N) -sleep 3 -zplugin creinstall %SNIPPETS/myid/sub -sleep 3 -cd $OLDPWD -zplugin delete myid/sub -zplugin cd myid/sub && ls -lthd .*(N) *(N) -zplugin cclear - -cd $INITIAL_CD -# vim:ft=zsh:sts=4:sw=4:et diff --git a/scripts/zunit-tests.sh b/scripts/zunit-tests.sh deleted file mode 100755 index caa5d3635..000000000 --- a/scripts/zunit-tests.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -run_tests() { - cd "$( - cd "$(dirname "$0")" > /dev/null 2>&1 - pwd -P - )/.." || exit 9 - - zunit run --verbose "$@" -} - -if [[ ${BASH_SOURCE[0]} == "${0}" ]]; then - run_tests "$@" -fi diff --git a/tests/_support/bootstrap b/tests/_support/bootstrap index 087761a96..ef6595399 100755 --- a/tests/_support/bootstrap +++ b/tests/_support/bootstrap @@ -31,7 +31,7 @@ info 'creating test env' \ && command chmod g-rwX $ZINIT[HOME_DIR] \ && zcompile $ZINIT[BIN_DIR]/zinit.zsh \ && info 'successfully created zunit env' \ - || err 'failed to create zunit env' + || error 'failed to create zunit env' source $ZINIT[BIN_DIR]/zinit.zsh \ && autoload -Uz _zinit \ @@ -41,7 +41,7 @@ source $ZINIT[BIN_DIR]/zinit.zsh \ # Install Annexes [[[ info 'installing test dependencies' # ver'fix/improve-lbin-logic' \ -zinit light-mode for \ +zinit depth'1' light-mode for \ zdharma-continuum/zinit-annex-binary-symlink \ zdharma-continuum/zinit-annex-{'bin-gem-node','default-ice'} # ]]] diff --git a/tests/gh-r.zunit b/tests/gh-r.zunit index 96922ea1a..943183067 100755 --- a/tests/gh-r.zunit +++ b/tests/gh-r.zunit @@ -10,23 +10,23 @@ local act="$ZBIN/act"; assert "$act" is_executable $act --version; assert $state equals 0 } -@test 'alist' { # A file list program that supports multiple storage, powered by Gin and React - run zinit lbin'!* -> alist' for @Xhofe/alist; assert $state equals 0 - local alist="$ZBIN/alist"; assert "$alist" is_executable - $alist --version; assert $state equals 0 -} @test 'alacritty' { # Run your GitHub alacrittyions locally [[ $OSTYPE =~ 'linux*' ]] && skip 'Alacritty test skipped on Linux/GNU' run zinit for @alacritty/alacritty; assert $state equals 0 local alacritty="$ZBIN/alacritty"; assert "$alacritty" is_executable $alacritty --version; assert $state equals 0 } +@test 'alist' { # A file list program that supports multiple storage, powered by Gin and React + run zinit lbin'!* -> alist' for @Xhofe/alist; assert $state equals 0 + local alist="$ZBIN/alist"; assert "$alist" is_executable + $alist --version; assert $state equals 0 +} @test 'asciigraph' { # Go package to make lightweight ASCII line graph ╭┈╯ in command line apps with no other dependencies. run zinit for @guptarohit/asciigraph; assert $state equals 0 local asciigraph="$ZBIN/asciigraph"; assert "$asciigraph" is_executable $asciigraph --help; assert $state equals 0 } -@test 'assh' { +@test 'assh' { # make your ssh client smarter run zinit for @moul/assh; assert $state equals 0 local assh="$ZBIN/assh"; assert "$assh" is_executable $assh --version; assert $state equals 0 @@ -36,16 +36,16 @@ local atmos="$ZBIN/atmos"; assert "$atmos" is_executable $atmos version; assert $state equals 0 } -@test 'aurora' { # Cross-platform beanstalkd queue server admin console - run zinit for @xuri/aurora; assert $state equals 0 - local aurora="$ZBIN/aurora"; assert "$aurora" is_executable - $aurora -v; assert $state equals 0 -} @test 'atuin' { # Magical shell history run zinit for @ellie/atuin; assert $state equals 0 local atuin="$ZBIN/atuin"; assert "$atuin" is_executable $atuin --version; assert $state equals 0 } +@test 'aurora' { # Cross-platform beanstalkd queue server admin console + run zinit for @xuri/aurora; assert $state equals 0 + local aurora="$ZBIN/aurora"; assert "$aurora" is_executable + $aurora -v; assert $state equals 0 +} @test 'bandwhich' { # Terminal bandwidth utilization tool [[ $OSTYPE =~ 'darwin*' ]] && skip 'Bandwhich test skipped on Darwin' run zinit for @imsnif/bandwhich; assert $state equals 0 @@ -104,19 +104,11 @@ $certificates --version; assert $state equals 0 } @test 'checkmake' { # experimental linter/analyzer for Makefiles - run zinit lbin'!checkmake* -> checkmake' for mrtazz/checkmake; assert $state equals 0 + run zinit lbin'!checkmake* -> checkmake' for @mrtazz/checkmake; assert $state equals 0 local checkmake="$ZBIN/checkmake"; assert "$checkmake" is_executable $checkmake --version; assert $state equals 0 } -# @test 'codeql' { # Binaries for the CodeQL CLI -# run zinit lbin'!**/codeql -> codeql' for @github/codeql-cli-binaries -# assert $state equals 0 -# local codeql="$ZBIN/codeql" -# assert "$codeql" is_executable -# $codeql --version -# assert $state equals 0 -# } -@test 'cog' { +@test 'cog' { # Containers for machine learning run zinit lbin'!cog* -> cog' for replicate/cog; assert $state equals 0 local cog="$ZBIN/cog"; assert "$cog" is_executable $cog --version; assert $state equals 0 @@ -137,27 +129,39 @@ $cgapp --version assert $state equals 0 } -@test 'csview' { +@test 'csview' { # Pretty csv viewer for cli with cjk/emoji support. run zinit for wfxr/csview; assert $state equals 0 local csview="$ZBIN/csview"; assert "$csview" is_executable $csview --version; assert $state equals 0 } -@test 'delta' { +@test 'delta' { # A syntax-highlighting pager for git, diff, and grep output run zinit for @dandavison/delta; assert $state equals 0 local delta="$ZBIN/delta"; assert "$delta" is_executable $delta --version; assert $state equals 0 } -@test 'dive' { +@test 'dive' { # A tool for exploring each layer in a docker image run zinit for @wagoodman/dive; assert $state equals 0 local dive="$ZBIN/dive"; assert "$dive" is_executable $dive --version; assert $state equals 0 } -@test 'docker-compose' { +@test 'docker-buildx' { # A monitor of resources + run zinit for as'completions' atclone'buildx* completion zsh > _buildx' lbin'!buildx-* -> buildx' @docker/buildx + assert $state equals 0 + local buildx="$ZBIN/buildx"; assert "$buildx" is_executable + $buildx version; assert $state equals 0 +} +@test 'docker-compose' { # Define and run multi-container applications with Docker run zinit lbin'!* -> docker-compose' for @docker/compose; assert $state equals 0 local dc="$ZBIN/docker-compose"; assert "$dc" is_executable $dc --version; assert $state equals 0 } -@test 'documize' { +@test 'docker-credential-helpers' { # A monitor of resources + [[ $OSTYPE =~ 'linux*' ]] && skip 'docker-credential-helpers test skipped on Linux' + run zinit for lbin'!* -> docker-credential-desktop' @docker/docker-credential-helpers; assert $state equals 0 + local credential_desktop="$ZBIN/docker-credential-desktop"; assert "$credential_desktop" is_executable + $credential_desktop version; assert $state equals 0 +} +@test 'documize' { # Modern Confluence alternative designed for internal & external docs, built with run zinit lbin'!* -> documize' for @documize/community; assert $state equals 0 local documize="$ZBIN/documize"; assert "$documize" is_executable $documize version; assert $state equals 0 @@ -193,12 +197,12 @@ local etcd="$ZBIN/etcd"; assert "$etcd" is_executable $etcd --version; assert $state equals 0 } -@test 'exa' { +@test 'exa' { # A modern replacement for ‘ls’. run zinit lbin'!**/exa' for ogham/exa; assert $state equals 0 local exa="$ZBIN/exa"; assert "$exa" is_executable $exa --version; assert $state equals 0 } -@test 'fd' { +@test 'fd' { # A simple, fast and user-friendly alternative to 'find run zinit for @sharkdp/fd; assert $state equals 0 local fd="$ZBIN/fd"; assert "$fd" is_executable $fd version; assert $state equals 0 @@ -208,12 +212,12 @@ local fogg="$ZBIN/fogg"; assert "$fogg" is_executable $fogg version; assert $state equals 0 } -@test 'fx' { +@test 'fx' { # Terminal JSON viewer run zinit lbin'!* -> fx' for @antonmedv/fx; assert $state equals 0 local fx="$ZBIN/fx"; assert "$fx" is_executable $fx -v; assert $state equals 0 } -@test 'fzf' { +@test 'fzf' { # A command-line fuzzy finder run zinit for @junegunn/fzf; assert $state equals 0 local fzf="$ZBIN/fzf"; assert "$fzf" is_executable $fzf --version; assert $state equals 0 @@ -234,27 +238,27 @@ local gf="$ZBIN/gf"; assert "$gf" is_executable $gf --version; assert $state equals 0 } -@test 'ggsrun' { +@test 'ggsrun' { # This is a CLI tool to execute Google Apps Script (GAS) at own terminal on local PC. Also this CLI tool can be used for managing files in Google Drive for OAuth2 and Service Account run zinit lbin'!* -> ggsrun' for @tanaikech/ggsrun; assert $state equals 0 local git_sizer="$ZBIN/ggsrun"; assert "$git_sizer" is_executable $git_sizer --version; assert $state equals 0 } -@test 'gh-cli' { +@test 'gh-cli' { # GitHub’s official command line tool run zinit lbin'!**/gh' for cli/cli; assert $state equals 0 local gh_cli="$ZBIN/gh"; assert "$gh_cli" is_executable $gh_cli --version; assert $state equals 0 } -@test 'gh-hub' { +@test 'gh-hub' { # A command-line tool that makes git easier to use with GitHub run zinit cp"hub-*/etc/hub.zsh_completion -> _hub" for @github/hub; assert $state equals 0 local hub="$ZBIN/hub"; assert "$hub" is_executable $hub --version; assert $state equals 0 } -@test 'ghg' { +@test 'ghg' { # Get the executable from github releases easily run zinit for @Songmu/ghg; assert $state equals 0 local ghg="$ZBIN/ghg"; assert "$ghg" is_executable $ghg version; assert $state equals 0 } -@test 'ghq' { +@test 'ghq' { # Remote repository management made easy run zinit for @x-motemen/ghq; assert $state equals 0 local ghq="$ZBIN/ghq"; assert "$ghq" is_executable $ghq --version; assert $state equals 0 @@ -335,16 +339,16 @@ local hadolint="$ZBIN/hadolint"; assert "$hadolint" is_executable $hadolint --version; assert $state equals 0 } -@test 'helix' { # A post-modern modal text editor - run zinit lbin'!**/hx' for @helix-editor/helix; assert $state equals 0 - local helix="$ZBIN/hx"; assert "$helix" is_executable - $helix --version; assert $state equals 0 -} @test 'heksa' { # CLI hex dumper with colors run zinit for @raspi/heksa; assert $state equals 0 local heksa="$ZBIN/heksa"; assert "$heksa" is_executable $heksa --version; assert $state equals 0 } +@test 'helix' { # A post-modern modal text editor + run zinit lbin'!**/hx' for @helix-editor/helix; assert $state equals 0 + local helix="$ZBIN/hx"; assert "$helix" is_executable + $helix --version; assert $state equals 0 +} @test 'hexyl' { # A command-line hex viewer run zinit for @sharkdp/hexyl; assert $state equals 0 local hexyl="$ZBIN/hexyl"; assert "$hexyl" is_executable @@ -396,7 +400,7 @@ local just="$ZBIN/just"; assert "$just" is_executable $just --version; assert $state equals 0 } -@test 'keepassxc' { +@test 'keepassxc' { # a cross-platform community-driven port of the Windows application “Keepass Password Safe if [[ $OSTYPE =~ 'linux.*' ]]; then skip 'keepassxc test only ran on macOS'; fi run zinit for @keepassxreboot/keepassxc; assert $state equals 0 local keepassxc="$ZBIN/keepassxc"; assert "$keepassxc" is_executable @@ -479,7 +483,7 @@ $kopia --version; assert $state equals 0 local mob="$ZBIN/mob"; assert "$mob" is_executable $mob --version; assert $state equals 0 } -@test 'mocword' { +@test 'mocword' { # Predict next words run zinit lbin'!**/mocword* -> mocword' for @high-moctane/mocword; assert $state equals 0 local mocword="$ZBIN/mocword"; assert "$mocword" is_executable $mocword --version; assert $state equals 0 @@ -494,47 +498,52 @@ $kopia --version; assert $state equals 0 local navi="$ZBIN/navi" && assert "$navi" is_executable $navi --version && assert $state equals 0 } -@test 'neovim::binary' { # Vim-fork focused on extensibility and usability - [[ $OSTYPE =~ 'darwin*' ]] && skip 'Neovim realease binary broken for macOS as of May 3rd, 2022' - run zinit lbin'!**/nvim' id-as'neovim/binary' for neovim/neovim; assert $state equals 0; assert $output does_not_contain 'appimage' - local nvim="$ZBIN/nvim"; assert "$nvim" is_executable - $nvim --version; assert $state equals 0 -} -@test 'neovim::appimage' { # Vim-fork focused on extensibility and usability - run zinit bpick'*appimage*' id-as'neovim/appimage' for neovim/neovim - assert $state equals 0; assert $output contains 'nvim.appimage' - assert "$ZINIT[PLUGINS_DIR]/neovim---appimage/nvim.appimage" is_file -} -@test 'onefetch' { +# @test 'neovim::appimage' { # Vim-fork focused on extensibility and usability +# run zinit bpick'*appimage*' id-as'neovim/appimage' for neovim/neovim +# assert $state equals 0; assert $output contains 'nvim.appimage' +# assert "$ZINIT[PLUGINS_DIR]/neovim---appimage/nvim.appimage" is_file +# } +# @test 'neovim::binary' { # Vim-fork focused on extensibility and usability +# [[ $OSTYPE =~ 'darwin*' ]] && skip 'Neovim realease binary broken for macOS as of May 3rd, 2022' +# run zinit lbin'!**/nvim' id-as'neovim/binary' for neovim/neovim; assert $state equals 0; assert $output does_not_contain 'appimage' +# local nvim="$ZBIN/nvim"; assert "$nvim" is_executable +# $nvim --version; assert $state equals 0 +# } +@test 'onefetch' { # Git repository summary on your terminal run zinit for o2sh/onefetch; assert $state equals 0 local onefetch="$ZBIN/onefetch"; assert "$onefetch" is_executable $onefetch --version; assert $state equals 0 } -@test 'peco' { +@test 'peco' { # Simplistic interactive filtering tool run zinit for @peco/peco; assert $state equals 0 local peco="$ZBIN/peco"; assert "$peco" is_executable $peco --version; assert $state equals 0 } -@test 'pmy' { +@test 'piknik' { # Copy/paste anything over the network + run zinit for @jedisct1/piknik; assert $state equals 0 + local piknik="$ZBIN/piknik"; assert "$piknik" is_executable + $piknik --version; assert $state equals 0 +} +@test 'pmy' { # General purpose context-aware zsh completion engine powered by fuzzy finder run zinit for @relastle/pmy; assert $state equals 0 local pmy="$ZBIN/pmy"; assert "$pmy" is_executable $pmy --version; assert $state equals 0 } -@test 'pokeget' { +@test 'pokeget' { # a bash script you can use to display cool sprites of pokemon in your terminal run zinit bpick'*.tar.gz' lbin'!* -> pokeget' for @talwat/pokeget; assert $state equals 0 local pokeget="$ZBIN/pokeget"; assert "$pokeget" is_executable $pokeget pikachu; assert $state equals 0 } -@test 'pulumi' { # A modern replacement for ps written in Rust - run zinit for @pulumi/pulumi; assert $state equals 0 - local pulumi="$ZBIN/pulumi"; assert "$pulumi" is_executable - $pulumi version; assert $state equals 0 -} @test 'procs' { # A modern replacement for ps written in Rust run zinit for @dalance/procs; assert $state equals 0 local procs="$ZBIN/procs"; assert "$procs" is_executable $procs --version; assert $state equals 0 } +@test 'pulumi' { # A modern replacement for ps written in Rust + run zinit for @pulumi/pulumi; assert $state equals 0 + local pulumi="$ZBIN/pulumi"; assert "$pulumi" is_executable + $pulumi version; assert $state equals 0 +} @test 'rare' { # Realtime regex-extraction and aggregation into common formats such as histograms, bar graphs, tables, etc. run zinit for @zix99/rare; assert $state equals 0 local rare="$ZBIN/rare"; assert "$rare" is_executable @@ -550,6 +559,11 @@ $kopia --version; assert $state equals 0 local reg="$ZBIN/reg"; assert "$reg" is_executable $reg version; assert $state equals 0 } +@test 'rip' { # A safe and ergonomic alternative to rm + run zinit for @nivekuil/rip; assert $state equals 0 + local rip="$ZBIN/rip"; assert "$rip" is_executable + $rip --version; assert $state equals 0 +} @test 'ripgrep' { # ripgrep recursively searches directories for a regex pattern while respecting your gitignore run zinit lbin'!**/rg' for @BurntSushi/ripgrep; assert $state equals 0 local rg="$ZBIN/rg"; assert "$rg" is_executable @@ -560,12 +574,8 @@ $kopia --version; assert $state equals 0 local rg="$ZBIN/rg"; assert "$rg" is_executable $rg --version; assert $state equals 0 } -@test 'rip' { # A safe and ergonomic alternative to rm - run zinit for @nivekuil/rip; assert $state equals 0 - local rip="$ZBIN/rip"; assert "$rip" is_executable - $rip --version; assert $state equals 0 -} @test 'rust-analyzer' { # A Rust compiler front-end for IDEs + [[ $OSTYPE =~ 'linux*' ]] && skip 'rust-analyzer test skipped on Linux' run zinit lbin'!* -> rust-analyzer' for @rust-lang/rust-analyzer; assert $state equals 0 local rust_analyzer="$ZBIN/rust-analyzer"; assert "$rust_analyzer" is_executable $rust_analyzer --version; assert $state equals 0 @@ -630,6 +640,12 @@ $kopia --version; assert $state equals 0 local up="$ZBIN/up"; assert "$up" is_executable run $up -h; assert $output contains "up is the Ultimate Plumber" } +@test 'volta-cli' { # JS Toolchains as Code + ! [[ $OSTYPE =~ 'darwin*' ]] && skip 'Volta-cli test skipped on Linux' + run zinit for volta-cli/volta; assert $state equals 0 + local volta="$ZBIN/volta"; assert "$volta" is_executable + run $volta --version; assert $state equals 0 +} @test 'warp' { # Secure and simple terminal sharing ! [[ $OSTYPE =~ 'darwin*' ]] && skip 'Warp test skipped on Linux' run zinit lbin'!* -> warp' for spolu/warp; assert $state equals 0 @@ -644,7 +660,7 @@ $kopia --version; assert $state equals 0 @test 'wifiqr' { # Create a QR code with your Wi-Fi login details run zinit lbin'!* -> wifiqr' for reugn/wifiqr; assert $state equals 0 local wifiqr="$ZBIN/wifiqr"; assert "$wifiqr" is_executable - run $wifiqr -v; assert $state equals 0 + run $wifiqr --version; assert $state equals 0 } @test 'wtf' { # The personal information dashboard for your terminal run zinit lbin'!**/wtf* -> wtf' for wtfutil/wtf; assert $state equals 0 diff --git a/zinit-autoload.zsh b/zinit-autoload.zsh index 3330ff284..780b233a9 100644 --- a/zinit-autoload.zsh +++ b/zinit-autoload.zsh @@ -3019,9 +3019,9 @@ builtin print -Pr \"\$ZINIT[col-obj]Done (with the exit code: \$_retval).%f%b\"" if [[ "$user" != "_local" && -n "$user" ]]; then builtin print "${ZINIT[col-info]}Creating Github repository${ZINIT[col-rst]}" if [[ $isorg = (y|yes) ]]; then - curl --silent -u "$user" https://api.github.com/orgs/$org/repos -d '{"name":"'"$plugin"'"}' >/dev/null + curl --tcp-fastopen --silent -u "$user" https://api.github.com/orgs/$org/repos -d '{"name":"'"$plugin"'"}' >/dev/null else - curl --silent -u "$user" https://api.github.com/user/repos -d '{"name":"'"$plugin"'"}' >/dev/null + curl --tcp-fastopen --silent -u "$user" https://api.github.com/user/repos -d '{"name":"'"$plugin"'"}' >/dev/null fi command git clone "https://github.com/${${${(M)isorg:#(y|yes)}:+$org}:-$user}/${plugin}.git" "${${${(M)isorg:#(y|yes)}:+$org}:-$user}---${plugin//\//---}" || { builtin print "${ZINIT[col-error]}Creation of remote repository $uspl2col ${ZINIT[col-error]}failed${ZINIT[col-rst]}" diff --git a/zinit-install.zsh b/zinit-install.zsh index 76a9111bb..784a26528 100644 --- a/zinit-install.zsh +++ b/zinit-install.zsh @@ -1,4 +1,5 @@ -# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; +# -*- # Copyright (c) 2016-2020 Sebastian Gniazdowski and contributors. builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || { @@ -661,9 +662,9 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || { if (( ${+commands[curl]} )); then if [[ -n $progress ]]; then - command curl --progress-bar -fSL "$url" 2> >($ZINIT[BIN_DIR]/share/single-line.zsh >&2) || return 1 + command curl --tcp-fastopen --progress-bar -fSL "$url" 2> >($ZINIT[BIN_DIR]/share/single-line.zsh >&2) || return 1 else - command curl -fsSL "$url" || return 1 + command curl --tcp-fastopen -fsSL "$url" || return 1 fi elif (( ${+commands[wget]} )); then command wget ${${progress:--q}:#1} "$url" -O - || return 1 @@ -680,9 +681,9 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || { } else { if type curl 2>/dev/null 1>&2; then if [[ -n $progress ]]; then - command curl --progress-bar -fSL "$url" 2> >($ZINIT[BIN_DIR]/share/single-line.zsh >&2) || return 1 + command curl --tcp-fastopen --progress-bar -fSL "$url" 2> >($ZINIT[BIN_DIR]/share/single-line.zsh >&2) || return 1 else - command curl -fsSL "$url" || return 1 + command curl --tcp-fastopen -fsSL "$url" || return 1 fi elif type wget 2>/dev/null 1>&2; then command wget ${${progress:--q}:#1} "$url" -O - || return 1 @@ -712,7 +713,7 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || { } if (( ${+commands[curl]} )) || type curl 2>/dev/null 1>&2; then - cmd=(command curl -sIL "$url") + cmd=(command curl --tcp-fastopen -sIL "$url") elif (( ${+commands[wget]} )) || type wget 2>/dev/null 1>&2; then cmd=(command wget --server-response --spider -q "$url" -O -) else @@ -1458,23 +1459,34 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || { local url=https://$urlpart } + local HAS_MUSL + if command -v musl-gcc >/dev/null 2>&1; then + HAS_MUSL='linux-musl' + elif command -v musl-gcc >/dev/null 2>&1; then + HAS_MUSL='linux-musl' + elif find /lib/ -maxdepth 1 -name '*musl*' >/dev/null 2>&1; then + HAS_MUSL='linux-musl' + else + HAS_MUSL=$MACHTYPE + fi + local -A matchstr matchstr=( - android '(apk|android|linux-android)' - amd64 '(amd64|x86_64|x64)' - x86_64 '(amd64|x86_64|x64)' - darwin '*((#s)|/)*(apple|darwin|mac|macos|osx|dmg)*((#e)|/)*' - linux-gnu '(linux|linux-gnu|linux-musl)' - linux-musl '(linux|linux-musl)' - linux 'linux[?-](musl|gnu|)' aarch64 '(arm64|aarch64|arm[?v]8)' - arm64 '(arm64|aarch64|arm[?v]8)' - armv5 'arm[?v]5' - armv6 'arm[?v]6' - armv7 'armv[?v]7' + amd64 '(amd|amd64|x64|x86|x86_64|64bit|)*~*(eabi(hf|)|powerpc|ppc64(le|)|[-_]mips*|aarch64|riscv(64|)|s390x|[-_.]arm*)*' + android '(apk|android|linux-android)' + arm64 '(arm64|aarch64|arm[?v]8)' + armv5 'arm[?v]5' + armv6 'arm[?v]6' + armv7 'armv[?v]7' cygwin '(cyg|-|_|)win(dows|32|64|))' - msys '(cyg|-|_|)win(dows|32|64|))' + darwin '*((#s)|/)*(apple|darwin|mac|macos|osx|dmg)*((#e)|/)*' + linux "*(linux-musl|musl|linux64|linux)*~^*(linux*${MACHTYPE}|${CPUTYPE}*linux)*" + linux-gnu "*(linux-musl|musl|linux)*~^*(${MACHTYPE}|${CPUTYPE}|)*" + linux-musl "*(linux-musl|musl|linux-~gnu|linux)*~^*(${MACHTYPE}|${CPUTYPE}|)*" + msys '(cyg|-|_|)win(dows|32|64|))' windows '(cyg|-|_|)win(dows|32|64|))' + x86_64 '(amd|amd64|x64|x86|x86_64|64bit|)*~*(eabi(hf|)|powerpc|ppc64(le|)|[-_]mips*|aarch64|riscv(64|)|s390x|[-_.]arm*)*' ) local -a list init_list @@ -1483,85 +1495,93 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || { command grep -o 'href=./'$user'/'$plugin'/releases/download/[^"]\+')"} ) init_list=( ${init_list[@]#href=?} ) - local -a list2 bpicks + local -a filtered bpicks bpicks=( ${(s.;.)ICE[bpick]} ) [[ -z $bpicks ]] && bpicks=( "" ) local bpick reply=() for bpick ( "${bpicks[@]}" ) { - list=( $init_list ) + list=( $init_list ) - if [[ -n $bpick ]] { list=( ${(M)list[@]:#(#i)*/$~bpick} ) } + if [[ -n $bpick ]] { list=( ${(M)list[@]:#(#i)*/$~bpick} ) } - # Remove artifacts that shouldn't be considered - list=( ${list[@]:#*(a(ccoutrements|ppimage.[a-z]*)|[3-6]86*|manifest|(md5|sha1)sums|.s(ha256sum|ig)|.md5|.pkg|.sh|.sha256|.txt|.vsix)(#e)} ) + # REMOVE ARTIFACTS THAT SHOULDN'T BE CONSIDERED + filtered=( ${list[@]:#(#i)*([3-6]86|md5|sig|asc|txt|vsix|sum|sha256*|pkg|.sh(#e))*} ) + (( $#filtered > 0 )) && list=( ${filtered[@]} ) - # filter .apk packages if anbox present - if (( $#list > 1 && ${+commands[anbox]} == 1 )) { - +zinit-message "{pre}gh-r:{msg2} found {cmd}anbox{info2} -- looking for {obj}.apk{info2} packages {rst}" - list2=( ${(M)list[@]:#(#i)*${~matchstr[android]}*} ) - } else { list2=( ${list[@]:#(#i)*${~matchstr[android]}*} ) } - (( $#list2 > 0 )) && list=( ${list2[@]} ) + # FILTER .APK PACKAGES IF ANBOX PRESENT + if (( $#list > 1 && ${+commands[anbox]} == 1 )) { filtered=( ${(M)list[@]:#(#i)*${~matchstr[android]}*} ) } \ + else { filtered=( ${list[@]:#(#i)*${~matchstr[android]}*} ) } + (( $#filtered > 0 )) && list=( ${filtered[@]} ) - # filter .deb packages if dpkg-deb present - if (( $#list > 1 && ${+commands[dpkg-deb]} == 1 )) { - list2=( ${list[@]:#(#i)*(?64)*deb(#e)} ) - } else { - list2=( ${list[@]:#*deb(#e)} ) - } - (( $#list2 > 0 )) && list=( ${list2[@]} ) + # FILTER .DEB PACKAGES IF DPKG-DEB PRESENT + if (( $#list > 1 && ${+commands[dpkg-deb]} == 1 )) { filtered=( ${list[@]:#(#i)*(64|)*deb(#e)} ) } \ + else { filtered=( ${list[@]:#*deb(#e)} ) } + (( $#filtered > 0 )) && list=( ${filtered[@]} ) - # filter .rpm packages if redhat package manager present - if (( $#list > 1 && ${+commands[rpm]} == 1 )) { - list2=( ${list[@]:#(#i)*(?64)*rpm(#e)} ) - } else { - list2=( ${list[@]:#*rpm(#e)} ) - } - (( $#list2 > 0 )) && list=( ${list2[@]} ) + # FILTER .RPM PACKAGES IF REDHAT PACKAGE MANAGER PRESENT + if (( $#list > 1 && ${+commands[rpm]} == 1 )) { filtered=( ${list[@]:#(#i)*(64|)*rpm(#e)} ) } \ + else { filtered=( ${list[@]:#*rpm(#e)} ) } + (( $#filtered > 0 )) && list=( ${filtered[@]} ) - # filter urls by os (e.g., darwin, linux, windows) - if (( $#list > 1 )) { - list2=( ${(M)list[@]:#(#i)*${~matchstr[${OSTYPE//[0-9.]/}]}*} ) - (( $#list2 > 0 )) && list=( ${list2[@]} ) - } + if (( $#list > 1 )) { + filtered=( ${(M)list[@]:#(#i)*${~matchstr[${$(uname)}]}*} ) && (( $#filtered > 0 )) && list=( ${filtered[@]} ) + # +zinit-message "{pre}gh-r{rst}:{info} ${matchstr[${$(uname)}]}\\n{obj}${(pj:\n:)${(@)list[1,5]:t}}{rst}" + } - if (( $#list > 1 )) { - list2=( ${(M)list[@]:#(#i)*${~matchstr[${CPUTYPE}]}*} ) - (( $#list2 > 0 )) && list=( ${list2[@]} ) - } + # FILTER URLS BY GENERIC OS NAME (E.G., DARWIN, LINUX, ETC.) + if (( $#list > 1 )) { + filtered=( ${(M)list[@]:#(#i)*/$~HAS_MUSL} ) && (( $#filtered > 0 )) && list=( ${filtered[@]} ) + # +zinit-message "{pre}gh-r{rst}:{info} ${HAS_MUSL} \\n{obj}${(pj:\n:)${(@)list[1,5]:t}}{rst}" + } - if (( $#list > 1 )) { - list2=( ${(M)list[@]:#(#i)*${~matchstr[${MACHTYPE}]}*} ) - (( $#list2 > 0 )) && list=( ${list2[@]} ) - } + if (( $#list > 1 )) { + filtered=( ${(M)list[@]:#(#i)*${~matchstr[${OSTYPE//[0-9.]/}]}*} ) && (( $#filtered > 0 )) && list=( ${filtered[@]} ) + # +zinit-message "{pre}gh-r{rst}:{info} ${matchstr[${OSTYPE//[0-9.]/}]}\\n{obj}${(pj:\n:)${(@)list[1,5]:t}}{rst}" + } - # filter urls by OS (e.g., darwin, linux, windows) - if (( $#list > 1 )) { - list2=( ${(M)list[@]:#(#i)*${~matchstr[${$(uname)}]}*} ) - (( $#list2 > 0 )) && list=( ${list2[@]} ) - } + if (( $#list > 1 )) { + filtered=( ${(M)list[@]:#(#i)*${~matchstr[${MACHTYPE}]}*} ) && (( $#filtered > 0 )) && list=( ${filtered[@]} ) + # +zinit-message "{pre}gh-r{rst}:{info} ${matchstr[${MACHTYPE}]}\\n{obj}${(pj:\n:)${(@)list[1,5]:t}}{rst}" + } - # filter urls by newest (i.e., highest number) - if (( $#list > 1 )) { - list2=( ${list[@]:#(#i)*.(sha[[:digit:]]#|asc)} ) - (( $#list2 > 0 )) && list=( ${list2[@]} ) - } + if (( $#list > 1 )) { + filtered=( ${(M)list[@]:#(#i)*${~matchstr[${OSTYPE//[0-9.]/}]}*} ) && (( $#filtered > 0 )) && list=( ${filtered[@]} ) + # +zinit-message "{pre}gh-r{rst}:{info} ${matchstr[${OSTYPE//[0-9.]/}]}\\n{obj}${(pj:\n:)${(@)list[1,5]:t}}{rst}" + } - if (( !$#list )) { - +zinit-message -n "{pre}gh-r:{error} failed to find the correct GitHub release asset to download" - if [[ -n $bpick ]] { - +zinit-message -n ", modify {obj}bpick{error}-ICE (current bpick{error}: {file}${bpick}{error})." - } else { - +zinit-message -n . - } - +zinit-message '{rst}' - return 1 - } + if (( $#list > 1 )) { + filtered=( ${(M)list[@]:#(#i)*${~matchstr[${CPUTYPE}]}*} ) && (( $#filtered > 0 )) && list=( ${filtered[@]} ) + # +zinit-message "{pre}gh-r{rst}:{info} ${matchstr[${CPUTYPE}]}\\n{obj}${(pj:\n:)${(@)list[1,5]:t}}{rst}" + } + + if (( $#list > 1 )) { + filtered=( ${(M)list[@]:#(#i)*${~matchstr[${$(uname)}]}*} ) && (( $#filtered > 0 )) && list=( ${filtered[@]} ) + # +zinit-message "{pre}gh-r{rst}:{info} ${matchstr[$(uname)]}\\n{obj}${(pj:\n:)${(@)list[1,5]:t}}{rst}" + } + + if (( $#list > 1 )) { + filtered=( ${(M)list[@]:#(#i)*${~HAS_MUSL}*} ) && (( $#filtered > 0 )) && list=( ${filtered[@]} ) + # +zinit-message "{pre}gh-r{rst}:{info} ${HAS_MUSL} \\n{obj}${(pj:\n:)${(@)list[1,5]:t}}{rst}" + } + + # FILTER URLS BY NEWEST (I.E., HIGHEST NUMBER) + if (( $#list > 1 )) { + filtered=( ${list[@]:#(#i)*.(sha[[:digit:]]#|asc)} ) && (( $#filtered > 0 )) && list=( ${filtered[@]} ) + } + + if (( !$#list )) { + +zinit-message -n "{pre}gh-r:{error} failed to find the correct GitHub release asset to download" + if [[ -n $bpick ]] { +zinit-message -n ", modify {obj}bpick{error}-ICE (current bpick{error}: {file}${bpick}{error})." } \ + else { +zinit-message -n . } + +zinit-message '{rst}' + return 1 + } - reply+=( $list[1] ) + reply+=( $list[1] ) } - [[ -n $reply ]] + [[ -n $reply ]] } # ]]] # FUNCTION: ziextract [[[ # If the file is an archive, it is extracted by this function.