Try to open a file which has in its name the backslash character OR
Try to pipe stdin containing backslash character
Expected results:
The file will be properly opened and in the case of stdin a new file with the stdin's content will be opened in CotEditor
Actual results:
The command fails with the following trace:
Traceback (most recent call last):
File "/Applications/CotEditor.app/Contents/SharedSupport/bin/cot", line 360, in <module>
main(args, stdin)
File "/Applications/CotEditor.app/Contents/SharedSupport/bin/cot", line 289, in main
app.tell_document('set contents to "{}"'.format(sanitized_stdin))
File "/Applications/CotEditor.app/Contents/SharedSupport/bin/cot", line 153, in tell_document
return self.tell('tell document {} to {}'.format(index, script))
File "/Applications/CotEditor.app/Contents/SharedSupport/bin/cot", line 120, in tell
return run_osascript(script, is_async)
File "/Applications/CotEditor.app/Contents/SharedSupport/bin/cot", line 92, in run_osascript
raise CalledProcessError(p.returncode, script)
subprocess.CalledProcessError: Command 'tell app "/Applications/CotEditor.app" to tell document 1 to set contents to "te\st"' returned non-zero exit status 1
Note:
I'm gonna prepare a PR, but the fix consists in escaping the backslash character, in addition to the quotes (i.e. instead of stdin.replace('"', '\\"') should be stdin.replace('\\', '\\\\').replace('"', '\\"'))
STR
Expected results:
Actual results:
Note:
stdin.replace('"', '\\"')
should bestdin.replace('\\', '\\\\').replace('"', '\\"')
)