* Detects if a command contains multiline strings in quotes
(command: string)
| 25 | * Detects if a command contains multiline strings in quotes |
| 26 | */ |
| 27 | function containsMultilineString(command: string): boolean { |
| 28 | // Check for strings with actual newlines in them |
| 29 | // Handle escaped quotes by using a more sophisticated pattern |
| 30 | // Match single quotes: '...\n...' where content can include escaped quotes \' |
| 31 | // Match double quotes: "...\n..." where content can include escaped quotes \" |
| 32 | const singleQuoteMultiline = /'(?:[^'\\]|\\.)*\n(?:[^'\\]|\\.)*'/ |
| 33 | const doubleQuoteMultiline = /"(?:[^"\\]|\\.)*\n(?:[^"\\]|\\.)*"/ |
| 34 | |
| 35 | return ( |
| 36 | singleQuoteMultiline.test(command) || doubleQuoteMultiline.test(command) |
| 37 | ) |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Quotes a shell command appropriately, preserving heredocs and multiline strings |