Skip to content

fix(r): correct shell quote escaping in lintr command#424

Open
sims1253 wants to merge 1 commit intopeteromallet:mainfrom
sims1253:fix/r-lintr-command-escaping
Open

fix(r): correct shell quote escaping in lintr command#424
sims1253 wants to merge 1 commit intopeteromallet:mainfrom
sims1253:fix/r-lintr-command-escaping

Conversation

@sims1253
Copy link

Bug: The R language plugin's lintr command had broken shell quote escaping that prevented it from executing properly.

Root Cause:

  1. Quote collision: The outer Python string used single quotes, but the shell command also used single quotes for the R expression, causing the shell to receive malformed commands.
  2. Over-engineering: The cat(paste(capture.output(...), collapse="\n")) wrapper was unnecessary — lintr::lint_dir() already prints to stdout by default.

The Fix:

     # Before (broken):
     'cmd': (
         'Rscript -e \'cat(paste(capture.output('
         'lintr::lint_dir(".", show_notifications=FALSE)'
         '), collapse="\\n"))\''
     ),

     # After (fixed):
     "cmd": (
         "Rscript -e \"lintr::lint_dir('.')\""
     ),

Changes:
• Switched to double quotes for the Python string, allowing single quotes inside for the R string
• Removed unnecessary cat/paste/capture.output wrapper
• Simplified to rely on lintr's default stdout behavior
• Output remains GNU-style formatted lint messages (compatible with fmt: "gnu")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant