gnu: Add fish-foreign-env.
[guix.git] / gnu / packages / shells.scm
blob8e2ca2a9a3a43041e84e1b30ae20dda935894e5a
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>
13 ;;;
14 ;;; This file is part of GNU Guix.
15 ;;;
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.
20 ;;;
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.
25 ;;;
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))
55 (define-public dash
56   (package
57     (name "dash")
58     (version "0.5.10.2")
59     (source
60      (origin
61        (method url-fetch)
62        (uri (string-append "http://gondor.apana.org.au/~herbert/dash/files/"
63                            "dash-" version ".tar.gz"))
64        (sha256
65         (base32
66          "0wb0bwmqc661hylqcfdp7l7x12myw3vpqk513ncyqrjwvhckjriw"))
67        (modules '((guix build utils)))
68        (snippet
69         '(begin
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"))
75            #t))))
76     (build-system gnu-build-system)
77     (inputs
78      `(("libedit" ,libedit)))
79     (arguments
80      '(#:configure-flags '("--with-libedit")))
81     (home-page "http://gondor.apana.org.au/~herbert/dash")
82     (synopsis "POSIX-compliant shell optimised for size")
83     (description
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}).")
88     (license (list bsd-3
89                    gpl2+))))    ; mksignames.c
91 (define-public fish
92   (package
93     (name "fish")
94     (version "3.0.0")
95     (source
96      (origin
97        (method url-fetch)
98        (uri (string-append "https://github.com/fish-shell/fish-shell/"
99                            "releases/download/" version "/"
100                            name "-" version ".tar.gz"))
101        (sha256
102         (base32 "1kzjd0n0sfslkd36lzrvvvgy3qwkd9y466bkrqlnhd5h9dhx77ga"))))
103     (build-system gnu-build-system)
104     (inputs
105      `(("groff" ,groff)                 ; for 'fish --help'
106        ("ncurses" ,ncurses)
107        ("pcre2" ,pcre2)      ; don't use the bundled PCRE2
108        ("python" ,python)))  ; for fish_config and manpage completions
109     (native-inputs
110      `(("doxygen" ,doxygen)))
111     (arguments
112      '(#:tests? #f                      ; no check target
113        #:phases
114        (modify-phases %standard-phases
115          (add-after 'unpack 'patch-source
116            (lambda _
117              (substitute* '("build_tools/build_commands_hdr.sh"
118                             "build_tools/build_user_doc.sh")
119                (("/usr/bin/env") "env"))
120              #t))
121          ;; Embed absolute paths.
122          (add-before 'install 'embed-absolute-paths
123            (lambda _
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")))
130              #t))
131          ;; Source /etc/fish/config.fish from $__fish_sysconf_dir/config.fish.
132          (add-before 'install 'patch-fish-config
133            (lambda _
134              (let ((port (open-file "etc/config.fish" "a")))
135                (display (string-append
136                          "\n\n"
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"
141                          "end\n")
142                         port)
143                (close-port port))
144              #t))
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
148            (lambda _
149              (let ((port (open-file "share/__fish_build_paths.fish" "a")))
150                (display
151                 (string-append
152                  "\n\n"
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_*"
156                  " variables.\n"
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")
171                 port)
172                (close-port port))
173              #t)))))
174     (synopsis "The friendly interactive shell")
175     (description
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/")
185     (license gpl2)))
187 (define-public fish-foreign-env
188   (package
189     (name "fish-foreign-env")
190     (version "0.20190116")
191     (source
192      (origin
193        (method git-fetch)
194        (uri (git-reference
195              (url "https://github.com/oh-my-fish/plugin-foreign-env.git")
196              (commit "dddd9213272a0ab848d474d0cbde12ad034e65bc")))
197        (file-name (git-file-name name version))
198        (sha256
199         (base32 "00xqlyl3lffc5l0viin1nyp819wf81fncqyz87jx8ljjdhilmgbs"))))
200     (build-system trivial-build-system)
201     (arguments
202      '(#:modules ((guix build utils))
203        #:builder
204        (begin
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")))
209            (mkdir-p func-path)
210            (copy-recursively (string-append source "/functions")
211                              func-path)
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"))
217              (("bash")
218               (string-append (assoc-ref %build-inputs "bash") "/bin/bash"))
219              (("sed")
220               (string-append (assoc-ref %build-inputs "sed") "/bin/sed"))
221              ((" tr ")
222               (string-append " " (assoc-ref %build-inputs "coreutils")
223                              "/bin/tr ")))))))
224     (inputs
225      `(("bash" ,bash)
226        ("coreutils" ,coreutils)
227        ("sed" ,sed)))
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
232 into fish.")
233     (license expat)))
235 (define-public rc
236   (package
237     (name "rc")
238     (version "1.7.4")
239     (source (origin
240               (method git-fetch)
241               (uri (git-reference
242                     (url "https://github.com/rakitzis/rc.git")
243                     (commit (string-append "v" version))))
244               (sha256
245                (base32
246                 "0vj1h4pcg13vxsiydmmk87dr2sra9h4gwx0c4q6fjsiw4in78rrd"))
247               (file-name (git-file-name name version))))
248     (build-system gnu-build-system)
249     (arguments
250      `(#:configure-flags
251        '("--with-edit=gnu")
252        #:phases
253        (modify-phases %standard-phases
254          (add-before 'bootstrap 'patch-trip.rc
255           (lambda _
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")) ")")))
261             #t)))))
262     (inputs `(("readline" ,readline)
263               ("perl" ,perl)))
264     (native-inputs `(("autoconf" ,autoconf)
265                      ("automake" ,automake)
266                      ("libtool" ,libtool)
267                      ("pkg-config" ,pkg-config)))
268     (synopsis "Alternative implementation of the rc shell by Byron Rakitzis")
269     (description
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")
273     (license zlib)))
275 (define-public es
276   (package
277     (name "es")
278     (version "0.9.1")
279     (source
280      (origin
281        (method url-fetch)
282        (uri (string-append "https://github.com/wryun/es-shell/releases/"
283                            "download/v" version "/es-" version ".tar.gz"))
284        (sha256
285         (base32
286          "1fplzxc6lncz2lv2fyr2ig23rgg5j96rm2bbl1rs28mik771zd5h"))
287        (file-name (string-append name "-" version ".tar.gz"))))
288     (build-system gnu-build-system)
289     (arguments
290      `(#:test-target "test"
291        #:phases
292        (modify-phases %standard-phases
293          (add-before 'configure 're-enter-rootdir
294            ;; The tarball has no folder.
295            (lambda _
296              (chdir ".."))))))
297     (inputs
298      `(("readline" ,readline)))
299     (native-inputs
300      `(("bison" ,bison)))
301     (synopsis "Extensible shell with higher-order functions")
302     (description
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)))
311 (define-public tcsh
312   (package
313     (name "tcsh")
314     (version "6.20.00")
315     (source (origin
316               (method url-fetch)
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")))
322               (sha256
323                (base32
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)
329     (native-inputs
330      `(("autoconf" ,autoconf)
331        ("perl" ,perl)))
332     (inputs
333      `(("ncurses" ,ncurses)))
334     (arguments
335      `(#:phases
336         (modify-phases %standard-phases
337           (add-before 'check 'patch-test-scripts
338             (lambda _
339               ;; Take care of pwd
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"))))
354               #t))
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"))
361                 #t))))))
362     (home-page "http://www.tcsh.org/")
363     (synopsis "Unix shell based on csh")
364     (description
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.")
370     (license bsd-4)))
372 (define-public zsh
373   (package
374     (name "zsh")
375     (version "5.6.2")
376     (source (origin
377               (method url-fetch)
378               (uri (list (string-append
379                            "https://www.zsh.org/pub/zsh-" version
380                            ".tar.xz")
381                          (string-append
382                            "https://www.zsh.org/pub/old/zsh-" version
383                            ".tar.xz")))
384               (sha256
385                (base32
386                 "17iffliqcj4hv91g0bd2sxsyfcz51mfyh97sp2iyrs2p0mndc2x5"))))
387     (build-system gnu-build-system)
388     (arguments `(#:configure-flags '("--with-tcsetpgrp" "--enable-pcre")
389                  #:phases
390                  (modify-phases %standard-phases
391                    (add-before 'configure 'fix-sh
392                      (lambda _
393                        ;; Some of the files are ISO-8859-1 encoded.
394                        (with-fluids ((%default-port-encoding #f))
395                                     (substitute*
396                                         '("configure"
397                                           "configure.ac"
398                                           "Src/exec.c"
399                                           "Src/mkmakemod.sh"
400                                           "Config/installfns.sh"
401                                           "Config/defs.mk.in"
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"
408                                           "Util/preconfig")
409                                       (("/bin/sh") (which "sh"))))))
410                    (add-before 'check 'patch-test
411                      (lambda _
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' "))
419                        #t)))))
420     (native-inputs `(("autoconf" ,autoconf)))
421     (inputs `(("ncurses" ,ncurses)
422               ("pcre" ,pcre)
423               ("perl" ,perl)))
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,
429 ksh, and tcsh.")
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+.
434     (license gpl2+)))
436 (define-public xonsh
437   (package
438     (name "xonsh")
439     (version "0.6.2")
440     (source
441       (origin
442         (method url-fetch)
443         (uri (pypi-uri "xonsh" version))
444         (sha256
445           (base32
446             "0c2bbmdg0n10q54vq9k1z5n53l0mh1hb1q5xprfhilvrbr6hlcwr"))
447         (modules '((guix build utils)))
448         (snippet
449          `(begin
450             ;; Delete bundled ply.
451             (delete-file-recursively "xonsh/ply")
452             (substitute* '("setup.py")
453               (("'xonsh\\.ply\\.ply',") ""))
454             #t))))
455     (build-system python-build-system)
456     (arguments
457      '(;; TODO Try running run the test suite.
458        ;; See 'requirements-tests.txt' in the source distribution for more
459        ;; information.
460        #:tests? #f))
461     (inputs
462      `(("python-ply" ,python-ply)))
463     (home-page "http://xon.sh/")
464     (synopsis "Python-ish shell")
465     (description
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.")
471     (license bsd-2)))
473 (define-public scsh
474   (let ((commit "114432435e4eadd54334df6b37fcae505079b49f")
475         (revision "1"))
476     (package
477       (name "scsh")
478       (version (string-append "0.0.0-" revision "." (string-take commit 7)))
479       (source
480        (origin
481          (method git-fetch)
482          (uri (git-reference
483                (url "https://github.com/scheme/scsh")
484                (commit commit)))
485          (file-name (string-append name "-" version "-checkout"))
486          (sha256
487           (base32
488            "1ghk08akiz7hff1pndi8rmgamgcrn2mv9asbss9l79d3c2iaav3q"))))
489       (build-system gnu-build-system)
490       (arguments
491        `(#:test-target "test"
492          #:phases
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)
499                                              "/rx")))
500                  (delete-file-recursively "rx")
501                  (symlink rxpath "rx"))
502                #t)))))
503       (inputs
504        `(("scheme48" ,scheme48)
505          ("scheme48-rx" ,scheme48-rx)))
506       (native-inputs
507        `(("autoconf" ,autoconf)
508          ("automake" ,automake)))
509       (home-page "https://github.com/scheme/scsh")
510       (synopsis "Unix shell embedded in Scheme")
511       (description
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
515 operating system.")
516       (license bsd-3))))
518 (define-public linenoise
519   (let ((commit "2105ce445821381cf1bca87b6d386d4ea88ee20d")
520         (revision "1"))
521     (package
522       (name "linenoise")
523       (version (string-append "1.0-" revision "." (string-take commit 7)))
524       (source
525        (origin
526          (method git-fetch)
527          (uri (git-reference
528                (url "https://github.com/antirez/linenoise")
529                (commit commit)))
530          (file-name (string-append name "-" version "-checkout"))
531          (sha256
532           (base32
533            "1z16qwix8z6a40fskdgxsibkqgdrp4q6ncp4n6hnv4r9iihy2d8r"))))
534       (build-system gnu-build-system)
535       (arguments
536        `(#:tests? #f ;No tests are included
537          #:make-flags (list "CC=gcc")
538          #:phases
539          (modify-phases %standard-phases
540            (delete 'configure)
541            (replace 'install
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"))
549                  #t))))))
550       (home-page "https://github.com/antirez/linenoise")
551       (synopsis "Minimal zero-config readline replacement")
552       (description
553        "Linenoise is a minimal, zero-config, readline replacement.
554 Its features include:
556 @enumerate
557 @item Single and multi line editing mode with the usual key bindings
558 @item History handling
559 @item Completion
560 @item Hints (suggestions at the right of the prompt as you type)
561 @item A subset of VT100 escapes, ANSI.SYS compatible
562 @end enumerate\n")
563       (license bsd-2))))
565 (define-public s-shell
566   (let ((commit "da2e5c20c0c5f477ec3426dc2584889a789b1659")
567         (revision "2"))
568     (package
569       (name "s-shell")
570       (version (git-version "0.0.0" revision commit))
571       (source
572        (origin
573          (method git-fetch)
574          (uri (git-reference
575                (url "https://github.com/rain-1/s")
576                (commit commit)))
577          (file-name (string-append name "-" version "-checkout"))
578          (sha256
579           (base32
580            "0qiny71ww5nhzy4mnc8652hn0mlxyb67h333gbdxp4j4qxsi13q4"))))
581       (build-system gnu-build-system)
582       (inputs
583        `(("linenoise" ,linenoise)))
584       (arguments
585        `(#:tests? #f
586          #:make-flags (list "CC=gcc"
587                             (string-append "PREFIX="
588                                            (assoc-ref %outputs "out")))
589          #:phases
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"
596                    (("out") bin))
597                  #t)))
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"))))
602            (replace 'configure
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
606                ;; of s.
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")
611                  (substitute* "s.c"
612                    (("/bin/s") (string-append out "/bin/s")))
613                  #t))))))
614       (home-page "https://github.com/rain-1/s")
615       (synopsis "Extremely minimal shell with the simplest syntax possible")
616       (description
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.")
626       (license bsd-3))))
628 (define-public oksh
629   (package
630     (name "oksh")
631     (version "0.5.9")
632     (source
633      (origin
634        (method url-fetch)
635        (uri (string-append "https://connochaetos.org/oksh/oksh-"
636                            version ".tar.gz"))
637        (sha256
638         (base32
639          "0ln9yf6pxngsviqszv8klnnvn8vcpplvj1njdn8xr2y8frkbw8r3"))))
640     (build-system gnu-build-system)
641     (arguments
642      `(; The test files are not part of the distributed tarball.
643        #:tests? #f))
644     (home-page "https://connochaetos.org/oksh")
645     (synopsis "Port of OpenBSD Korn Shell")
646     (description
647      "Oksh is a port of the OpenBSD Korn Shell.
648 The OpenBSD Korn Shell is a cleaned up and enhanced ksh.")
649     (license gpl3+)))
651 (define-public loksh
652   (package
653     (name "loksh")
654     (version "6.4")
655     (source
656      (origin
657        (method git-fetch)
658        (uri (git-reference
659              (url "https://github.com/dimkr/loksh.git")
660              (commit version)))
661        (file-name (git-file-name name version))
662        (sha256
663         (base32 "1d92cf5iadj1vwg0wwksaq1691zaxjrd2y4qygj4sdd25zsahj6p"))))
664     (build-system gnu-build-system)
665     (inputs
666      `(("libbsd" ,libbsd)
667        ("ncurses" ,ncurses)))
668     (native-inputs
669      `(("pkg-config" ,pkg-config)))
670     (arguments
671      `(#:tests? #f                      ; no tests included
672        #:make-flags (list "CC=gcc" "HAVE_LIBBSD=1"
673                           (string-append "PREFIX="
674                                          (assoc-ref %outputs "out")))
675        #:phases
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")
680     (description
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)))
687 (define-public mksh
688   (package
689     (name "mksh")
690     (version "56")
691     (source
692      (origin
693        (method url-fetch)
694        (uri (string-append "https://www.mirbsd.org/MirOS/dist/mir/mksh/mksh-R"
695                            version ".tgz"))
696        (sha256
697         (base32
698          "1x4zjj9259ijpf8jw0nyh1fnr1pbm5fwvylclpvcrlb45xrglf5d"))))
699     (build-system gnu-build-system)
700     (arguments
701      `(#:tests? #f ; tests require access to /dev/tty
702        #:phases
703        (modify-phases %standard-phases
704          (delete 'configure)
705          (replace 'build
706            (lambda _
707              (setenv "CC" "gcc")
708              (invoke (which "sh") "Build.sh")))
709          (replace 'install
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)
718                #t))))))
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
723 Shell (pdksh).")
724     (license (list miros
725                    isc)))) ; strlcpy.c
727 (define-public oil-shell
728   (package
729     (name "oil-shell")
730     (version "0.5.0")
731     (source (origin
732               (method url-fetch)
733               (uri (string-append "https://www.oilshell.org/download/oil-"
734                                   version ".tar.xz"))
735               (sha256
736                (base32
737                 "03zc7rhhpl0cybng2i3c33pky1knsnyvn526bn91hg6w4znvn66w"))))
738     (build-system gnu-build-system)
739     (arguments
740      '(#:tests? #f ; the tests are not distributed in the tarballs
741        #:strip-binaries? #f ; the binaries cannot be stripped
742        #:phases
743        (modify-phases %standard-phases
744          (add-after 'unpack 'patch-compiler-invocation
745            (lambda _
746              (substitute* "configure"
747                ((" cc ") " gcc "))
748              #t))
749          (replace 'configure
750            (lambda* (#:key outputs #:allow-other-keys)
751              (let ((out (assoc-ref outputs "out")))
752                (setenv "CC" "gcc")
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
758            (lambda _
759              ;; The build scripts don't create the destination directory.
760              (mkdir-p (string-append (assoc-ref %outputs "out") "/bin")))))))
761     (inputs
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
771                    asl2.0))))