git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Error in bash completion

From
HMHarrison McCullough <mccullough.harrison@gmail.com>
Date
Jun 16, 2021, 15:44 UTC
Message-ID
<CAHLeu+y3DxLv7M4SM2f5yVxtKXbpAWD7Ad2m+rVKpKfKiA6PVw@mail.gmail.com>
What did you do before the bug happened? (Steps to reproduce your issue)
1. Create a Bash function, e.g. `ga() { git add "${@:-.}"; }`
2. Use the `__git_complete` function to add Bash tab completion for your custom
   Bash function, e.g. `__git_complete ga git_add`
3. Attempt to tab complete a file path, e.g. `ga my-incomplete-file-path<TAB>`
What did you expect to happen? (Expected behavior)
Bash tab-completes the file path.
What happened instead? (Actual behavior)
Bash tab-completes the file path but also displays an error:

$ ga fi-bash: [: -lt: unary operator expected le3.txt

(This is when I was using tab completion to add a file called `file3.txt`).
What's different between what you expected and what actually happened?
I do not expect using tab completion to display an error.
Anything else you want to add:

I have tested this with a minial setup with Bash version 5.1.8(1)-release with no other files sourced at startup except /usr/local/Cellar/git/2.32.0/etc/bash_completion.d/git-completion.bash

[System Info] git version: git version 2.32.0 cpu: x86_64 no commit associated with this build sizeof-long: 8 sizeof-size_t: 8 shell-path: /bin/sh uname: Darwin 20.5.0 Darwin Kernel Version 20.5.0: Sat May 8 05:10:33 PDT 2021; root:xnu-7195.121.3~9/RELEASE_X86_64 x86_64 compiler info: clang: 12.0.5 (clang-1205.0.22.9) libc info: no libc information available $SHELL (typically, interactive shell): /usr/local/bin/bash

[Enabled Hooks]
-Harrison McCullough
Next: Denton Liu
Message 1 of 6 in “Error in bash completion”
  1. Harrison McCulloughJun 16, 2021
  2. Denton LiuJun 16, 2021
  3. Harrison McCulloughJun 16, 2021
  4. Felipe ContrerasJun 16, 2021
  5. Felipe ContrerasJun 17, 2021
  6. Harrison McCulloughJun 17, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.