Giter VIP home page Giter VIP logo

mgree / smoosh Goto Github PK

View Code? Open in Web Editor NEW
112.0 8.0 4.0 3.75 MB

The Symbolic, Mechanized, Observable, Operational SHell: an executable formalization of the POSIX shell standard.

Home Page: http://shell.cs.pomona.edu

License: MIT License

Makefile 0.47% OCaml 83.10% Shell 3.71% Dockerfile 0.53% Ruby 0.56% CSS 0.15% JavaScript 9.66% HTML 1.51% eC 0.01% C 0.31%
posix formalization posix-sh posix-shell sh shell-scripting shell semantics symbolic-execution

smoosh's Introduction

Main workflow

Smoosh (the Symbolic, Mechanized, Observable, Operational SHell) is a formalization of the POSIX shell standard; Smoosh is one part of Michael Greenberg's broader project on the POSIX shell.

Smoosh is written in a mix of Lem and OCaml, using libdash to parse shell code.

Installation

There are two ways to work with Smoosh: virtually (in a Vagrant VM or in a Docker container) or natively. Because Smoosh depends on many parts and specific versions of some libraries, it may be easier to install via a VM or Docker.

Building Smoosh natively

To install Smoosh directly on your computer, you will need to manually configure your system with the dependencies listed in .github/workflows/build.yml. In particular:

  • A C toolchain
  • Autoconf, autotools, libtool, pkg-config, libffi, and libgmp (on macOS, this may be called glibtoolize, e.g., run brew install libtool)
  • OPAM (well sourced, i.e., eval $(opam env))
  • Ruby and Ruby bundler (for the web server)

Once you have those dependencies, you should be able to crib from .travis.yml:

$ git clone --recurse-submodules https://github.com/mgree/smoosh.git
Cloning into 'smoosh'...
... [lots of fetching] ...
Submodule path 'libdash': checked out 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
Submodule path 'modernish': checked out 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'
$ cd smoosh
$ opam install -y ocamlfind ocamlbuild num zarith extunix lem
$ (cd libdash; opam pin -y add .)
$ make -C src all all.byte
$ export PATH="$(pwd)/src:$PATH"

Thanks to @idkjs for documenting a macOS build.

Building Smoosh in a Vagrant VM

In a system with Vagrant, you should be able to download the Smoosh VM image from the Vagrant Cloud service (~1.3GB):

~$ mkdir smoosh; cd smoosh
~/smoosh$ vagrant init mgree/smoosh --box-version 0.1.1
~/smoosh$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'mgree/smoosh' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: 0.1.1
==> default: Loading metadata for box 'mgree/smoosh'
    default: URL: https://vagrantcloud.com/mgree/smoosh
==> default: Adding box 'mgree/smoosh' (v0.1.1) for provider: virtualbox
    default: Downloading: https://vagrantcloud.com/mgree/boxes/smoosh/versions/0.1.1/providers/virtualbox.box
...
~/smoosh$ vagrant ssh
vagrant@debian9:~$ cd smoosh
vagrant@debian9:~/smoosh$

You are now in a directory where you can run tests. The smoosh executable should be on your path in any case.

Building Smoosh in Docker

To build via Docker, you merely need to fetch the Smoosh repo and its submodules. The build.sh script in the base of the repo will invoke the appropriate Docker commands.

$ git clone --recurse-submodules https://github.com/mgree/smoosh.git
Cloning into 'smoosh'...
... [lots of fetching] ...
Submodule path 'libdash': checked out 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
Submodule path 'modernish': checked out 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'
$ cd smoosh
$ ./build.sh
... [long docker build] ...
Successfully tagged smoosh:latest
... [tests build] ...
Successfully tagged smoosh-test:latest
... [tests run] ...
========================================================================

smoosh v0.1 (build YYYY-MM-DD_HH:MM)

ALL TESTS PASSED
... [more docker builds] ...
Successfully tagged smoosh-web:latest

If the build process was successful, there are now two tagged Docker images, which can be run interactively via docker run -it [image tag]. The two images are:

  • smoosh, a Docker environment with Smoosh installed as /bin/smoosh
  • smoosh-test, an extension of the smoosh image with unit and system tests

Running tests using the Docker image

  • To run the test suite after building, run: docker build -t smoosh-test -f Dockerfile.test . && docker run smoosh-test
  • To explore the built image, run: docker run -it smoosh

