# Add run compiler command · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/2e5115b0687ee9b7078dbf70da7d7070a7c80399)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 2e5115b0687ee9b7078dbf70da7d7070a7c80399

Requested commit: 2e5115b0687ee9b7078dbf70da7d7070a7c80399

Commit: 2e5115b0687ee9b7078dbf70da7d7070a7c80399

Tree: 23f3acc2db17931b0bbb2ef4837de7b06dcfcc25

Author: Marc Tiehuis

Committer: Marc Tiehuis

## Message

```
Add run compiler command

'zig run file.zig' builds a file and stores the artifacts in the global
cache. On successful compilation the binary is executed.

'zig run file.zig -- a b c' does the same, but passes the arguments a,
b and c as runtime arguments to the program. Everything after an '--' are
treated as runtime arguments.

On a posix system, a shebang can be used to run a zig file directly. An
example shebang would be '#!/usr/bin/zig run'. You may not be able pass
extra compile arguments currently as part of the shebang. Linux for example
treats all arguments after the first as a single argument which will result
in an 'invalid command'.

Currently there is no customisability for the cache path as a compile
argument. For a posix system you can use `TMPDIR=. zig run file.zig` to
override, in this case using the current directory for the run cache.

The input file is always recompiled, even if it has changed. This is
intended to be cached but further discussion/thought needs to go into
this.

Closes #466.

```

## Parents

- [67f11190d10caac1d08b76d60ec28eb2f5173946](https://git.cafe/gitcafe/zig/commit/67f11190d10caac1d08b76d60ec28eb2f5173946?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/2e5115b0687ee9b7078dbf70da7d7070a7c80399?format=markdown)
