Skip to content

V for Bash script developers

Turiiya edited this page Apr 11, 2024 · 10 revisions

V can be used as a platform independent script like language too.

All you have to do is save your file with a .vsh extension.

By doing so, v will make functions inside the os module automatically available to your scripts, without you having to import them manually.

You also will not need to specify the main function (that is a work in progress, for now, please do so ... simple linear examples work, but for now v scripting is more stable with a fn main(){} ).

To run your .vsh scripts, on *nix platforms, just set the executable bit for your script with for example chmod +x script.vsh . After that, you can start the script like any other executable, with ./script.vsh .

On Windows, you have to associate the .vsh file extension with v.exe . After that, just double click your script.vsh file in Windows Explorer.

Hello World
#!/usr/bin/env bash
echo "Hello world"
#!/usr/bin/env -S v
println('Hello World!')
Listing files in current folder
#!/usr/bin/env bash
ls
#!/usr/bin/env -S v
println(ls('.')!)