sudo-prompt icon indicating copy to clipboard operation
sudo-prompt copied to clipboard

Workaround issue #97 by copying cmd.exe into the temporary folder and running it from here

Open zvin opened this issue 5 years ago • 5 comments

Hello @jorangreef There's been no activity on https://github.com/jorangreef/sudo-prompt/issues/97 or https://github.com/microsoft/terminal/issues/2419 for a year so I came up with a (quite ugly) workaround.

Since the issue is with escaping the execute.bat file path, I copy cmd.exe in the temporary folder and run it from here. It avoids dealing with the path completely. cmd.exe is ~274KiB so it isn't taking too long to copy.

I acknowledge this is ugly but I couldn't find anything better.

zvin avatar Sep 11 '20 12:09 zvin

Thanks @zvin ! It's an ugly (but beautiful) hack...

It looks good, but would you please make the copy conditional on there being an ampersand in the path? This way, the common case is not affected by the copy, and we may also avoid knock-on bugs.

jorangreef avatar Sep 15 '20 09:09 jorangreef

@zvin, perhaps it would also be good to make the copy cmd.exe branch dependent on a few more special characters, not just ampersand, e.g. see https://github.com/jorangreef/sudo-prompt/issues/119

jorangreef avatar Sep 15 '20 10:09 jorangreef

@jorangreef Added, I hope I didn't forget any

zvin avatar Sep 15 '20 10:09 zvin

This second commit was very wrong, it avoids copying but still runs cmd from the tmp path, I'll fix that.

zvin avatar Nov 20 '20 18:11 zvin

PR updated @jorangreef I'd prefer merging only the first commit as it makes it less complex (not creating 2 code paths).

zvin avatar Nov 20 '20 19:11 zvin