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-06-20 16:47:22
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/bat-extras (Old)
 and      /work/SRC/openSUSE:Factory/.bat-extras.new.15902 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "bat-extras"

Tue Jun 20 16:47:22 2023 rev:4 rq:1093582 version:2023.06.15

Changes:
--------
--- /work/SRC/openSUSE:Factory/bat-extras/bat-extras.changes    2023-03-26 
20:19:38.215095913 +0200
+++ /work/SRC/openSUSE:Factory/.bat-extras.new.15902/bat-extras.changes 
2023-06-20 16:47:24.255017385 +0200
@@ -1,0 +2,10 @@
+Sat Jun 17 12:47:47 UTC 2023 - Jan-Luca Kiok <opensuse-packa...@jlk.one>
+
+- Update to release 2023-06-16
+  * batdiff: Add '--staged' flag
+  * batgrep: Add '--help'
+  * batman: Use self as MANPAGER
+  * prettybat: Fix short flags passed to bat
+  * build: Add termux support
+
+-------------------------------------------------------------------

Old:
----
  v2023.03.21.tar.gz

New:
----
  v2023.06.15.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ bat-extras.spec ++++++
--- /var/tmp/diff_new_pack.2Lbeqv/_old  2023-06-20 16:47:26.379030150 +0200
+++ /var/tmp/diff_new_pack.2Lbeqv/_new  2023-06-20 16:47:26.387030198 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           bat-extras
-Version:        2023.03.21
+Version:        2023.06.15
 Release:        0
 Summary:        Extra scripts for bat
 License:        MIT

++++++ v2023.03.21.tar.gz -> v2023.06.15.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/bat-extras-2023.03.21/.github/actions/build/action.yaml 
new/bat-extras-2023.06.15/.github/actions/build/action.yaml
--- old/bat-extras-2023.03.21/.github/actions/build/action.yaml 2023-03-21 
09:58:48.000000000 +0100
+++ new/bat-extras-2023.06.15/.github/actions/build/action.yaml 2023-06-16 
02:15:14.000000000 +0200
@@ -21,7 +21,7 @@
 runs:
   using: composite
   steps:
-  
+
     - name: Run build script
       shell: bash
       run: |
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/bat-extras-2023.03.21/.github/actions/build/create-release-notes.sh 
new/bat-extras-2023.06.15/.github/actions/build/create-release-notes.sh
--- old/bat-extras-2023.03.21/.github/actions/build/create-release-notes.sh     
1970-01-01 01:00:00.000000000 +0100
+++ new/bat-extras-2023.06.15/.github/actions/build/create-release-notes.sh     
2023-06-16 02:15:14.000000000 +0200
@@ -0,0 +1,31 @@
+#!/usr/bin/env bash
+# -----------------------------------------------------------------------------
+# bat-extras | Copyright (C) 2019-2023 eth-p | MIT License
+#
+# Repository: https://github.com/eth-p/bat-extras
+# Issues:     https://github.com/eth-p/bat-extras/issues
+# -----------------------------------------------------------------------------
+HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+PROJECT_DIR="$GITHUB_WORKSPACE"
+
+# -----------------------------------------------------------------------------
+# Overrides from release.sh:
+# -----------------------------------------------------------------------------
+
+batextras:get_git_workspace() {
+       printf "%s\n" "${GITHUB_WORKSPACE}"
+}
+
+batextras:get_current_commit() {
+       printf "%s\n" "${GITHUB_SHA:-$(git -C "$GITHUB_WORKSPACE" rev-parse 
HEAD)}"
+}
+
+# -----------------------------------------------------------------------------
+# Generate changelog:
+# -----------------------------------------------------------------------------
+set -euo pipefail
+
+source "${PROJECT_DIR}/release.sh"
+batextras:generate_release_notes \
+       "$(batextras:get_previous_tag_commit)" \
+       "$(batextras:get_current_commit)"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/bat-extras-2023.03.21/.github/actions/build/create-zipball.sh 
new/bat-extras-2023.06.15/.github/actions/build/create-zipball.sh
--- old/bat-extras-2023.03.21/.github/actions/build/create-zipball.sh   
1970-01-01 01:00:00.000000000 +0100
+++ new/bat-extras-2023.06.15/.github/actions/build/create-zipball.sh   
2023-06-16 02:15:14.000000000 +0200
@@ -0,0 +1,31 @@
+#!/usr/bin/env bash
+# -----------------------------------------------------------------------------
+# bat-extras | Copyright (C) 2019-2023 eth-p | MIT License
+#
+# Repository: https://github.com/eth-p/bat-extras
+# Issues:     https://github.com/eth-p/bat-extras/issues
+# -----------------------------------------------------------------------------
+HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+PROJECT_DIR="$GITHUB_WORKSPACE"
+
+# -----------------------------------------------------------------------------
+# Overrides from release.sh:
+# -----------------------------------------------------------------------------
+
+batextras:get_git_workspace() {
+       printf "%s\n" "${GITHUB_WORKSPACE}"
+}
+
+batextras:get_current_commit() {
+       printf "%s\n" "${GITHUB_SHA:-$(git -C "$GITHUB_WORKSPACE" rev-parse 
HEAD)}"
+}
+
+# -----------------------------------------------------------------------------
+# Generate changelog:
+# -----------------------------------------------------------------------------
+set -euo pipefail
+source "${PROJECT_DIR}/release.sh"
+
+zipball_name="bat-extras-$(batextras:get_version | sed 's/\.//')"
+zipball="${PROJECT_DIR}/${zipball_name}.zip"
+batextras:create_package "$zipball"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/bat-extras-2023.03.21/.github/actions/install-dependencies/action.yaml 
new/bat-extras-2023.06.15/.github/actions/install-dependencies/action.yaml
--- old/bat-extras-2023.03.21/.github/actions/install-dependencies/action.yaml  
2023-03-21 09:58:48.000000000 +0100
+++ new/bat-extras-2023.06.15/.github/actions/install-dependencies/action.yaml  
2023-06-16 02:15:14.000000000 +0200
@@ -23,7 +23,7 @@
 runs:
   using: "composite"
   steps:
-  
+
     - name: Create directories
       shell: bash
       run: |
@@ -40,7 +40,7 @@
           --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' }}
@@ -89,5 +89,4 @@
       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-2023.03.21/.github/workflows/release.yaml 
