Interacting with the shell
One of the things that makes Lua powerful as a scripting language is its ability to interact with the operating system through a shell/terminal. os.execute takes a string and returns a status code. Whatever the provided string is will be executed as a shell command. The return value is whatever the running program returned.
If Lua is running embedded in a program, or is on an OS with no shell/terminal, the os.execute command will return 0. You can test if the current Lua environment has a shell by calling os.execute with no arguments. If a non-zero value is returned, a shell is available. If zero is returned, there is no shell or terminal.
The code here tries to pull from git. Using os.execute, Lua could be used ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access