dan200 / ComputerCraft

Programmable Computers for Minecraft
Other
964 stars 199 forks source link

Shell.run requests curly brackets for no reason #607

Closed mopishlynx23 closed 3 years ago

mopishlynx23 commented 3 years ago

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.

SquidDev commented 3 years ago

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.

Lupus590 commented 3 years ago

or use \\ to escape the escape