To test by hand, there are three sets of relevant tests: the libdash tests (in libdash/test), the unit tests for symbolic smoosh (in src), and the shell test suite (in tests). All three directories have Makefiles with appropriate test targets, so you can test both by running the following:

$ docker run -it smoosh-test
opam@XXXXXXXXXXXX:~$ make -C libdash/test test
opam@XXXXXXXXXXXX:~$ make -C src/ test
opam@XXXXXXXXXXXX:~$ make -C tests test

Using the Shtepper

The Shtepper is a web-based visualization tool for symbolically running POSIX shell scripts. While available online, you can also run a local version of the Shtepper using the smoosh-web Docker image. To start the local Shtepper, you must build the web interface first. Run, from the smoosh repo root:

$ docker build -t smoosh-web -f Dockerfile.web .
...
$ docker run -p 80:2080 --name smoosh-web -t smoosh-web
Thin web server (v1.7.2 codename Bachmanity)
Maximum connections set to 1024
Listening on 0.0.0.0:2080, CTRL+C to stop
...

You can then navigate to http://localhost/ in your web browser of choice. The Shtepper should work in any web browser, but has only undergone extensive testing in Firefox.

Running tests

However you've installed Smoosh, you can run the tests by going to the appropriate Smoosh directory (the home directory in Docker; ~/smoosh in a Vagrant VM). There are three sets of local Smoosh tests: libdash parser tests, unit tests, and system tests. You can run them in one go as follows:

vagrant@debian9:~/smoosh$ make -C libdash/test test && make -C src test && make -C tests
make: Entering directory '/home/vagrant/smoosh/libdash/test'
ocamlfind ocamlopt -g -package dash,ctypes,ctypes.foreign -linkpkg test.ml -o test.native
ocamlfind ocamlcp -p a -package dash,ctypes,ctypes.foreign -linkpkg test.ml -o test.byte
TESTING test.native
tests/braces_amp.sh OK
tests/builtin.trap.exitcode.test OK
tests/diverge.sh OK
tests/empty_case OK
tests/escaping OK
tests/for_spaces.sh OK
tests/grab_submissions.sh OK
tests/grade.sh OK
tests/redir_indirect OK
tests/run_grader.sh OK
tests/run_lda.sh OK
tests/send_emails.sh OK
tests/syntax OK
tests/test.sh OK
tests/tilde_arith OK
tests/timeout3 OK
TESTING test.byte
tests/braces_amp.sh OK
tests/builtin.trap.exitcode.test OK
tests/diverge.sh OK
tests/empty_case OK
tests/escaping OK
tests/for_spaces.sh OK
tests/grab_submissions.sh OK
tests/grade.sh OK
tests/redir_indirect OK
tests/run_grader.sh OK
tests/run_lda.sh OK
tests/send_emails.sh OK
tests/syntax OK
tests/test.sh OK
tests/tilde_arith OK
tests/timeout3 OK
make: Leaving directory '/home/vagrant/smoosh/libdash/test'
make: Entering directory '/home/vagrant/smoosh/src'
./runtest

=== Initializing Dash parser...
=== Running evaluation tests...
=== ...ran 229 evaluation tests with 0 failures.


=== Running word expansion tests...
=== ...ran 64 word expansion tests with 0 failures.


=== Running path/fs tests...
=== ...ran 27 path/fs tests with 0 failures.


=== Running arithmetic tests...
=== ...ran 253 arithmetic tests with 0 failures.

make: Leaving directory '/home/vagrant/smoosh/src'
make: Entering directory '/home/vagrant/smoosh/tests'
== Running shell tests ===============================================
......................................................................
......................................................................
......................
shell_tests.sh: 162/162 tests passed
make: Leaving directory '/home/vagrant/smoosh/tests'

The unit tests are run directly via a binary, smoosh/src/runtest; the system tests use the Makefile in the smoosh/tests directory. These system tests are shell scripts paired with expected STDOUT, STDERR, and exit statuses.

Running tests on another shell

Both the Docker image and Vagrant VM will have other shells installed. The versions are nearly the same as those mentioned in the paper, but may have changed slightly due to rolling releases. (Numbers may therefore differ slightly.)

Shell Version
dash 0.5.8-2.4
bash 4.4-5
yash 2.43-1
zsh 5.3.1-4+b3
ksh 93u+20120801-3.1
mksh 54-2+b4

You can run the system tests on any shell by setting TEST_SHELL. Some shells may not terminate on all tests; you may need to run make clean while changing tests.

