diff --git a/docs/en/src/writing-plugins.md b/docs/en/src/writing-plugins.md index a25f13a..d3848f9 100644 --- a/docs/en/src/writing-plugins.md +++ b/docs/en/src/writing-plugins.md @@ -19,8 +19,7 @@ A minimal plugin should confirm to the following structure: └── init.lua ``` -You can also use -[this template][2]. +You can also use [this template][2]. ### README.md @@ -51,6 +50,18 @@ to append `.xplr` to the name to make them distinguishable. Similar to the Finally, after publishing, don't hesitate to [let us know][4]. +## Best practices + +- Try not to execute a lot of commands at startup, it may make xplr slow to + start. +- When executing commands, prefer `Call0` over `Call`, `BashExec0` over + `BashExec` and so on. File names may contain newline characters + (e.g. `foo$'\n'bar`). +- File names may also contain quotes. Use the syntax + `printf 'Call0: "%s"' "${FOO_ESC}"` where `FOO_ESC=${FOO//\"/\\\"}`. +- Check for empty variables using the syntax `${FOO:?}` or use a default value + `${FOO:-defaultvalue}`. + ## Examples Visit [Awesome Plugins][5] for xplr plugin examples. diff --git a/src/init.lua b/src/init.lua index 6118be5..c099bb8 100644 --- a/src/init.lua +++ b/src/init.lua @@ -1803,9 +1803,9 @@ xplr.config.modes.builtin.delete = { fi else if rm -v -- "${LINE:?}"; then - printf 'LogSuccess: "%s"\0' "$line deleted" >> "${XPLR_PIPE_MSG_IN:?}" + printf 'LogSuccess: "%s"\0' "$LINE_ESC deleted" >> "${XPLR_PIPE_MSG_IN:?}" else - printf 'LogError: "%s"\0' "Failed to delete $line" >> "${XPLR_PIPE_MSG_IN:?}" + printf 'LogError: "%s"\0' "Failed to delete $LINE_ESC" >> "${XPLR_PIPE_MSG_IN:?}" fi fi done < "${XPLR_PIPE_RESULT_OUT:?}")