Forrest logo
back to the comby tool

comby:tldr:f9810

comby: Match and rewrite templates, and print changes.
$ comby '${assert_eq!(:[a], :[b])}' '${assert_eq!(:[b], :[a])}' ${-rs}
try on your machine

This command is using the "comby" tool to perform a search and replace operation in some files.

Here is the breakdown of the command:

  • The first argument, '${assert_eq!(:[a], :[b])}', is the search pattern. It is a string that represents a specific code pattern or structure that needs to be found. In this case, it is looking for the presence of the "assert_eq!" macro or function, with two arguments: ': [a]' and ': [b]'.

  • The second argument, '${assert_eq!(:[b], :[a])}', is the replacement pattern. It defines how the found pattern will be modified or replaced. In this case, it swaps the positions of the two arguments, so ': [b]' comes first and ': [a]' comes second.

  • The third argument, '${-rs}', provides additional options to the "comby" tool. The '-r' option means recursive, which tells the tool to search for the pattern in all files and directories recursively. The '-s' option means silent, which suppresses any output or summary after the operation.

Overall, this command is effectively finding instances of the "assert_eq!" macro or function in files, where the arguments are in the original order ': [a]' and ': [b]', and swapping their positions to ': [b]' and ': [a]'.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the comby tool