vagrant@debian9:~/smoosh$ TEST_SHELL=dash make -C tests
...

To get more detail on test failures, you should set the TEST_DEBUG variable, e.g.:

vagrant@debian9:~/smoosh$ TEST_DEBUG=1 TEST_SHELL=dash make -C tests
...

Running Modernish's tests/shell diagnostic

To run the Modernish tests, you must go to smoosh/modernish and simulate an install as follows:

vagrant@debian9:~/smoosh/modernish$ yes n | ./install.sh -s smoosh
Relaunching install.sh with /home/mgree/.local/bin/smoosh...
* Modernish version 0.15.2-dev, now running on /home/mgree/.local/bin/smoosh.
* This shell identifies itself as smoosh version 0.1.
  Modernish detected the following bugs, quirks and/or extra features on it:
... [weird noise on native Linux/VM; crash in Docker] ...
   LOCALVARS TRAPPRSUBSH BUG_MULTIBYTE
* Running modernish test suite on /home/mgree/.local/bin/smoosh ...
* lib/modernish/tst/@sanitychecks.t 
  002: ASCII chars and control char constants   - FAIL
* WARNING: modernish has some bug(s) in combination with this shell.
           Run 'modernish --test' after installation for more details.
Are you happy with /home/mgree/.local/bin/smoosh as the default shell? (y/n) install.sh: Aborting.

To test another shell, run yes n | smoosh/modernish/install.sh -s [shell name].

NB that the HDOCMASK bug seems to appear only in Linux and not on macOS.

POPL 2020 Artifact Evaluation

What can be reproduced from the Smoosh paper?

  • You should be able to build Smoosh on any computer that supports Docker.

  • The built Smoosh should pass all of its unit and system tests.

  • You should be able to run the Smoosh system tests on other shells. Due to rolling releases, your environment may have slightly different shell versions (which may then pass a different number of tests).

What can not be reproduced from the Smoosh paper?

  • The POSIX test suite cannot be distributed, so we cannot reproduce those tests. We do, however, have permission to distribute the resulting journals from running the test suite. Look in smoosh/posix-journals.

  • As of 2019-10-21, Modernish under virtualization (whether in Docker or in a Vagrant VM) exposes a bug in Smoosh's interaction with the dash parser. This bug wasn't poked when running on macOS.

    The manifestations are different: in Docker, Smoosh crashes with a 'broken DEFPATH' error; in a VM, some backtraces appear but the Modernish diagnostic completes with the correct output (just BUG_MULTIBYTE).

    Modernish should still complete without a problem on macOS, but I'm unable to test this (as my Mac is not booting).

smoosh's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

smoosh's Issues

Building on macOS

I am working through build this on macOS. I have hit a bunch of error which are for the most part resolvable.

I am currently stuck at this error:

~/Github/smoosh/libdash 0.2-rc~16*
❯ sudo gmake install
Password:
Making install in src
gmake[1]: Entering directory '/Users/mandalarian/Github/smoosh/libdash/src'
gmake  install-am
gmake[2]: Entering directory '/Users/mandalarian/Github/smoosh/libdash/src'
gmake[3]: Entering directory '/Users/mandalarian/Github/smoosh/libdash/src'
 .././install-sh -c -d '/usr/lib/x86_64-linux-gnu'
mkdir: /usr/lib/x86_64-linux-gnu: Operation not permitted
gmake[3]: *** [Makefile:668: install-libLTLIBRARIES] Error 1
gmake[3]: Leaving directory '/Users/mandalarian/Github/smoosh/libdash/src'
gmake[2]: *** [Makefile:1881: install-am] Error 2
gmake[2]: Leaving directory '/Users/mandalarian/Github/smoosh/libdash/src'
gmake[1]: *** [Makefile:1875: install] Error 2
gmake[1]: Leaving directory '/Users/mandalarian/Github/smoosh/libdash/src'
gmake: *** [Makefile:397: install-recursive] Error 1

I am guessing I need to change .././install-sh -c -d '/usr/lib/x86_64-linux-gnu' to something else but what I dont know. Any guidance provided would be greatly appreciated. Thank you.

Generally, speaking, the install tools required in the Dockerfile are not the same tools to be installed on mac, apparently. For example, libtools-dev and autotools-dev dont seem to be required. I think those are Fedora specific.

Alternatively, how would i connect a docker build smoosh to my local machine?

Thanks for all the great work done here. Looking forward to typed shell commands!

