ComputerCraft

ComputerCraft

21M Downloads

Shell.run requests curly brackets for no reason

mopishlynx23 opened this issue ยท 2 comments

commented

I was working on a file that saves all necessary files to a floppy disk when shell.run randomly requested an open curly bracket.

os.loadAPI("utils")
local a = utils.checkPeripherals()
for side, peripheral in pairs(a) do
  if peripheral == "drive" then
    shell.run("delete", "drive\menu")
    shell.run("delete", "drive\startup")
    shell.run("delete", "drive\utils") -- "missing '{' near '"drive\ut'" ???
    shell.run("delete", "drive\button")
    shell.run("delete", "drive\dropDown")
    shell.run("copy", "menu", "drive")
    shell.run("copy", "startup", "drive")
    shell.run("copy", "utils", "drive")
    shell.run("copy", "button", "drive")
    shell.run("copy", "dropDown", "drive")
  end
end

I see absolutely no reason for this to happen, and it only happens for utils for whatever reason. I understand there's probably a much simpler solution than calling the delete and copy programs but I didn't think it'd matter. I'm really confused.

commented

or use \\ to escape the escape

commented

This isn't anything to do with the nhell, but just Lua in general. Backslashes are parsed as escape characters. For instance, \n is considered a new line. In this case, \u is the start of a Unicode escape sequence.

You don't want this - replace your backslashes with forward ones and it should work.