Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Add support for cli completion in git bash for windows

Aperta Adatta ai principianti
#34,150 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
68/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
bash
Ambito
cli

Direzione di ricerca

Start with the upstream az.completion script referenced in the issue and reproduce completion on Windows 11 using Git Bash and the Windows MSI installation. Compare its behavior with the provided tempfile-aware workaround and the related discussion in Azure CLI #26051. Done means pressing Tab after az offers Azure CLI commands instead of filesystem paths, or the Git Bash limitation and workaround are documented.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

customer-reported

Request

Please make the Azure CLI Bash completion script honor
ARGCOMPLETE_USE_TEMPFILES by using _ARGCOMPLETE_STDOUT_FILENAME and
reading the completion results from that file. This would allow Git Bash on
Windows to use the completion script without users replacing its completion
function in their .bashrc.

Alternatively, document the Git Bash limitation and this workaround.

Reproduction

On Windows 11 with Git Bash and Azure CLI installed via the Windows MSI,
sourcing the upstream az.completion script and setting
ARGCOMPLETE_USE_TEMPFILES=1 is not sufficient: pressing Tab after az
offers filesystem paths instead of CLI commands.

The tempfile-aware function below works in this environment. I tested it with
Azure CLI 2.90.0. It creates _ARGCOMPLETE_STDOUT_FILENAME, reads the
completion results from the temporary file, and cleans it up.

Related discussion: Azure CLI #26051, which describes the Git Bash file
descriptor limitation.

Environment

  • OS: Windows 11
  • Shell: Git Bash (MINGW64)
  • Azure CLI installation: Windows MSI
  • Azure CLI version:
{
  "azure-cli": "2.90.0",
  "azure-cli-core": "2.90.0",
  "azure-cli-telemetry": "1.1.0",
  "extensions": {
    "azure-devops": "1.0.8"
  }
}

Workaround

Using the stock bash completion file
curl -fsSL https://raw.githubusercontent.com/Azure/azure-cli/dev/az.completion -o ~/.azure/.az.completion

The completion in this scenario needs to use temp files and to get this going you need the completion to also be temp-file aware like this:

if [[ -r "$HOME/.azure/.az.completion" ]]; then
  export ARGCOMPLETE_USE_TEMPFILES=1
  source "$HOME/.azure/.az.completion"

  _az_python_argcomplete() {
    local IFS=$'\013'
    local SUPPRESS_SPACE=0
    local TMPFILE
    local STATUS

    if compopt +o nospace 2>/dev/null; then
      SUPPRESS_SPACE=1
    fi

    TMPFILE=$(mktemp) || return 1

    COMPREPLY=($(
      IFS="$IFS" \
        COMP_LINE="$COMP_LINE" \
        COMP_POINT="$COMP_POINT" \
        COMP_TYPE="$COMP_TYPE" \
        _ARGCOMPLETE_COMP_WORDBREAKS="$COMP_WORDBREAKS" \
        _ARGCOMPLETE=1 \
        _ARGCOMPLETE_SUPPRESS_SPACE=$SUPPRESS_SPACE \
        ARGCOMPLETE_USE_TEMPFILES=1 \
        _ARGCOMPLETE_STDOUT_FILENAME="$TMPFILE" \
        "$1" 8>&1 9>&2 1>/dev/null 2>/dev/null
      STATUS=$?
      cat "$TMPFILE"
      rm -f "$TMPFILE"
      exit "$STATUS"
    ))

    STATUS=$?
    if [[ $STATUS != 0 ]]; then
      unset COMPREPLY
    elif [[ $SUPPRESS_SPACE == 1 ]] && [[ "${COMPREPLY[0]}" =~ [=/:]$ ]]; then
      compopt -o nospace
    fi
  }
fi
Lingua principale
Python
Stelle
4.6k
Fork
3.5k
Merge medio
4g 11h
PR unite (30g)
54

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Azure/azure-cli

Tutte le issue di Azure/azure-cli

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.