Portable shebang line for Julia with command-line options?

I'm writing "scripts" in Julia, that I use from the command line. For example:

#!/usr/bin/env julia

@info "Hello world!"

Using a shebang line like this makes it possible to make such a script executable and easily run it without explicitly invoking julia:

$ ./hello
[ Info: Hello world!

However, passing additional command-line arguments to julia in such a shebang line is not portable (at least does not work for Linux, which I care about). Is there a way to overcome this limitation? For example, how could I make sure that my script will be run with julia -O0 --compile=min?

Upvotes: 4

Views: 699

Answers (1)

The recommended way to do this is documented in the FAQ. Adapting the example to your case:

#!/bin/bash
#=
exec julia -O0 --compile=min "${BASH_SOURCE[0]}" "$@"
=#

@info "Hello world!"

Upvotes: 4

Related Questions