* Detects if a command contains a heredoc pattern * Matches patterns like: <<EOF, <<'EOF', <<"EOF", <<-EOF, <<-'EOF', <<\EOF, etc.
(command: string)
| 5 | * Matches patterns like: <<EOF, <<'EOF', <<"EOF", <<-EOF, <<-'EOF', <<\EOF, etc. |
| 6 | */ |
| 7 | function 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 |
no outgoing calls
no test coverage detected