This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Watcher7's profile picture

[1.33][Minor] directory climbing bug

Started by Watcher7, 29 April 2012 - 02:50 AM
Watcher7 #1
Posted 29 April 2012 - 04:50 AM
Doing the following will "break" your in-game "OS".
cd rom => cd help
Due to the fact that it cannot tell the difference between the program you want to use and the help file of that program, you cannot run any default programs.
I came up with a very small fix in the "shell" file that is applied to the "shell.run" function, though you may prefer some other method.
function shell.run(_sCommand, ...)
	local sPath = shell.resolveProgram(_sCommand)
	if sPath ~= nil then
		if shell.dir() == "rom/help" then
			sPath = string.gsub(sPath, "help", "programs")
		end
		tProgramStack[#tProgramStack + 1] = sPath
		   local result = os.run(tEnv, sPath, ...)
		tProgramStack[#tProgramStack] = nil
		return result
	   else
		print("No such program")
		return false
	end
end
Another solution would be to add extensions to those files and then add this to the top of "help", you may prefer another method.
tArgs = { ... }
tArgs[1] = tArgs[1]..".help"
Also I did not see a topic related to this bug, so if it exists sorry.
Dirkus7 #2
Posted 06 May 2012 - 10:14 PM
Got this problem too, nice fix, should be added by Dan
sam_technologeek #3
Posted 07 May 2012 - 05:18 PM
Nice, I can use it in my virus!
Riddla #4
Posted 25 June 2012 - 01:05 PM
A quick fix would be a reboot command, or shutdown command(I.e. Control+S/ Control+R)
inventor2514 #5
Posted 03 July 2012 - 05:03 PM
You could still run a default program with its file path.
ex. /rom/programs/cd
It is an inconvenience though, so nice fix.