Skip to content

Commit

Permalink
Execute compopt only when it's present (#12248)
Browse files Browse the repository at this point in the history
`compopt` has been introduced in bash 4.0, but macOS uses bash 3.2 by default.
  • Loading branch information
potomak authored Jul 15, 2022
1 parent c19df0b commit fd12842
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions etc/completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ _crystal_compgen_options(){
_crystal_compgen_sources(){
local IFS=$'\n'
local pattern=$1
compopt -o filenames
type compopt &> /dev/null && compopt -o filenames
COMPREPLY=( $(compgen -f -o plusdirs -X '!*.cr' -- "${pattern}") )
}

# Return list of files or directories, that match $pattern (the default action)
_crystal_compgen_files(){
local IFS=$'\n'
local pattern=$1
compopt -o filenames
type compopt &> /dev/null && compopt -o filenames
COMPREPLY=( $(compgen -o default -- "${pattern}") )
}

Expand Down

0 comments on commit fd12842

Please sign in to comment.