sh_06.ex tp379 fails on Linux

Assertion #379 (A): Test of GA11 - the utility recreates files with correct attributes.
Contents of _ga11_errout:
Testing GA11 for directory
Testing GA11 for regular file
getconf: Unrecognized variable `_POSIX_TIMESTAMP_RESOLUTION'
CheckFileTimes: could not obtain timestamp resolution -
continuing with assumed resolution of 1 second
Testing GA11 for FIFO
getconf: Unrecognized variable `_POSIX_TIMESTAMP_RESOLUTION'
CheckFileTimes: could not obtain timestamp resolution -
continuing with assumed resolution of 1 second
Failure: File ctime 1571676327.687798556 outside of acceptable range 1571676330.000000000 to 1571676330.843451261
Testing GA11 for a symbolic link to an existing file
getconf: Unrecognized variable `_POSIX_TIMESTAMP_RESOLUTION'
CheckFileTimes: could not obtain timestamp resolution -
continuing with assumed resolution of 1 second
Testing GA11 for a symbolic link to a non-existing file
getconf: Unrecognized variable `_POSIX_TIMESTAMP_RESOLUTION'
CheckFileTimes: could not obtain timestamp resolution -
continuing with assumed resolution of 1 second

Either my new laptop is too slow, Linux/Docker is misconfigured, or there's an actual bug.

True processes in symbolic mode

Core problem: the symbolic process model is inadequate.

The variable $$ isn't currently installed in a symbolic shell, but PPID is. Trickiness: $$ is unchanged in subshells, which can signal the top-level. We need to carefully hold on to such signals.

It's not currently possible for symbolic shells to send signals to themselves---including SIGPIPE, which leads to a wrong execution of the following two programs:

while true; do echo 5; done | true
while true; do echo 5; done | { read x; echo $((x + 42)) ; }

The first should terminate immediately; the second should print 47 and terminate. Right now neither loop ever stops, because the first process in either pipeline never receives the SIGPIPE.

Plan (checked means done in local branch sigpipe):

  • Check readers in symbolic_write_fd
  • Add process entry for top-level shell
  • Each shell process has an status : maybe nat (of a possible exit status) and pending : list signal and stepped : bool
  • Stepping sets stepped
  • Symbolic state has curpid representing current thread of execution
  • Symbolic system calls require that curpid is a live thread, otherwise immediate abort of call
  • Sending a signal mutates shell process state. Set status on, e.g., uncaught SIGPIPE
  • Implement os_pending_signal for symbolic mode
  • Tests for pending signals in symbolic mode
  • Tracer looks up pid 0 each time and steps it (with a cascade of curpid updates)
  • Tracer finds pids that weren't stepped and steps them
  • Update visualization
    • Change shim.ml to send over the full OS state, including the proc list
    • Render all of the live procs side by side, collapsing all but the main shell and the active proc

Separate builtin parsing and implementation

Right now each builtin does its own ad hoc parsing in command.lem. We should separate the parsing descriptions from the builtin implementations. Not only will be able to give better help text, we'll be able to do more static reasoning, e.g., identifying unspec argument use early.

It would be interesting to follow the fish approach of parsing the man page directly.

Broken POSIX tests in the VM: SIGTSTP?

I'm unable to even build the POSIX test suite when running in a Vagrant VM; the TET3.8 test-suite manager complains about getting spurious TSTP signals. No such issue on Docker; issue is present in v0.1.

0|3.8-lite 22:20:49 20200210|User: vagrant (1000) TCC Start, Command line: tcc -bp vsc posix_shell
5|Linux debian9.localdomain 4.9.0-11-amd64 #1 SMP Debian 4.9.189-3+deb9u2 (2019-11-11) x86_64|System Information
20|/home/vagrant/posix/tet3.8/vsc/tetbuild.cfg 0|Config Start
30||TET_OUTPUT_CAPTURE=False
30||TET_EXPAND_CONF_VARS=true
30||TET_BUILD_TOOL=sh
30||TET_BUILD_FILE=/home/vagrant/posix/tet3.8/vsc/Bin/buildtool
30||TET_API_COMPLIANT=True
30||TET_PASS_TC_NAME=False
30||TET_VERSION=3.8-lite
40||Config End
110|0 /tset/POSIX.shell/shell/sh_04.ex 22:20:49|Build Start, scenario ref 1-0
15|0 3.8 1|TCM Start
510|0|unexpected signal 20 received by TCM
510|0 0 1 22:20:49|IC Start
510|0|unexpected signal 20 received by TCM
510|0 1 22:20:49|TP Start
510|0|unexpected signal 20 received by TCM
510|0|unexpected signal 20 received by TCM
510|0 1 7 22:20:50|NORESULT
510|0|unexpected signal 20 received by TCM
510|0 0 1 22:20:50|IC End
510|0|Abandoning test case: caught unexpected signal 20
130|0 0 22:20:50|Build End, scenario ref 1-0
110|1 /tset/POSIX.shell/shell/sh_05.ex 22:20:50|Build Start, scenario ref 2-0
15|1 3.8 1|TCM Start
510|1|unexpected signal 20 received by TCM
510|1 0 1 22:20:50|IC Start
510|1|unexpected signal 20 received by TCM
510|1 1 22:20:50|TP Start
510|1|unexpected signal 20 received by TCM
510|1|unexpected signal 20 received by TCM
510|1 1 7 22:20:51|NORESULT
510|1|unexpected signal 20 received by TCM
510|1 0 1 22:20:51|IC End
510|1|Abandoning test case: caught unexpected signal 20
130|1 0 22:20:51|Build End, scenario ref 2-0
110|2 /tset/POSIX.shell/shell/sh_06.ex 22:20:51|Build Start, scenario ref 3-0
15|2 3.8 1|TCM Start
510|2|unexpected signal 20 received by TCM
510|2 0 1 22:20:51|IC Start
510|2|unexpected signal 20 received by TCM
510|2 1 22:20:51|TP Start
510|2|unexpected signal 20 received by TCM
510|2|unexpected signal 20 received by TCM
510|2 1 7 22:20:52|NORESULT
510|2|unexpected signal 20 received by TCM
510|2 0 1 22:20:52|IC End
510|2|Abandoning test case: caught unexpected signal 20
130|2 0 22:20:52|Build End, scenario ref 3-0
110|3 /tset/POSIX.shell/shell/sh_07.ex 22:20:52|Build Start, scenario ref 4-0
15|3 3.8 1|TCM Start
510|3|unexpected signal 20 received by TCM
510|3 0 1 22:20:52|IC Start
510|3|unexpected signal 20 received by TCM
510|3 1 22:20:52|TP Start
510|3|unexpected signal 20 received by TCM
510|3|unexpected signal 20 received by TCM
510|3 1 7 22:20:53|NORESULT
510|3|unexpected signal 20 received by TCM
510|3 0 1 22:20:53|IC End
510|3|Abandoning test case: caught unexpected signal 20
130|3 0 22:20:53|Build End, scenario ref 4-0
110|4 /tset/POSIX.shell/shell/sh_08.ex 22:20:53|Build Start, scenario ref 5-0
15|4 3.8 1|TCM Start
510|4|unexpected signal 20 received by TCM
510|4 0 1 22:20:53|IC Start
510|4|unexpected signal 20 received by TCM
510|4 1 22:20:54|TP Start
510|4|unexpected signal 20 received by TCM
510|4|unexpected signal 20 received by TCM
510|4 1 7 22:20:54|NORESULT
510|4|unexpected signal 20 received by TCM
510|4 0 1 22:20:54|IC End
510|4|Abandoning test case: caught unexpected signal 20
130|4 0 22:20:54|Build End, scenario ref 5-0
110|5 /tset/POSIX.shell/shell/sh_09.ex 22:20:54|Build Start, scenario ref 6-0
15|5 3.8 1|TCM Start
510|5|unexpected signal 20 received by TCM
510|5 0 1 22:20:54|IC Start
510|5|unexpected signal 20 received by TCM
510|5 1 22:20:55|TP Start
510|5|unexpected signal 20 received by TCM
510|5|unexpected signal 20 received by TCM
510|5 1 7 22:20:55|NORESULT
510|5|unexpected signal 20 received by TCM
510|5 0 1 22:20:55|IC End
510|5|Abandoning test case: caught unexpected signal 20
130|5 0 22:20:55|Build End, scenario ref 6-0
110|6 /tset/POSIX.shell/shell/sh_10.ex 22:20:55|Build Start, scenario ref 7-0
15|6 3.8 1|TCM Start
510|6|unexpected signal 20 received by TCM
510|6 0 1 22:20:55|IC Start
510|6|unexpected signal 20 received by TCM
510|6 1 22:20:56|TP Start
510|6|unexpected signal 20 received by TCM
510|6|unexpected signal 20 received by TCM
510|6 1 7 22:20:56|NORESULT
510|6|unexpected signal 20 received by TCM
510|6 0 1 22:20:56|IC End
510|6|Abandoning test case: caught unexpected signal 20
130|6 0 22:20:56|Build End, scenario ref 7-0
110|7 /tset/POSIX.shell/shell/sh_11.ex 22:20:56|Build Start, scenario ref 8-0
15|7 3.8 1|TCM Start
510|7|unexpected signal 20 received by TCM
510|7 0 1 22:20:56|IC Start
510|7|unexpected signal 20 received by TCM
510|7 1 22:20:57|TP Start
510|7|unexpected signal 20 received by TCM
510|7|unexpected signal 20 received by TCM
510|7 1 7 22:20:57|NORESULT
510|7|unexpected signal 20 received by TCM
510|7 0 1 22:20:57|IC End
510|7|Abandoning test case: caught unexpected signal 20
130|7 0 22:20:57|Build End, scenario ref 8-0
110|8 /tset/POSIX.shell/shell/sh_12.ex 22:20:57|Build Start, scenario ref 9-0
15|8 3.8 1|TCM Start
510|8|unexpected signal 20 received by TCM
510|8 0 1 22:20:57|IC Start
510|8|unexpected signal 20 received by TCM
510|8 1 22:20:58|TP Start
510|8|unexpected signal 20 received by TCM
510|8|unexpected signal 20 received by TCM
510|8 1 7 22:20:58|NORESULT
510|8|unexpected signal 20 received by TCM
510|8 0 1 22:20:58|IC End
510|8|Abandoning test case: caught unexpected signal 20
130|8 0 22:20:58|Build End, scenario ref 9-0
110|9 /tset/POSIX.shell/shell/sh_13.ex 22:20:58|Build Start, scenario ref 10-0
15|9 3.8 1|TCM Start
510|9|unexpected signal 20 received by TCM
510|9 0 1 22:20:58|IC Start
510|9|unexpected signal 20 received by TCM
510|9 1 22:20:59|TP Start
510|9|unexpected signal 20 received by TCM
510|9|unexpected signal 20 received by TCM
510|9 1 7 22:20:59|NORESULT
510|9|unexpected signal 20 received by TCM
510|9 0 1 22:20:59|IC End
510|9|Abandoning test case: caught unexpected signal 20
130|9 0 22:20:59|Build End, scenario ref 10-0
900|22:20:59|TCC End

