Open main menu
Posts
Gists
Guilds
Users
Decipher
Docs
Open user menu
Log in
Sign up
Create a new gist
Posts
Gists
Guilds
Users
Decipher
Docs
Files
shex.src
shexy.src
shex.src
//command: shex (shellexec) v0.2.0
// Changelog:
// * Added file checks
// * Add automatic cleanup of older builds
if not params or params[0] == "-h" or params[0] == "--help" then exit(launch_path.split("/")[-1]+" [source] [args]")
cache_path = home_dir+"/"+"Cache"+"/"+"shex"
source = get_shell.host_computer.File(current_path+"/"+params[0])
if source == null then exit("Target is invalid."+char(10)+"It must be located at your Working Directory.")
if source.is_binary then exit("Target is not a Source File.")
if not source.has_permission("r") then exit("Target has no read permissions.")
if not params[0].indexOf(".src") then exit("Target must have the suffix [*.src].")
args = params[1:].join(" ")
if params[0].indexOf(".src") then
if not source then exit(params[0] + " not found.")
if source.is_binary then exit(params[0] + " a binary.")
if source != null then
if get_shell.host_computer.File(cache_path) == null then
get_shell.host_computer.create_folder(home_dir,"Cache")
get_shell.host_computer.create_folder(home_dir+"/"+"Cache","shex")
end if
src = get_shell.host_computer.File(current_path+"/"+params[0])
md5sum = md5(get_shell.host_computer.File(current_path+"/"+params[0]).get_content)
BinName = params[0].remove(".src")
program = cache_path+"/"+BinName+"-"+md5sum
for file in get_shell.host_computer.File(cache_path).get_files
FileName = file.name.split("-")[0]
FileSum = file.name.split("-")[1]
if FileSum != md5sum and FileName == BinName then
file.delete
continue
end if
if FileSum == md5sum and FileName == BinName then
get_shell.launch(file.path, args)
exit
end if
end for
print( get_shell.build(current_path+"/"+params[0],cache_path,false) )
BinPath = get_shell.host_computer.File(cache_path+"/"+BinName)
if BinPath != null then
get_shell.host_computer.File(cache_path+"/"+BinName).rename(BinName+"-"+md5sum)
else
exit("File not compiled")
end if
get_shell.launch(cache_path+"/"+BinName+"-"+md5sum, args)
exit
end if
end if
end if
shexy.src
//command: shexy (shellexec) v0.3.1
// Changelog
// * Added Fullpath and Relatvepath
// * Prepared Binary Mode
// * Added debug messages
// * Reworked Parameters
// * Improved code
// * shex is now called shexy -> shellexec is shexy :-P
DebugOn = 0
BinaryOn = 0
filepath = ""
tocolor = function(color)
return "<color="+color+">"+self.str+"</color>"
end function
convert = function(text)
obj = {}
obj.str = str(text)
obj.tocolor = @tocolor
return obj
end function
debug = function(msg)
if DebugOn == 1 then
print( convert("[DEBUG] "+msg).tocolor("purple") )
end if
end function
for parm in params
if parm == "-h" or parm == "--help" then
exit(launch_path.split("/")[-1]+" [source] [args]")
end if
if parm == "-d" then
DebugOn = 1
continue
end if
if parm == "-c" then
BinaryOn = 1
continue
end if
if parm.indexOf("/") == 0 then
if typeof(get_shell.host_computer.File(parm)) != "file" then
debug(parm+" is invalid")
continue
end if
if typeof(get_shell.host_computer.File(parm)) == "file" then
filepath = parm
args = params[1:].join(" ")
break
end if
end if
if parm.indexOf("/") != 0 then
p = parent_path(launch_path)+"/"+parm
if typeof(get_shell.host_computer.File(p)) != "file" then
debug(p+" is invalid")
debug("Arguments: "+args)
continue
end if
if typeof(get_shell.host_computer.File(p)) == "file" then
filepath = p
args = params[1:].join(" ")
debug("Arguments: "+args)
break
end if
end if
end for
debug("Path: "+filepath)
if filepath == "" then
debug("No valid path")
exit()
end if
cache_path = home_dir+"/"+"Cache"+"/"+"shex"
source = get_shell.host_computer.File(filepath)
if source.is_binary then exit("Target is not a Source File.")
if not source.has_permission("r") then exit("Target has no read permissions.")
if not filepath.indexOf(".src") then exit("Target must have the suffix [*.src].")
if filepath.indexOf(".src") then
if source != null then
if get_shell.host_computer.File(cache_path) == null then
get_shell.host_computer.create_folder(home_dir,"Cache")
get_shell.host_computer.create_folder(home_dir+"/"+"Cache","shex")
end if
src = get_shell.host_computer.File(current_path+"/"+params[0])
md5sum = md5(get_shell.host_computer.File(filepath).get_content)
BinName = filepath.split("/")[-1].remove(".src")
program = cache_path+"/"+BinName+"-"+md5sum
for file in get_shell.host_computer.File(cache_path).get_files
FileName = file.name.split("-")[0]
FileSum = file.name.split("-")[1]
if FileSum != md5sum and FileName == BinName then
file.delete
continue
end if
if FileSum == md5sum and FileName == BinName then
get_shell.launch(file.path, args)
exit
end if
end for
print( get_shell.build(filepath,cache_path,false) )
BinPath = get_shell.host_computer.File(cache_path+"/"+BinName)
if BinPath != null then
get_shell.host_computer.File(cache_path+"/"+BinName).rename(BinName+"-"+md5sum)
else
exit("File not compiled")
end if
get_shell.launch(cache_path+"/"+BinName+"-"+md5sum, args)
exit
end if
end if
end if