OSDN Git Service

Establish default preferences for GUI; (cf. MinGW-Feature #2036)
[mingw/mingw-get.git] / scripts / libexec / wsh.lua
1 --
2 -- wsh.lua
3 --
4 -- $Id$
5 --
6 -- Lua 5.2 module providing a simple API for invoking system services
7 -- via the Microsoft Windows Scripting Host.
8 --
9 --
10 -- This file is a component of mingw-get.
11 --
12 -- Written by Keith Marshall <keithmarshall@users.sourceforge.net>
13 -- Copyright (C) 2012, MinGW Project
14 --
15 --
16 -- Permission is hereby granted, free of charge, to any person obtaining a
17 -- copy of this software and associated documentation files (the "Software"),
18 -- to deal in the Software without restriction, including without limitation
19 -- the rights to use, copy, modify, merge, publish, distribute, sublicense,
20 -- and/or sell copies of the Software, and to permit persons to whom the
21 -- Software is furnished to do so, subject to the following conditions:
22 --
23 -- The above copyright notice and this permission notice shall be included
24 -- in all copies or substantial portions of the Software.
25 --
26 -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
27 -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28 -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
29 -- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30 -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
31 -- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
32 -- DEALINGS IN THE SOFTWARE.
33 --
34    local M = {}
35    local cscript = "cscript -nologo"
36 --
37    function M.execute( ... )
38      local function wsh_prepare( interpreter, ... )
39        for argind, argval in ipairs {...}
40        do
41          interpreter = interpreter .. " " .. argval
42        end
43        return interpreter
44      end
45      os.execute( wsh_prepare( cscript, ... ) )
46    end
47 --
48    function M.libexec_path( script, subsystem )
49      local script_path = os.getenv( "APPROOT" )
50      if script_path
51      then
52        script_path = script_path .. "libexec\\"
53      else
54        script_path = ".\\libexec\\"
55      end
56      if subsystem
57      then
58        script_path = script_path .. subsystem .. "\\"
59      end
60      return script_path .. script
61    end
62 --
63    return M
64 --
65 -- $RCSfile$: end of file */