Skip to content

Commit 64e4afd

Browse files
committed
fix quoting when checking choices
1 parent d83ed67 commit 64e4afd

1 file changed

Lines changed: 5 additions & 9 deletions

File tree

src/main/scala/io/viash/wrapper/BashWrapper.scala

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -665,41 +665,37 @@ object BashWrapper {
665665

666666
param match {
667667
case _ if param.multiple && param.direction == Input =>
668-
s"""if [ ! -z "$$${param.VIASH_PAR}" ]; then
668+
s"""if [ $${#${param.VIASH_PAR}[@]} -gt 0 ]; then
669669
| ${param.VIASH_PAR}_CHOICES=($allowedChoicesString)
670-
| set -f
671-
| for val in $${${param.VIASH_PAR}}[@]}; do
670+
| for val in "$${${param.VIASH_PAR}[@]}"; do
672671
| found=0
673-
| for choice in $${${param.VIASH_PAR}_CHOICES[@]}; do
672+
| for choice in "$${${param.VIASH_PAR}_CHOICES[@]}"; do
674673
| if [ "$$val" == "$$choice" ]; then
675674
| found=1
676675
| break
677676
| fi
678677
| done
679678
| if [ $$found -eq 0 ]; then
680-
| ViashError '${param.name}' specified value of \\'$${val}\\' is not in the list of allowed values. Use "--help" to get more information on the parameters.
679+
| ViashError '${param.name}' specified value of \\'$$val\\' is not in the list of allowed values. Use "--help" to get more information on the parameters.
681680
| exit 1
682681
| fi
683682
| done
684-
| set +f
685683
|fi
686684
|""".stripMargin
687685
case _ =>
688686
s"""if [ ! -z "$$${param.VIASH_PAR}" ]; then
689687
| ${param.VIASH_PAR}_CHOICES=($allowedChoicesString)
690688
| found=0
691-
| for choice in $${${param.VIASH_PAR}_CHOICES[@]}; do
689+
| for choice in "$${${param.VIASH_PAR}_CHOICES[@]}"; do
692690
| if [ "$$${param.VIASH_PAR}" == "$$choice" ]; then
693691
| found=1
694692
| break
695693
| fi
696694
| done
697-
| set -f
698695
| if [ $$found -eq 0 ]; then
699696
| ViashError '${param.name}' specified value of \\'$$${param.VIASH_PAR}\\' is not in the list of allowed values. Use "--help" to get more information on the parameters.
700697
| exit 1
701698
| fi
702-
| set +f
703699
|fi
704700
|""".stripMargin
705701
}

0 commit comments

Comments
 (0)