diff --git a/README.md b/README.md index 6df35d5..392381b 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,5 @@ Merry ----- A library for building shells in OCaml. + +Comes with a default, experimental POSIX shell called `msh`. diff --git a/dune-project b/dune-project index 0043365..d7f9cb5 100644 --- a/dune-project +++ b/dune-project @@ -5,12 +5,13 @@ (generate_opam_files true) (source - (uri https://tangled.org/patrick.sirref.org/merry)) + (uri git+https://tangled.org/patrick.sirref.org/merry)) (authors "Patrick Ferris ") + (maintainers "Patrick Ferris ") -(license LICENSE) +(license ISC) (documentation https://url/to/documentation) @@ -18,15 +19,43 @@ (name merry) (synopsis "A shell library") (description "A library for writing shells") - (depends ocaml) + (depends + morbig + linenoise + (yojson + (>= 2.2.2)) + (ppxlib + (>= 0.37.0)) + (ppx_deriving_yojson + (>= 3.10.0)) + (globlon + (>= 0)) + (fpath + (>= 0.7.3)) + (eio_posix + (= "dev")) + (eio + (= "dev")) + (cmdliner + (>= 1.3.0)) + ocaml) (tags ("add topics" "to describe" your project))) (package - (name osh) - (synopsis "A shell") - (description "osh is a shell written completely in OCaml using the merry library") - (depends - merry - eio_main)) -; See the complete stanza docs at https://dune.readthedocs.io/en/stable/reference/dune-project/index.html + (name msh) + (synopsis "A shell") + (description + "msh is a shell written completely in OCaml using the merry library") + (depends + (eio + (and + (>= 1.3) + :with-test)) + (fmt + (>= 0.11.0)) + (eio_posix + (>= 1.3)) + (cmdliner + (>= 1.3.0)) + merry)) \ No newline at end of file diff --git a/merry.opam b/merry.opam index fb9187a..b686675 100644 --- a/merry.opam +++ b/merry.opam @@ -4,11 +4,21 @@ synopsis: "A shell library" description: "A library for writing shells" maintainer: ["Patrick Ferris "] authors: ["Patrick Ferris "] -license: "LICENSE" +license: "ISC" tags: ["add topics" "to describe" "your" "project"] doc: "https://url/to/documentation" depends: [ "dune" {>= "3.20"} + "morbig" + "linenoise" + "yojson" {>= "2.2.2"} + "ppxlib" {>= "0.37.0"} + "ppx_deriving_yojson" {>= "3.10.0"} + "globlon" {>= "0"} + "fpath" {>= "0.7.3"} + "eio_posix" {= "dev"} + "eio" {= "dev"} + "cmdliner" {>= "1.3.0"} "ocaml" "odoc" {with-doc} ] @@ -26,5 +36,9 @@ build: [ "@doc" {with-doc} ] ] -dev-repo: "https://tangled.org/patrick.sirref.org/merry" +dev-repo: "git+https://tangled.org/patrick.sirref.org/merry" x-maintenance-intent: ["(latest)"] +pin-depends:[ + [ "eio.dev" "git+https://github.com/ocaml-multicore/eio#c44ee5ce96c120b7ccc23a12d241dc8672e2888f" ] + [ "eio_posix.dev" "git+https://github.com/ocaml-multicore/eio#c44ee5ce96c120b7ccc23a12d241dc8672e2888f" ] +] diff --git a/merry.opam.template b/merry.opam.template new file mode 100644 index 0000000..91d54cc --- /dev/null +++ b/merry.opam.template @@ -0,0 +1,4 @@ +pin-depends:[ + [ "eio.dev" "git+https://github.com/ocaml-multicore/eio#c44ee5ce96c120b7ccc23a12d241dc8672e2888f" ] + [ "eio_posix.dev" "git+https://github.com/ocaml-multicore/eio#c44ee5ce96c120b7ccc23a12d241dc8672e2888f" ] +] diff --git a/osh.opam b/msh.opam similarity index 68% rename from osh.opam rename to msh.opam index 073dd94..76ab138 100644 --- a/osh.opam +++ b/msh.opam @@ -2,15 +2,18 @@ opam-version: "2.0" synopsis: "A shell" description: - "osh is a shell written completely in OCaml using the merry library" + "msh is a shell written completely in OCaml using the merry library" maintainer: ["Patrick Ferris "] authors: ["Patrick Ferris "] -license: "LICENSE" +license: "ISC" doc: "https://url/to/documentation" depends: [ "dune" {>= "3.20"} + "eio" {>= "1.3" & with-test} + "fmt" {>= "0.11.0"} + "eio_posix" {>= "1.3"} + "cmdliner" {>= "1.3.0"} "merry" - "eio_main" "odoc" {with-doc} ] build: [ @@ -27,5 +30,5 @@ build: [ "@doc" {with-doc} ] ] -dev-repo: "https://tangled.org/patrick.sirref.org/merry" +dev-repo: "git+https://tangled.org/patrick.sirref.org/merry" x-maintenance-intent: ["(latest)"] diff --git a/src/bin/dune b/src/bin/dune index 386ab18..d796af0 100644 --- a/src/bin/dune +++ b/src/bin/dune @@ -1,5 +1,5 @@ (executable - (public_name osh) - (package osh) + (public_name msh) + (package msh) (name main) (libraries merry merry.posix eio_posix cmdliner fmt.tty)) diff --git a/src/bin/main.ml b/src/bin/main.ml index 9a7b764..061ab56 100644 --- a/src/bin/main.ml +++ b/src/bin/main.ml @@ -74,7 +74,7 @@ let cmd env = `P "Report bugs at https://tangled.org/patrick.sirref.org/merry/issues."; ] in - Cmd.make (Cmd.info "osh" ~version:"v0.0.1" ~doc ~man) + Cmd.make (Cmd.info "msh" ~version:"v0.0.1" ~doc ~man) @@ let+ command = command and+ dump = dump and+ file = file in sh ~command ~dump ~file env diff --git a/test/async.t b/test/async.t index 8719fb7..681005e 100644 --- a/test/async.t +++ b/test/async.t @@ -1,12 +1,12 @@ Asynchronous jobs are tricky. For now, we disable them behind a flag in [set]. - $ osh -c "echo hello &" + $ msh -c "echo hello &" You are using asynchronous operators and [set -o async] has not been called. [1] But we do have some support for them. - $ cat > osh.sh << EOF + $ cat > msh.sh << EOF > set -o async > sleep 10000 & echo hello > kill -9 \$! @@ -19,5 +19,5 @@ But we do have some support for them. $ sh test.sh hello - $ osh osh.sh + $ msh msh.sh hello diff --git a/test/built_ins.t b/test/built_ins.t index 305d0ec..1ef4016 100644 --- a/test/built_ins.t +++ b/test/built_ins.t @@ -2,20 +2,20 @@ Testing some shell built-ins 1. Cd - $ osh -c "cd /usr; pwd" + $ msh -c "cd /usr; pwd" /usr - $ osh -c "mkdir testing; cd testing; ls -a" + $ msh -c "mkdir testing; cd testing; ls -a" . .. 2. Exit - $ osh -c "exit 123" + $ msh -c "exit 123" exit [123] - $ osh -c "exit" + $ msh -c "exit" exit 2. Wait diff --git a/test/dune b/test/dune index 73e1762..cf677f9 100644 --- a/test/dune +++ b/test/dune @@ -1,6 +1,6 @@ (cram - (package osh) - (deps %{bin:osh})) + (package msh) + (deps %{bin:msh})) (test (name test_merry) diff --git a/test/forloops.t b/test/forloops.t index 7e1b1c3..51b6daf 100644 --- a/test/forloops.t +++ b/test/forloops.t @@ -3,7 +3,7 @@ For loops 1.1 Simple loop without needing to expand - $ osh -c "for i in a b c; do echo hello; done" + $ msh -c "for i in a b c; do echo hello; done" hello hello hello @@ -11,7 +11,7 @@ For loops 1.2. Simple word list to echo - $ osh -c "for foo in a b c; do echo \$foo; done" + $ msh -c "for foo in a b c; do echo \$foo; done" a b c @@ -22,7 +22,7 @@ For loops $ sh -c "for foo in *.txt; do echo \$foo; done" hello.txt world.txt - $ osh -c "for foo in *.txt; do echo \$foo; done" + $ msh -c "for foo in *.txt; do echo \$foo; done" hello.txt world.txt @@ -32,16 +32,16 @@ For loops > echo hello > abc.md > echo world > def.md > for f in *.md; do - > cmarkit html --unsafe -e -c -h -k "\$f" > "\$(basename -- "\$f" .md).html" + > rev "\$f" > "\$(basename -- "\$f" .md).rev" > done > EOF - $ osh test.sh + $ msh test.sh $ ls - abc.html abc.md - def.html + abc.rev def.md + def.rev hello.txt test.sh world.txt diff --git a/test/if.t b/test/if.t index 473426f..c906c17 100644 --- a/test/if.t +++ b/test/if.t @@ -7,7 +7,7 @@ Testing if-then-else constructs > fi > EOF - $ osh test.sh + $ msh test.sh hello world @@ -22,5 +22,5 @@ Testing if-then-else constructs $ sh test.sh goodbye - $ osh test.sh + $ msh test.sh goodbye diff --git a/test/paths.t b/test/paths.t index 852aed2..9fb02ee 100644 --- a/test/paths.t +++ b/test/paths.t @@ -2,10 +2,10 @@ Here we test some specific semantics of how a shell should handle paths. In particular, things like globbing. $ touch hello.txt; touch world.txt - $ osh -c "basename --suffix='.txt' *.txt" + $ msh -c "basename --suffix='.txt' *.txt" hello world $ touch Hello.txt - $ osh -c "basename --suffix='.txt' ?ello.txt" + $ msh -c "basename --suffix='.txt' ?ello.txt" Hello hello diff --git a/test/pipelines.t b/test/pipelines.t index 052469d..f7a2559 100644 --- a/test/pipelines.t +++ b/test/pipelines.t @@ -11,11 +11,11 @@ Under normal execution, only the very last command matters in terms of exit code ls: invalid option -- 'j' Try 'ls --help' for more information. hello - $ osh -c "ls -j" + $ msh -c "ls -j" ls: invalid option -- 'j' Try 'ls --help' for more information. [2] - $ osh -c "ls -j | sleep 0.1; ls" + $ msh -c "ls -j | sleep 0.1; ls" ls: invalid option -- 'j' Try 'ls --help' for more information. hello @@ -25,6 +25,6 @@ And an exclaimation point should invert that. $ sh -c "! exit 1 | ls" hello [1] - $ osh -c "! exit 1 | ls" + $ msh -c "! exit 1 | ls" hello [1] diff --git a/test/simple.t b/test/simple.t index a13dbaa..378844b 100644 --- a/test/simple.t +++ b/test/simple.t @@ -1,4 +1,4 @@ -A series of simple shell scripting tests for osh. +A series of simple shell scripting tests for msh. 1. Variables and Parameters @@ -9,25 +9,25 @@ A series of simple shell scripting tests for osh. > echo \$P > EOF - $ osh test.sh + $ msh test.sh hello world $ cat >test.sh < FOO=bar > echo "\$FOO" > EOF - $ osh test.sh + $ msh test.sh bar - $ osh -c "FOO=bar echo \$FOO" + $ msh -c "FOO=bar echo \$FOO" - $ osh -c "FOO=bar; echo \$FOO" + $ msh -c "FOO=bar; echo \$FOO" bar - $ osh -c "FOO=~/foo; echo \$FOO" + $ msh -c "FOO=~/foo; echo \$FOO" /home/patrick/foo - $ osh -c "FOO=~/foo env | grep FOO" + $ msh -c "FOO=~/foo env | grep FOO" FOO=/home/patrick/foo $ cat >test.sh << EOF @@ -39,14 +39,14 @@ A series of simple shell scripting tests for osh. $ sh test.sh hello VAR2: world () - $ osh test.sh + $ msh test.sh hello VAR2: world () $ sh -c "FOO=abc env | grep FOO; env | grep FOO" FOO=abc [1] - $ osh -c "FOO=abc env | grep FOO; env | grep FOO" + $ msh -c "FOO=abc env | grep FOO; env | grep FOO" FOO=abc [1] @@ -58,7 +58,7 @@ A series of simple shell scripting tests for osh. > sh -c "exit 1" || echo hello > EOF - $ osh test.sh + $ msh test.sh hello 2.2 Simple And @@ -67,7 +67,7 @@ A series of simple shell scripting tests for osh. > sh -c "exit 1" && echo hello > EOF - $ osh test.sh + $ msh test.sh [1] 2.3 Simple And and Or @@ -76,15 +76,15 @@ A series of simple shell scripting tests for osh. > echo first || sh -c "echo never && exit 1" && echo second > EOF - $ osh test.sh + $ msh test.sh first second 2.4 Simple Pipeline - $ osh -c "echo hello | rev" + $ msh -c "echo hello | rev" olleh - $ osh -c "echo hello | rev | rev | rev | rev" + $ msh -c "echo hello | rev | rev | rev | rev" hello 2.5 Input redirection @@ -96,27 +96,27 @@ Simple example of redirecing stdin to an open file. > --------------- > EOF - $ osh -c "cat < hello.md" + $ msh -c "cat < hello.md" # Hello, World! --------------- Using `<&-` to close stdin - $ osh -c "cat <&-" + $ msh -c "cat <&-" cat: -: Bad file descriptor cat: closing standard input: Bad file descriptor [1] Using `<&` to copy a file descriptor - $ osh -c "cat 3 @@ -126,20 +126,20 @@ But also, some simple errors should work too. Simple example of redirecting some output - $ osh -c "echo hello > hello.txt && cat hello.txt" + $ msh -c "echo hello > hello.txt && cat hello.txt" hello $ stat --format="%A" hello.txt -rw-r--r-- Simple appending example - $ osh -c "echo world >> hello.txt && cat hello.txt" + $ msh -c "echo world >> hello.txt && cat hello.txt" hello world Redirection of fds - $ osh -c "echo hello 3>out.txt >&3" + $ msh -c "echo hello 3>out.txt >&3" $ cat out.txt hello @@ -147,7 +147,7 @@ Redirection of fds A simple, semicolon sequence. - $ osh -c "echo hello; echo world; echo 'that is all'" + $ msh -c "echo hello; echo world; echo 'that is all'" hello world that is all @@ -158,7 +158,7 @@ A simple, semicolon sequence. > echo 'that is all' > EOF - $ osh test.sh + $ msh test.sh hello world that is all diff --git a/test/subshell.t b/test/subshell.t index 39b7c90..2eaeae4 100644 --- a/test/subshell.t +++ b/test/subshell.t @@ -5,10 +5,10 @@ A simple test. $ cat > test.md << EOF > Just some text here > EOF - $ osh -c "cat '$(echo test.md)'" + $ msh -c "cat '$(echo test.md)'" Just some text here - $ osh -c "'$(which echo)' hello" + $ msh -c "'$(which echo)' hello" hello - $ osh -c "`which echo` hello" + $ msh -c "`which echo` hello" hello