f17aa2ffa8c12b71518f1b0233edca3a0dd7cade

Author
Maxime Brunet <max@brnt.mx>
Committer
GitHub <noreply@github.com>
Date

Message

fix(terraform): pass `-chdir` to completion commands (#12254)

Diff

This diff is truncated to protect this page.

 1diff --git a/plugins/terraform/_terraform b/plugins/terraform/_terraform
 2index aad1c6096e37690819e3df515a9424c00891c16d..f72f3e552a0e7162d62034598f35297f600616f2 100644
 3--- a/plugins/terraform/_terraform
 4+++ b/plugins/terraform/_terraform
 5@@ -29,7 +29,7 @@ compdef _terraform terraform
 6     'version:Show the current Terraform version'
 7     'workspace:Workspace management'
 8   )
 9-  if ((CURRENT == 1)); then
10+  if (( CURRENT == 1 )); then
11     _describe -t commands 'terraform commands' _terraform_cmds
12     return
13   fi
14@@ -38,6 +38,8 @@ compdef _terraform terraform
15   cmd="${${_terraform_cmds[(r)$words[1]:*]%%:*}}"
16   curcontext="${curcontext%:*:*}:terraform-${cmd}:"
17 
18+  local __chdir="${opt_args[-chdir]:-.}"
19+
20   if (( ${+functions[_terraform_$cmd]} )); then
21     "_terraform_${cmd}"
22   else
23@@ -48,7 +50,7 @@ compdef _terraform terraform
24 (( ${+functions[_terraform_apply]} )) || _terraform_apply() {
25   _arguments \
26     '-auto-approve[Skip interactive approval of plan before applying.]' \
27-    '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -g "*.backup"' \
28+    '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -W __chdir -g "*.backup"' \
29     '-compact-warnings[If Terraform produces any warnings that are not accompanied by errors, show them in a more compact form that includes only the summary messages.]' \
30     '-destroy[Destroy Terraform-managed infrastructure. The command "terraform destroy" is a convenience alias for this option.]' \
31     '-lock=[(true) Don'\''t hold a state lock during the operation. This is dangerous if others might concurrently run commands against the same workspace.]:lock:(true false)' \
32@@ -58,12 +60,12 @@ compdef _terraform terraform
33     '-parallelism=[(10) Limit the number of parallel resource operations.]' \