1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

compiler: add -raw-vsh-tmp-prefix tmp flag, to allow for executing scripts without .vsh extension (#15829)

This commit is contained in:
Annie
2022-09-20 14:52:18 +02:00
committed by GitHub
parent 453cc41c32
commit 8f7958273b
5 changed files with 73 additions and 35 deletions

View File

@ -127,6 +127,7 @@ To do so, run the command `v up`.
* [Hot code reloading](#hot-code-reloading)
* [Cross compilation](#cross-compilation)
* [Cross-platform shell scripts in V](#cross-platform-shell-scripts-in-v)
* [Vsh scripts with no extension](#vsh-scripts-with-no-extension)
* [Attributes](#attributes)
* [Goto](#goto)
* [Appendices](#appendices)
@ -5949,6 +5950,18 @@ Or just run it more like a traditional Bash script:
On Unix-like platforms, the file can be run directly after making it executable using `chmod +x`:
`./deploy.vsh`
## Vsh scripts with no extension
Whilst V does normally not allow vsh scripts without the designated file extension, there is a way
to circumvent this rule and have a file with a fully custom name and shebang. Whilst this feature
exists it is only recommended for specific usecases like scripts that will be put in the path and
should **not** be used for things like build or deploy scripts. To access this feature start the
file with `#!/usr/bin/env -S v -raw-vsh-tmp-prefix tmp` where `tmp` is the prefix for
the built executable. This will run in crun mode so it will only rebuild if changes to the script
were made and keep the binary as `tmp.<scriptfilename>`. **Caution**: if this filename already
exists the file will be overriden. If you want to rebuild each time and not keep this binary instead
use `#!/usr/bin/env -S v -raw-vsh-tmp-prefix tmp run`.
## Attributes
V has several attributes that modify the behavior of functions and structs.