Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

How to handle lots of quote recursion in an execute string... #21

Open
tobybellwood opened this issue Sep 8, 2021 · 1 comment
Open
Assignees

Comments

@tobybellwood
Copy link

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 😱

@pirog pirog self-assigned this Oct 15, 2021
@pirog
Copy link
Member

pirog commented Oct 15, 2021

@tobybellwood i think we are going to leverage this stringargv module which, if works as advertised should be able to handle this.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants