Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

interp: process substitution on Windows #995

Open
graf0 opened this issue Apr 25, 2023 · 3 comments
Open

interp: process substitution on Windows #995

graf0 opened this issue Apr 25, 2023 · 3 comments

Comments

@graf0
Copy link
Contributor

graf0 commented Apr 25, 2023

Hello!

I've done short research about process substitution on windows.

So - theoretically - you can create named pipe, then create server for this pipe and voila, you have something simillar to unix pipes. But not quite the same!

Named pipes could be addressed via \.\pipe\NAME - but cli tool must explicitly support pipes, it's not direct replacement! Most tools CANNOT read from \.\pipe\

You can do trick - create symlink - ie.: c:\symlink - that point to \.\pipe\NAME. But first - it's not always possible without admin rights (depends on OS version I think). Second - named pipes ARE NOT same as unix pipes, you NEED to properly handle errors, if not - server and/or client will hang. And third - there was at least one serious attack using this scheme (symlink to pipe) so there is risk, that antiviruses will treat using such trick as very suspicious.

So imho implementation using named pipes is not good idea.

Only other option I see: just run command which is in process substitution syntax, capture it's output to file, and after command finishes - resume script with normal file. Plus info in docs, that on windows it works differently.

@mvdan
Copy link
Owner

mvdan commented Apr 25, 2023

Just so I understand, I assume that you want to replace fmt.Errorf("TODO: support process substitution on Windows") with a working implementation?

Windows support in the interpreter is best-effort, simply because that's generally the best we can do. I think using regular files would be good enough in many cases, so I would welcome a pull request.

@mvdan
Copy link
Owner

mvdan commented Jun 18, 2023

Friendly ping @graf0 - see my comment above.

@graf0
Copy link
Contributor Author

graf0 commented Jun 18, 2023

Yes - I want to replace process substituion on windows with files. So command is executed, it's whole output is saved to temporary file and then we can "pipe" it into command, that uses substitution.

I'll try to implement this in following month and send pull request.

@mvdan mvdan removed the needs info label Jul 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants