Subject: [bug#74180] [PATCH] gnu: add bash-preexec

From: Javier Olaechea <[email-masked]>
Date: Mon, 4 Nov 2024 04:27:45 +0000

> > +
> > +       (sha256
> > +        (base32
> "0nx0m1bhm4f4v033ngi2m9zq3vppimsmn8kmwqbvyqr4n6gkjmgq"))))
> > +    (build-system gnu-build-system)
>
> Looks like you can simply use the copy-build-system here, no?
>

Good call, I've updated the the package to do so. One thing I changed as
well is the location for bash-preexec.sh. I saw arch (
https://gitlab.archlinux.org/archlinux/packaging/packages/bash-preexec/-/blob/main/PKGBUILD?ref_type=heads#L30)
and nix package it under share/ instance of bin/.

Another thing I did was filtering the test files from the package. As they
require the bats package to run.

> > +    (description
> > +     "preexec and precmd hook functions for Bash 3.1+ in the style of
> > Zsh.")
>
> The description should be more descriptive. You can describe the two
> functions like they do in the README.  Use @command{bash/zsh}.  Prefix
> with "This package provides".
>

Updated accordingly. Let me know if there are any other improvements

-- 
"I object to doing things that computers can do." — Olin Shivers
From e4d7600ba9208f6850a92ba413eec32a764a79bb Mon Sep 17 00:00:00 2001
Message-ID: <[email-masked]>
From: Javier Olaechea <[email-masked]>
Date: Sat, 2 Nov 2024 15:57:54 -0500
Subject: [PATCH v2] gnu: add bash-preexec

* gnu/packages/bash.scm: (bash-preexec): New variable.

Change-Id: I642be370c903183c89174da30666b08f07d3a118
---
 gnu/packages/bash.scm | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/gnu/packages/bash.scm b/gnu/packages/bash.scm
index 93641a78d5..8a1de5a34c 100644
--- a/gnu/packages/bash.scm
+++ b/gnu/packages/bash.scm
@@ -47,6 +47,7 @@ (define-module (gnu packages bash)
   #:use-module (guix gexp)
   #:use-module (guix monads)
   #:use-module (guix store)
+  #:use-module (guix build-system copy)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system trivial)
   #:autoload   (guix gnupg) (gnupg-verify*)
@@ -488,3 +489,32 @@ (define-public blesh
 which replaces the default GNU Readline.  It adds syntax highlighting, auto
 suggestions, vim modes, and more to Bash interactive sessions.")
     (license license:bsd-3)))
+
+(define-public bash-preexec
+  (package
+    (name "bash-preexec")
+    (version "0.5.0")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/rcaloras/bash-preexec")
+             (commit version)))
+
+       (sha256
+        (base32 "0nx0m1bhm4f4v033ngi2m9zq3vppimsmn8kmwqbvyqr4n6gkjmgq"))))
+    (build-system copy-build-system)
+    (arguments
+     (list
+      #:install-plan #~'(("./" "share/bash-preexec/"
+                          #:exclude-regexp (".travis.yml" ".github/"
+                                            "LICENSE.md" "README.md" "test/")))))
+    (home-page "https://github.com/rcaloras/bash-preexec")
+    (synopsis "preexec and precmd functions for Bash just like Zsh")
+    (description
+     "This package provides preexec and precmd hook functions for @command{Bash} 3.1+ in the style of @command{Zsh}.
+
+• preexec Executed just after a command has been read and is about to be executed. The string that the user typed is passed as the first argument.
+• precmd Executed just before each prompt. Equivalent to PROMPT_COMMAND, but more flexible and resilient.
+")
+    (license license:expat)))

base-commit: ea11d3608566174c4bae70faa4f9d0c67748d2db
-- 
2.46.0