1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013 Cyril Roelandt <tipecaml@gmail.com>
3 ;;; Copyright © 2014, 2015 David Thompson <davet@gnu.org>
4 ;;; Copyright © 2014 Kevin Lemonnier <lemonnierk@ulrar.net>
5 ;;; Copyright © 2015 Jeff Mickey <j@codemac.net>
6 ;;; Copyright © 2016, 2017, 2018 Tobias Geerinckx-Rice <me@tobias.gr>
7 ;;; Copyright © 2016 Stefan Reichör <stefan@xsteve.at>
8 ;;; Copyright © 2017, 2018 Ricardo Wurmus <rekado@elephly.net>
9 ;;; Copyright © 2017, 2018 Nils Gillmann <ng0@n0.is>
10 ;;; Copyright © 2017, 2018 Leo Famulari <leo@famulari.name>
11 ;;; Copyright © 2017 Arun Isaac <arunisaac@systemreboot.net>
12 ;;; Copyright © 2019 Meiyo Peng <meiyo.peng@gmail.com>
14 ;;; This file is part of GNU Guix.
16 ;;; GNU Guix is free software; you can redistribute it and/or modify it
17 ;;; under the terms of the GNU General Public License as published by
18 ;;; the Free Software Foundation; either version 3 of the License, or (at
19 ;;; your option) any later version.
21 ;;; GNU Guix is distributed in the hope that it will be useful, but
22 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
23 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 ;;; GNU General Public License for more details.
26 ;;; You should have received a copy of the GNU General Public License
27 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
29 (define-module (gnu packages shells)
30 #:use-module (gnu packages)
31 #:use-module (gnu packages autotools)
32 #:use-module (gnu packages base)
33 #:use-module (gnu packages bash)
34 #:use-module (gnu packages bison)
35 #:use-module (gnu packages documentation)
36 #:use-module (gnu packages groff)
37 #:use-module (gnu packages libbsd)
38 #:use-module (gnu packages libedit)
39 #:use-module (gnu packages ncurses)
40 #:use-module (gnu packages pcre)
41 #:use-module (gnu packages perl)
42 #:use-module (gnu packages pkg-config)
43 #:use-module (gnu packages python)
44 #:use-module (gnu packages python-xyz)
45 #:use-module (gnu packages readline)
46 #:use-module (gnu packages scheme)
47 #:use-module (guix build-system gnu)
48 #:use-module (guix build-system python)
49 #:use-module (guix build-system trivial)
50 #:use-module (guix download)
51 #:use-module (guix git-download)
52 #:use-module (guix licenses)
53 #:use-module (guix packages))
62 (uri (string-append "http://gondor.apana.org.au/~herbert/dash/files/"
63 "dash-" version ".tar.gz"))
66 "0wb0bwmqc661hylqcfdp7l7x12myw3vpqk513ncyqrjwvhckjriw"))
67 (modules '((guix build utils)))
70 ;; The man page hails from BSD, where (d)ash is the default shell.
71 ;; This isn't the case on Guix or indeed most other GNU systems.
72 (substitute* "src/dash.1"
73 (("the standard command interpreter for the system")
74 "a command interpreter based on the original Bourne shell"))
76 (build-system gnu-build-system)
78 `(("libedit" ,libedit)))
80 '(#:configure-flags '("--with-libedit")))
81 (home-page "http://gondor.apana.org.au/~herbert/dash")
82 (synopsis "POSIX-compliant shell optimised for size")
84 "dash is a POSIX-compliant @command{/bin/sh} implementation that aims to be
85 as small as possible, often without sacrificing speed. It is faster than the
86 GNU Bourne-Again Shell (@command{bash}) at most scripted tasks. dash is a
87 direct descendant of NetBSD's Almquist Shell (@command{ash}).")
89 gpl2+)))) ; mksignames.c
98 (uri (string-append "https://github.com/fish-shell/fish-shell/"
99 "releases/download/" version "/"
100 name "-" version ".tar.gz"))
102 (base32 "1kzjd0n0sfslkd36lzrvvvgy3qwkd9y466bkrqlnhd5h9dhx77ga"))))
103 (build-system gnu-build-system)
105 `(("groff" ,groff) ; for 'fish --help'
107 ("pcre2" ,pcre2) ; don't use the bundled PCRE2
108 ("python" ,python))) ; for fish_config and manpage completions
110 `(("doxygen" ,doxygen)))
112 '(#:tests? #f ; no check target
114 (modify-phases %standard-phases
115 (add-after 'unpack 'patch-source
117 (substitute* '("build_tools/build_commands_hdr.sh"
118 "build_tools/build_user_doc.sh")
119 (("/usr/bin/env") "env"))
121 ;; Embed absolute paths.
122 (add-before 'install 'embed-absolute-paths
124 (substitute* '("share/functions/__fish_config_interactive.fish"
125 "share/functions/fish_config.fish"
126 "share/functions/fish_update_completions.fish")
127 (("python3") (which "python3")))
128 (substitute* "share/functions/__fish_print_help.fish"
129 (("nroff") (which "nroff")))
131 ;; Source /etc/fish/config.fish from $__fish_sysconf_dir/config.fish.
132 (add-before 'install 'patch-fish-config
134 (let ((port (open-file "etc/config.fish" "a")))
135 (display (string-append
137 "# Patched by Guix.\n"
138 "# Source /etc/fish/config.fish.\n"
139 "if test -f /etc/fish/config.fish\n"
140 " source /etc/fish/config.fish\n"
145 ;; Enable completions, functions and configurations in user's and
146 ;; system's guix profiles by adding them to __extra_* variables.
147 (add-before 'install 'patch-fish-extra-paths
149 (let ((port (open-file "share/__fish_build_paths.fish" "a")))
153 "# Patched by Guix.\n"
154 "# Enable completions, functions and configurations in user's"
155 " and system's guix profiles by adding them to __extra_*"
157 "set -l __guix_profile_paths ~/.guix-profile"
158 " /run/current-system/profile\n"
159 "set __extra_completionsdir"
160 " $__guix_profile_paths\"/etc/fish/completions\""
161 " $__guix_profile_paths\"/share/fish/vendor_completions.d\""
162 " $__extra_completionsdir\n"
163 "set __extra_functionsdir"
164 " $__guix_profile_paths\"/etc/fish/functions\""
165 " $__guix_profile_paths\"/share/fish/vendor_functions.d\""
166 " $__extra_functionsdir\n"
167 "set __extra_confdir"
168 " $__guix_profile_paths\"/etc/fish/conf.d\""
169 " $__guix_profile_paths\"/share/fish/vendor_conf.d\""
170 " $__extra_confdir\n")
174 (synopsis "The friendly interactive shell")
176 "Fish (friendly interactive shell) is a shell focused on interactive use,
177 discoverability, and friendliness. Fish has very user-friendly and powerful
178 tab-completion, including descriptions of every completion, completion of
179 strings with wildcards, and many completions for specific commands. It also
180 has extensive and discoverable help. A special @command{help} command gives
181 access to all the fish documentation in your web browser. Other features
182 include smart terminal handling based on terminfo, an easy to search history,
183 and syntax highlighting.")
184 (home-page "https://fishshell.com/")
187 (define-public fish-foreign-env
189 (name "fish-foreign-env")
190 (version "0.20190116")
195 (url "https://github.com/oh-my-fish/plugin-foreign-env.git")
196 (commit "dddd9213272a0ab848d474d0cbde12ad034e65bc")))
197 (file-name (git-file-name name version))
199 (base32 "00xqlyl3lffc5l0viin1nyp819wf81fncqyz87jx8ljjdhilmgbs"))))
200 (build-system trivial-build-system)
202 '(#:modules ((guix build utils))
205 (use-modules (guix build utils))
206 (let* ((source (assoc-ref %build-inputs "source"))
207 (out (assoc-ref %outputs "out"))
208 (func-path (string-append out "/share/fish/functions")))
210 (copy-recursively (string-append source "/functions")
213 ;; Embed absolute paths.
214 (substitute* `(,(string-append func-path "/fenv.fish")
215 ,(string-append func-path "/fenv.apply.fish")
216 ,(string-append func-path "/fenv.main.fish"))
218 (string-append (assoc-ref %build-inputs "bash") "/bin/bash"))
220 (string-append (assoc-ref %build-inputs "sed") "/bin/sed"))
222 (string-append " " (assoc-ref %build-inputs "coreutils")
226 ("coreutils" ,coreutils)
228 (home-page "https://github.com/oh-my-fish/plugin-foreign-env")
229 (synopsis "Foreign environment interface for fish shell")
230 (description "@code{fish-foreign-env} wraps bash script execution in a way
231 that environment variables that are exported or modified get imported back
242 (url "https://github.com/rakitzis/rc.git")
243 (commit (string-append "v" version))))
246 "0vj1h4pcg13vxsiydmmk87dr2sra9h4gwx0c4q6fjsiw4in78rrd"))
247 (file-name (git-file-name name version))))
248 (build-system gnu-build-system)
253 (modify-phases %standard-phases
254 (add-before 'bootstrap 'patch-trip.rc
256 (substitute* "trip.rc"
257 (("/bin/pwd") (which "pwd"))
258 (("/bin/sh") (which "sh"))
259 (("/bin/rm") (which "rm"))
260 (("/bin\\)") (string-append (dirname (which "rm")) ")")))
262 (inputs `(("readline" ,readline)
264 (native-inputs `(("autoconf" ,autoconf)
265 ("automake" ,automake)
267 ("pkg-config" ,pkg-config)))
268 (synopsis "Alternative implementation of the rc shell by Byron Rakitzis")
270 "This is a reimplementation by Byron Rakitzis of the Plan 9 shell. It
271 has a small feature set similar to a traditional Bourne shell.")
272 (home-page "https://github.com/rakitzis/rc")
282 (uri (string-append "https://github.com/wryun/es-shell/releases/"
283 "download/v" version "/es-" version ".tar.gz"))
286 "1fplzxc6lncz2lv2fyr2ig23rgg5j96rm2bbl1rs28mik771zd5h"))
287 (file-name (string-append name "-" version ".tar.gz"))))
288 (build-system gnu-build-system)
290 `(#:test-target "test"
292 (modify-phases %standard-phases
293 (add-before 'configure 're-enter-rootdir
294 ;; The tarball has no folder.
298 `(("readline" ,readline)))
301 (synopsis "Extensible shell with higher-order functions")
303 "Es is an extensible shell. The language was derived from the Plan 9
304 shell, rc, and was influenced by functional programming languages, such as
305 Scheme, and the Tcl embeddable programming language. This implementation is
306 derived from Byron Rakitzis's public domain implementation of rc, and was
307 written by Paul Haahr and Byron Rakitzis.")
308 (home-page "https://wryun.github.io/es-shell/")
309 (license public-domain)))
317 ;; Old tarballs are moved to old/.
318 (uri (list (string-append "ftp://ftp.astron.com/pub/tcsh/"
319 "tcsh-" version ".tar.gz")
320 (string-append "ftp://ftp.astron.com/pub/tcsh/"
321 "old/tcsh-" version ".tar.gz")))
324 "17ggxkkn5skl0v1x0j6hbv5l0sgnidfzwv16992sqkdm983fg7dq"))
325 (patches (search-patches "tcsh-fix-autotest.patch"
326 "tcsh-fix-out-of-bounds-read.patch"))
327 (patch-flags '("-p0"))))
328 (build-system gnu-build-system)
330 `(("autoconf" ,autoconf)
333 `(("ncurses" ,ncurses)))
336 (modify-phases %standard-phases
337 (add-before 'check 'patch-test-scripts
340 (substitute* '("tests/commands.at" "tests/variables.at")
341 (("/bin/pwd") (which "pwd")))
342 ;; The .at files create shell scripts without shebangs. Erk.
343 (substitute* "tests/commands.at"
344 (("./output.sh") "/bin/sh output.sh"))
345 (substitute* "tests/syntax.at"
346 (("; other_script.csh") "; /bin/sh other_script.csh"))
347 ;; Now, let's generate the test suite and patch it
348 (invoke "make" "tests/testsuite")
350 ;; This file is ISO-8859-1 encoded.
351 (with-fluids ((%default-port-encoding #f))
352 (substitute* "tests/testsuite"
353 (("/bin/sh") (which "sh"))))
355 (add-after 'install 'post-install
356 (lambda* (#:key inputs outputs #:allow-other-keys)
357 (let* ((out (assoc-ref %outputs "out"))
358 (bin (string-append out "/bin")))
359 (with-directory-excursion bin
360 (symlink "tcsh" "csh"))
362 (home-page "http://www.tcsh.org/")
363 (synopsis "Unix shell based on csh")
365 "Tcsh is an enhanced, but completely compatible version of the Berkeley
366 UNIX C shell (csh). It is a command language interpreter usable both as an
367 interactive login shell and a shell script command processor. It includes a
368 command-line editor, programmable word completion, spelling correction, a
369 history mechanism, job control and a C-like syntax.")
378 (uri (list (string-append
379 "https://www.zsh.org/pub/zsh-" version
382 "https://www.zsh.org/pub/old/zsh-" version
386 "17iffliqcj4hv91g0bd2sxsyfcz51mfyh97sp2iyrs2p0mndc2x5"))))
387 (build-system gnu-build-system)
388 (arguments `(#:configure-flags '("--with-tcsetpgrp" "--enable-pcre")
390 (modify-phases %standard-phases
391 (add-before 'configure 'fix-sh
393 ;; Some of the files are ISO-8859-1 encoded.
394 (with-fluids ((%default-port-encoding #f))
400 "Config/installfns.sh"
402 "Test/E01options.ztst"
403 "Test/A05execution.ztst"
404 "Test/A01grammar.ztst"
405 "Test/A06assign.ztst"
406 "Test/B02typeset.ztst"
407 "Completion/Unix/Command/_init_d"
409 (("/bin/sh") (which "sh"))))))
410 (add-before 'check 'patch-test
412 ;; In Zsh, `command -p` searches a predefined set of
413 ;; paths that don't exist in the build environment. See
414 ;; the assignment of 'path' in Src/init.c'
415 (substitute* "Test/A01grammar.ztst"
416 (("command -pv") "command -v")
417 (("command -p") "command ")
418 (("'command' -p") "'command' "))
420 (native-inputs `(("autoconf" ,autoconf)))
421 (inputs `(("ncurses" ,ncurses)
424 (synopsis "Powerful shell for interactive use and scripting")
425 (description "The Z shell (zsh) is a Unix shell that can be used
426 as an interactive login shell and as a powerful command interpreter
427 for shell scripting. Zsh can be thought of as an extended Bourne shell
428 with a large number of improvements, including some features of bash,
430 (home-page "https://www.zsh.org/")
432 ;; The whole thing is under an MIT/X11-style license, but there's one
433 ;; command, 'Completion/Unix/Command/_darcs', which is under GPLv2+.
443 (uri (pypi-uri "xonsh" version))
446 "0c2bbmdg0n10q54vq9k1z5n53l0mh1hb1q5xprfhilvrbr6hlcwr"))
447 (modules '((guix build utils)))
450 ;; Delete bundled ply.
451 (delete-file-recursively "xonsh/ply")
452 (substitute* '("setup.py")
453 (("'xonsh\\.ply\\.ply',") ""))
455 (build-system python-build-system)
457 '(;; TODO Try running run the test suite.
458 ;; See 'requirements-tests.txt' in the source distribution for more
462 `(("python-ply" ,python-ply)))
463 (home-page "http://xon.sh/")
464 (synopsis "Python-ish shell")
466 "Xonsh is a Python-ish, BASHwards-looking shell language and command
467 prompt. The language is a superset of Python 3.4+ with additional shell
468 primitives that you are used to from Bash and IPython. It works on all major
469 systems including Linux, Mac OSX, and Windows. Xonsh is meant for the daily
470 use of experts and novices alike.")
474 (let ((commit "114432435e4eadd54334df6b37fcae505079b49f")
478 (version (string-append "0.0.0-" revision "." (string-take commit 7)))
483 (url "https://github.com/scheme/scsh")
485 (file-name (string-append name "-" version "-checkout"))
488 "1ghk08akiz7hff1pndi8rmgamgcrn2mv9asbss9l79d3c2iaav3q"))))
489 (build-system gnu-build-system)
491 `(#:test-target "test"
493 (modify-phases %standard-phases
494 (add-before 'configure 'replace-rx
495 (lambda* (#:key inputs #:allow-other-keys)
496 (let* ((rx (assoc-ref inputs "scheme48-rx"))
497 (rxpath (string-append rx "/share/scheme48-"
498 ,(package-version scheme48)
500 (delete-file-recursively "rx")
501 (symlink rxpath "rx"))
504 `(("scheme48" ,scheme48)
505 ("scheme48-rx" ,scheme48-rx)))
507 `(("autoconf" ,autoconf)
508 ("automake" ,automake)))
509 (home-page "https://github.com/scheme/scsh")
510 (synopsis "Unix shell embedded in Scheme")
512 "Scsh is a Unix shell embedded in Scheme. Scsh has two main
513 components: a process notation for running programs and setting up pipelines
514 and redirections, and a complete syscall library for low-level access to the
518 (define-public linenoise
519 (let ((commit "2105ce445821381cf1bca87b6d386d4ea88ee20d")
523 (version (string-append "1.0-" revision "." (string-take commit 7)))
528 (url "https://github.com/antirez/linenoise")
530 (file-name (string-append name "-" version "-checkout"))
533 "1z16qwix8z6a40fskdgxsibkqgdrp4q6ncp4n6hnv4r9iihy2d8r"))))
534 (build-system gnu-build-system)
536 `(#:tests? #f ;No tests are included
537 #:make-flags (list "CC=gcc")
539 (modify-phases %standard-phases
542 (lambda* (#:key outputs #:allow-other-keys)
543 ;; At the moment there is no 'make install' in upstream.
544 (let* ((out (assoc-ref outputs "out")))
545 (install-file "linenoise.h"
546 (string-append out "/include/linenoise"))
547 (install-file "linenoise.c"
548 (string-append out "/include/linenoise"))
550 (home-page "https://github.com/antirez/linenoise")
551 (synopsis "Minimal zero-config readline replacement")
553 "Linenoise is a minimal, zero-config, readline replacement.
554 Its features include:
557 @item Single and multi line editing mode with the usual key bindings
558 @item History handling
560 @item Hints (suggestions at the right of the prompt as you type)
561 @item A subset of VT100 escapes, ANSI.SYS compatible
565 (define-public s-shell
566 (let ((commit "da2e5c20c0c5f477ec3426dc2584889a789b1659")
570 (version (git-version "0.0.0" revision commit))
575 (url "https://github.com/rain-1/s")
577 (file-name (string-append name "-" version "-checkout"))
580 "0qiny71ww5nhzy4mnc8652hn0mlxyb67h333gbdxp4j4qxsi13q4"))))
581 (build-system gnu-build-system)
583 `(("linenoise" ,linenoise)))
586 #:make-flags (list "CC=gcc"
587 (string-append "PREFIX="
588 (assoc-ref %outputs "out")))
590 (modify-phases %standard-phases
591 (add-after 'unpack 'install-directory-fix
592 (lambda* (#:key outputs #:allow-other-keys)
593 (let* ((out (assoc-ref outputs "out"))
594 (bin (string-append out "/bin")))
595 (substitute* "Makefile"
598 (add-after 'install 'manpage
599 (lambda* (#:key outputs #:allow-other-keys)
600 (install-file "s.1" (string-append (assoc-ref outputs "out")
601 "/share/man/man1"))))
603 (lambda* (#:key inputs outputs #:allow-other-keys)
604 ;; At this point linenoise is meant to be included,
605 ;; so we have to really copy it into the working directory
607 (let* ((linenoise (assoc-ref inputs "linenoise"))
608 (noisepath (string-append linenoise "/include/linenoise"))
609 (out (assoc-ref outputs "out")))
610 (copy-recursively noisepath "linenoise")
612 (("/bin/s") (string-append out "/bin/s")))
614 (home-page "https://github.com/rain-1/s")
615 (synopsis "Extremely minimal shell with the simplest syntax possible")
617 "S is a new shell that aims to be extremely simple.
618 S does not implemnt the POSIX shell standard.
619 There are no globs or \"splatting\" where a variable $FOO turns into multiple
620 command line arguments. One token stays one token forever.
621 This is a \"no surprises\" straightforward approach.
623 There are no redirection operators > in the shell language, they are added as
624 extra programs. > is just another unix command, < is essentially cat(1).
625 A @code{andglob} program is also provided along with s.")
635 (uri (string-append "https://connochaetos.org/oksh/oksh-"
639 "0ln9yf6pxngsviqszv8klnnvn8vcpplvj1njdn8xr2y8frkbw8r3"))))
640 (build-system gnu-build-system)
642 `(; The test files are not part of the distributed tarball.
644 (home-page "https://connochaetos.org/oksh")
645 (synopsis "Port of OpenBSD Korn Shell")
647 "Oksh is a port of the OpenBSD Korn Shell.
648 The OpenBSD Korn Shell is a cleaned up and enhanced ksh.")
659 (url "https://github.com/dimkr/loksh.git")
661 (file-name (git-file-name name version))
663 (base32 "1d92cf5iadj1vwg0wwksaq1691zaxjrd2y4qygj4sdd25zsahj6p"))))
664 (build-system gnu-build-system)
667 ("ncurses" ,ncurses)))
669 `(("pkg-config" ,pkg-config)))
671 `(#:tests? #f ; no tests included
672 #:make-flags (list "CC=gcc" "HAVE_LIBBSD=1"
673 (string-append "PREFIX="
674 (assoc-ref %outputs "out")))
676 (modify-phases %standard-phases
677 (delete 'configure)))) ; no configure script
678 (home-page "https://github.com/dimkr/loksh")
679 (synopsis "Korn Shell from OpenBSD")
681 "loksh is a Linux port of OpenBSD's @command{ksh}. It is a small,
682 interactive POSIX shell targeted at resource-constrained systems.")
683 ;; The file 'LEGAL' says it is the public domain, and the 2
684 ;; exceptions which are listed are not included in this port.
685 (license public-domain)))
694 (uri (string-append "https://www.mirbsd.org/MirOS/dist/mir/mksh/mksh-R"
698 "1x4zjj9259ijpf8jw0nyh1fnr1pbm5fwvylclpvcrlb45xrglf5d"))))
699 (build-system gnu-build-system)
701 `(#:tests? #f ; tests require access to /dev/tty
703 (modify-phases %standard-phases
708 (invoke (which "sh") "Build.sh")))
710 (lambda* (#:key outputs #:allow-other-keys)
711 (let* ((out (assoc-ref outputs "out"))
712 (bin (string-append out "/bin"))
713 (man (string-append out "/share/man/man1")))
714 (install-file "mksh" bin)
715 (with-directory-excursion bin
716 (symlink "mksh" "ksh"))
717 (install-file "mksh.1" man)
719 (home-page "https://www.mirbsd.org/mksh.htm")
720 (synopsis "Korn Shell from MirBSD")
721 (description "mksh is an actively developed free implementation of the
722 Korn Shell programming language and a successor to the Public Domain Korn
727 (define-public oil-shell
733 (uri (string-append "https://www.oilshell.org/download/oil-"
737 "03zc7rhhpl0cybng2i3c33pky1knsnyvn526bn91hg6w4znvn66w"))))
738 (build-system gnu-build-system)
740 '(#:tests? #f ; the tests are not distributed in the tarballs
741 #:strip-binaries? #f ; the binaries cannot be stripped
743 (modify-phases %standard-phases
744 (add-after 'unpack 'patch-compiler-invocation
746 (substitute* "configure"
750 (lambda* (#:key outputs #:allow-other-keys)
751 (let ((out (assoc-ref outputs "out")))
753 ;; The configure script doesn't recognize CONFIG_SHELL.
754 (setenv "CONFIG_SHELL" (which "sh"))
755 (invoke "./configure" (string-append "--prefix=" out)
756 "--with-readline"))))
757 (add-before 'install 'make-destination
759 ;; The build scripts don't create the destination directory.
760 (mkdir-p (string-append (assoc-ref %outputs "out") "/bin")))))))
762 `(("readline" ,readline)))
763 (synopsis "Bash-compatible Unix shell")
764 (description "Oil is a Unix / POSIX shell, compatible with Bash. It
765 implements the Oil language, which is a new shell language to which Bash can be
766 automatically translated. The Oil language is a superset of Bash. It also
767 implements the OSH language, a statically-parseable language based on Bash as it
768 is commonly written.")
769 (home-page "https://www.oilshell.org/")
770 (license (list psfl ; The Oil sources include a patched Python 2 source tree