@@ -249,7 +249,9 @@ for (const replacement of ["deleted", "file"]) {
249249 const subdir = path . join ( workspace , "child" ) ;
250250 fs . mkdirSync ( subdir ) ;
251251 const context = createContext ( `bash-cwd-${ replacement } ` , workspace ) ;
252- assert . equal ( ( await handleBashTool ( { command : "cd child" } , context ) ) . ok , true ) ;
252+ const changed = await handleBashTool ( { command : "cd child" } , context ) ;
253+ assert . equal ( changed . ok , true ) ;
254+ assert . equal ( fs . realpathSync ( String ( changed . metadata ?. cwd ) ) , fs . realpathSync ( subdir ) ) ;
253255 const retained = await handleBashTool ( { command : "pwd" } , context ) ;
254256 assert . equal ( fs . realpathSync ( String ( retained . metadata ?. startCwd ) ) , fs . realpathSync ( subdir ) ) ;
255257 fs . rmdirSync ( subdir ) ;
@@ -260,6 +262,25 @@ for (const replacement of ["deleted", "file"]) {
260262 } ) ;
261263}
262264
265+ test (
266+ "Bash preserves Git Bash virtual mount cwd as a native Windows directory" ,
267+ { skip : process . platform !== "win32" } ,
268+ async ( ) => {
269+ const context = createContext ( "bash-virtual-cwd" , createTempWorkspace ( ) ) ;
270+ const changed = await handleBashTool ( { command : "cd /tmp && pwd -W" } , context ) ;
271+ assert . equal ( changed . ok , true ) ;
272+ const nativeCwd = String ( changed . metadata ?. cwd ) ;
273+ assert . equal ( path . isAbsolute ( nativeCwd ) , true ) ;
274+ assert . equal ( fs . statSync ( nativeCwd ) . isDirectory ( ) , true ) ;
275+ assert . equal ( fs . realpathSync ( nativeCwd ) , fs . realpathSync ( ( changed . output ?? "" ) . trim ( ) ) ) ;
276+
277+ const retained = await handleBashTool ( { command : "pwd -W" } , context ) ;
278+ assert . equal ( retained . ok , true ) ;
279+ assert . equal ( fs . realpathSync ( String ( retained . metadata ?. startCwd ) ) , fs . realpathSync ( nativeCwd ) ) ;
280+ assert . equal ( fs . realpathSync ( ( retained . output ?? "" ) . trim ( ) ) , fs . realpathSync ( nativeCwd ) ) ;
281+ }
282+ ) ;
283+
263284test ( "Bash reports an invalid project root as a spawn failure" , { timeout : 3_000 } , async ( ) => {
264285 const root = path . join ( createTempWorkspace ( ) , "missing" ) ;
265286 const result = await handleBashTool ( { command : "pwd" } , createContext ( "bash-invalid-root" , root ) ) ;
0 commit comments