Skip to content

When input prompt starts with '-': /bin/bash: line 1: history: -1: invalid option #75

@gedex

Description

@gedex

Bug Report

Describe the current, buggy behavior

Type something that starts with -, i.e. -1:

wp> -1
/bin/bash: line 1: history: -1: invalid option
history: usage: history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg...]
=> int(-1)

Describe how other contributors can replicate this bug

$ wp shell
wp> -1
/bin/bash: line 1: history: -1: invalid option
history: usage: history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg...]
=> int(-1)

Describe what you would expect as the correct outcome

If it's negative number in PHP, it should evaluate to negative number:

wp> -1
=> int(-1)

Let us know what environment you are running this on

OS:	Linux 5.10.0-31-amd64 #1 SMP Debian 5.10.221-1 (2024-07-14) x86_64
Shell:	/bin/bash
PHP binary:	/usr/local/php8.3/bin/php
PHP version:	8.3.24
php.ini used:	/usr/local/php8.3/conf/php.ini
MySQL binary:	/usr/bin/mariadb
MySQL version:	mariadb  Ver 15.1 Distrib 10.5.29-MariaDB, for debian-linux-gnu (x86_64) using  EditLine wrapper
SQL modes:	ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
WP-CLI root dir:	phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:	phar://wp-cli.phar/vendor
WP_CLI phar path:	phar:///usr/local/bin/wp
WP-CLI packages dir:
WP-CLI cache dir:	/root/.wp-cli/cache
WP-CLI global config:	/chroot/var/www/config/wp-cli.yml
WP-CLI project config:
WP-CLI version:	2.12.0

Provide a possible solution

Likely the input prompt in https://github.com/wp-cli/shell-command/blob/main/src/WP_CLI/Shell/REPL.php#L135-L144 need to be escaped?

Just leave this section out if you don't know how to fix it.

Provide additional context/Screenshots

Add any other context about the problem here.

If applicable, add screenshots to help explain (you can just drag&drop images into the Github issue).

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions