Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package bat-extras for openSUSE:Factory checked in at 2023-03-26 20:19:36 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/bat-extras (Old) and /work/SRC/openSUSE:Factory/.bat-extras.new.31432 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "bat-extras" Sun Mar 26 20:19:36 2023 rev:3 rq:1074348 version:2023.03.21 Changes: -------- --- /work/SRC/openSUSE:Factory/bat-extras/bat-extras.changes 2022-07-29 16:47:41.078616978 +0200 +++ /work/SRC/openSUSE:Factory/.bat-extras.new.31432/bat-extras.changes 2023-03-26 20:19:38.215095913 +0200 @@ -1,0 +2,15 @@ +Sat Mar 25 13:07:25 UTC 2023 - Jan-Luca Kiok <[email protected]> + +- Update to release 2023-03-21 + * batdiff: Update docs to add BATDIFF_USE_DELTA + * batman: Allow spaces in manual sections + * batman: Fix parsing manual pages in fzf preview + * batman: Only parse first manpage when selected + * batman: Fix bug where some man pages would fail to open + * batpipe: Fix SELF variable being wrong when compressed + * batpipe: Add BATPIPE_TERM_WIDTH + * batpipe: Fix opened-in-less detection + * batwatch docs: Fix link to entr project + * docs: Update README about manual files + +------------------------------------------------------------------- Old: ---- v2022.07.27.tar.gz New: ---- v2023.03.21.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ bat-extras.spec ++++++ --- /var/tmp/diff_new_pack.bvfplZ/_old 2023-03-26 20:19:39.199101054 +0200 +++ /var/tmp/diff_new_pack.bvfplZ/_new 2023-03-26 20:19:39.207101096 +0200 @@ -1,7 +1,7 @@ # # spec file for package bat-extras # -# Copyright (c) 2022 SUSE LLC +# Copyright (c) 2023 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: bat-extras -Version: 2022.07.27 +Version: 2023.03.21 Release: 0 Summary: Extra scripts for bat License: MIT ++++++ v2022.07.27.tar.gz -> v2023.03.21.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bat-extras-2022.07.27/.circleci/config.yml new/bat-extras-2023.03.21/.circleci/config.yml --- old/bat-extras-2022.07.27/.circleci/config.yml 2022-07-27 22:30:27.000000000 +0200 +++ new/bat-extras-2023.03.21/.circleci/config.yml 1970-01-01 01:00:00.000000000 +0100 @@ -1,107 +0,0 @@ -version: 2.1 - -executors: - linux_alpine: - docker: - - image: alpine:latest - environment: - TERM: xterm - -commands: - setup: - description: "Set up the environment needed to test and run the scripts." - steps: - - run: - name: "APK: Add repository." - command: | - printf "\n%s\n" "http://nl.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories - printf "\n%s\n" "http://nl.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories - - run: - name: "APK: Update cache." - command: apk update - - run: - name: "Setup: Install build packages." - command: apk add git openssh bash python3 diffutils ca-certificates curl shfmt - - run: - name: "Setup: Install test packages." - command: apk add util-linux coreutils fish - - run: - name: "Setup: Install runtime packages." - command: apk add bat ripgrep ncurses - - build: - description: "Build the self-contained scripts." - parameters: - minify: - type: string - default: "lib" - manuals: - type: string - default: "false" - steps: - - run: - name: "Build" - command: ./build.sh --minify=<<parameters.minify>> --manuals=<<parameters.manuals>> --no-verify - -jobs: - build: - executor: linux_alpine - steps: - - setup - - checkout - - build: - minify: "all" - manuals: "true" - - build: - minify: "all" - manuals: "true" - - store_artifacts: - path: bin - - store_artifacts: - path: man - - test: - executor: linux_alpine - steps: - - setup - - checkout - - build: - minify: "all" - - run: - name: "Test: Unit Tests / Snapshots" - command: ./test.sh --verbose --strict --snapshot:show - - test-consistency: - executor: linux_alpine - steps: - - setup - - checkout - - build: - minify: "all" - - run: - name: "Test: Consistency" - command: ./test.sh --compiled --verbose --snapshot:show - - test-symlink: - executor: linux_alpine - steps: - - setup - - checkout - - run: - name: "Symlink" - command: ln -s "$PWD/src/batgrep.sh" /tmp/batgrep - - run: - name: "Test: Symlink" - command: /tmp/batgrep 'a' >/dev/null - -workflows: - version: 2 - default: - jobs: - - build - - test: - requires: [build] - - test-consistency: - requires: [build, test] - - test-symlink: - requires: [build] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bat-extras-2022.07.27/.github/actions/build/action.yaml new/bat-extras-2023.03.21/.github/actions/build/action.yaml --- old/bat-extras-2022.07.27/.github/actions/build/action.yaml 1970-01-01 01:00:00.000000000 +0100 +++ new/bat-extras-2023.03.21/.github/actions/build/action.yaml 2023-03-21 09:58:48.000000000 +0100 @@ -0,0 +1,54 @@ +name: 'Build' +description: 'Builds bat-extras' +inputs: + manuals: + description: 'Builds manuals' + required: false + default: true + inline: + description: 'Inlines executable names in script' + required: false + default: true + verify: + description: 'Verifies after building' + required: false + default: false + minify: + description: 'Minification mode (none, all, lib)' + required: false + default: 'none' + +runs: + using: composite + steps: + + - name: Run build script + shell: bash + run: | + args=( + --banner + --minify="${{ inputs.minify }}" + ) + + if "${{ inputs.manuals }}"; then + args+=(--manuals) + else + args+=(--no-manuals) + fi + + if "${{ inputs.verify }}"; then + args+=(--verify) + else + args+=(--no-verify) + fi + + if "${{ inputs.inline }}"; then + args+=(--inline) + else + args+=(--no-inline) + fi + + # Run the build script. + cd "${{ github.workspace }}" + PATH="${{ runner.temp }}/bin:${PATH}" + bash "${{ github.workspace }}/build.sh" "${args[@]}" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bat-extras-2022.07.27/.github/actions/install-dependencies/action.yaml new/bat-extras-2023.03.21/.github/actions/install-dependencies/action.yaml --- old/bat-extras-2022.07.27/.github/actions/install-dependencies/action.yaml 1970-01-01 01:00:00.000000000 +0100 +++ new/bat-extras-2023.03.21/.github/actions/install-dependencies/action.yaml 2023-03-21 09:58:48.000000000 +0100 @@ -0,0 +1,93 @@ +name: 'Install dependencies' +description: 'Installs all the dependencies needed.' +inputs: + build: + description: 'Install build dependencies.' + required: false + default: true + test: + description: 'Install test dependencies.' + required: true + default: false + + version_bat: + description: 'The version of bat to install.' + required: false + default: "latest" + + version_ripgrep: + description: 'The version of ripgrep to install.' + required: false + default: "latest" + +runs: + using: "composite" + steps: + + - name: Create directories + shell: bash + run: | + test -d "${RUNNER_TEMP}/bin" || mkdir -p "${RUNNER_TEMP}/bin" + test -d "${RUNNER_TEMP}/dl" || mkdir -p "${RUNNER_TEMP}/dl" + + - name: Install shfmt (build dependency) + shell: bash + if: ${{ env.ACT || inputs.build == 'true' }} + run: | + curl \ + --silent \ + --location \ + --output "${RUNNER_TEMP}/bin/shfmt" \ + "https://github.com/patrickvane/shfmt/releases/download/master/shfmt_linux_amd64" + chmod +x "${RUNNER_TEMP}/bin/shfmt" + + - name: Download bat (test dependency) + uses: dsaltares/fetch-gh-release-asset@master + if: ${{ env.ACT || inputs.test == 'true' }} + with: + file: "bat-v[0-9\\.]+-x86_64-unknown-linux-gnu.tar.gz" + repo: "sharkdp/bat" + # version: "${{ inputs.version_bat || "latest" }}" + regex: true + target: ".dl/" + + - name: Install bat + shell: bash + if: ${{ env.ACT || inputs.test == 'true' }} + run: | + tar -xf \ + "${{ github.workspace }}/.dl"/bat-*.tar.* \ + -C "${{ runner.temp }}/dl/" + + find "${{ runner.temp }}/dl" \ + -type f -iname "bat" \ + -exec mv {} "${RUNNER_TEMP}/bin/" \; + + - name: Download ripgrep (test dependency) + uses: dsaltares/fetch-gh-release-asset@master + if: ${{ env.ACT || inputs.test == 'true' }} + with: + file: "ripgrep_[0-9\\.]+_amd64.deb" + repo: "BurntSushi/ripgrep" + # version: "${{ inputs.version_ripgrep || "latest" }}" + regex: true + target: ".dl/" + + - name: Install ripgrep + shell: bash + if: ${{ env.ACT || inputs.test == 'true' }} + run: | + dpkg-deb -x \ + "${{ github.workspace }}/.dl"/ripgrep_*.deb \ + "${{ runner.temp }}/dl/" + + find "${{ runner.temp }}/dl" \ + -type f -path "*/bin/rg" \ + -exec mv {} "${{ runner.temp }}/bin/" \; + + - name: Set executable permissions + shell: bash + run: | + chmod -R +x "${{ runner.temp }}/bin" + tree "${{ runner.temp }}/bin" + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bat-extras-2022.07.27/.github/actions/test/action.yaml new/bat-extras-2023.03.21/.github/actions/test/action.yaml --- old/bat-extras-2022.07.27/.github/actions/test/action.yaml 1970-01-01 01:00:00.000000000 +0100 +++ new/bat-extras-2023.03.21/.github/actions/test/action.yaml 2023-03-21 09:58:48.000000000 +0100 @@ -0,0 +1,33 @@ +name: 'Test' +description: 'Tests bat-extras' +inputs: + strict: + description: 'Tests should be run under strict mode' + required: false + default: false + compiled: + description: 'Test scripts that have been built' + required: false + default: false + +runs: + using: composite + steps: + + - name: Run tests + shell: bash + run: | + args=() + + if "${{ inputs.compiled }}"; then + args+=(--compiled) + fi + + if "${{ inputs.strict }}"; then + args+=(--strict) + fi + + cd "${{ github.workspace }}" + PATH="${{ runner.temp }}/bin:${PATH}" + bash "${{ github.workspace }}/test.sh" "${args[@]}" \ + --verbose --snapshot:show diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bat-extras-2022.07.27/.github/workflows/test.yaml new/bat-extras-2023.03.21/.github/workflows/test.yaml --- old/bat-extras-2022.07.27/.github/workflows/test.yaml 1970-01-01 01:00:00.000000000 +0100 +++ new/bat-extras-2023.03.21/.github/workflows/test.yaml 2023-03-21 09:58:48.000000000 +0100 @@ -0,0 +1,96 @@ +name: Test +on: + push: {} + pull_request: + types: [opened, synchronize] + +jobs: + "Build": + runs-on: ubuntu-latest + steps: + - name: Check out sources + uses: actions/checkout@v3 + - name: Install build dependencies + uses: ./.github/actions/install-dependencies + with: + build: true + test: false + - name: Build artifacts + uses: ./.github/actions/build + with: + minify: lib + manuals: true + verify: false + inline: false + - name: Upload artifacts + uses: actions/upload-artifact@v3 + if: ${{ !env.ACT && !failure() }} + with: + path: | + ${{ github.workspace }}/bin/ + ${{ github.workspace }}/doc/ + + "Test": + runs-on: ubuntu-latest + steps: + - name: Check out sources + uses: actions/checkout@v3 + - name: Install test dependencies + uses: ./.github/actions/install-dependencies + with: + build: false + test: true + - name: Test scripts + uses: ./.github/actions/test + + "Test_Consistency": + runs-on: ubuntu-latest + needs: "Test" + steps: + - name: Check out sources + uses: actions/checkout@v3 + - name: Install dependencies + uses: ./.github/actions/install-dependencies + with: + build: true + test: true + - name: Build scripts + uses: ./.github/actions/build + with: + minify: lib + manuals: false + verify: false + inline: false + - name: Test built scripts + uses: ./.github/actions/test + with: + compiled: true + + "Test_Symlinks": + runs-on: ubuntu-latest + needs: "Test" + env: + BAT_PAGER: 'cat' + steps: + - name: Check out sources + uses: actions/checkout@v3 + - name: Install dependencies + uses: ./.github/actions/install-dependencies + with: + build: false + test: true + - name: Prepare symlinks + run: | + chmod +x "${{ github.workspace }}/src/batgrep.sh" + ln -s "${{ github.workspace }}/src/batgrep.sh" "${{ runner.temp }}/absolute-batgrep" + (cd "${{ github.workspace }}" && ln -s "src/batgrep.sh" relative-batgrep) + - name: Test absolute symlink + run: | + PATH="${{ runner.temp }}/bin:${PATH}" + "${{ runner.temp }}/absolute-batgrep" 'a' <<< 'abc' + - name: Test relative symlink + run: | + PATH="${{ runner.temp }}/bin:${PATH}" + "${{ github.workspace }}/relative-batgrep" 'a' <<< 'abc' + + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bat-extras-2022.07.27/.gitignore new/bat-extras-2023.03.21/.gitignore --- old/bat-extras-2022.07.27/.gitignore 2022-07-27 22:30:27.000000000 +0200 +++ new/bat-extras-2023.03.21/.gitignore 2023-03-21 09:58:48.000000000 +0100 @@ -4,6 +4,7 @@ # Developer .idea +.vscode *.iml # Project diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bat-extras-2022.07.27/README.md new/bat-extras-2023.03.21/README.md --- old/bat-extras-2022.07.27/README.md 2022-07-27 22:30:27.000000000 +0200 +++ new/bat-extras-2023.03.21/README.md 2023-03-21 09:58:48.000000000 +0100 @@ -53,9 +53,45 @@ If you would only like to install one of the scripts, you can use `brew install eth-p/software/bat-extras-[SCRIPT]` to install it. +### Pacman + +`bat-extras` is [officially available](https://archlinux.org/packages/community/any/bat-extras/) on the Arch community repository! + +If you have the community repository enabled, you can install `bat-extras` by running: + +```bash +pacman -S bat-extras +``` + +### Gentoo +`bat-extras` is available on **Gentoo's Guru Overlay** as `sys-apps/bat-extras`. + +To install, first make sure you've added the [Gentoo Guru Overlay](https://wiki.gentoo.org/wiki/Project:GURU) to your local repositories, then emerge accordingly... + +```bash +emerge sys-apps/bat-extras +``` + +### Fedora (Unofficial) +`bat-extras` is available in an unofficial Fedora Copr +[repository](https://copr.fedorainfracloud.org/coprs/awood/bat-extras/). +**Note**: this package does not contain `prettybat` since `prettier` is not yet +packaged for Fedora. + +Install the Copr plugin, enable the repository, and then install the package +by running: + +```bash +dnf install dnf-plugins-core +dnf copr enable awood/bat-extras +dnf install bat-extras +``` + -## Installation () +## Installation + +[](https://github.com/eth-p/bat-extras/actions/workflows/test.yaml) The scripts in this repository are designed to run as-is, provided that they aren't moved around. This means that you're free to just symlink `src/[script].sh` to your local bin folder. @@ -97,11 +133,10 @@ -**Manuals:** (EXPERIMENTAL) +**Manuals:** -You can specify `--manuals` to have the build script generate a `man` page for each of the markdown documentation files. -This is an experimental feature that uses a non-compliant Markdown "parser" written in Bash, and there is no guarantee -as for the quality of the generated manual pages. +The build script will automatically generate a `man` page for each of the markdown documentation files. +This is a beta feature that uses a non-compliant Markdown "parser" written in Bash, and there is no guarantee towards the quality of the generated manual pages. If you do not want to generate manual files, you can provide the `--no-manuals` option to disable manual file generation. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bat-extras-2022.07.27/build.sh new/bat-extras-2023.03.21/build.sh --- old/bat-extras-2022.07.27/build.sh 2022-07-27 22:30:27.000000000 +0200 +++ new/bat-extras-2023.03.21/build.sh 2023-03-21 09:58:48.000000000 +0100 @@ -14,6 +14,7 @@ source "${LIB}/print.sh" source "${LIB}/opt.sh" source "${LIB}/constants.sh" +source "${HERE}/mdroff.sh" # ----------------------------------------------------------------------------- set -eo pipefail exec 3>&1 @@ -120,12 +121,18 @@ # # Arguments: # 1 -- The source file. +# 2 -- A description of what is being read. # # Output: # The file contents. step_read() { + local what="" + if [[ -n "${2:-}" ]]; then + what=" $2" + fi + cat "$1" - smsg "Reading" + smsg "Reading${what}" } # Build step: preprocess @@ -218,7 +225,7 @@ smsg "Building" } -# Build step: write +# Build step: write_install # Optionally writes the output script to a file. # # Arguments: @@ -241,6 +248,47 @@ smsg "Installing" } +# Build step: manpage_install +# Optionally writes the manpage to a gzipped file. +# +# Arguments: +# 1 -- The file to write to. +# +# Input: +# The file contents. +# +# Output: +# The file contents. +step_manpage_install() { + if [[ "$OPT_INSTALL" != true ]]; then + cat + smsg "Installing manual" "SKIP" + return 0 + fi + + gzip | tee "$1" + smsg "Installing manual" +} + +# Build step: manpage_generate +# Generates a manpage document from a markdown document. +# +# Input: +# The markdown doc contents. +# +# Output: +# The roff manpage contents. +step_manpage_generate() { + if [[ "$OPT_MANUALS" != true ]]; then + cat + smsg "Generating manual" "SKIP" + return 0 + fi + + (mdroff) + smsg "Generating manual" +} + # ----------------------------------------------------------------------------- # Preprocessor: # ----------------------------------------------------------------------------- @@ -382,8 +430,11 @@ --compress) OPT_COMPRESS=true ;; --manuals) OPT_MANUALS="${OPT_VAL:-true}" ;; --no-manuals) OPT_MANUALS=false ;; + --verify) OPT_VERIFY=true ;; --no-verify) OPT_VERIFY=false ;; + --banner) OPT_BANNER=true ;; --no-banner) OPT_BANNER=false ;; + --inline) OPT_INLINE=true ;; --no-inline) OPT_INLINE=false ;; --prefix) shiftval; OPT_PREFIX="$OPT_VAL" ;; --alternate-executable) shiftval; OPT_BAT="$OPT_VAL" ;; @@ -441,6 +492,12 @@ if "$OPT_INSTALL"; then [[ -d "${OPT_PREFIX}/bin" ]] || mkdir -p "${OPT_PREFIX}/bin" + [[ "$OPT_MANUALS" = "true" && ! -d "${OPT_PREFIX}/share/man/man1" ]] \ + && mkdir -p "${OPT_PREFIX}/share/man/man1" +fi + +if [[ "$OPT_MANUALS" = "true" ]]; then + [[ -d "$MAN" ]] || mkdir -p "$MAN" fi # ----------------------------------------------------------------------------- @@ -476,29 +533,6 @@ printf "\n" fi -# ----------------------------------------------------------------------------- -# Build manuals. - -if [[ "$OPT_MANUALS" = "true" ]]; then - source "${HERE}/mdroff.sh" - if ! [[ -d "$MAN" ]]; then - mkdir -p "$MAN" - fi - - printc_msg "%{YELLOW}Building manuals...%{CLEAR}\n" - for source in "${SOURCES[@]}"; do - name="$(basename "$source" .sh)" - doc="${MAN_SRC}/${name}.md" - docout="${MAN}/${name}.1" - if ! [[ -f "$doc" ]]; then - continue - fi - - printc_msg " %{YELLOW} %{MAGENTA}%s%{CLEAR}\n" "$(basename "$docout")" - (mdroff < "$doc" > "${MAN}/${name}.1") - done - printc_msg "\n" -fi # ----------------------------------------------------------------------------- # Build files. @@ -521,6 +555,15 @@ next step_write "${BIN}/${filename}" | next step_write_install "${OPT_PREFIX}/bin/${filename}" | cat >/dev/null + + # Build manuals. + if [[ -f "${HERE}/doc/${filename}.md" && "$OPT_MANUALS" = "true" ]]; then + step_read "${HERE}/doc/${filename}.md" "manual" | + next step_manpage_generate | + next step_write "${MAN}/${filename}.1" | + next step_manpage_install "${OPT_PREFIX}/share/man/man1/${filename}.1.gz" | + cat >/dev/null + fi done # ----------------------------------------------------------------------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bat-extras-2022.07.27/doc/batdiff.md new/bat-extras-2023.03.21/doc/batdiff.md --- old/bat-extras-2022.07.27/doc/batdiff.md 2022-07-27 22:30:27.000000000 +0200 +++ new/bat-extras-2023.03.21/doc/batdiff.md 2023-03-21 09:58:48.000000000 +0100 @@ -12,7 +12,11 @@ batdiff [OPTIONS] FILE batdiff [OPTIONS] FILE OTHER_FILE +## Environment +| Variable | Description | +| ------------------------ | ------------------------------------------------ | +| `BATDIFF_USE_DELTA=true` | If `delta` is installed, use `delta` by default. | ## Options diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bat-extras-2022.07.27/doc/batpipe.md new/bat-extras-2023.03.21/doc/batpipe.md --- old/bat-extras-2022.07.27/doc/batpipe.md 2022-07-27 22:30:27.000000000 +0200 +++ new/bat-extras-2023.03.21/doc/batpipe.md 2023-03-21 09:58:48.000000000 +0100 @@ -17,6 +17,14 @@ +## Environment + +| Variable | Description | +| -------------------- | ------------------------------------------------------------ | +| `BATPIPE_TERM_WIDTH` | Sets the terminal width provided to `bat`. If this variable starts with a hyphen (`-`), the number provided will be relative to the detected terminal size. | + + + ## Built-in Viewers | Files | Program | @@ -51,7 +59,7 @@ batpipe_header [pattern] [...] -- Print a viewer header line. batpipe_subheader [pattern] [...] -- Print a viewer subheader line. - + strip_trailing_slashes [path] -- Strips trailing slashes from a path. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bat-extras-2022.07.27/doc/batwatch.md new/bat-extras-2023.03.21/doc/batwatch.md --- old/bat-extras-2022.07.27/doc/batwatch.md 2022-07-27 22:30:27.000000000 +0200 +++ new/bat-extras-2023.03.21/doc/batwatch.md 2023-03-21 09:58:48.000000000 +0100 @@ -34,7 +34,7 @@ Batwatch uses external programs to watch for file changes. Currently, the following programs are supported: -- [entr](http://entrproject.org/) +- [entr](https://eradman.com/entrproject/) There is also a fallback `poll` watcher available. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bat-extras-2022.07.27/src/batman.sh new/bat-extras-2023.03.21/src/batman.sh --- old/bat-extras-2022.07.27/src/batman.sh 2022-07-27 22:30:27.000000000 +0200 +++ new/bat-extras-2023.03.21/src/batman.sh 2023-03-21 09:58:48.000000000 +0100 @@ -49,10 +49,9 @@ selected_page="$(man -k . | "$EXECUTABLE_FZF" --delimiter=" - " --reverse -e --preview=" echo {1} \ | sed 's/, /\n/g;' \ - | sed 's/\([^(]*\)(\([0-9]\))/\2\t\1/' \ - | BAT_STYLE=plain xargs batman --color=always --paging=never - " | sed 's/^\(.*\) - .*$/\1/; s/, /\n/g' - )" + | sed 's/\([^(]*\)(\([0-9A-Za-z ]\))/\2\t\1/g' \ + | BAT_STYLE=plain xargs -n2 batman --color=always --paging=never + ")" if [[ -z "$selected_page" ]]; then exit 0 @@ -60,7 +59,7 @@ # Convert the page(section) format to something that can be fed to the man command. while read -r line; do - if [[ "$line" =~ ^(.*)\(([0-9]+)\)$ ]]; then + if [[ "$line" =~ ^(.*)\(([0-9a-zA-Z ]+)\) ]]; then MAN_ARGS+=("${BASH_REMATCH[2]}" "$(echo ${BASH_REMATCH[1]} | xargs)") fi done <<< "$selected_page" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bat-extras-2022.07.27/src/batpipe.sh new/bat-extras-2023.03.21/src/batpipe.sh --- old/bat-extras-2022.07.27/src/batpipe.sh 2022-07-27 22:30:27.000000000 +0200 +++ new/bat-extras-2023.03.21/src/batpipe.sh 2023-03-21 09:58:48.000000000 +0100 @@ -37,8 +37,9 @@ # # ----------------------------------------------------------------------------- # shellcheck disable=SC1090 disable=SC2155 -SELF="$(cd "$(dirname "${BASH_SOURCE[0]}")" && cd "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo ".")")" && pwd)/$(basename "${BASH_SOURCE[0]}")" -LIB="$(cd "$(dirname "${BASH_SOURCE[0]}")" && cd "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo ".")")/../lib" && pwd)" +SELF_NC="${BASH_SOURCE:-$0}" +SELF="$(cd "$(dirname "${SELF_NC}")" && cd "$(dirname "$(readlink "${SELF_NC}" || echo ".")")" && pwd)/$(basename "${SELF_NC}")" +LIB="$(cd "$(dirname "${SELF_NC}")" && cd "$(dirname "$(readlink "${SELF_NC}" || echo ".")")/../lib" && pwd)" source "${LIB}/constants.sh" source "${LIB}/dirs.sh" source "${LIB}/str.sh" @@ -115,10 +116,35 @@ BATPIPE_INSIDE_BAT=false TERM_WIDTH="$(term_width)" -if [[ "$(basename -- "$(parent_executable | cut -f1 -d' ')")" == less ]]; then - BATPIPE_INSIDE_LESS=true -elif [[ "$(basename -- "$(parent_executable | cut -f1 -d' ')")" == "$(basename -- "$EXECUTABLE_BAT")" ]]; then - BATPIPE_INSIDE_BAT=true +if [[ -n "${BATPIPE_TERM_WIDTH:-}" ]]; then + if [[ "${BATPIPE_TERM_WIDTH:0:1}" = "-" ]]; then + TERM_WIDTH=$((TERM_WIDTH + BATPIPE_TERM_WIDTH)) || true + else + TERM_WIDTH="$BATPIPE_TERM_WIDTH" + fi +fi + +BATPIPE_PARENT_EXECUTABLE_PID="$PPID" +for i in 1 2 3; do + BATPIPE_PARENT_EXECUTABLE="${BATPIPE_DEBUG_PARENT_EXECUTABLE:-$(parent_executable "$BATPIPE_PARENT_EXECUTABLE_PID")}" + BATPIPE_PARENT_EXECUTABLE_BASENAME="$(basename -- "${BATPIPE_PARENT_EXECUTABLE}" | cut -d' ' -f1)" + BATPIPE_PARENT_EXECUTABLE_PID="$(parent_executable_pid "$BATPIPE_PARENT_EXECUTABLE_PID")" + + if [[ "${BATPIPE_PARENT_EXECUTABLE_BASENAME}" = "less" ]]; then + BATPIPE_INSIDE_LESS=true + break + elif [[ "${BATPIPE_PARENT_EXECUTABLE_BASENAME}" == "$(basename -- "$EXECUTABLE_BAT")" ]]; then + BATPIPE_INSIDE_BAT=true + break + fi +done + +if [[ -n "${BATPIPE_DEBUG:-}" ]]; then + printf "batpipe debug:\n" + printf " %s: %s\n" \ + "BATPIPE_INSIDE_LESS" "${BATPIPE_INSIDE_LESS}" \ + "BATPIPE_INSIDE_BAT" "${BATPIPE_INSIDE_BAT}" + printf "\n" fi # ----------------------------------------------------------------------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bat-extras-2022.07.27/test/snapshot/batpipe/test_batpipe_term_width.stdout.snapshot new/bat-extras-2023.03.21/test/snapshot/batpipe/test_batpipe_term_width.stdout.snapshot --- old/bat-extras-2022.07.27/test/snapshot/batpipe/test_batpipe_term_width.stdout.snapshot 1970-01-01 01:00:00.000000000 +0100 +++ new/bat-extras-2023.03.21/test/snapshot/batpipe/test_batpipe_term_width.stdout.snapshot 2023-03-21 09:58:48.000000000 +0100 @@ -0,0 +1,26 @@ +[38;5;238mââââââââ¬ââââââââââââââââââââââââââââââââ[0m + [38;5;238mâ [0mFile: [1mfile.txt[0m +[38;5;238mââââââââ¼ââââââââââââââââââââââââââââââââ[0m +[38;5;238m 1[0m [38;5;238mâ[0m [38;5;231mcat[0m +[38;5;238m 2[0m [38;5;238mâ[0m [38;5;231mdog[0m +[38;5;238m 3[0m [38;5;238mâ[0m [38;5;231mcar[0m +[38;5;238m 4[0m [38;5;238mâ[0m [38;5;231mfrog[0m +[38;5;238m 5[0m [38;5;238mâ[0m [38;5;231mfox[0m +[38;5;238m 6[0m [38;5;238mâ[0m [38;5;231mclocks[0m +[38;5;238m 7[0m [38;5;238mâ[0m [38;5;231mbash[0m +[38;5;238m 8[0m [38;5;238mâ[0m [38;5;231m$300[0m +[38;5;238m 9[0m [38;5;238mâ[0m [38;5;231m^$!@[0m +[38;5;238mââââââââ´ââââââââââââââââââââââââââââââââ[0m +[38;5;238mââââââââ¬ââââââââââââââââââââââââââââââââââââââââââââââââââââ[0m + [38;5;238mâ [0mFile: [1mfile.txt[0m +[38;5;238mââââââââ¼ââââââââââââââââââââââââââââââââââââââââââââââââââââ[0m +[38;5;238m 1[0m [38;5;238mâ[0m [38;5;231mcat[0m +[38;5;238m 2[0m [38;5;238mâ[0m [38;5;231mdog[0m +[38;5;238m 3[0m [38;5;238mâ[0m [38;5;231mcar[0m +[38;5;238m 4[0m [38;5;238mâ[0m [38;5;231mfrog[0m +[38;5;238m 5[0m [38;5;238mâ[0m [38;5;231mfox[0m +[38;5;238m 6[0m [38;5;238mâ[0m [38;5;231mclocks[0m +[38;5;238m 7[0m [38;5;238mâ[0m [38;5;231mbash[0m +[38;5;238m 8[0m [38;5;238mâ[0m [38;5;231m$300[0m +[38;5;238m 9[0m [38;5;238mâ[0m [38;5;231m^$!@[0m +[38;5;238mââââââââ´ââââââââââââââââââââââââââââââââââââââââââââââââââââ[0m diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bat-extras-2022.07.27/test/suite/batgrep.sh new/bat-extras-2023.03.21/test/suite/batgrep.sh --- old/bat-extras-2022.07.27/test/suite/batgrep.sh 2022-07-27 22:30:27.000000000 +0200 +++ new/bat-extras-2023.03.21/test/suite/batgrep.sh 2023-03-21 09:58:48.000000000 +0100 @@ -124,3 +124,13 @@ batgrep "ca" file.txt --no-separator --color=always } + +test:sanity_rg_works() { + description "Ensure the ripgrep executable works" + + require_rg + + rg --version + rg "ca" file.txt | grep "ca" || fail "Ripgrep executable not working." +} + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bat-extras-2022.07.27/test/suite/batpipe.sh new/bat-extras-2023.03.21/test/suite/batpipe.sh --- old/bat-extras-2022.07.27/test/suite/batpipe.sh 2022-07-27 22:30:27.000000000 +0200 +++ new/bat-extras-2023.03.21/test/suite/batpipe.sh 2023-03-21 09:58:48.000000000 +0100 @@ -25,3 +25,14 @@ assert_equal "$(batpipe compressed.txt.gz)" "OK" } + +test:batpipe_term_width() { + description "Test support for BATPIPE_TERM_WIDTH" + snapshot STDOUT + + export BATPIPE=color + export BATPIPE_DEBUG_PARENT_EXECUTABLE=less + + BATPIPE_TERM_WIDTH=40 batpipe file.txt + BATPIPE_TERM_WIDTH=-20 batpipe file.txt +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bat-extras-2022.07.27/version.txt new/bat-extras-2023.03.21/version.txt --- old/bat-extras-2022.07.27/version.txt 2022-07-27 22:30:27.000000000 +0200 +++ new/bat-extras-2023.03.21/version.txt 2023-03-21 09:58:48.000000000 +0100 @@ -1 +1 @@ -2022.07.27 +2023.03.21
