preservim / nerdcommenter

Vim plugin for intensely nerdy commenting powers
Creative Commons Zero v1.0 Universal
4.99k stars 445 forks source link

feat(dosbatch): change `dosbatch` delimiters #508

Closed MeShootIn closed 1 year ago

MeShootIn commented 1 year ago

Change left and leftAlt delimiters to nestable REM (extra space character is required) for security and compatibility reasons. Here is two (the shortest) of the many justifications:

alerque commented 1 year ago

Is the extra space actually required for the syntax to be valid? Including the space here is problematic since it might get doubled or not properly removed when uncommenting based on user settings. If it is actually part of the language spec (and not just a recommended style) then we can go ahead, just know that it doesn't cleanly solve the problem and forces some people to change their configurations to work around the other issues with this plugin not supporting spaces as part of delimiters.

MeShootIn commented 1 year ago

@alerque

Is the extra space actually required for the syntax to be valid?

Yes, otherwise there will be an error when executing the command (see example below).

Input:

@echo off
REM echo commented
REMecho comment error
echo printed

Output:

"REMecho" is not recognized as an internal or external command,
operable program or batch file.
printed

Including the space here is problematic since it might get doubled or not properly removed when uncommenting based on user settings.

However, without the extra space and with the plugin's default settings, uncommenting the line will leave the space at the beginning.

If it is actually part of the language spec (and not just a recommended style)

The REM command is the only part of the language dedicated directly to commenting.

just know that it doesn't cleanly solve the problem and forces some people to change their configurations

Yes, may be. However, REM is better than :: because due to :: there is a chance to get a subtle, but possibly fatal, error during script execution.