passage icon indicating copy to clipboard operation
passage copied to clipboard

README: use safer/better fzf script

Open cuonglm opened this issue 3 years ago • 0 comments

The current script has some drawbacks:

  • It spawns a sed command for each .age file.
  • If "$PREFIX" contains newline, sed command won't work correctly.
  • Using "$PREFIX" as pattern may lead to code injection.

Fixing those things are simple:

  • cd to "$PREFIX" before running find, we do this in subshell, so no effect to the current shell.
  • Use "find ... -exec sh -c '' sh-find {} +" form, so we can process as much as possible for each exec sh.
  • Use parameter expansion for stripping "./" prefix and ".age" suffix.

The script is now safer, maybe faster, and guarantee to work in all POSIX shells.

cuonglm avatar Dec 28 '22 18:12 cuonglm