I'd like to be able to make scripts executable on UNIX-like systems by having the first line of the script include the interpreter, in the UNIX tradition:
1 2 3 4 | #!/usr/bin/bwbasic FOR I = 1 TO 10 PRINT I NEXT I |
This is called "shebang" or "hashbang". https://en.wikipedia.org/wiki/Shebang_(Unix)
The script also has to be made executable: chmod a+x <script-name>
This feature allows you to run the script by just typing its name rathar than having to type "bwbasic <script-name>. But, it not just that convenience, this feature also allows you to put scripts in a directory in your PATH and find them without having to type their full path name. I general, it would allow bwbasic scripts to be run just like any other UNIX command, making them a first class citizen of the system.
Currently the "#" on the first line causes an error with bwbasic. Making this work will require adding a special case in the code just for the "#" on the first line.
The correct link is: Shebang
This functionality has been added to bwBASIC 3.30.. Here is the fix for bwb_fload() in bwbasic.c:
Last edit: AF5NE 2019-07-02
Hey Howard, can you share the code for bwbasic 3.30? Also, FYI, I have created a GitHub repository: https://github.com/nerun/bwbasic. If you want access, let me know.
Here is the testcase (SHEBANG1.BAS) added to bwBASIC 3.30:
Last edit: AF5NE 2019-07-02
Thanks! You rock! Now I just have to find out why Fedora is still shipping bwBASIC 3.20.
I guess you could close the ticket now.
I think we need to wait for bwBASIC 3.30 to actually be released. I don't have all the code from Howard yet.
Oh. I see. I didn't realize it was still in progress.