The English word 'and' is not a statement separator
args quoting · case
Affectspowershell 51, pwsh 7, windows
Fails asPARAMETERBINDING
Mechanismprose as argument
Safe fixsemicolon separator
Symptom
Section titled “Symptom”A user (or an agent-generated recovery message) pastes a line like
“remove the variable and set the new one” written as actual commands joined by
the word and — and PowerShell throws a baffling parameter-binding error on
the FIRST command, or silently binds and as an argument.
Remove-Item Env:CODEX_HOME -ErrorAction SilentlyContinue and $env:CODEX_HOME = "C:\new"# 'and' plus everything after it binds into Remove-Item's argument list —# one broken statement, not two commands.PowerShell has -and as a boolean operator inside expressions, but bare and
between commands is just another positional argument. Prose-style command
chaining parses as one statement. Documentation and agent prompts that render
“do X and do Y” as a single line produce copy-paste traps.
Workaround
Section titled “Workaround”- Separate statements with
;(unconditional) or check$?/useiffor conditional chaining (5.1 has no&&). - The referenced fix changed a shipped recovery one-liner from “… and …” to “…; …” exactly because users pasted it verbatim.