zx icon indicating copy to clipboard operation
zx copied to clipboard

Paths in Git Bash on Windows don't work

Open Schweinepriester opened this issue 8 months ago • 6 comments

Reproduction

windows-test.mjs:

import { $ } from 'zx'
import path from 'node:path'
import { fileURLToPath } from 'url'

const __dirname = path.dirname(fileURLToPath(import.meta.url))

$.verbose = true
await $`zx --version`
await $`mkdir -p ${path.join(__dirname, 'AA-zx-test')}`
await $`mkdir -p BB-zx-test`
await $`ls -l | grep zx-test`

Actual behavior

await $`mkdir -p ${path.join(__dirname, 'AA-zx-test')}`

silently does nothing on Windows in Git Bash.

The generated command

mkdir -p $'C:\\git\\frontend_main\\apps\\acheron\\AA-zx-test'

appears to be correct though, as running it manually works.

Image

Works without issue on macOS & Linux in Bash.

Expected

await $`mkdir -p ${path.join(__dirname, 'AA-zx-test')}`

working, as on other OS.

Schweinepriester avatar May 09 '25 12:05 Schweinepriester

ah, btw., also had a colleague on windows run the windows-test.mjs from above - same behavior, so it's not just my setup…

Schweinepriester avatar Jun 03 '25 12:06 Schweinepriester

I apologize for the confusion with the two PRs I created and closed #1237 and #1274. I ran into some configuration issues on my end.

nizar0x1f avatar Jul 17 '25 07:07 nizar0x1f

not tested yet, but maybe the \f is the issue? 🤔

https://stackoverflow.com/questions/3091524/what-are-carriage-return-linefeed-and-form-feed

Schweinepriester avatar Sep 11 '25 21:09 Schweinepriester

^ yes it is! :D

having \f in the path causes the command to silently fail:

Image

curiously having run that^, there's 'C:'$'\f''zxtest'/ in the folder in there's AA-zx-test:

Image

Schweinepriester avatar Sep 12 '25 13:09 Schweinepriester

ok, I don't think it's form feed, but rather drive letters that are in use/reserved(?)

doesn't work

  • a
  • b
  • c
  • f

works

  • z
  • w

which, so far, is plausible for my system.

Image

Schweinepriester avatar Sep 12 '25 20:09 Schweinepriester

something else of note I came across:

$ caddy run --config $'C:\\git\\web_main\\packages\\devenv\\src\\commands\\start_server\\zcaddy.json'

turned into

  'Error: reading config from file: open C:\\git\\web_main\\packages\\devenv\\src\x0Fmmands\\start_server\\zcaddy.json: The filen
ame, directory name, or volume label syntax is incorrect.\n',

note the \c (or \co?) => \x0F

Schweinepriester avatar Sep 12 '25 20:09 Schweinepriester