Skip to Content
Lua Quick Start Guide
book

Lua Quick Start Guide

by Gabor Szauer
July 2018
Beginner
202 pages
5h 42m
English
Packt Publishing
Content preview from Lua Quick Start Guide

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.
Start your free trial

You might also like

Beginning Lua Programming

Beginning Lua Programming

Kurt Jung, Aaron Brown
Vim Masterclass

Vim Masterclass

Jason Cannon

Publisher Resources

ISBN: 9781789343229Supplemental Content