cc.shell.complete.file/dir/fileOrDir should quote paths containg a space in them
walksanatora opened this issue · 10 comments
cc.shell.complete should quote file paths containg mutiple lines to prevent them from being counted as seperate arguments
Yeah, this has been a pain for a while. The main problem is that read
's auto-completion system doesn't support replacing the preceding text (i.e. you need to replace hel
with "hel
as well as auto-completing lo world"
), and it's not clear how to do that in a backwards-compatible fashion.
currently not, but that would be a valid option i think since that doesen't have you editing the allready written part of the string
I'm working on a solution right now. Escaping the spaces with backslashes seems to pose an issue for me though.
So I'm working on an alternative, which might include an additional optional parameter to "shell.complete()".
Going to mention this issue in the commit.
Edit: Just noticed that I have to be a contributor in order to open a new branch. How would I become one?
You are supposed to fork the project
Then make changes there
Then open a Pull Request
A cursory regex over the pastebin archive shows that it has been used at least a few times, possibly unsuccessfully:
rg 'fs\.(open|move|delete)\(\s*["\u0022].*\\\\'
A8kCA8Zc.txt
729: local myFile = fs.open("\\cards\\"..fileList[i],"r")
kCTERg1Z.txt
919: local myFile = fs.open("\\disk\\id","w")
CQUAprWH.txt
9: local output = fs.open("disk\\inventory.txt","w")
37: local input = fs.open("disk\\inventory.txt","r")
dBHuAvka.txt
45: fs.delete("Databases\\" .. dbName)
PyqB5cWf.txt
14: file = fs.open("\\update","w")
112:local file = fs.open("\\disk\\id","r")
119:file = fs.open("\\startup","w")
rYsd9J8B.txt
9: local output = fs.open("disk\\inventory.txt","w")
82: local input = fs.open("disk\\inventory.txt","r")
0Edr7vmL.txt
11: local handle = assert(fs.open("disk\\startup", "w"), "Couldn't save data!")
u22vpVU6.txt
192: f = fs.open("builder\\templates\\" .. fileName, "w")
Compared to the frequency of not doing this, I would say it's not a high risk, and would be incompatible in most places anyway so is a reasonable migration pain for the one or two people that might run into it
It occurs to me that using backwards slashes for escapes may be confusing for those used to Windows paths (for instance foo\bar\baz.lua
). I don't know if any programs actually rely on that, but we should do a search over Pastebin and GitHub.
With shell.run
:
rg 'shell\.run\(\s*["\u0022].*\\\\'
ZcffhsFX.txt
1:shell.run("cd \\")
PyqB5cWf.txt
9: shell.run("\\startup")
19: shell.run("pastebin","get","kCTERg1Z","\\startup")
116:shell.run("cp","\\disk\\update","\\update")
117:shell.run("cp","\\disk\\node"..myID,"\\node")
123:shell.run("pastebin","get","waF1RFPz","\\chopper")
MmJwcLT9.txt
1:shell.run("cd \\")
It occurs to me that using backwards slashes for escapes may be confusing for those used to Windows paths (for instance foo\bar\baz.lua). I don't know if any programs actually rely on that, but we should do a search over Pastebin and GitHub.
Unless I'm forgetting something, I don't think there's any valid backslash escape for any path-characters. (Like alphabetics like \r \e). We could simply restrict the backslash syntax solely for space escapes.
For example, something like foo\bar\baz\ faz.lua
would be interpreted as "foo/bar/baz faz.lua"
.