tools: add a small utility script cmd/tools/vrun, to make it easier to use .vsh scripts on systems, with /usr/bin/env still not supporting -S

This commit is contained in:
Delyan Angelov 2025-02-04 14:51:38 +02:00
parent d30598bbca
commit 7ea5b4a020
No known key found for this signature in database
GPG key ID: 66886C0F12D595ED
2 changed files with 30 additions and 0 deletions

26
cmd/tools/vrun Executable file
View file

@ -0,0 +1,26 @@
#!/bin/sh
v run $@
## The purpose of this script, is to make it easier to run V scripts on systems, where
## the `/usr/bin/env` implementation, does not yet support a `-S` option.
## Notes: FreeBSD's env supports it since 2006.
## GNU's coreutils env supports it since 2018.
## However, for example BusyBox's env still does not (2025/02/04), and there may
## be others like it too :-| .
## On such systems, you can copy this script, or symlink it, somewhere in your PATH,
## and then start your .vsh scripts with: `#!/usr/bin/env vrun`.
## You can also start them with `#!/usr/bin/env /full/path/to/v/cmd/tools/vrun` directly,
## if you prefer.
## You can check, if it works, by saving this as a /tmp/args.vsh file:
## ```v
## !/usr/bin/env vrun
## println(arguments())
## ```
##
## ... then run `chmod 755 /tmp/args.vsh`, and finally run:
## `/tmp/args.vsh abc 123`
##
## If everything works correctly, you should see something like:
## ['/tmp/args', 'abc', '123']

View file

@ -8132,6 +8132,10 @@ were made and keep the binary as `tmp.<scriptfilename>`. **Caution**: if this fi
exists the file will be overridden. If you want to rebuild each time and not keep this binary exists the file will be overridden. 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`. instead use `#!/usr/bin/env -S v -raw-vsh-tmp-prefix tmp run`.
Note: there is a small shell script `cmd/tools/vrun`, that can be useful for systems, that have an
env program (`/usr/bin/env`), that still does not support an `-S` option (like BusyBox).
See https://github.com/vlang/v/blob/master/cmd/tools/vrun for more details.
# Appendices # Appendices
## Appendix I: Keywords ## Appendix I: Keywords