shell-command icon indicating copy to clipboard operation
shell-command copied to clipboard

Internal variables bleed over and cause conflicts

Open WPprodigy opened this issue 6 years ago • 2 comments

I haven't had the chance to dig into this further, but just wanted to log this somewhere to prevent forgetting about it.

Assigning a value to $line in wp shell gives very unexpected results, causing some pretty confusing behavior and bugs.

Behavior:

wp shell

wp> $line = 'this wont work';
=> string(14) 'this wont work'
wp> $line;
=> string(13) "return $line;"

wp> $linetest = 'this will';
=> string(9) "this will"
wp> $linetest;
=> string(9) "this will"

WPprodigy avatar Oct 07 '19 20:10 WPprodigy

$line is one of the variables that bleed over from the context that evaluates the code that was typed in.

While I don't think we can provide a completely clean context with eval(), we can certainly make sure we're not using something that is as easy to run into conflicts with than $line.

schlessera avatar Oct 08 '19 04:10 schlessera

well it looks like this was 3 years ago This is working perfectly fine in mine.

WP-CLI 2.6.0
>>> $line = 'this wont work';
=> "this wont work"
>>> $line;
=> "this wont work"

deepyes02 avatar Aug 22 '22 10:08 deepyes02