File tree Expand file tree Collapse file tree
packages/opencode/src/cli/cmd/tui/util Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -125,9 +125,25 @@ export namespace Clipboard {
125125 if ( os === "win32" ) {
126126 console . log ( "clipboard: using powershell" )
127127 return async ( text : string ) => {
128- // need to escape backticks because powershell uses them as escape code
129- const escaped = text . replace ( / " / g, '""' ) . replace ( / ` / g, "``" )
130- await $ `powershell -NonInteractive -NoProfile -Command "Set-Clipboard -Value \"${ escaped } \""` . nothrow ( ) . quiet ( )
128+ // Pipe via stdin to avoid PowerShell string interpolation ($env:FOO, $(), etc.)
129+ const proc = Bun . spawn (
130+ [
131+ "powershell.exe" ,
132+ "-NonInteractive" ,
133+ "-NoProfile" ,
134+ "-Command" ,
135+ "[Console]::InputEncoding = [System.Text.Encoding]::UTF8; Set-Clipboard -Value ([Console]::In.ReadToEnd())" ,
136+ ] ,
137+ {
138+ stdin : "pipe" ,
139+ stdout : "ignore" ,
140+ stderr : "ignore" ,
141+ } ,
142+ )
143+
144+ proc . stdin . write ( text )
145+ proc . stdin . end ( )
146+ await proc . exited . catch ( ( ) => { } )
131147 }
132148 }
133149
You can’t perform that action at this time.
0 commit comments