(tools)=
# Useful tools and scripts

This page collects small tools that help with the course work.

## Pre-submission check

The script {download}`presub.sh <tools/presub.sh>` checks a submission
for the Dolphin assignments before it is handed in. It unpacks the zip
file into a temporary directory and checks that

- all files required for the given phase are present and not empty,
- the project compiles with `dune build`, and
- the compiled compiler accepts a minimal Dolphin program for the phase.

The first two checks are critical: if either fails, the script reports
that the zip file must not be submitted. A failure of the third check
is reported as a warning.

A downloaded file is not executable, so the script must be made
executable once after the download:

```
chmod +x presub.sh
```

The script takes the phase number (1 to 5) and the path to the zip
file:

```
./presub.sh 3 group07.zip
```

The script requires Bash 4 or later, because it uses associative
arrays. The [development container](dev-container.md) provides a suitable
Bash. The Bash that ships with macOS as `/bin/bash` is version 3.2, and
the script fails there with the error `files: unbound variable`; on
macOS, the script should be run inside the container.
