;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2019, 2020 Ludovic Courtès ;;; Copyright © 2014, 2015, 2018 Mark H Weaver ;;; Copyright © 2015, 2017 Leo Famulari ;;; Copyright © 2016, 2017, 2018, 2019 Efraim Flashner ;;; Copyright © 2018, 2019, 2020 Tobias Geerinckx-Rice ;;; Copyright © 2019 Mathieu Othacehe ;;; Copyright © 2020 Zhu Zihao ;;; Copyright © 2021 Marius Bakke ;;; ;;; This file is part of GNU Guix. ;;; ;;; GNU Guix is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 3 of the License, or (at ;;; your option) any later version. ;;; ;;; GNU Guix is distributed in the hope that it will be useful, but ;;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with GNU Guix. If not, see . (define-module (gnu packages bash) #:use-module ((guix licenses) #:prefix license:) #:use-module (gnu packages) #:use-module (gnu packages base) #:use-module (gnu packages bootstrap) #:use-module (gnu packages compression) #:use-module (gnu packages elf) #:use-module (gnu packages ncurses) #:use-module (gnu packages readline) #:use-module (gnu packages bison) #:use-module (gnu packages linux) #:use-module (gnu packages libffi) #:use-module (gnu packages pkg-config) #:use-module (gnu packages guile) #:use-module (gnu packages version-control) #:use-module (gnu packages less) #:use-module (guix packages) #:use-module (guix download) #:use-modul;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2016 Nikita <nikita@n0.is> ;;; Copyright © 2016 Sou Bunnbu <iyzsong@gmail.com> ;;; Copyright © 2023 B. Wilson <elaexuotee@wilsonb.com> ;;; ;;; This file is part of GNU Guix. ;;; ;;; GNU Guix is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 3 of the License, or (at ;;; your option) any later version. ;;; ;;; GNU Guix is distributed in the hope that it will be useful, but ;;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. (define-module (gnu packages forth) #:use-module (guix build-system gnu) #:use-module (guix build-system trivial) #:use-module (guix download) #:use-module (guix gexp) #:use-module ((guix licenses) #:prefix license:) #:use-module (guix packages) #:use-module (gnu packages m4) #:use-module (gnu packages vim)) (define-public gforth (package (name "gforth") (version "0.7.3") (source (origin (method url-fetch) (uri (string-append "mirror://gnu/gforth/gforth-" version ".tar.gz")) (sha256 (base32 "1c1bahc9ypmca8rv2dijiqbangm1d9av286904yw48ph7ciz4qig")))) (build-system gnu-build-system) (arguments '(#:parallel-build? #f ; XXX: parallel build fails #:phases (modify-phases %standard-phases (add-after 'install 'install-gforth.el (lambda* (#:key outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (emacs-sitedir (string-append out "/share/emacs/site-lisp"))) ;; TODO: compile and autoload it. (install-file "gforth.el" emacs-sitedir) #t)))))) (native-inputs (list m4)) (synopsis "Forth interpreter") (description "Gforth is a fast and portable implementation of the ANSI Forth language. It includes an editing mode for Emacs and an interpreter featuring completion and history. A generic virtual machine environment, vmgen, is also included.") (home-page "https://www.gnu.org/software/gforth/") (license license:gpl3+))) (define-public smithforth (package (name "smithforth") (version "220711") (source (origin (method url-fetch) (uri (string-append "https://dacvs.neocities.org/SF/SForth" version "dmp.txt")) (sha256 (base32 "0a39pv7529llsa3f48fmvwvlcp3f9v8qkn5ziw2l6kxf0qvli3lm")))) (build-system trivial-build-system) (native-inputs (list xxd)) (arguments (list #:modules '((guix build utils)) #:builder #~(begin (use-modules (guix build utils) (ice-9 textual-ports)) (let* ((sforth.dmp #$(package-source this-package)) (system.fs #$(origin (method url-fetch) (uri (string-append "https://dacvs.neocities.org/SF/system" version "fs.txt")) (sha256 (base32 "17v1pp64s6n8q8w3kg48nd7zdcx2208y4svr5fpfms5lkyzg7z1m")))) (xxd (string-append (assoc-ref %build-inputs "xxd") "/bin/xxd")) (bin (string-append (assoc-ref %outputs "out") "/bin"))) (copy-file sforth.dmp "sforth.dmp") (substitute* "sforth.dmp" (("#.*$") "\n")) (with-output-to-file "sforth" (lambda _ (invoke xxd "-p" "-r" "sforth.dmp") (call-with-input-file system.fs (lambda (port) (display (get-string-all port))))) #:binary #t) (chmod "sforth" #o755) (install-file "sforth" bin))))) (home-page "https://dacvs.neocities.org/SF/") (synopsis "Forth programming language for x86-64 desktop computers") (description "SmithForth is an implementation of the Forth programming language for x86-64 desktop computers. SmithForth is a text interpreter that runs in a Linux text console.") (supported-systems '("x86_64-linux")) (license license:expat-0))) include (assoc-ref outputs "include")) (lib (cut string-append <> "/lib/bash"))) (mkdir-p (lib include)) (rename-file (string-append (lib out) "/Makefile.inc") (string-append (lib include) "/Makefile.inc")) (rename-file (string-append out "/lib/pkgconfig") (string-append include "/lib/pkgconfig")) ;; Don't capture the absolute file name of 'install' to avoid ;; retaining a dependency on Coreutils. (substitute* (string-append (lib include) "/Makefile.inc") (("^INSTALL =.*") "INSTALL = install -c\n")) #t)))))) (native-search-paths (list (search-path-specification ;new in 4.4 (variable "BASH_LOADABLES_PATH") (files '("lib/bash"))))) (synopsis "The GNU Bourne-Again SHell") (description "Bash is the shell, or command-line interpreter, of the GNU system. It is compatible with the Bourne Shell, but it also integrates useful features from the Korn Shell and the C Shell and new improvements of its own. It allows command-line editing, unlimited command history, shell functions and aliases, and job control while still allowing most sh scripts to be run without modification.") (license license:gpl3+) (home-page "https://www.gnu.org/software/bash/")))) (define-public bash-minimal ;; A stripped-down Bash for non-interactive use. (package (inherit bash) (name "bash-minimal") (inputs '()) ; no readline, no curses ;; No "include" output because there's no support for loadable modules. (outputs (delete "include" (package-outputs bash))) (arguments (substitute-keyword-arguments (package-arguments bash) ((#:modules _ '()) '((guix build gnu-build-system) (guix build utils) (srfi srfi-1) (srfi srfi-26))) ((#:configure-flags flags '()) `(list "--without-bash-malloc" "--disable-readline" "--disable-history" "--disable-help-builtin" "--disable-progcomp" "--disable-net-redirections" "--disable-nls" ;; Pretend 'dlopen' is missing so we don't build loadable ;; modules and related code. "ac_cv_func_dlopen=no" ,@(if (%current-target-system) '("bash_cv_job_control_missing=no" "bash_cv_getcwd_malloc=yes") '()))) ((#:phases phases) `(modify-phases ,phases ;; No loadable modules. (delete 'move-development-files))))))) (define-public static-bash ;; Statically-linked Bash that contains nothing but the 'bash' binary and ;; 'sh' symlink, without any reference. (let ((bash (static-package bash-minimal))) (package (inherit bash) (name "bash-static") (arguments (substitute-keyword-arguments `(#:allowed-references ("out") ,@(package-arguments bash)) ((#:phases phases) `(modify-phases ,phases (add-after 'strip 'remove-everything-but-the-binary (lambda* (#:key outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (bin (string-append out "/bin"))) (remove-store-references (string-append bin "/bash")) (delete-file (string-append bin "/bashbug")) (delete-file-recursively (string-append out "/share")) #t)))))))))) (define-public bash-with-syslog (package (inherit bash) (name "bash-with-syslog") (arguments (substitute-keyword-arguments (package-arguments bash) ((#:phases phases '%standard-phases) `(modify-phases ,phases (add-after 'unpack 'enable-syslogging (lambda _ (substitute* "config-top.h" (("/\\* #define SYSLOG_HISTORY \\*/") "#define SYSLOG_HISTORY")))))))) (description "Bash is the shell, or command-line interpreter, of the GNU system. This variant logs the history to syslog."))) (define-public bash-completion (package (name "bash-completion") (version "2.8") (source (origin (method url-fetch) (uri (string-append "https://github.com/scop/" name "/releases/download/" version "/" name "-" version ".tar.xz")) (sha256 (base32 "0kgmflrr1ga9wfk770vmakna3nj46ylb5ky9ipd0v2k9ymq5a7y0")) (patches (search-patches "bash-completion-directories.patch")))) (build-system gnu-build-system) (native-inputs (list util-linux)) (arguments `(#:phases (modify-phases %standard-phases (add-after 'install 'remove-redundant-completions (lambda* (#:key inputs native-inputs outputs #:allow-other-keys) ;; Util-linux comes with a bunch of completion files for ;; its own commands which are more sophisticated and ;; up-to-date than those of bash-completion. Remove those ;; from bash-completion. (let* ((out (assoc-ref outputs "out")) (util-linux (assoc-ref (or native-inputs inputs) "util-linux")) (completions (string-append out "/share/bash-completion" "/completions")) (already (find-files (string-append util-linux "/etc/bash_completion.d")))) (with-directory-excursion completions (for-each (lambda (file) (when (file-exists? file) (delete-file file))) (map basename already))) #t)))))) (synopsis "Bash completions for common commands") (description "This package provides extensions that allow Bash to provide adapted completion for many common commands.") (home-page "https://github.com/scop/bash-completion") (license license:gpl2+))) (define-public bash-tap (package (name "bash-tap") (version "1.0.2") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/illusori/bash-tap") (commit version))) (file-name (git-file-name name version)) (sha256 (base32 "13zz9h6bhhnk3hiwhlpafrnf2isws249h3fz785dcgymk02arz9c")))) ;; There is no compilation process to use this package, however, the bash ;; scripts installed by this package start with "#!/bin/bash". To fix ;; these lines, we use the patch-shebangs of the GNU build system. The ;; project does not use a Makefile. (build-system gnu-build-system) (arguments `(#:tests? #f ; There is no test suite. #:phases (modify-phases %standard-phases ;; Because there are no configure scripts or Makefile, we can ;; remove these phases. (delete 'configure) (delete 'build) ;; The installation involves manually copying the files to a location. ;; To make them easily accessible by setting PATH, we add the scripts ;; to the "bin" folder. (replace 'install (lambda* (#:key outputs #:allow-other-keys) (let ((bin (string-append (assoc-ref outputs "out") "/bin"))) (install-file "bash-tap" bin) (install-file "bash-tap-bootstrap" bin) (install-file "bash-tap-mock" bin))))))) (home-page "https://www.illusori.co.uk/projects/bash-tap/") (synopsis "Bash port of a Test::More/Test::Builder-style TAP-compliant test library") (description "Bash TAP is a TAP-compliant Test::More-style testing library for Bash shell scripts and functions. Along with the Test::More-style testing helpers it provides helper functions for mocking commands and in-process output capturing.") (license license:expat))) (define-public bats (package (name "bats") (version "1.2.0") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/bats-core/bats-core") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "0f59zh4d4pa1a7ybs5zl6h0csbqqv11lbnq0jl1dgwm1s6p49bsq")))) (inputs (list bash coreutils guile-3.0 ;for wrap-script grep)) (arguments `(#:modules ((guix build utils)) #:builder (begin (use-modules (guix build utils)) (copy-recursively (assoc-ref %build-inputs "source") ".") (setenv "PATH" (string-append (assoc-ref %build-inputs "bash") "/bin" ":" (assoc-ref %build-inputs "coreutils") "/bin" ":" (assoc-ref %build-inputs "grep") "/bin" ":" (assoc-ref %build-inputs "guile") "/bin" ":" (getenv "PATH"))) (for-each (lambda (file) (patch-shebang file)) (find-files ".")) (substitute* "bin/bats" (("export BATS_ROOT" line) (string-append "BATS_ROOT=\"${BATS_ROOT:-" %output "/libexec/bats-core}\"\n" line))) ;; Install phase (invoke "./install.sh" %output) (wrap-script (string-append %output "/bin/bats") #:guile (search-input-file %build-inputs "bin/guile") (list "PATH" 'prefix (string-split (getenv "PATH") #\:)))))) (build-system trivial-build-system) (home-page "https://github.com/bats-core/bats-core/") (synopsis "Bash Automated Testing System") (description "Bats is a @acronym{TAP, Test Anything Protocol}-compliant testing framework for Bash. It provides a simple way to verify that the UNIX programs you write behave as expected. Bats is most useful when testing software written in Bash, but you can use it to test any UNIX program.") (license license:expat))) (define-public bash-ctypes (package (name "bash-ctypes") (version "1.2") (source (origin (method url-fetch) (uri (string-append "https://github.com/taviso/ctypes.sh/releases/download/v" version "/ctypes-sh-" version ".tar.gz")) (sha256 (base32 "0s1sifqzqmr0dnciv06yqrpzgj11d7n0gy5zaxh6b3x8bx7k75l8")))) (build-system gnu-build-system) (inputs (list elfutils libelf libffi zlib ;; Require a bash with C plugin support to build. bash)) (native-inputs (list pkg-config)) (home-page "https://github.com/taviso/ctypes.sh") (synopsis "Foreign function interface for Bash") (description "Bash-ctypes is a Bash plugin that provides a foreign function interface (FFI) directly in your shell. In other words, it allows you to call routines in shared libraries from within Bash.") (license license:expat))) (define-public blesh (package (name "blesh") (version "0.4.0-devel2") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/akinomyoga/ble.sh") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "02fdjyh4x6wr5hg3i86nsxhz8ysgjrvvxdmk6pqr0lm8ngw9p3sh")))) (arguments (list #:make-flags #~(list (string-append "PREFIX=" #$output)) #:phases #~(modify-phases %standard-phases (add-after 'unpack 'pretend-contrib-.git-exists (lambda _ (mkdir-p "contrib/.git"))) (add-after 'unpack 'make-readlink-work (lambda _ (substitute* "ble.pp" (("PATH=/bin:/usr/bin readlink") "readlink")))) (delete 'configure) ;no configure (add-before 'check 'use-LANG-for-tests (lambda _ (setenv "LANG" (getenv "LC_ALL")) (unsetenv "LC_ALL")))))) (build-system gnu-build-system) (native-inputs (list less)) (home-page "https://github.com/akinomyoga/ble.sh") (synopsis "Bash Line Editor") (description "Bash Line Editor (ble.sh) is a command line editor written in pure Bash which replaces the default GNU Readline. It adds syntax highlighting, auto suggestions, vim modes, and more to Bash interactive sessions.") (license license:bsd-3)))