Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[Bug] COMP_WORDS is unquoted in bashcompinit which triggers npm completion bug
- X-seq: zsh-workers 45488
- From: Marc <marc.cornella@xxxxxxxx>
- To: "zsh-workers@xxxxxxx" <zsh-workers@xxxxxxx>
- Subject: [Bug] COMP_WORDS is unquoted in bashcompinit which triggers npm completion bug
- Date: Mon, 24 Feb 2020 18:50:33 +0000
- Accept-language: ca-ES, en-US
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ABfOaIxlRi1iG6N07CJSzKFHgjyaduZZPmN4Ksq/WnA=; b=fLNVF0kTKkk5+rFpeKWsi5bAahN9brFZXCcMk22/5bIpL+9f+FbBsi9jGMPYowRSj40mRfodwqlou+OxfqbN54CgFpqgkoCryrmUSbN04OxIXyt+WOsKEFKB3olFAPff0MKLuviiznDcsbbrq3CJ6K9rpBTzVVD4xNexCpdqpMdhOTsiFHzxfg2B1CIn1I2DTLb9RsPMYTrC+Hfo56z82pWw1cU7woVWcTKWP0km12NbYHyCDAd8eJqvyDyzC+nHOsTt97XbjevgxiZqfjkXzottb/Q0mgts+L54jsQTTkeXZ+oIZp+6/pjW/1E9tm2ea8v6QTEK1O+XCXFh4jTXxg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NCZ9ajK0gJXtvwjGDSaC2BPmdat2GqDSGonPdriSMKK807daCzjfWb1i5qvnY+v06bI237n/qKd7zEwMzQCeCb46L5quaSUcDXk5ckhbQsDq6qw68D61bKcs1Pxn0GzhVOKqfFi9IJv7HR/scJNZKgOng6tcjc9G+nobcMqwaZYDeNHyBhLOzsvD2mXpaE0v/SHkO2Q1x6r1SQQZuQno21j6KowZ3T2vFLs/itS6Pat1fhaQeENC839XUXl5MpktL7Iz+WZtFm/iHVpPyYh3kCUwaY372REEzuAjvuqHbIHZF85Xz+etDKtlZahs3sQ4OFh7lWjrChQP16AZmbIfkw==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- Thread-index: AQHV60NLl5IIt2az5EuuBD+nma/NpQ==
- Thread-topic: [Bug] COMP_WORDS is unquoted in bashcompinit which triggers npm completion bug
This is a bug posted on Oh My Zsh, here's the direct link to my findings:
https://github.com/ohmyzsh/ohmyzsh/issues/8665#issuecomment-590482957
In _bash_complete, the COMP_WORDS array is initialized like so
COMP_WORDS=( $words )
The npm completion function, when having called bashcompinit, uses the `COMP_WORDS` array, while
the native zsh one uses the `$words` array. There is a mismatch between both when completing the
`npm run` command:
$ npm run [TAB]
This makes `$words` have 3 elements, the last one being empty string, but the `$COMP_WORDS` array
ends up having just 2 elements `('npm' 'run')`. When the npm completion function makes its call, it only
passes these 2 elements, triggering a TypeError ("Cannot read property length of undefined").
The fix is simple: quote `$words` so that empty strings are preserved:
COMP_WORDS=( "${words[@]}" )
I have made the patch on my system and can confirm that it works.
Cheers,
Marc
PS. Are you aware that the searchable mailing list gives a 500 error?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author