leia
leia copied to clipboard
How to handle lots of quote recursion in an execute string...
We're using Leia - because it's awesome - to do some testing, and have hit a stumbling block around nesting ' and "...
If I have the line
docker-compose exec -T php sh -c "sed -i \'1 aremove_filter('template_redirect','redirect_canonical');' /app/web/content/themes/twentytwenty/functions.php"
because I want the second line of my functions.php file to be remove_filter('template_redirect','redirect_canonical');
How could I go about quoting it, so that mocha doesn't freak out...
/home/tobybellwood/sites/wordpress-example/test/docker-compose-wordpress-simple-php-7-4-nginx-mariadb.func.js:225
cli.exec('docker-compose exec -T php sh -c "sed -i '1 aremove_filter('template_redirect','redirect_canonical');' /app/web/content/themes/twentytwenty/functions.php"').then(res => {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
adding a \ before the ' works for mocha but doesn't do anything
cli.exec('docker-compose exec -T php sh -c "sed -i \'1 aremove_filter(\'template_redirect\',\'redirect_canonical\');\' /app/web/content/themes/twentytwenty/functions.php"').then(res => {
If there's no easy fix, I can just find a way that doesn't involve single quotes :scream:
@tobybellwood i think we are going to leverage this stringargv module which, if works as advertised should be able to handle this.