# 检测lua文件使用到全局变量

代码

luac -p -l /usr/local/openresty/lualib/comm/business_func.lua |grep  GLOBAL |grep -vE 'ngx|string|print|os|table|tonumber|require|pairs|next'
1
[root@cpc_test ~]# luac -p -l /usr/local/openresty/lualib/comm/business_func.lua |grep  GLOBAL |grep -vE 'ngx|string|print|os|table|tonumber|require|pairs|next'
        18      [9]     SETGLOBAL       6 -8    ; _VERSION
        151     [536]   GETGLOBAL       23 -34  ; math
        26      [605]   GETGLOBAL       10 -9   ; math
        61      [617]   GETGLOBAL       14 -9   ; math
        65      [617]   GETGLOBAL       15 -9   ; math
[root@cpc_test ~]#
1
2
3
4
5
6
7