Skip to content

Fix history command error when input starts with dash#78

Merged
swissspidy merged 4 commits intomainfrom
copilot/fix-1570774-85307675-a3581af5-4b01-4bc1-9e7d-38e6e62dd0d1
Jan 22, 2026
Merged

Fix history command error when input starts with dash#78
swissspidy merged 4 commits intomainfrom
copilot/fix-1570774-85307675-a3581af5-4b01-4bc1-9e7d-38e6e62dd0d1

Conversation

Copy link
Contributor

Copilot AI commented Nov 3, 2025

Bash's history -s command interprets strings starting with - as options rather than arguments, causing errors when users enter expressions like -1 or --help in the shell REPL.

Changes

  • src/WP_CLI/Shell/REPL.php: Added -- separator to history -s command to mark end of options
  • features/shell.feature: Added test case for dash-prefixed input

Technical Details

# Before (line 140)
'history -s "$LINE"; '

# After
'history -s -- "$LINE"; '

The -- separator is the POSIX standard way to prevent option parsing of arguments.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/Behat/Behat/zipball/1b6b08efa995fe4135901b862d112adc7e95ecbb
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Tqooe8 /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/Behat/Gherkin/zipball/34c9b59c59355a7b4c53b9f041c8dbd1c8acc3b4
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Tqooe8 /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/PHPCSStandards/PHPCSExtra/zipball/8e89a01c7b8fed84a12a2a7f5a23a44cdbe4f62e
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Tqooe8 /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/8b8e17615d04f2fc2cd46fc1d2fd888fa21b3cf9
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Tqooe8 /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/ad545ea9c1b7d270ce0fc9cbfb884161cd706119
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Tqooe8 /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/e9cf5e4bbf7eeaf9ef5db34938942602838fc2b1
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Tqooe8 /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/ff4efdd80e094a81fd6329b570c9a632f21d42b4
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Tqooe8 /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/d2421de7cec3274ae622c22c744de9a62c7925af
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Tqooe8 /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/Yoast/PHPUnit-Polyfills/zipball/134921bfca9b02d8f374c48381451da1d98402f9
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Tqooe8 /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/composer/pcre/zipball/b2bed4734f0cc156ee1fe9c0da2550420d99a21e
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Tqooe8 /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/composer/semver/zipball/198166618906cb2de69b95d7d47e5fa8aa1b2b95
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Tqooe8 /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/composer/xdebug-handler/zipball/6c1925561632e83d60a44492e0b344cf48ab85ef
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/myclabs/DeepCopy/zipball/07d290f0c47959fd5eed98c95ee5602db07e0b6a
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/nikic/PHP-Parser/zipball/3a454ca033b9e06b63282ce19562e892747449bb
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/phar-io/manifest/zipball/54750ef60c58e43759730615a392c31c80e23176
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Tqooe8 /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Tqooe8 /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/php-fig/log/zipball/f16e1d5863e37f8d8c2a01719f5b34baa2b714d3
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Tqooe8 /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/php-parallel-lint/PHP-Console-Color/zipball/7adfefd530aa2d7570ba87100a99e2483a543b88
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/php-parallel-lint/PHP-Console-Highlighter/zipball/5b4803384d3303cf8e84141039ef56c8a123138d
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Tqooe8 /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/php-parallel-lint/PHP-Parallel-Lint/zipball/6db563514f27e19595a19f45a4bf757b6401194e
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Tqooe8 /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/abeb5a8b58fda7ac21f15ee596f302f2959a7114
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/phpstan/extension-installer/zipball/85e90b3942d06b2326fba0403ec24fe912372936
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Tqooe8 /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/f94d246cc143ec5a23da868f8f7e1393b50eaa82
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Tqooe8 /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/72a6721c9b64b3e4c9db55abbc38f790b318267e
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/b564ca479e7e735f750aaac4935af965572a7845
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/phpstan/phpstan/zipball/2770dcdf5078d0b0d53f94317e06affe88419aa8
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Tqooe8 /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/90f41072d220e5c40df6e8635f5dafba2d9d4d04
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/comparator/zipball/dc904b4bb3ab070865fa4068cd84f3da8b945148
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/complexity/zipball/bad4316aba5303d0221f43f8cee37eb58d384bbb
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/diff/zipball/7ab1ea946c012266ca32390913653d844ecd085f
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/environment/zipball/24a711b5c916efc6d6e62aa65aa2ec98fef77f68
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/exporter/zipball/016951ae10980765e4e7aee491eb288c64e505b7
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/global-state/zipball/ef1377171613d09edd25b7816f05be8313f9115d
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/97ffee3bcfb5805568d6af7f0f893678fc076d2f
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/1effe8e9b8e068e9ae228e542d5d11b5d16db894
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/4bfa827c969c98be1e527abd576533293c634f6a
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/67e8aed88f93d0e6e1cb7effe1a2dfc2fee6022c
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/961bc913d42fe24a257bfff826a5068079ac7782
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/12b54e689b07a25a9b41e57736dfab6ec9ae5406
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/e1367a453f0eda562eedb4f659e13aa900d66c53
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/php-timer/zipball/f258ce36aa457f3aa3339f9ed4c81fc66dc8c2cc
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a94ea4d26d865875803b23aaf78c3c2c670ea2ea
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Tqooe8 /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/0b01998a7d5b1f122911a66bebcb8d46f0c82d8c
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/type/zipball/e549163b9760b8f71f191651d22acf32d56d6d4d
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/version/zipball/3e6ccf7657d4f0a59200564b08cead899313b53c
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/staabm/side-effects-detector/zipball/d8334211a140ce329c13726d4a715adbddd0a163
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/swissspidy/phpstan-no-private/zipball/f7a1890e350c8d8bf26370426a971d7490ae4245
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/config/zipball/8a09223170046d2cfda3d2e11af01df2c641e961
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/console/zipball/cdb80fa5869653c83cfe1a9084a673b6daf57ea7
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Tqooe8 /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/dependency-injection/zipball/82119812ab0bf3425c1234d413efd1b19bb92ae4
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Tqooe8 /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/deprecation-contracts/zipball/63afe740e99a13ba87ec199bb07bbdee937a5b62
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/59eb412e93815df44f05f342958efa9f46b1e586
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Tqooe8 /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/event-dispatcher/zipball/b7dc69e71de420ac04bc9ab830cf3ffebba48191
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Tqooe8 /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/filesystem/zipball/edcbb768a186b5c3f25d0643159a787d3e63b7fd
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/finder/zipball/9f696d2f1e340484b4683f7853b273abff94421f
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Tqooe8 /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/380872130d3a5dd3ace2f4010d95125fde5d5c70
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Tqooe8 /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/3833d7255cc303546435cb650316bff708a1c75c
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Tqooe8 /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/polyfill-mbstring/zipball/6d857f4d76bd4b343eac26d6b539585d2bc56493
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/polyfill-php73/zipball/0f68c03565dcaaf25a890667542e8bd75fe7e5bb
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Tqooe8 /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/service-contracts/zipball/f021b05a130d35510bd6b25fe9053c2a8a15d5d4
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Tqooe8 /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/string/zipball/f96476035142921000338bad71e5247fbc138872
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Tqooe8 /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/translation-contracts/zipball/df210c7a2573f1913b2d17cc95f90f53a73d8f7d
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Tqooe8 /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/translation/zipball/ec25870502d0c7072d086e8ffba1420c85965174
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Tqooe8 /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/var-exporter/zipball/0f020b544a30a7fe8ba972e53ee48a74c0bc87f4
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Tqooe8 /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/yaml/zipball/90208e2fc6f68f613eae7ca25a2458a931b1bacc
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Tqooe8 /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/szepeviktor/phpstan-wordpress/zipball/7f8cfe992faa96b6a33bbd75c7bace98864161e7
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/theseer/tokenizer/zipball/737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/wp-cli/config-command/zipball/994b3dc9e8284fc978366920d5c5ae0dde3a004e
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/wp-cli/core-command/zipball/ac6f8d742808e11e349ce099c7de2fc3c7009b84
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/wp-cli/eval-command/zipball/20ec428a7b9bc604fab0bd33ee8fa20662650455
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/wp-cli/mustache.php/zipball/ca23b97ac35fbe01c160549eb634396183d04a59
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Tqooe8 /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/wp-cli/php-cli-tools/zipball/f12b650d3738e471baed6dd47982d53c5c0ab1c3
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Tqooe8 /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/wp-cli/spyc/zipball/6aa0b4da69ce9e9a2c8402dab8d43cf32c581cc7
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Tqooe8 /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/wp-cli/wp-cli-tests/zipball/75b660dddaa9f512d104d93da4a0a3ede1183a93
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Tqooe8 /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/wp-cli/wp-cli/zipball/03d30d4138d12b4bffd8b507b82e56e129e0523f
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/wp-cli/wp-config-transformer/zipball/b78cab1159b43eb5ee097e2cfafe5eab573d2a8a
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/aMRaK0 /usr/bin/composer install --no-interaction (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>When input prompt starts with '-': /bin/bash: line 1: history: -1: invalid option</issue_title>
<issue_description>## 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 wp-cli/shell-command#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).
</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] When input prompt starts with '-': /bin/bash: line 1: history: -1: invalid option Fix history command error when input starts with dash Nov 3, 2025
Copilot AI requested a review from swissspidy November 3, 2025 14:53
@codecov
Copy link

codecov bot commented Nov 3, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@swissspidy swissspidy marked this pull request as ready for review November 3, 2025 20:35
@swissspidy swissspidy requested a review from a team as a code owner November 3, 2025 20:35
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug where the shell REPL throws an error when users input expressions starting with a dash (e.g., -1, --help). The issue occurred because bash's history -s command interprets strings starting with - as options rather than arguments.

Changes:

  • Added -- separator to history -s command in REPL.php to mark end of options
  • Added test case to verify dash-prefixed input works correctly

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/WP_CLI/Shell/REPL.php Fixed history -s command by adding -- separator to prevent option parsing
features/shell.feature Added test scenario to verify input starting with dash works correctly

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@swissspidy swissspidy merged commit b43370c into main Jan 22, 2026
51 checks passed
@swissspidy swissspidy deleted the copilot/fix-1570774-85307675-a3581af5-4b01-4bc1-9e7d-38e6e62dd0d1 branch January 22, 2026 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants