File tree Expand file tree Collapse file tree
packages/opencode/src/tool Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -89,10 +89,18 @@ export const BashTool = Tool.define("bash", {
8989 . text ( )
9090 . then ( ( x ) => x . trim ( ) )
9191 log . info ( "resolved path" , { arg, resolved } )
92- if ( resolved && ! Filesystem . contains ( Instance . directory , resolved ) ) {
93- throw new Error (
94- `This command references paths outside of ${ Instance . directory } so it is not allowed to be executed.` ,
95- )
92+ if ( resolved ) {
93+ // Git Bash on Windows returns Unix-style paths like /c/Users/...
94+ const normalized =
95+ process . platform === "win32" && resolved . match ( / ^ \/ [ a - z ] \/ / )
96+ ? resolved . replace ( / ^ \/ ( [ a - z ] ) \/ / , ( _ , drive ) => `${ drive . toUpperCase ( ) } :\\` ) . replace ( / \/ / g, "\\" )
97+ : resolved
98+
99+ if ( ! Filesystem . contains ( Instance . directory , normalized ) ) {
100+ throw new Error (
101+ `This command references paths outside of ${ Instance . directory } so it is not allowed to be executed.` ,
102+ )
103+ }
96104 }
97105 }
98106 }
You can’t perform that action at this time.
0 commit comments