Add hashbangs
crabdancing opened this issue ยท 2 comments
Or in this case...hyphen bangs. A special optional line at the top of a text file to tell CraftOS to open a file with a specific program. For instance, --!/bin/py
at the top of a Python script, or --!paint
to load a paint file directly into the paint program when launched. :)
Related? #547
One'd probably would be able to get away with standard hashbangs - the Lua parser is smart enough to skip them.
This should be pretty easy to implement - one'd just need to read the first line in the file before the shell actually executes the program, and check if it starts with "#!"
.
If it matches, just tokenize the string and pass that + file name + args to execute
again. We probably want to limit the recursion depth (say to 10 or something sane) to avoid crashing with a file foo.lua
starting with #! foo.lua
.