MCPcopy Index your code
hub / github.com/codeaashu/claude-code / stripCommentLines

Function stripCommentLines

src/tools/BashTool/bashPermissions.ts:508–522  ·  view source on GitHub ↗

* Strips full-line comments from a command. * This handles cases where Claude adds comments in bash commands, e.g.: * "# Check the logs directory\nls /home/user/logs" * Should be stripped to: "ls /home/user/logs" * * Only strips full-line comments (lines where the entire line is a comment),

(command: string)

Source from the content-addressed store, hash-verified

506 * not inline comments that appear after a command on the same line.
507 */
508function stripCommentLines(command: string): string {
509 const lines = command.split('\n')
510 const nonCommentLines = lines.filter(line => {
511 const trimmed = line.trim()
512 // Keep lines that are not empty and don't start with #
513 return trimmed !== '' && !trimmed.startsWith('#')
514 })
515
516 // If all lines were comments/empty, return original
517 if (nonCommentLines.length === 0) {
518 return command
519 }
520
521 return nonCommentLines.join('\n')
522}
523
524export function stripSafeWrappers(command: string): string {
525 // SECURITY: Use [ \t]+ not \s+ — \s matches \n/\r which are command

Callers 2

stripSafeWrappersFunction · 0.85
stripAllLeadingEnvVarsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected