Posted 21 August 2014 - 07:12 AM
I'm currently in the process of rewriting the shell program to add my own twists to it (nothing too out of the ordinary), so I'm looking at the code of the default shell program that comes shipped with ComputerCraft to base my changes off of. As I was looking through the code of the shell program, I noticed that shell.setDir() is defined as
Is there any particular purpose to allowing the setting of the CWD to whatever you please, be it a folder that doesn't exist or a file? I know other languages prevent being able to do that: Python, for example, raises an exception if you tried to set the CWD to an imaginary directory. In my edits, I'm considering changing the function definition to check if the directory exists before setting it (if it doesn't, then it won't change the CWD), but I don't want to do that if it would break some fundamental CC principle that I'm unaware of.
function shell.setDir( _sDir )
sDir = _sDir
end
With that implementation, any program, or someone in the Lua interpreter, could run shell.setDir("/sunshineRainbowsAndUnicorns") and it would set the CWD to that directory, even though it may not exist.Is there any particular purpose to allowing the setting of the CWD to whatever you please, be it a folder that doesn't exist or a file? I know other languages prevent being able to do that: Python, for example, raises an exception if you tried to set the CWD to an imaginary directory. In my edits, I'm considering changing the function definition to check if the directory exists before setting it (if it doesn't, then it won't change the CWD), but I don't want to do that if it would break some fundamental CC principle that I'm unaware of.