Use -E instead of -P for OSX compatibility

pull/1185/head
Ahmed Kamal 2018-04-25 22:18:59 +02:00 committed by GitHub
parent c053c65a9f
commit 209a55ab9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -28,21 +28,21 @@ _terraform()
if [[ ${cword} -eq 1 ]] ; then if [[ ${cword} -eq 1 ]] ; then
# Options that do not start with a hyphen, are always starting with four spaces. # Options that do not start with a hyphen, are always starting with four spaces.
opts="$(terraform --help | grep -P '^\s\s\s\s\S' | awk '{print $1}')" opts="$(terraform --help | grep -E '^\s\s\s\s\S' | awk '{print $1}')"
opts="${opts} --help --version" opts="${opts} --help --version"
elif [[ ${cword} -gt 1 ]] ; then elif [[ ${cword} -gt 1 ]] ; then
if [[ ${cword} -eq 2 && ${prev} == '--help' ]] ; then if [[ ${cword} -eq 2 && ${prev} == '--help' ]] ; then
opts="$(terraform --help | grep -P '^\s\s\s\s\S' | awk '{print $1}')" opts="$(terraform --help | grep -E '^\s\s\s\s\S' | awk '{print $1}')"
elif [[ ${words[1]} != "--help" && ${words[1]} != "--version" && ${words[1]} != "version" ]] ; then elif [[ ${words[1]} != "--help" && ${words[1]} != "--version" && ${words[1]} != "version" ]] ; then
# Some commands accept hyphened parameters, ... # Some commands accept hyphened parameters, ...
opts="$(terraform --help "${words[1]}" | grep -P '^\s+-' | awk '{print $1}' | awk -F '=' '{ if ($0 ~ /=/) {print $1"="} else {print $1} }')" opts="$(terraform --help "${words[1]}" | grep -E '^\s+-' | awk '{print $1}' | awk -F '=' '{ if ($0 ~ /=/) {print $1"="} else {print $1} }')"
# but some other commands accept non-hyphened parameters. # but some other commands accept non-hyphened parameters.
opts="${opts} $(terraform --help "${words[1]}" | grep -P '^\s\s\s\s\S' | awk '{print $1}')" opts="${opts} $(terraform --help "${words[1]}" | grep -E '^\s\s\s\s\S' | awk '{print $1}')"
# All of the commands accept the --help parameter which is not listed # All of the commands accept the --help parameter which is not listed
# by the 'terraform --help <command> # by the 'terraform --help <command>
opts="${opts} --help" opts="${opts} --help"