[scl.org] scl wrapper mishandles quotes in command parameters?
Pavel Valena
pvalena at redhat.com
Tue Dec 8 22:56:58 UTC 2020
----- Original Message -----
> From: "John Beranek" <John.Beranek at pamediagroup.com>
> To: sclorg at redhat.com
> Sent: Tuesday, December 8, 2020 6:59:17 PM
> Subject: [scl.org] scl wrapper mishandles quotes in command parameters?
>
> So, just discovered what looks like a bug in the 'scl' wrapper with handling
> double-quote (at least) characters in command parameters. This is with:
>
> scl-utils-20130529-19.el7.x86_64
>
> Given the test scripts:
>
> ===============test.pl======================
> #!/usr/bin/perl
>
> print "SCL wrapper\n===============\n";
>
> system(
> 'scl',
> 'enable',
> 'rh-php72',
> '--',
> 'php',
> 'test.php',
> '"hello world"'
> );
>
> system(
> 'scl',
> 'enable',
> 'rh-php72',
> '--',
> 'php',
> 'test.php',
> 'another"test'
> );
>
> print "\nWithout wrapper\n===============\n";
>
> system(
> '/opt/rh/rh-php72/root/bin/php',
> 'test.php',
> '"hello world"'
> );
>
> system(
> '/opt/rh/rh-php72/root/bin/php',
> 'test.php',
> 'another"test'
> );
> ===================================================
Hello John,
although I don't have solution for you, I think the `scl enable XXX --` syntax is more aimed at shell usage. If you run it in shell, instead of using `system()`, will it help?
I think I've also seen this worked around somewhere by nesting the command in a shell:
```
$ scl enable -- sh -c "...."
```
AFAIK the scl-utils are quite outdated, and there's no suitable successor.
>
> ==============test.php==============================
> <?php
> print("\$argv:\n");
> print_r($argv);
> ?>
> ===================================================
>
> This is the rather unexpected output:
>
> ===================================================
> $ ./test.pl
> SCL wrapper
> ===============
> $argv:
> Array
> (
> [0] => test.php
> [1] => hello
> [2] => world
> )
> /var/tmp/sclbhWRnY: line 8: unexpected EOF while looking for matching `"'
> /var/tmp/sclbhWRnY: line 9: syntax error: unexpected end of file
>
> Without wrapper
> ===============
> $argv:
> Array
> (
> [0] => test.php
> [1] => "hello world"
> )
> $argv:
> Array
> (
> [0] => test.php
> [1] => another"test
> )
> =====================================================
>
> All the above available in a gist, in case it's hard to read from the list
> post:
> https://gist.github.com/pa-jberanek/8942f39573edf6044e42bf8724d657a5
>
> Cheers,
>
> John
>
> --
> John Beranek
>
> This email is from the PA Media Group. For more information, see
> www.pamediagroup.com. This email may contain confidential information. Only
> the addressee is permitted to read, copy, distribute or otherwise use this
> email or any attachments. If you have received it in error, please contact
> the sender immediately. Any opinion expressed in this email is personal to
> the sender and may not reflect the opinion of the PA Media Group. Any email
> reply to this address may be subject to interception or monitoring for
> operational reasons or for lawful business practices.
>
>
Regards,
--
Pavel Valena
Software Engineer, Red Hat
Brno, Czech Republic
More information about the SCLorg
mailing list