* Helper function to restore placeholders in a command string.
( command: string, quotes: string[], singleQuotes: string[], redirections: string[], arithmeticExpressions: string[], parameterExpansions: string[], variables: string[], subshells: string[], )
| 730 | * Helper function to restore placeholders in a command string. |
| 731 | */ |
| 732 | function restorePlaceholders( |
| 733 | command: string, |
| 734 | quotes: string[], |
| 735 | singleQuotes: string[], |
| 736 | redirections: string[], |
| 737 | arithmeticExpressions: string[], |
| 738 | parameterExpansions: string[], |
| 739 | variables: string[], |
| 740 | subshells: string[], |
| 741 | ): string { |
| 742 | let result = command |
| 743 | // Restore double-quoted strings |
| 744 | result = result.replace(/__QUOTE_(\d+)__/g, (_, i) => quotes[parseInt(i)]) |
| 745 | // Restore single-quoted strings |
| 746 | result = result.replace(/__SQUOTE_(\d+)__/g, (_, i) => singleQuotes[parseInt(i)]) |
| 747 | // Restore redirections |
| 748 | result = result.replace(/__REDIR_(\d+)__/g, (_, i) => redirections[parseInt(i)]) |
| 749 | // Restore arithmetic expressions |
| 750 | result = result.replace(/__ARITH_(\d+)__/g, (_, i) => arithmeticExpressions[parseInt(i)]) |
| 751 | // Restore parameter expansions |
| 752 | result = result.replace(/__PARAM_(\d+)__/g, (_, i) => parameterExpansions[parseInt(i)]) |
| 753 | // Restore variable references |
| 754 | result = result.replace(/__VAR_(\d+)__/g, (_, i) => variables[parseInt(i)]) |
| 755 | result = result.replace(/__SUBSH_(\d+)__/g, (_, i) => subshells[parseInt(i)]) |
| 756 | return result |
| 757 | } |
no test coverage detected