passage
passage copied to clipboard
README: use safer/better fzf script
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.