If the TSTP signals are my fault, I suspect it's an issue with the monitoring/interactive work in system.ml. This seems unlikely because the build was working on Linux in October.

Issues with substring processing in parameter expansion

Consider the following snippet:

FOO="\\a"
echo ${FOO#*\\}

What I expect this to output is a (and this is what dash and bash does), but smoosh outputs \a.

Another issue:

FOO="a?b"
echo ${FOO#*"?"}

This should output b (as it does on dash and bash), but with smoosh is outputs ?b, because it does not consider the question mark as escaped.

It seems that when try_match_substring receives the pattern, it is already fully expanded, with quotes removed, despite the code assuming that it still has quotes and escaping backslashes in it.

A similar pattern to the first example is used in the Modernish test suite to iterate over a string, this bug causes it to be stuck in an endless loop forever.

BUG_HDOCMASK in Modernish on Linux platforms.

There's a bug on true Linux platforms that never showed up in OS X/Docker on OS X (though who could tell because of #5).

$ yes n | ./install.sh -s smoosh
Relaunching install.sh with /home/mgree/.local/bin/smoosh...
* Modernish version 0.15.2-dev, now running on /home/mgree/.local/bin/smoosh.
* This shell identifies itself as smoosh version 0.1.
  Modernish detected the following bugs, quirks and/or extra features on it:
34:ln=01: command not found
36:mh=00:pi=40: command not found
33:so=01: command not found
35:do=01: command not found
35:bd=40: command not found
33: command not found
01:cd=40: command not found
33: command not found
01:or=40: command not found
31: command not found
01:mi=00:su=37: command not found
41:sg=30: command not found
43:ca=30: command not found
41:tw=30: command not found
42:ow=34: command not found
42:st=37: command not found
44:ex=01: command not found
32:*.tar=01: command not found
31:*.tgz=01: command not found
31:*.arc=01: command not found
31:*.arj=01: command not found
31:*.taz=01: command not found
31:*.lha=01: command not found
31:*.lz4=01: command not found
31:*.lzh=01: command not found
31:*.lzma=01: command not found
31:*.tlz=01: command not found
31:*.txz=01: command not found
31:*.tzo=01: command not found
31:*.t7z=01: command not found
31:*.zip=01: command not found
31:*.z=01: command not found
31:*.Z=01: command not found
31:*.dz=01: command not found
31:*.gz=01: command not found
31:*.lrz=01: command not found
31:*.lz=01: command not found
31:*.lzo=01: command not found
31:*.xz=01: command not found
31:*.zst=01: command not found
31:*.tzst=01: command not found
31:*.bz2=01: command not found
31:*.bz=01: command not found
31:*.tbz=01: command not found
31:*.tbz2=01: command not found
31:*.tz=01: command not found
31:*.deb=01: command not found
31:*.rpm=01: command not found
31:*.jar=01: command not found
31:*.war=01: command not found
31:*.ear=01: command not found
31:*.sar=01: command not found
31:*.rar=01: command not found
31:*.alz=01: command not found
31:*.ace=01: command not found
31:*.zoo=01: command not found
31:*.cpio=01: command not found
31:*.7z=01: command not found
31:*.rz=01: command not found
31:*.cab=01: command not found
31:*.wim=01: command not found
31:*.swm=01: command not found
31:*.dwm=01: command not found
31:*.esd=01: command not found
31:*.jpg=01: command not found
35:*.jpeg=01: command not found
35:*.mjpg=01: command not found
35:*.mjpeg=01: command not found
35:*.gif=01: command not found
35:*.bmp=01: command not found
35:*.pbm=01: command not found
35:*.pgm=01: command not found
35:*.ppm=01: command not found
35:*.tga=01: command not found
35:*.xbm=01: command not found
35:*.xpm=01: command not found
35:*.tif=01: command not found
35:*.tiff=01: command not found
35:*.png=01: command not found
35:*.svg=01: command not found
35:*.svgz=01: command not found
35:*.mng=01: command not found
35:*.pcx=01: command not found
35:*.mov=01: command not found
35:*.mpg=01: command not found
35:*.mpeg=01: command not found
35:*.m2v=01: command not found
35:*.mkv=01: command not found
35:*.webm=01: command not found
35:*.ogm=01: command not found
35:*.mp4=01: command not found
35:*.m4v=01: command not found
35:*.mp4v=01: command not found
35:*.vob=01: command not found
35:*.qt=01: command not found
35:*.nuv=01: command not found
35:*.wmv=01: command not found
35:*.asf=01: command not found
35:*.rm=01: command not found
35:*.rmvb=01: command not found
35:*.flc=01: command not found
35:*.avi=01: command not found
35:*.fli=01: command not found
35:*.flv=01: command not found
35:*.gl=01: command not found
35:*.dl=01: command not found
35:*.xcf=01: command not found
35:*.xwd=01: command not found
35:*.yuv=01: command not found
35:*.cgm=01: command not found
35:*.emf=01: command not found
35:*.ogv=01: command not found
35:*.ogx=01: command not found
35:*.aac=00: command not found
36:*.au=00: command not found
36:*.flac=00: command not found
36:*.m4a=00: command not found
36:*.mid=00: command not found
36:*.midi=00: command not found
36:*.mka=00: command not found
36:*.mp3=00: command not found
36:*.mpc=00: command not found
36:*.ogg=00: command not found
36:*.ra=00: command not found
36:*.wav=00: command not found
36:*.oga=00: command not found
36:*.opus=00: command not found
36:*.spx=00: command not found
36:*.xspf=00: command not found
36:: command not found
   LOCALVARS TRAPPRSUBSH BUG_MULTIBYTE BUG_HDOCMASK
* Running modernish test suite on /home/mgree/.local/bin/smoosh ...
* lib/modernish/tst/@sanitychecks.t 
  002: ASCII chars and control char constants   - FAIL
* WARNING: modernish has some bug(s) in combination with this shell.
           Run 'modernish --test' after installation for more details.
Are you happy with /home/mgree/.local/bin/smoosh as the default shell? (y/n) install.sh: Aborting.

More faithful representation of words

There's no way for us to represent a single word, leading to some minor inadequacies. There are a few places where there really only ever ought to be a single word, statically:

  • assignments
  • redirect targets

Changes here will be tricky, because they'll interfere with expansion. It may make sense to make these changes after accommodating multiple parsers #6.

Unspec/undef rundown

We currently track unspec/undef behavior on a per-shell basis.

  • Find all mentions of unspec/undef in the POSIX spec: unspec.md and undef.md
  • Log them in smoosh
  • A way to log unspec/undef to an external location (to track in subshells); timestamped occurrences w/maximum context (PID, shell state, etc.)

Once this is done, try logging all unspec/undef in the various test suites.

Clearer versioning

version.lem just adds a timestamp but it doesn't tell you which branch/commit was built.

History

Implement:

  • Track history (can we integrate this with logging?)
  • Sh_nolog
  • HISTFILE
  • builtin_fc

Explicit escaping throughout

With #36 (a fix for #21, among other things), escaping is explicit in words. It's still the case that expanded_words and intermediate_fields use backslashes to escape things. It would be good to have explicit escapes throughout, though getting all the details right will be tricky.

Hashing

Once a utility has been searched for and found (either as a result of this specific search or as part of an unspecified shell start-up activity), an implementation may remember its location and need not search for the utility again unless the PATH variable has been the subject of an assignment. If the remembered location fails for a subsequent invocation, the shell shall repeat the search to find the new location for the utility, if any.

  • Add hash to shell state (record hits, like bash!)
  • Have checked_set_param clear hash table on $PATH update
  • Update resolve_command_name to do memoization
  • builtin_hash with -r flag (report hits)
  • Implement -h/-o earlyhash (called hash-on-def in yash and hashall in bash)

Bash reports whether or not a command is hashed. Non-POSIX but semi-useful. Would need to update a few things to be able to report that.

  • Measure difference in timing on POSIX suite.

Exit unexpectedly when errexit is enabled

Hello,

First off, thank you for your impressive project.
I was looking for various POSIX shell implementations and found your project. The goal of this project seems to be to formalize the POSIX shell standard, but I have determined that you are also developing an executable POSIX shell.

I was assuming that smoosh would actually work, but the following code terminated unexpectedly.

set -e
putsn() { echo "$@"; }
false && true
putsn "It should be executed" # Not executed by smoosh.

I'm developing ShellSpec, a unit testing framework that works with POSIX shells, and one of its goals is to support all POSIX shells. The goal is almost achieved, and it already works with almost all POSIX shells (even if there are some bugs). As part of this development, I am reporting a bug of the shell.

Due to the above bug, smoosh is not yet working with ShellSpec. If your project its (one of) goals is to develop an executable POSIX shell, I will gladly report back.

Regards,

Packaging and build systems

Things are a disaster. I have to unset SDKROOT when on macOS to get a build to work. (But I need it set to get Haskell to work.)

Ideally we should have:

  • opam package for libdash
  • change .travis.yml to actually build things rather than use Docker
  • build on multiple OSes
  • make -j4 or something, i mean come on breaks lem and maybe us too?
  • add back Modernish tests
  • change to just depend on an opam package for lem
  • build uses lem OPAM package, submodule removed
  • opam package for smoosh
  • build just uses these packages (with local pinning?)
  • have a Travis build that actually tests Docker (and Vagrant, too?) best approach: use OPAM!
  • log test output and post somewhere meaningful (run other shells, too? or is all this a separate repo?)

Show call stack/positional parameter info in Shtepper

  • Show positional parameter info whenever a call or return happens
  • Show call stack somewhere

Real talk: we should get rid of the JS stateful morass and reimplement this all in Elm. (That's the part that's a "good student project".)

Parse abort in Modernish under virtualization

Running ./install -s smoosh in Docker yields a parse abort. It's probably related to the other parse aborts we've seen, which I suspect is a mishandling of erroneous parsing in eval.

Upgrade Modernish

Our fork is currently several hundred commits behind. What new bugs await?!

Abstracting over the parser

  • fix PS1 and PS2 expansion
  • "The shell shall replace each instance of the character '!' in PS1 with the history file number of the next command to be typed. Escaping the '!' with another '!' (that is, "!!" ) shall place the literal character '!' in the prompt. This volume of POSIX.1-2017 specifies the effects of the variable only for systems supporting the User Portability Utilities option."

functions needed:

  • libdash instance

  • support for EvalLoop

    • context (e.g., stackmark/parser state)
    • parse_next function
  • set_ps1

  • set_ps2

  • morbig instance colis-anr/morbig#102

  • Oil instance?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.