draios/sysdig — pull request #249 by Erethon (2014-09-24 20:28:51+00:00)
Title: Chisels: Add a function to parse and handle numeric user input

Hello, this small patch set adds a function in common.lua to properly handle and parse numeric user input.

Most chisels up until now, used `tonumber()` for user input, without checking if `tonumber()` returned `nil`. This meant in most cases, that sysdig would crash later on, as shown here:

```
root@snf-578833:~# sysdig -c netlower testing123
TIME PROCESS TYPE LATENCY(ms) SOCKET
netlower chisel error: [string "--[[..."]:67: attempt to compare nil with number
```
This is after applying the patch:

```
root@snf-578833:~# sysdig -c netlower testing123
Input min_msec must be a number.
```

The first commit introduces function `parse_user_input`,
which uses tonumber() to convert user input to a
number. If tonumber() returns 'nil', aka input wasn't a number, the
function prints an error message to inform the user and calls
os.exit() to stop program execution. All chisels that need to accept
numeric user input should use this function from now on.

The second commit, updates most chisels to use this new function.