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

Function containsHeredoc

src/utils/bash/shellQuoting.ts:7–22  ·  view source on GitHub ↗

* Detects if a command contains a heredoc pattern * Matches patterns like: <<EOF, <<'EOF', <<"EOF", <<-EOF, <<-'EOF', <<\EOF, etc.

(command: string)

Source from the content-addressed store, hash-verified

5 * Matches patterns like: <<EOF, <<'EOF', <<"EOF", <<-EOF, <<-'EOF', <<\EOF, etc.
6 */
7function containsHeredoc(command: string): boolean {
8 // Match heredoc patterns: << followed by optional -, then optional quotes or backslash, then word
9 // Matches: <<EOF, <<'EOF', <<"EOF", <<-EOF, <<-'EOF', <<\EOF
10 // Check for bit-shift operators first and exclude them
11 if (
12 /\d\s*<<\s*\d/.test(command) ||
13 /\[\[\s*\d+\s*<<\s*\d+\s*\]\]/.test(command) ||
14 /\$\(\(.*<<.*\)\)/.test(command)
15 ) {
16 return false
17 }
18
19 // Now check for heredoc patterns
20 const heredocRegex = /<<-?\s*(?:(['"]?)(\w+)\1|\\(\w+))/
21 return heredocRegex.test(command)
22}
23
24/**
25 * Detects if a command contains multiline strings in quotes

Callers 2

quoteShellCommandFunction · 0.70
shouldAddStdinRedirectFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected