fart-it icon indicating copy to clipboard operation
fart-it copied to clipboard

Issue with "//" in replacement string

Open thdoan opened this issue 4 years ago • 1 comments

Steps to reproduce:

fart script.js "if (DEBUG" "//if (DEBUG"

My workaround for now (adding space before "//"), but hope it can be fixed:

fart script.js "if (DEBUG" " //if (DEBUG"

thdoan avatar Jul 21 '20 01:07 thdoan

I think you have to escape a forward slash with a backslash.

For example \/\/if (DEBUG

icnocop avatar Mar 21 '22 19:03 icnocop

@lionello This does not work. If you escape a slash with a backslash in the replace_string, then the backslash is inserted as well.

If you don't escape a backslash in the replace_string, then the help text pops up.

ltguillaume avatar Oct 07 '23 22:10 ltguillaume

Because on Windows / can be used for the short command line options, you have to use -- if you want to use / as the prefix for the search or replace string:

fart script.js "if (DEBUG" -- "//if (DEBUG"

or

fart script.js -- "if (DEBUG" "//if (DEBUG"

lionello avatar Oct 09 '23 22:10 lionello

  1. Thanks for explaining this! While I see [--] in the help after [options], it isn't explained anywhere, nor is it explained as you do above (apparently the position of it matters, too). As such, I reckon it would be vital that this is properly explained.
  2. Secondly, I don't see why -- should still be used if the search and/or replace string is already placed between double quotes.

ltguillaume avatar Oct 09 '23 23:10 ltguillaume

The command interpreter removes the double quotes so the application doesn’t know there were quotes around it. I’ll add a note about the — to the help. Good idea.

lionello avatar Oct 10 '23 01:10 lionello