fresh icon indicating copy to clipboard operation
fresh copied to clipboard

Fresh seems to be adding backslashes for unknown reasons

Open louisch opened this issue 5 years ago • 1 comments

UPDATE: Actually, this seems to be happening with regular fresh invocations in the command line now, I'm not sure what is going on other than there seems to be something wrong with my setup.

~~When doing something like the following:~~

❯ find tmux -name '*.yml' -exec fresh {} --file=~/.config/tmuxinator/{} ';'

~~Either find or fresh seems to escape its input incorrectly because this happens:~~

Add `fresh tmux/config\.yml \-\-file\=\~/\.config/tmuxinator/tmux/config\.yml` to /home/user/.freshrc [Y/n]? ^C

~~Dashes, dots, equal signs, and tildes seem to get backslashes added to them. The resulting line won't execute properly as fresh needs --file, not `--file'.~~

~~I did try quoting the special characters:~~

❯ find tmux -name '*.yml' -exec fresh '{} --file=~/.config/tmuxinator/{}' ';'

~~But this only seemed to make things worse:~~

Add `fresh tmux/config\.yml\ \-\-file\=\~/\.config/tmuxinator/tmux/config\.yml` to /home/user/.freshrc [Y/n]? ^C

louisch avatar Jul 30 '19 02:07 louisch

I suspect it's happening inside the parse_fresh_add_args function which seems to add backslashes before characters in arguments that doesn't match /[A-Za-z_0-9]/, but that still doesn't explain why some of my fresh lines with dots or dashes in them work, and some get escaped.

If I write

fresh tmux/config.yml --file="${HOME}/.config/tmuxinator/config.yml"

inside freshrc it works fine, but if I try to use find -exec like this for example:

find tmux -name '*.yml' -exec sh -c 'fresh {} --file="${HOME}/.config/tmuxinator/$(basename {})"' ';'

It will exhibit the 'dashes and dots get escaped' problem. Also, if I use fresh on the command line (not inside the freshrc file), any dots and dashes will definitely get escaped in that case.

louisch avatar Aug 02 '19 09:08 louisch