semgrep icon indicating copy to clipboard operation
semgrep copied to clipboard

semgrep bash_completion has no nosort option, MacOS, bash shell only.

Open teochenglim opened this issue 1 month ago • 2 comments

Describe the bug A clear and concise description of what the bug is.

/opt/homebrew/etc/bash_completion.d/semgrep: line 25: complete: nosort: invalid option name

To Reproduce Steps to reproduce the behavior, ideally a link to https://semgrep.dev/playground (click "share" and make public to get a shortlink):

Each time do homebrew package update has this problem, this is part of bash_completion

Expected behavior A clear and concise description of what you expected to happen.

Since nosort is not compatible on Macbook, please remove it.

Screenshots If applicable, add screenshots to help explain your problem.

Image

What is the priority of the bug to you?

  • [ ] P0: blocking your adoption of Semgrep or workflow
  • [x] P1: important to fix or quite annoying
  • [ ] P2: regular bug that should get fixed

each time called bash completion semgrep throw error.

Environment If not using semgrep.dev: are you running off docker, an official binary, a local build?

Homebrew

Use case What will fixing this bug enable for you?

complete has no nosort option on MBP (MacBook Pro). has a OS MBP detected and alternative _semgrep_completion_setup based on OS type

chenglim.teo@Mac:~$ cat /opt/homebrew/etc/bash_completion.d/semgrep
_semgrep_completion() {
    local IFS=$'\n'
    local response

    response=$(env COMP_WORDS="${COMP_WORDS[*]}" COMP_CWORD=$COMP_CWORD _SEMGREP_COMPLETE=bash_complete $1)

    for completion in $response; do
        IFS=',' read type value <<< "$completion"

        if [[ $type == 'dir' ]]; then
            COMPREPLY=()
            compopt -o dirnames
        elif [[ $type == 'file' ]]; then
            COMPREPLY=()
            compopt -o default
        elif [[ $type == 'plain' ]]; then
            COMPREPLY+=($value)
        fi
    done

    return 0
}

_semgrep_completion_setup() {
    complete -F _semgrep_completion semgrep
}

_semgrep_completion_setup;

teochenglim avatar Nov 22 '25 23:11 teochenglim

it is annoying the bug keep coming back with brew auto upgrade.

teochenglim avatar Nov 22 '25 23:11 teochenglim

Seems similar to #10618. Likely requires a PR to homebrew to address

nmote avatar Dec 02 '25 18:12 nmote