Search code examples
zsh

How can I correct "zsh parse error near do"


I'm relatively new to zsh and scripts in general. I need to write an automated command script in zsh with the following code.

#!/usr/bin/env zsh


for ((i = 0; i < 41; i++));

export K='SOME NUMBER'

do ./A-PROGRAM *SOME FLAGS* $i *MORE FLAGS* $K 1 ;

done;

I get the following error: program.zsh:8: parse error near `do'

How can i correct this? Thanks for the help in advance!


Solution

  • What is the EXPORT doing there between the for () and the do? And do you really need to EXPORT the variable $K. You seem to pass it as parameter to A-PROGRAM anyways?

    #!/usr/bin/env zsh
    
    K='SOME NUMBER'
    for ((i = 0; i < 41; i++)); do
      ./A-PROGRAM *SOME FLAGS* $i *MORE FLAGS* $K 1
    done