spacewander commented on a change in pull request #2395:
URL: https://github.com/apache/apisix/pull/2395#discussion_r514094203



##########
File path: apisix/cli/env.lua
##########
@@ -0,0 +1,77 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+local util = require("apisix.cli.util")
+
+local execute_cmd   = util.execute_cmd
+local trim          = util.trim
+local pcall         = pcall
+local error         = error
+local str_match     = string.match
+local pkg_cpath_org = package.cpath
+local pkg_path_org  = package.path
+
+local apisix_home   = "/usr/local/apisix"
+local pkg_cpath = apisix_home .. "/deps/lib64/lua/5.1/?.so;"
+                  .. apisix_home .. "/deps/lib/lua/5.1/?.so;;"
+local pkg_path  = apisix_home .. "/deps/share/lua/5.1/?.lua;;"
+
+
+-- only for developer, use current folder as working space
+local is_root_path = false
+local script_path = arg[0]
+if script_path:sub(1, 2) == './' then
+    apisix_home = trim(execute_cmd("pwd"))
+    if not apisix_home then
+        error("failed to fetch current path")
+    end
+
+    if str_match(apisix_home .. "/", '^/root/') then

Review comment:
       We can use plain `string.find` like this issue suggested: 
https://github.com/apache/apisix/issues/1268




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to