Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bash syntax errors reported when loading cargo shell completions #6874

Closed
jimmycuadra opened this issue Apr 24, 2019 · 2 comments · Fixed by rust-lang/rust#60596
Closed

Bash syntax errors reported when loading cargo shell completions #6874

jimmycuadra opened this issue Apr 24, 2019 · 2 comments · Fixed by rust-lang/rust#60596
Labels
A-completions Area: shell completions C-bug Category: bug

Comments

@jimmycuadra
Copy link
Contributor

This is a re-report of rust-lang/rustup#1799, per the comment it received.


Problem

The cargo command completion shell script produces syntax errors when loaded:

-bash: /redacted/.rustup/toolchains/stable-x86_64-apple-darwin/etc/bash_completion.d/cargo: line 82: syntax error in conditional expression: unexpected token `('
-bash: /redacted/.rustup/toolchains/stable-x86_64-apple-darwin/etc/bash_completion.d/cargo: line 82: syntax error near `@(t'
-bash: /redacted/.rustup/toolchains/stable-x86_64-apple-darwin/etc/bash_completion.d/cargo: line 82: `		if [[ "${cmd}" = @(test|bench) ]]; then'

Steps

  1. Install latest rustup. I'm using rustup 1.18.0 (8603e2c56 2019-04-22).
  2. Run source $(rustc --print sysroot)/etc/bash_completion.d/cargo in a shell.
  3. Observe output.

Possible Solution(s)

Notes

Output of bash --version:
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin18)
Copyright (C) 2007 Free Software Foundation, Inc.

Output of rustup --version: rustup 1.18.0 (8603e2c56 2019-04-22)
Output of cargo --version: cargo 1.34.0 (6789d8a 2019-04-01)

@jimmycuadra jimmycuadra added the C-bug Category: bug label Apr 24, 2019
@ArifRoktim
Copy link

ArifRoktim commented Apr 24, 2019

The @(pattern-list) syntax was introduced in bash 4.0 4.1*. Is it feasible for you to update your version of bash?

The feature was actually introduced in bash 2.02, controlled by the extglob option, but enabled by default starting with version 4.1. So you can either upgrade bash to be version 4.1 or greater, or manually enable the extglob option in your .bashrc.

Source: http://tiswww.case.edu/php/chet/bash/NEWS

@jimmycuadra
Copy link
Contributor Author

I'm apparently using the version that comes installed on the latest macOS. I could have sworn I used to have a more recent version installed via Homebrew...

In any case, I can fix upgrade/enable the option, but if this script will fail in the same way for everyone else on stock macOS, that doesn't seem acceptable.

@ehuss ehuss added the A-completions Area: shell completions label Apr 25, 2019
@ArifRoktim ArifRoktim mentioned this issue May 4, 2019
bors added a commit that referenced this issue May 5, 2019
Fixes #6874

Bash completion for cargo on the latest version of stock macOS produced syntax errors. More info in #6874 . This PR should fix that, but as I don't have any apple devices, I can't test it.

Pinging @jimmycuadra or anyone who runs macOS: If you have the time, could you please check if applying the commit in this PR fixes the syntax error when running the stock bash that comes with macOS?
Quick one-liner to apply the commit would be:
```bash
patch -d "$(rustc --print sysroot)/etc/bash_completion.d/" cargo <(curl https://github.com/rust-lang/cargo/commit/e2c519dd7ac61e4d2f94cad60ef920ce4aa1718f.patch)
```

Once this PR is confirmed to work, it can marked as ready.
@bors bors closed this as completed in e2c519d May 5, 2019
bors added a commit to rust-lang/rust that referenced this issue May 7, 2019
Update cargo

12 commits in beb8fcb5248dc2e6aa488af9613216d5ccb31c6a..759b6161a328db1d4863139e90875308ecd25a75
2019-04-30 23:58:00 +0000 to 2019-05-06 20:47:49 +0000
- Small things (rust-lang/cargo#6910)
- Fix skipping over invalid registry packages (rust-lang/cargo#6912)
- Fixes rust-lang/cargo#6874 (rust-lang/cargo#6905)
- doc: Format examples of version to ease reading (rust-lang/cargo#6907)
- fix more typos (codespell) (rust-lang/cargo#6903)
- Parse less JSON on null builds (rust-lang/cargo#6880)
- chore: Update opener to 0.4 (rust-lang/cargo#6902)
- Update documentation for auto-discovery. (rust-lang/cargo#6898)
- Update some doc links. (rust-lang/cargo#6897)
- Default Cargo.toml template provide help for completing the metadata (rust-lang/cargo#6881)
- Run 'cargo fmt --all' (rust-lang/cargo#6896)
- Refactor command definition (rust-lang/cargo#6894)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-completions Area: shell completions C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants