andsens / homeshick

git dotfiles synchronizer written in bash
MIT License
2.11k stars 145 forks source link

File names with % cause problems with printf #223

Closed ncallister closed 3 months ago

ncallister commented 4 months ago

There are some applications which create files with % characters in them such as .config/kate/externaltools/Insert\%20UUID.ini. Unfortunately printf interprets the % character as an escape character and so the homeshick link command fails with the message: .homesick/repos/homeshick/lib/commands/link.sh: line 108: printf:U': invalid format character`.

andsens commented 4 months ago

Good catch Nathan! I have pushed a bug fix that is a little more robust than your PR, where $path is instead passed as an arg to printf. I figured out what initially caused the issue with printf "%s\0" "$path" not working: git ls-files escapes special chars, which makes a lot of sense, but that means we need to re-interpret the escaped chars with printf. By telling git to nulbyte delimit the paths we avoid that whole escaping/re-interpreting and can just pass them along verbatim.

andsens commented 4 months ago

p.s.: The changes are now available in the testing branch, so go ahead and switch to that if you want to run it right away :-)

ncallister commented 3 months ago

homeshick link is now working with all files using the testing branch. Thank you :grinning:

andsens commented 3 months ago

Merged to master