new/bat-extras-2023.06.15/.github/workflows/release.yaml
--- old/bat-extras-2023.03.21/.github/workflows/release.yaml    1970-01-01 
01:00:00.000000000 +0100
+++ new/bat-extras-2023.06.15/.github/workflows/release.yaml    2023-06-16 
02:15:14.000000000 +0200
@@ -0,0 +1,45 @@
+name: Release
+on:
+  release: {}
+  push:
+    tags: ['*']
+
+jobs:
+  "Release":
+    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:  true
+
+      - name: Build
+        uses: ./.github/actions/build
+        with:
+          minify: lib
+          manuals: true
+          verify: true
+          inline: false
+
+      - name: Create zipball
+        run:  bash "${{ github.workspace 
}}/.github/actions/build/create-zipball.sh"
+
+      - name: Generate changelog
+        id:   changelog
+        run: |
+          output_file="release-notes.md"
+          output_title="Release: $(date '+%Y-%m-%d')"
+
+          bash "${{ github.workspace 
}}/.github/actions/build/create-release-notes.sh" | tee "${output_file}"
+          echo "::set-output name=file::${output_file}"
+          echo "::set-output name=title::${output_title}"
+
+      - name: Create release
+        uses: ncipollo/release-action@v1
+        with:
+          artifacts: "bat-extras-*.zip"
+          bodyFile: "${{steps.changelog.outputs.file}}"
+          name: "${{steps.changelog.outputs.title}}"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/bat-extras-2023.03.21/README.md 
new/bat-extras-2023.06.15/README.md
--- old/bat-extras-2023.03.21/README.md 2023-03-21 09:58:48.000000000 +0100
+++ new/bat-extras-2023.06.15/README.md 2023-06-16 02:15:14.000000000 +0200
@@ -48,9 +48,9 @@
 
 ### Homebrew
 
-All of the `bat-extras` scripts can be installed with `brew install 
eth-p/software/bat-extras`.
+All of the `bat-extras` scripts can be installed with `brew install 
bat-extras`.
 
-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.
+If you would prefer to only install the specific scripts you need, you can use 
the `eth-p/software` tap to install individual scripts: `brew install 
eth-p/software/bat-extras-[SCRIPT]`
 
 
 ### Pacman 
@@ -145,6 +145,7 @@
 Depending on the distribution, bat may have been renamed to avoid package 
conflicts.
 If you wish to use these scripts on a distribution where this is the case, 
there is an `--alternate-executable=NAME` option which will build the scripts 
to use an alternate executable name.
 
+You may also specify alternate executables for `ripgrep`, `delta`, `fzf`, or 
`git` with `--alternate-executable:PROGRAM NAME` where `PROGRAM` is one the 
aforementioned programs. Note that doing so may cause verification to fail.
 
 
 **Verification:**
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/bat-extras-2023.03.21/build.sh 
new/bat-extras-2023.06.15/build.sh
--- old/bat-extras-2023.03.21/build.sh  2023-03-21 09:58:48.000000000 +0100
+++ new/bat-extras-2023.06.15/build.sh  2023-06-16 02:15:14.000000000 +0200
@@ -1,16 +1,115 @@
 #!/usr/bin/env bash
 # -----------------------------------------------------------------------------
-# bat-extras | Copyright (C) 2019 eth-p | MIT License
+# bat-extras | Copyright (C) 2019-2023 eth-p | MIT License
 #
 # Repository: https://github.com/eth-p/bat-extras
 # Issues:     https://github.com/eth-p/bat-extras/issues
 # -----------------------------------------------------------------------------
-HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
-BIN="$HERE/bin"
-SRC="$HERE/src"
-MAN="$HERE/man"
-MAN_SRC="$HERE/doc"
+
+# -----------------------------------------------------------------------------
+# Build-as-a-Library Functions:
+# -----------------------------------------------------------------------------
+
+# Redefines a function to print a constant string whenever called.
+# This is used for lazy-loading of some getter functions.
+#
+# Arguments:
+#     1  -- The function name.
+#     2  -- The constant string to print.
+#
+# Output:
+#     The constant string.
+batextras:lazy_done() {
+       eval "$(printf "%s() { printf \"%%s\n\" %q; }" "$1" "$2")"
+       "$1"
+}
+
+# Checks to see if a function is defined.
+# Arguments:
+#     1  -- The function name.
+#           If prefixed with "::", it will use "batextras:" as a namespace.
+batextras:is_function_defined() {
+       local name="$1"
+       if [[ "${name:0:2}" = "::" ]]; then name="batextras:${name:2}"; fi
+       [[ "$(type -t "$name" || echo 'undefined')" = "function" ]]
+       return $?
+}
+
+# Prints the path to the project directory.
+if ! batextras:is_function_defined ::get_project_directory; then
+       batextras:get_project_directory() {
+               batextras:lazy_done "${FUNCNAME[0]}" \
+                       "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+       }
+fi
+
+# Prints the path to the project source directory.
+if ! batextras:is_function_defined ::get_source_directory; then
+       batextras:get_source_directory() {
+               batextras:lazy_done "${FUNCNAME[0]}" \
+                       "$(batextras:get_project_directory)/src"
+       }
+fi
+
+# Prints the path to the project output directory for executables.
+if ! batextras:is_function_defined ::get_output_bin_directory; then
+       batextras:get_output_bin_directory() {
+               batextras:lazy_done "${FUNCNAME[0]}" \
+                       "$(batextras:get_project_directory)/bin"
+       }
+fi
+
+# Prints the path to the project output directory for manuals.
+if ! batextras:is_function_defined ::get_output_man_directory; then
+       batextras:get_output_man_directory() {
+               batextras:lazy_done "${FUNCNAME[0]}" \
+                       "$(batextras:get_project_directory)/man"
+       }
+fi
+
+# Prints the path to the project directory for documentation.
+if ! batextras:is_function_defined ::get_docs_directory; then
+       batextras:get_docs_directory() {
+               batextras:lazy_done "${FUNCNAME[0]}" \
+                       "$(batextras:get_project_directory)/doc"
+       }
+fi
+
+# Prints the declared version (in version.txt).
+if ! batextras:is_function_defined ::get_version; then
+       batextras:get_version() {
+               batextras:lazy_done "${FUNCNAME[0]}" \
+                       "$(cat 
"$(batextras:get_project_directory)/version.txt")"
+       }
+fi
+
+# Prints the paths for all source scripts in this project.
+#
+# Output:
+#     One line for each script with the full path to the script.
+if ! batextras:is_function_defined ::get_source_paths; then
+       batextras:get_source_paths() {
+               for file in "$(batextras:get_source_directory)"/*.sh; do
+                       printf "%s\n" "$file"
+                       file_bin="$(basename -- "$file" ".sh")"
+               done
+       }
+fi
+
+
+# -----------------------------------------------------------------------------
+# Main:
+# Only run everything past this point if the script is not sourced.
+# -----------------------------------------------------------------------------
+(return 0 2>/dev/null) && return 0
+
+HERE="$(batextras:get_project_directory)"
+SRC="$(batextras:get_source_directory)"
+BIN="$(batextras:get_output_bin_directory)"
+MAN="$(batextras:get_output_man_directory)"
+MAN_SRC="$(batextras:get_docs_directory)"
 LIB="$HERE/lib"
+
 source "${LIB}/print.sh"
 source "${LIB}/opt.sh"
 source "${LIB}/constants.sh"
@@ -130,7 +229,7 @@
        if [[ -n "${2:-}" ]]; then
                what=" $2"
        fi
-       
+
        cat "$1"
        smsg "Reading${what}"
 }
@@ -417,12 +516,25 @@
 OPT_INLINE=true
 OPT_MINIFY="lib"
 OPT_PREFIX="/usr/local"
-OPT_BAT="$(basename "$EXECUTABLE_BAT")"
+EXECUTABLE_BAT="$(basename -- "$EXECUTABLE_BAT")"
+ALT_EXECS=()
 BUILD_FILTER=()
 
 DOCS_URL="https://github.com/eth-p/bat-extras/blob/master/doc";
 DOCS_MAINTAINER="eth-p <eth-p@hidden.email>"
 
+# -----------------------------------------------------------------------------
+# Use a different default prefix when running on Termux.
+
+if [[ "$(uname -o)" = "Android" ]] && [[ -n "${TERMUX_VERSION:-}" ]]; then
+     OPT_PREFIX="/data/data/com.termux/files/usr/"
+else
+     OPT_PREFIX="/usr/local"
+fi
+
+# -----------------------------------------------------------------------------
+# Parse arguments.
+
 while shiftopt; do
        # shellcheck disable=SC2034
        case "$OPT" in
@@ -437,29 +549,40 @@
        --inline)                         OPT_INLINE=true ;;
        --no-inline)                      OPT_INLINE=false ;;
        --prefix)               shiftval; OPT_PREFIX="$OPT_VAL" ;;
-       --alternate-executable) shiftval; OPT_BAT="$OPT_VAL" ;;
+       --alternate-executable)         shiftval; ALT_EXECS+=("bat");     
EXECUTABLE_BAT="$OPT_VAL" ;;
+       --alternate-executable:bat)     shiftval; ALT_EXECS+=("bat");     
EXECUTABLE_BAT="$OPT_VAL" ;;
+       --alternate-executable:ripgrep) shiftval; ALT_EXECS+=("ripgrep"); 
EXECUTABLE_RIPGREP="$OPT_VAL" ;;
+       --alternate-executable:delta)   shiftval; ALT_EXECS+=("delta");   
EXECUTABLE_DELTA="$OPT_VAL" ;;
+       --alternate-executable:fzf)     shiftval; ALT_EXECS+=("fzf");     
EXECUTABLE_FZF="$OPT_VAL" ;;
+       --alternate-executable:git)     shiftval; ALT_EXECS+=("git");     
EXECUTABLE_GIT="$OPT_VAL" ;;
        --minify)                       shiftval; OPT_MINIFY="$OPT_VAL" ;;
 
+       # Print scripts.
+       --show:source-paths) get_source_paths; exit 0 ;;
+
+       # Unknown options.
        *)
                if ! [[ -f "${SRC}/${OPT}.sh" ]]; then
                        printc_err "%{RED}%s: unknown option '%s'%{CLEAR}" 
"$PROGRAM" "$OPT"
                        exit 1
                fi
-               
+
                BUILD_FILTER+=("$OPT")
                ;;
        esac
 done
 
-if [[ "$OPT_BAT" != "bat" ]]; then
-       printc_msg "%{YELLOW}Building executable scripts with an alternate bat 
executable %{CLEAR}%s%{YELLOW}.%{CLEAR}\n" "$OPT_BAT"
-       if ! command -v "$OPT_BAT" &>/dev/null; then
-               printc_err "%{YELLOW}WARNING: Bash cannot execute the specified 
file.\n"
+if [[ "${#ALT_EXECS[@]}" -gt 0 ]]; then
+       printc_msg "%{YELLOW}Building executable scripts with alternate 
executables for:%{CLEAR}\n"
+       printc_msg "%{YELLOW} - %{CLEAR}%s\n" "${ALT_EXECS[@]}"
+       printc_msg "\n"
+
+       if ! command -v "$EXECUTABLE_BAT" &>/dev/null; then
+               printc_err "%{YELLOW}WARNING: Bash cannot execute bat's 
executable file.\n"
                printc_err "%{YELLOW}         The finished scripts may not run 
properly.%{CLEAR}\n"
        fi
 
        # shellcheck disable=SC2034
-       EXECUTABLE_BAT="$OPT_BAT"
        printc_msg "\n"
 fi
 
@@ -506,31 +629,31 @@
 SOURCES=()
 
 printc_msg "%{YELLOW}Preparing scripts...%{CLEAR}\n"
-for file in "$SRC"/*.sh; do
+while read -r file; do
        file_bin="$(basename -- "$file" ".sh")"
        buildable=false
-       
+
        if ! "$buildable" && [[ "${#BUILD_FILTER[@]}" -eq 0 ]]; then
                buildable=true
        elif ! "$buildable"; then
                for buildable_file in "${BUILD_FILTER[@]}"; do
                        if [[ "$buildable_file" = "$file_bin" ]]; then
                                buildable=true
-                               break   
+                               break
                        fi
                done
        fi
-       
+
        # If that one is allowed to build, add it to the sources list.
        if "$buildable"; then
                SOURCES+=("$file")
        else
                printc_msg "          %{YELLOW}Skipping %{MAGENTA}%s%{CLEAR}\n" 
"$(basename "$file_bin")"
        fi
-done
+done < <(batextras:get_source_paths)
 
 if [[ "${#BUILD_FILTER[@]}" -gt 0 ]]; then
-       printf "\n"     
+       printf "\n"
 fi
 
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/bat-extras-2023.03.21/doc/batdiff.md 
new/bat-extras-2023.06.15/doc/batdiff.md
--- old/bat-extras-2023.03.21/doc/batdiff.md    2023-03-21 09:58:48.000000000 
+0100
+++ new/bat-extras-2023.06.15/doc/batdiff.md    2023-06-16 02:15:14.000000000 
+0200
@@ -11,6 +11,7 @@
 
     batdiff [OPTIONS] FILE
     batdiff [OPTIONS] FILE OTHER_FILE
+    batdiff --staged
 
 ## Environment
 
@@ -29,6 +30,7 @@
 |       | `--paging=["never"/"always"]` | Enable/disable paging.               
                        |
 |       | `--pager=[PAGER]`             | Specify the pager to use.            
                        |
 |       | `--terminal-width=[COLS]`     | Generate output for the specified 
terminal width.            |
+|       | `--staged`                    | Show staged changes.                 
                        |
 
 
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/bat-extras-2023.03.21/release.sh 
new/bat-extras-2023.06.15/release.sh
--- old/bat-extras-2023.03.21/release.sh        2023-03-21 09:58:48.000000000 
+0100
+++ new/bat-extras-2023.06.15/release.sh        2023-06-16 02:15:14.000000000 
+0200
@@ -1,10 +1,256 @@
 #!/usr/bin/env bash
 # -----------------------------------------------------------------------------
-# bat-extras | Copyright (C) 2019-2020 eth-p | MIT License
+# bat-extras | Copyright (C) 2019-2023 eth-p | MIT License
 #
 # Repository: https://github.com/eth-p/bat-extras
 # Issues:     https://github.com/eth-p/bat-extras/issues
 # -----------------------------------------------------------------------------
+source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/build.sh"
+
+# -----------------------------------------------------------------------------
+# Release-as-a-Library Functions:
+# -----------------------------------------------------------------------------
+
+# Prints the path to the git workspace.
+if ! batextras:is_function_defined ::get_git_workspace; then
+       batextras:get_git_workspace() {
+               batextras:lazy_done "${FUNCNAME[0]}" \
+                       "$(batextras:get_project_directory)"
+       }
+fi
+
+# Prints the commit of the latest-tagged version of bat-extras.
+if ! batextras:is_function_defined ::get_current_commit; then
+       batextras:get_current_commit() {
+               batextras:lazy_done "${FUNCNAME[0]}" \
+                       "$(batextras:git rev-parse HEAD)"
+       }
+fi
+
+# Prints the commit of the latest-tagged version of bat-extras.
+if ! batextras:is_function_defined ::get_previous_tag_commit; then
+       batextras:get_previous_tag_commit() {
+               local latest_tag
+               local before_latest_tag
+               {
+                       read -r latest_tag
+                       read -r before_latest_tag
+               } < <(batextras:git rev-list --tags --max-count=2)
+
+               # If the latest commit is a tag, go to the one before that.
+               if [[ "$(batextras:get_current_commit)" = "$latest_tag" ]]; then
+                       latest_tag="${before_latest_tag}"
+               fi
+
+               batextras:lazy_done "${FUNCNAME[0]}" "$latest_tag"
+       }
+fi
+
+# Prints the ref name of the latest-tagged version of bat-extras.
+if ! batextras:is_function_defined ::get_previous_tag_name; then
+       batextras:get_previous_tag_name() {
+               batextras:lazy_done "${FUNCNAME[0]}" \
+                       "$(batextras:git describe --tags --abbrev=0 
"$(batextras:get_previous_tag_commit)")"
+       }
+fi
+
+# Returns the suffix for a day of the month.
+#
+# Arguments:
+#     1  -- The day number.
+#
+# Output:
+#     The suffix.
+batextras:day_suffix() {
+       case "$1" in
+               11 | 12 | 13) echo "th" ;;
+               *1) echo "st" ;;
+               *2) echo "nd" ;;
+               *3) echo "rd" ;;
+               *)  echo "th" ;;
+       esac
+}
+
+# Runs `git` within the project directory.
+#
+# This takes the same arguments as git (with the exception of `-C`), and
+# does exactly what `git` would normally do.
+batextras:git() {
+       git -C "$(batextras:get_git_workspace)" "$@"
+       return $?
+}
+
+# Creates the zipball for release.
+# YOU MUST BUILD THE PROJECT FIRST!
+#
+# Arguments:
+#     1  -- The absolute path to the output zip file.
+#
+# Stderr:
+#     Messages.
+batextras:create_package() {
+       local artifact="$1"
+       local bin_dir man_dir doc_dir
+       bin_dir="$(batextras:get_output_bin_directory)"
+       man_dir="$(batextras:get_output_man_directory)"
+       doc_dir="$(batextras:get_docs_directory)"
+
+       (
+               # Remove the old zipball, if one exists.
+               if [[ -f "$artifact" ]]; then
+                       rm "$artifact" || return $?
+               fi
+
+               # Add the bin directory.
+               cd "$(dirname -- "$bin_dir")" || return $?
+               zip -r "$artifact" "$(basename -- "$bin_dir")"
+
+               # Add the doc directory.
+               cd "$(dirname -- "$doc_dir")" || return $?
+               zip -ru "$artifact" "$(basename -- "$doc_dir")"
+
+               # Add the man directory.
+               if [[ -d "$man_dir" ]]; then
+                       cd "$(dirname -- "$man_dir")" || return $?
+                       zip -ru "$artifact" "$(basename -- "$man_dir")"
+               fi
+       ) 1>&2
+}
+
+# Generates a Markdown changelog for all changes between two commits.
+#
+# Arguments:
+#     1  -- The first commit, exclusive.
+#     2  -- The second commit, inclusive.
+#     3  -- A filter in regex.
+#
+# Output:
+#     The changelog.
+batextras:generate_changelog() {
+       local start_commit="$1"
+       local end_commit="$2"
+       local filter="${3}"
+
+       # Generate sed replacement patterns.
+       local script_links=()
+       local script_names=()
+       local script script_name
+       while read -r script; do
+               script_name="$(basename "$script" .sh)"
+               script_names+=("$script_name")
+       done < <(batextras:get_source_paths)
+
+       local script_pattern
+       script_pattern="$(printf 's/\\(%s\\)/`\\1`/;' "${script_names[@]}")"
+
+       # Generate the changelog.
+       local changelog=''
+       local commit
+       local affected_module
+       local commit_message
+       while read -r commit; do
+               commit_message="$(batextras:git show -s --format=%s "$commit")"
+
+               if ! [[ "$commit_message" =~ ^([a-z-]+):[[:space:]]*(.*)$ ]]; 
then
+                       continue
+               fi
+
+               affected_module="${BASH_REMATCH[1]}"
+
+               # Make module names consistent.
+               case "$affected_module" in
+                       dev | lib | mdroff) affected_module="developer" ;;
+                       tests) affected_module="test" ;;
+                       doc) affected_module="docs" ;;
+               esac
+
+               # Append to changelog.
+               if [[ "$affected_module" =~ ^($filter)$ ]]; then
+                       changelog="$changelog"$'\n'" - ${commit_message}"
+               fi
+       done < <(batextras:git rev-list "${start_commit}..${end_commit}")
+
+       # Print the changelog.
+       changelog="$(sed "$script_pattern" <<< "$changelog")"
+       printf "%s\n" "${changelog:1}"
+       return 0
+}
+
+# Generates the Markdown release notes.
+#
+# Arguments:
+#     1  -- The oldest commit, exclusive.
+#     2  -- The newest commit, inclusive.
+#
+# Output:
+#     The changelog.
+batextras:generate_release_notes() {
+       local commit_oldest="$1"
+       local commit_newest="$2"
+       local 
commit_newest_url="https://github.com/eth-p/bat-extras/tree/${commit_newest}";
+       local date_str
+
+       # Get the commit date.
+       local date_year date_month date_day date_month_text date_day_suffix
+       read -r date_year date_month date_day date_month_text \
+               < <(batextras:git show -s --format="%cd" --date="format:%Y %m 
%d %B" "$commit_newest")
+
+       date_day_suffix="$(batextras:day_suffix "$date_day")"
+       date_str="${date_month_text} ${date_day}${date_day_suffix}, 
${date_year}"
+
+       # For each built script, we want to:
+       #   - Get the name of the script.
+       #   - Get a link to the documentation.
+       #   - Add it to the filter for non-developer items.
+       local script_name script_names script_links script_filters 
script_list_markdown
+       script_links=()
+       script_names=()
+       script_filters=''
+
+       while read -r script; do
+               script_name="$(basename "$script" .sh)"
+               script_names+=("$script_name")
+               
script_links+=("[\`${script_name}\`](https://github.com/eth-p/bat-extras/blob/${commit_newest}/doc/${script_name}.md)")
+               script_filters="${script_filters}|$(printf "%q" "$script_name")"
+       done < <(batextras:get_source_paths)
+
+       script_filters="${script_filters:1}" # Remove the leading "|"
+       script_list_markdown="$(printf "%s, " 
"${script_links[@]:0:$((${#script_links[@]} - 1))}")"
+       script_list_markdown="${script_list_markdown}and 
${script_links[$((${#script_links[@]} - 1))]}"
+
+       # Get the changelog.
+       local changelog changelog_dev
+       changelog="$(batextras:generate_changelog "$commit_oldest" 
"$commit_newest" "$script_filters")"
+       changelog_dev="$(batextras:generate_changelog "$commit_oldest" 
"$commit_newest" "test|developer|ci|build")"
+
+       # Print the template.
+       { sed '/\\$/{N;s/\\\n//;s/\n//p;}'; } <<- EOF
+               This contains the latest versions of ${script_list_markdown} as 
of commit [${commit_newest}](${commit_newest_url}) (${date_str}).
+
+               **This is provided as a convenience only.**
+               I would still recommend following the installation instructions 
in [the README](https://github.com/eth-p/bat-extras#installation-) for the most 
up-to-date versions.
+
+               ### Changes
+               ${changelog}
+
+               ### Developer
+               <details>
+               <div markdown="1">
+
+               ${changelog_dev}
+
+               </div>
+               </details>
+       EOF
+
+}
+
+# -----------------------------------------------------------------------------
+# Main:
+# Only run everything past this point if the script is not sourced.
+# -----------------------------------------------------------------------------
+(return 0 2>/dev/null) && return 0
+
 HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
 DATE="$(date +%Y%m%d)"
 VERSION="$(< "${HERE}/version.txt")"
@@ -14,22 +260,23 @@
 source "${LIB}/print.sh"
 source "${LIB}/opt.sh"
 # -----------------------------------------------------------------------------
+set -euo pipefail
 
 # -----------------------------------------------------------------------------
 # Options.
 OPT_ARTIFACT="bat-extras-${DATE}.zip"
 OPT_SINCE=
 OPT_BAD_IDEA=false
-OPT_BIN_DIR="$HERE/bin"
-OPT_DOC_DIR="$HERE/doc"
-OPT_MAN_DIR="$HERE/man"
+OPT_BIN_DIR="$(batextras:get_output_bin_directory)"
+OPT_DOC_DIR="$(batextras:get_docs_directory)"
+OPT_MAN_DIR="$(batextras:get_output_man_directory)"
 
 while shiftopt; do
        case "$OPT" in
                --since)
                        shiftval
                        OPT_SINCE="$OPT_VAL"
-                       if ! git rev-parse "$OPT_SINCE" &> /dev/null; then
+                       if ! batextras:git rev-parse "$OPT_SINCE" &> /dev/null; 
then
                                printc "%{RED}%s: unknown commit or tag for 
'%s'\n" "$PROGRAM" "$OPT"
                                exit 1
                        fi
@@ -48,6 +295,10 @@
 
 # -----------------------------------------------------------------------------
 # Verify the version matches today's date.
+
+VERSION="$(source "${LIB}/constants.sh" && echo "${PROGRAM_VERSION}")"
+VERSION_EXPECTED="$(date +%Y.%m.%d)"
+
 if [[ "$VERSION" != "$VERSION_EXPECTED" ]] && ! "$OPT_BAD_IDEA"; then
        printc "%{RED}The expected version does not match 
%{DEFAULT}version.txt%{RED}!%{CLEAR}\n"
        printc "%{RED}Expected: %{YELLOW}%s%{CLEAR}\n" "$VERSION_EXPECTED"
@@ -56,6 +307,18 @@
 fi
 
 # -----------------------------------------------------------------------------
+# Verify the working tree is clean-ish.
+
+if ! "$OPT_BAD_IDEA"; then
+       while read -r flags file; do
+               if [[ "$flags" =~ M ]]; then
+                       printc "%{RED}Found an uncommitted change in 
%{DEFAULT}%s%{RED}!%{CLEAR}\n" "$file"
+                       exit 1
+               fi
+       done < <(batextras:git status --porcelain)
+fi
+
+# -----------------------------------------------------------------------------
 # Build files.
 
 # Clean the old files.
@@ -75,110 +338,13 @@
 # Build package.
 
 printc "%{YELLOW}Packaging artifacts...%{CLEAR}\n"
-(
-       rm "$OPT_ARTIFACT"
-       cd "$(dirname "$OPT_BIN_DIR")"
-       zip -r "$OPT_ARTIFACT" "$(basename "$OPT_BIN_DIR")"
-       cd "$(dirname "$OPT_DOC_DIR")"
-       zip -ru "$OPT_ARTIFACT" "$(basename "$OPT_DOC_DIR")"
-       if [[ -d "$OPT_MAN_DIR" ]]; then
-               cd "$(dirname "$OPT_MAN_DIR")"
-               zip -ru "$OPT_ARTIFACT" "$(basename "$OPT_MAN_DIR")"
-       fi
-)
-
+batextras:create_package "$OPT_ARTIFACT"
 printc "%{YELLOW}Package created as %{BLUE}%s%{YELLOW}.%{CLEAR}\n" 
"$OPT_ARTIFACT"
 
 # -----------------------------------------------------------------------------
 # Print template description package.
 
 printc "%{YELLOW}Release description:%{CLEAR}\n"
-
-# Get the commit hash.
-COMMIT="$(git rev-parse HEAD)"
-COMMIT_URL="https://github.com/eth-p/bat-extras/tree/${COMMIT}";
-
-# Get the release date string.
-DATE_DAY="$(date +%e | sed 's/ //')"
-DATE_SUFFIX=""
-case "$DATE_DAY" in
-       11 | 12 | 13) DATE_SUFFIX="th" ;;
-       *1) DATE_SUFFIX="st" ;;
-       *2) DATE_SUFFIX="nd" ;;
-       *3) DATE_SUFFIX="rd" ;;
-       *)  DATE_SUFFIX="th" ;;
-esac
-DATE_STR="$(date +'%B') ${DATE_DAY}${DATE_SUFFIX}, $(date +'%Y')"
-
-# Get the script names.
-script_links=()
-script_names=()
-for script in "$SRC"/*.sh; do
-       script_name="$(basename "$script" .sh)"
-       script_names+=("$script_name")
-       
script_links+=("[\`${script_name}\`](https://github.com/eth-p/bat-extras/blob/${COMMIT}/doc/${script_name}.md)")
-done
-
-script_pattern="$(printf 's/\\(%s\\)/`\\1`/;' "${script_names[@]}")"
-SCRIPTS="$(printf "%s, " "${script_links[@]:0:$((${#script_links[@]} - 1))}")"
-SCRIPTS="${SCRIPTS}and ${script_links[$((${#script_links[@]} - 1))]}"
-
-# Get the changelog.
-CHANGELOG_DEV=''
-CHANGELOG=''
-if [[ -n "$OPT_SINCE" ]]; then
-       ref="$(git rev-parse HEAD)"
-       end="$(git rev-parse "$OPT_SINCE")"
-       while [[ "$ref" != "$end" ]]; do
-               is_developer=false
-               ref_message="$(git show -s --format=%s "$ref")"
-               ref="$(git rev-parse "${ref}~1")"
-
-               if [[ "$ref_message" =~ ^([a-z-]+):[[:space:]]*(.*)$ ]]; then
-                       affected_module="${BASH_REMATCH[1]}"
-
-                       # Make module names consistent.
-                       case "$affected_module" in
-                               dev | lib | mdroff) affected_module="developer" 
;;
-                               tests) affected_module="test" ;;
-                               doc) affected_module="docs" ;;
-                       esac
-
-                       # Switch to the correct changelog.
-                       case "$affected_module" in
-                               test | developer | ci | build) 
is_developer=true ;;
-                       esac
-               fi
-
-               # Append to changelog.
-               if "$is_developer"; then
-                       CHANGELOG_DEV="$CHANGELOG_DEV"$'\n'" - ${ref_message}"
-               else
-                       CHANGELOG="$CHANGELOG"$'\n'" - ${ref_message}"
-               fi
-       done
-fi
-
-CHANGELOG="$(sed "$script_pattern" <<< "$CHANGELOG")"
-CHANGELOG_DEV="$(sed "$script_pattern" <<< "$CHANGELOG_DEV")"
-
-# Print the template.
-sed '/\\$/{N;s/\\\n//;s/\n//p;}' <<- EOF
-       This contains the latest versions of $SCRIPTS as of commit [$(git 
rev-parse --short HEAD)]($COMMIT_URL) (${DATE_STR}).
-       
-       **This is provided as a convenience only.**
-       I would still recommend following the installation instructions in \
-       [the README](https://github.com/eth-p/bat-extras#installation-) for the 
most up-to-date versions.
-       
-       ### Changes
-       $CHANGELOG
-       
-       ### Developer
-       <details>
-       <div markdown="1">
-       
-       $CHANGELOG_DEV
-       
-       </div>
-       </details>
-EOF
+batextras:generate_release_notes \
+       "$(batextras:get_previous_tag_name)" \
+       "$(batextras:get_current_commit)"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/bat-extras-2023.03.21/src/batdiff.sh 
new/bat-extras-2023.06.15/src/batdiff.sh
--- old/bat-extras-2023.03.21/src/batdiff.sh    2023-03-21 09:58:48.000000000 
+0100
+++ new/bat-extras-2023.06.15/src/batdiff.sh    2023-06-16 02:15:14.000000000 
+0200
@@ -34,10 +34,12 @@
 BAT_VERSION="$(bat_version)"
 BAT_ARGS=()
 DELTA_ARGS=()
+GIT_ARGS=()
 
 FILES=()
 OPT_TABS=
 OPT_CONTEXT=2
+OPT_STAGED=false
 OPT_ALL_CHANGES=false
 
 # Set options based on bat version.
@@ -61,6 +63,7 @@
 
        # Script options
        --all)                      OPT_ALL_CHANGES=true ;;
+       --staged)                   OPT_STAGED=true; GIT_ARGS+=("--staged") ;;
        --delta)                    BATDIFF_USE_DELTA=true ;;
 
        # ???
@@ -95,6 +98,9 @@
        DELTA_ARGS+=("--tabs=${OPT_TABS}")
 fi
 
+# Append arguments for git.
+GIT_ARGS+=(-U"$OPT_CONTEXT")
+
 # -----------------------------------------------------------------------------
 # Printing:
 # -----------------------------------------------------------------------------
@@ -107,11 +113,26 @@
                return $?
        fi
 
+       # Diff staged git file.
+       if "$OPT_STAGED"; then
+               if false && "$SUPPORTS_DELTA"; then
+                       # bat doesn't support diffing staged changes against 
the HEAD.
+                       # Delta is better suited for printing diffs in this 
case.
+                       print_delta_diff "$@"
+               else
+                       difftext="$("$EXECUTABLE_GIT" diff "${GIT_ARGS[@]}" 
"${files[0]}")"
+                       if [[ "${#difftext}" -gt 0 ]]; then
+                               "$EXECUTABLE_BAT" --language=diff 
--file-name="${files[0]}" - "${BAT_ARGS[@]}" <<< "$difftext"
+                       fi
+               fi
+               return $?
+       fi
+
        # Diff git file.
        if "$SUPPORTS_BAT_DIFF"; then
                "$EXECUTABLE_BAT" --diff --diff-context="$OPT_CONTEXT" 
"${files[0]}" "${BAT_ARGS[@]}"
        else
-               "$EXECUTABLE_GIT" diff -U"$OPT_CONTEXT" "${files[0]}" | 
"$EXECUTABLE_BAT" --language=diff - "${BAT_ARGS[@]}"
+               "$EXECUTABLE_GIT" diff "${GIT_ARGS[@]}" "${files[0]}" | 
"$EXECUTABLE_BAT" --language=diff - "${BAT_ARGS[@]}"
        fi
 }
 
@@ -125,7 +146,7 @@
        fi
 
        # Diff git file.
-       "$EXECUTABLE_GIT" diff -U"$OPT_CONTEXT" "${files[0]}" | 
"$EXECUTABLE_DELTA" "${DELTA_ARGS[@]}"
+       "$EXECUTABLE_GIT" diff "${GIT_ARGS[@]}" "${files[0]}" | 
"$EXECUTABLE_DELTA" "${DELTA_ARGS[@]}"
 }
 
 if [[ "$BATDIFF_USE_DELTA" = "true" && "$SUPPORTS_DELTA" = "true" ]]; then
@@ -167,7 +188,7 @@
                        if [[ -f "$file" ]]; then
                                print_diff "$file"
                        fi
-               done < <("${EXECUTABLE_GIT}" diff --name-only --diff-filter=d)
+               done < <("${EXECUTABLE_GIT}" diff "${GIT_ARGS[@]}" --name-only 
--diff-filter=d)
                return
        fi
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/bat-extras-2023.03.21/src/batgrep.sh 
new/bat-extras-2023.06.15/src/batgrep.sh
--- old/bat-extras-2023.03.21/src/batgrep.sh    2023-03-21 09:58:48.000000000 
+0100
+++ new/bat-extras-2023.06.15/src/batgrep.sh    2023-06-16 02:15:14.000000000 
+0200
@@ -5,6 +5,8 @@
 # Repository: https://github.com/eth-p/bat-extras
 # Issues:     https://github.com/eth-p/bat-extras/issues
 # -----------------------------------------------------------------------------
+
+
 # shellcheck disable=SC1090
 LIB="$(cd "$(dirname "${BASH_SOURCE[0]}")" && cd "$(dirname "$(readlink 
"${BASH_SOURCE[0]}" || echo ".")")/../lib" && pwd)"
 source "${LIB}/constants.sh"
@@ -12,6 +14,7 @@
 source "${LIB}/pager.sh"
 source "${LIB}/opt.sh"
 source "${LIB}/opt_hook_color.sh"
+source "${LIB}/opt_hook_help.sh"
 source "${LIB}/opt_hook_pager.sh"
 source "${LIB}/opt_hook_version.sh"
 source "${LIB}/opt_hook_width.sh"
@@ -20,10 +23,122 @@
 # Init:
 # -----------------------------------------------------------------------------
 hook_color
+hook_help
 hook_pager
 hook_version
 hook_width
 # -----------------------------------------------------------------------------
+# Help:
+# -----------------------------------------------------------------------------
+show_help() {
+    cat <<-'EOF'
+Quickly search through and highlight files using ripgrep.
+
+Search through files or directories looking for matching regular expressions 
(or fixed strings with -F), and print the output using bat for an easy and 
syntax-highlighted experience.
+
+Usage: batgrep [OPTIONS] PATTERN [PATH...]
+
+Arguments:
+  [OPTIONS]
+          See Options below
+  PATTERN
+          Pattern passed to ripgrep
+  [PATH...]
+          Path(s) to search
+
+Options:
+  -i, --ingore-case:
+          Use case insensitive searching.
+
+  -s, --case-sensitive:
+          Use case sensitive searching.
+
+  -S, --smart-case:
+          Use smart case searching
+
+  -A, --after-context=[LINES]:
+          Display the next n lines after a matched line.
+
+  -B, --before-context=[LINES]:
+          Display the previous n lines before a matched line.
+
+  -C, --context=[LINES]:
+          A combination of --after-context and --before-context
+
+  -p, --search-pattern:
+          Tell pager to search for PATTERN. Currently supported pagers: less.
+
+      --no-follow:
+          Do not follow symlinks
+
+      --no-snip:
+          Do not show the snip decoration
+
+          This is automatically enabled when --context=0 or when bat --version 
is less than 0.12.x
+
+      --no-highlight:
+          Do not highlight matching lines.
+
+          This is automatically enabled when --context=0.
+
+      --color:
+          Force color output.
+
+      --no-color:
+          Force disable color output.
+
+      --paging=["never"/"always"]:
+          Enable/disable paging.
+
+      --pager=[PAGER]:
+          Specify the pager to use.
+
+      --terminal-wdith=[COLS]:
+          Generate output for the specified terminal width.
+
+      --no-seperator:
+          Disable printing separator between files
+
+Options passed directly to ripgrep:
+  -F, --fixed-strings
+
+  -U, --multiline
+
+  -P, --pcre2
+
+  -z, --search-zip
+
+  -w, --word-regexp
+
+      --one-file-system
+
+      --multiline-dotall
+
+      --ignore, --no-ignore
+
+      --crlf, --no-crlf
+
+      --hidden, --no-hidden
+
+  -E --encoding:
+          This is unsupported by bat, and may cause issues when trying to 
display unsupported encodings.
+
+  -g, --glob
+
+  -t, --type
+
+  -T, --type-not
+
+  -m, --max-count
+
+      --max-depth
+
+      --iglob
+
+      --ignore-file
+EOF
+}
+# -----------------------------------------------------------------------------
 # Options:
 # -----------------------------------------------------------------------------
 RG_ARGS=()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/bat-extras-2023.03.21/src/batman.sh 
new/bat-extras-2023.06.15/src/batman.sh
--- old/bat-extras-2023.03.21/src/batman.sh     2023-03-21 09:58:48.000000000 
+0100
+++ new/bat-extras-2023.06.15/src/batman.sh     2023-06-16 02:15:14.000000000 
+0200
@@ -6,7 +6,9 @@
 # Issues:     https://github.com/eth-p/bat-extras/issues
 # -----------------------------------------------------------------------------
 # shellcheck disable=SC1090 disable=SC2155
-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 "$(readlink "${SELF_NC}" || echo 
"${SELF_NC}")")"
+LIB="$(cd "$(dirname "${SELF_NC}")" && cd "$(dirname "$(readlink "${SELF_NC}" 
|| echo ".")")/../lib" && pwd)"
 if [[ -n "${MANPAGER}" ]]; then BAT_PAGER="$MANPAGER"; fi
 source "${LIB}/constants.sh"
 source "${LIB}/pager.sh"
@@ -18,12 +20,14 @@
 hook_color
 hook_version
 # -----------------------------------------------------------------------------
+FORWARDED_ARGS=()
 MAN_ARGS=()
 BAT_ARGS=()
 
 while shiftopt; do
        case "$OPT" in
-               --paging|--pager) shiftval; BAT_ARGS+=("${OPT}=${OPT_VAL}") ;;
+               --paging|--pager) shiftval; 
FORWARDED_ARGS+=("${OPT}=${OPT_VAL}");
+                                           BAT_ARGS+=("${OPT}=${OPT_VAL}") ;;
                *)                          MAN_ARGS+=("$OPT") ;;
        esac
 done
@@ -39,7 +43,27 @@
 fi
 
 # -----------------------------------------------------------------------------
-export MANPAGER='sh -c "col -bx | '"$(printf "%q" "$EXECUTABLE_BAT")"' 
--language=man '$(printf "%q " "${BAT_ARGS[@]}")'"'
+# When called as the manpager, do some preprocessing and feed everything to 
bat.
+
+if [[ "${BATMAN_IS_BEING_MANPAGER:-}" = "yes" ]]; then
+       print_manpage() {
+               col -bx | "$EXECUTABLE_BAT" --language=man "${BAT_ARGS[@]}"
+               exit $?
+       }
+
+       if [[ "${#MAN_ARGS[@]}" -eq 1 ]]; then
+               # The input was passed as a file.
+               cat "${MAN_ARGS[0]}" | print_manpage
+       else
+               # The input was passed via stdin.
+               cat | print_manpage
+       fi
+
+       exit
+fi
+
+# -----------------------------------------------------------------------------
+export MANPAGER="env BATMAN_IS_BEING_MANPAGER=yes bash $(printf "%q " "$SELF" 
"${FORWARDED_ARGS[@]}")"
 export MANROFFOPT='-c'
 
 # If no argument is provided and fzf is installed, use fzf to search for man 
pages.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/bat-extras-2023.03.21/src/prettybat.sh 
new/bat-extras-2023.06.15/src/prettybat.sh
--- old/bat-extras-2023.03.21/src/prettybat.sh  2023-03-21 09:58:48.000000000 
+0100
+++ new/bat-extras-2023.06.15/src/prettybat.sh  2023-06-16 02:15:14.000000000 
+0200
@@ -289,7 +289,9 @@
 
        # bat options
        -*) {
-               BAT_ARGS+=("$OPT=$OPT_VAL")
+               if [[ -n "$OPT_VAL" ]]; then BAT_ARGS+=("$OPT=$OPT_VAL");
+               else                         BAT_ARGS+=("$OPT");
+               fi
        } ;;
 
        # Files
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/bat-extras-2023.03.21/test/snapshot/batgrep/test_help.stdout.snapshot 
new/bat-extras-2023.06.15/test/snapshot/batgrep/test_help.stdout.snapshot
--- old/bat-extras-2023.03.21/test/snapshot/batgrep/test_help.stdout.snapshot   
1970-01-01 01:00:00.000000000 +0100
+++ new/bat-extras-2023.06.15/test/snapshot/batgrep/test_help.stdout.snapshot   
2023-06-16 02:15:14.000000000 +0200
@@ -0,0 +1,104 @@
+Quickly search through and highlight files using ripgrep.
+
+Search through files or directories looking for matching regular expressions 
(or fixed strings with -F), and print the output using bat for an easy and 
syntax-highlighted experience.
+
+Usage: batgrep [OPTIONS] PATTERN [PATH...]
+
+Arguments:
+  [OPTIONS]
+          See Options below
+  PATTERN
+          Pattern passed to ripgrep
+  [PATH...]
+          Path(s) to search
+
+Options:
+  -i, --ingore-case:
+          Use case insensitive searching.
+
+  -s, --case-sensitive:
+          Use case sensitive searching.
+
+  -S, --smart-case:
+          Use smart case searching
+
+  -A, --after-context=[LINES]:
+          Display the next n lines after a matched line.
+
+  -B, --before-context=[LINES]:
+          Display the previous n lines before a matched line.
+
+  -C, --context=[LINES]:
+          A combination of --after-context and --before-context
+
+  -p, --search-pattern:
+          Tell pager to search for PATTERN. Currently supported pagers: less.
+
+      --no-follow:
+          Do not follow symlinks
+
+      --no-snip:
+          Do not show the snip decoration
+
+          This is automatically enabled when --context=0 or when bat --version 
is less than 0.12.x
+
+      --no-highlight:
+          Do not highlight matching lines.
+
+          This is automatically enabled when --context=0.
+
+      --color:
+          Force color output.
+
+      --no-color:
+          Force disable color output.
+
+      --paging=["never"/"always"]:
+          Enable/disable paging.
+
+      --pager=[PAGER]:
+          Specify the pager to use.
+
+      --terminal-wdith=[COLS]:
+          Generate output for the specified terminal width.
+
+      --no-seperator:
+          Disable printing separator between files
+
+Options passed directly to ripgrep:
+  -F, --fixed-strings
+
+  -U, --multiline
+
+  -P, --pcre2
+
+  -z, --search-zip
+
+  -w, --word-regexp
+
+      --one-file-system
+
+      --multiline-dotall
+
+      --ignore, --no-ignore
+
+      --crlf, --no-crlf
+
+      --hidden, --no-hidden
+
+  -E --encoding:
+          This is unsupported by bat, and may cause issues when trying to 
display unsupported encodings.
+
+  -g, --glob
+
+  -t, --type
+
+  -T, --type-not
+
+  -m, --max-count
+
+      --max-depth
+
+      --iglob
+
+      --ignore-file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/bat-extras-2023.03.21/test/suite/batgrep.sh 
new/bat-extras-2023.06.15/test/suite/batgrep.sh
--- old/bat-extras-2023.03.21/test/suite/batgrep.sh     2023-03-21 
09:58:48.000000000 +0100
+++ new/bat-extras-2023.06.15/test/suite/batgrep.sh     2023-06-16 
02:15:14.000000000 +0200
@@ -16,6 +16,15 @@
        fi
 }
 
+test:help() {
+    description "Test 'batgrep --help'"
+    snapshot stdout
+    batgrep --help
+
+    assert batgrep --help
+    batgrep --help | grep -q 'Usage'
+}
+
 test:version() {
        description "Test 'batgrep --version'"
        snapshot stdout

Reply via email to