Install multiple casks with homebrew looping through a defined list










0














I'm trying to create a script to use to get my Mac ready to work with all the tools/app I need.



I created a list of casks I need:



CASKS=(
transmission
vlc
)


I'm trying to loop through the CASKS list (is it a list?) to install casks 1 by 1 seeing what actually is getting installed:



echo "Installing casks"
for i in "$CASKS[@]"; do
echo "Installing "$CASKS[@]
brew cask install $CASKS[@]
done


The script is not working as I want. On the terminal I can read:



Installing transmission vlc


whereas I'd like to see



Installing transmission...
(installation process going on...)

Installing VLC...
(installation process going on...)


Basically the whole process is getting repeated over and over for all the elements in the CASKS list and Homebrew is telling me that casks have been already installed.



How can I fix it?










share|improve this question




























    0














    I'm trying to create a script to use to get my Mac ready to work with all the tools/app I need.



    I created a list of casks I need:



    CASKS=(
    transmission
    vlc
    )


    I'm trying to loop through the CASKS list (is it a list?) to install casks 1 by 1 seeing what actually is getting installed:



    echo "Installing casks"
    for i in "$CASKS[@]"; do
    echo "Installing "$CASKS[@]
    brew cask install $CASKS[@]
    done


    The script is not working as I want. On the terminal I can read:



    Installing transmission vlc


    whereas I'd like to see



    Installing transmission...
    (installation process going on...)

    Installing VLC...
    (installation process going on...)


    Basically the whole process is getting repeated over and over for all the elements in the CASKS list and Homebrew is telling me that casks have been already installed.



    How can I fix it?










    share|improve this question


























      0












      0








      0







      I'm trying to create a script to use to get my Mac ready to work with all the tools/app I need.



      I created a list of casks I need:



      CASKS=(
      transmission
      vlc
      )


      I'm trying to loop through the CASKS list (is it a list?) to install casks 1 by 1 seeing what actually is getting installed:



      echo "Installing casks"
      for i in "$CASKS[@]"; do
      echo "Installing "$CASKS[@]
      brew cask install $CASKS[@]
      done


      The script is not working as I want. On the terminal I can read:



      Installing transmission vlc


      whereas I'd like to see



      Installing transmission...
      (installation process going on...)

      Installing VLC...
      (installation process going on...)


      Basically the whole process is getting repeated over and over for all the elements in the CASKS list and Homebrew is telling me that casks have been already installed.



      How can I fix it?










      share|improve this question















      I'm trying to create a script to use to get my Mac ready to work with all the tools/app I need.



      I created a list of casks I need:



      CASKS=(
      transmission
      vlc
      )


      I'm trying to loop through the CASKS list (is it a list?) to install casks 1 by 1 seeing what actually is getting installed:



      echo "Installing casks"
      for i in "$CASKS[@]"; do
      echo "Installing "$CASKS[@]
      brew cask install $CASKS[@]
      done


      The script is not working as I want. On the terminal I can read:



      Installing transmission vlc


      whereas I'd like to see



      Installing transmission...
      (installation process going on...)

      Installing VLC...
      (installation process going on...)


      Basically the whole process is getting repeated over and over for all the elements in the CASKS list and Homebrew is telling me that casks have been already installed.



      How can I fix it?







      shell terminal sh






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 11 at 13:05

























      asked Nov 11 at 12:57









      teo-gamba

      174




      174






















          2 Answers
          2






          active

          oldest

          votes


















          0














          You need to actually use your loop variable (i) instead of referring to the whole array with $CASKS[@]:



          echo "Installing casks"
          for i in "$CASKS[@]"; do
          echo "Installing $i"
          brew cask install "$i"
          done


          Also note that it's generally a good idea to quote your variable expansions (e.g. "$i"). (This advice does not apply if your CASKS array elements contain multiple words that are meant to be taken as separate arguments to brew cask install; in that case you'd use brew cask install $i without quotes.)






          share|improve this answer




























            0














            The looping way like this:



            ## declare an array variable
            ## can be on the same line or on multi-lines
            declare -a arr=("zsh" "zsh-completions"
            "ffmpeg --with-zimg --with-xz --with-theora --with-tools --with-rubberband --with-fontconfig --with-frei0r --with-game-music-emu --with-libass --with-libcaca --with-libssh --with-libvorbis --with-fdk-aac --with-ffplay --with-freetype --with-libass --with-libquvi --with-opencore-amr --with-openh264 --with-openjpeg --with-theora --with-snappy --with-two-lame --with-wavpack --with-webp --with-xz --with-libvorbis --with-libvpx --with-opus --with-x265"
            "asciidoc"
            )

            ## now loop through the above array with use of the loop-variable `i`
            for i in "$arr[@]"
            do
            echo "Installing $i..."
            brew install $i
            done


            You could do it the easy way and just do this in a script:



            brew install zsh
            brew install zsh-completions
            brew install ffmpeg --with-zimg --with-xz --with-theora --with-tools --with-rubberband --with-fontconfig --with-frei0r --with-game-music-emu --with-libass --with-libcaca --with-libssh --with-libvorbis --with-fdk-aac --with-ffplay --with-freetype --with-libass --with-libquvi --with-opencore-amr --with-openh264 --with-openjpeg --with-theora --with-snappy --with-two-lame --with-wavpack --with-webp --with-xz --with-libvorbis --with-libvpx --with-opus --with-x265
            brew install asciidoc


            Just add a new brew install ... line every time you add somthing so you can repeat it on a new machine...



            I myself have two of these lists. One for the brew installs and one for the brew cask installs and it has served me just fine :-)






            share|improve this answer






















            • Thank you! what does the declare -a stand for?
              – teo-gamba
              Nov 11 at 13:24











            • @teo-gamba It declares arr to be an array, but arr=( ... ) would do the same thing on its own, so it's redundant here.
              – melpomene
              Nov 11 at 13:26










            • what @melpomene says. I like to be explicit though so there 😄
              – Ivonet
              Nov 11 at 13:30











            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53248965%2finstall-multiple-casks-with-homebrew-looping-through-a-defined-list%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            You need to actually use your loop variable (i) instead of referring to the whole array with $CASKS[@]:



            echo "Installing casks"
            for i in "$CASKS[@]"; do
            echo "Installing $i"
            brew cask install "$i"
            done


            Also note that it's generally a good idea to quote your variable expansions (e.g. "$i"). (This advice does not apply if your CASKS array elements contain multiple words that are meant to be taken as separate arguments to brew cask install; in that case you'd use brew cask install $i without quotes.)






            share|improve this answer

























              0














              You need to actually use your loop variable (i) instead of referring to the whole array with $CASKS[@]:



              echo "Installing casks"
              for i in "$CASKS[@]"; do
              echo "Installing $i"
              brew cask install "$i"
              done


              Also note that it's generally a good idea to quote your variable expansions (e.g. "$i"). (This advice does not apply if your CASKS array elements contain multiple words that are meant to be taken as separate arguments to brew cask install; in that case you'd use brew cask install $i without quotes.)






              share|improve this answer























                0












                0








                0






                You need to actually use your loop variable (i) instead of referring to the whole array with $CASKS[@]:



                echo "Installing casks"
                for i in "$CASKS[@]"; do
                echo "Installing $i"
                brew cask install "$i"
                done


                Also note that it's generally a good idea to quote your variable expansions (e.g. "$i"). (This advice does not apply if your CASKS array elements contain multiple words that are meant to be taken as separate arguments to brew cask install; in that case you'd use brew cask install $i without quotes.)






                share|improve this answer












                You need to actually use your loop variable (i) instead of referring to the whole array with $CASKS[@]:



                echo "Installing casks"
                for i in "$CASKS[@]"; do
                echo "Installing $i"
                brew cask install "$i"
                done


                Also note that it's generally a good idea to quote your variable expansions (e.g. "$i"). (This advice does not apply if your CASKS array elements contain multiple words that are meant to be taken as separate arguments to brew cask install; in that case you'd use brew cask install $i without quotes.)







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 11 at 13:16









                melpomene

                58.4k54489




                58.4k54489























                    0














                    The looping way like this:



                    ## declare an array variable
                    ## can be on the same line or on multi-lines
                    declare -a arr=("zsh" "zsh-completions"
                    "ffmpeg --with-zimg --with-xz --with-theora --with-tools --with-rubberband --with-fontconfig --with-frei0r --with-game-music-emu --with-libass --with-libcaca --with-libssh --with-libvorbis --with-fdk-aac --with-ffplay --with-freetype --with-libass --with-libquvi --with-opencore-amr --with-openh264 --with-openjpeg --with-theora --with-snappy --with-two-lame --with-wavpack --with-webp --with-xz --with-libvorbis --with-libvpx --with-opus --with-x265"
                    "asciidoc"
                    )

                    ## now loop through the above array with use of the loop-variable `i`
                    for i in "$arr[@]"
                    do
                    echo "Installing $i..."
                    brew install $i
                    done


                    You could do it the easy way and just do this in a script:



                    brew install zsh
                    brew install zsh-completions
                    brew install ffmpeg --with-zimg --with-xz --with-theora --with-tools --with-rubberband --with-fontconfig --with-frei0r --with-game-music-emu --with-libass --with-libcaca --with-libssh --with-libvorbis --with-fdk-aac --with-ffplay --with-freetype --with-libass --with-libquvi --with-opencore-amr --with-openh264 --with-openjpeg --with-theora --with-snappy --with-two-lame --with-wavpack --with-webp --with-xz --with-libvorbis --with-libvpx --with-opus --with-x265
                    brew install asciidoc


                    Just add a new brew install ... line every time you add somthing so you can repeat it on a new machine...



                    I myself have two of these lists. One for the brew installs and one for the brew cask installs and it has served me just fine :-)






                    share|improve this answer






















                    • Thank you! what does the declare -a stand for?
                      – teo-gamba
                      Nov 11 at 13:24











                    • @teo-gamba It declares arr to be an array, but arr=( ... ) would do the same thing on its own, so it's redundant here.
                      – melpomene
                      Nov 11 at 13:26










                    • what @melpomene says. I like to be explicit though so there 😄
                      – Ivonet
                      Nov 11 at 13:30
















                    0














                    The looping way like this:



                    ## declare an array variable
                    ## can be on the same line or on multi-lines
                    declare -a arr=("zsh" "zsh-completions"
                    "ffmpeg --with-zimg --with-xz --with-theora --with-tools --with-rubberband --with-fontconfig --with-frei0r --with-game-music-emu --with-libass --with-libcaca --with-libssh --with-libvorbis --with-fdk-aac --with-ffplay --with-freetype --with-libass --with-libquvi --with-opencore-amr --with-openh264 --with-openjpeg --with-theora --with-snappy --with-two-lame --with-wavpack --with-webp --with-xz --with-libvorbis --with-libvpx --with-opus --with-x265"
                    "asciidoc"
                    )

                    ## now loop through the above array with use of the loop-variable `i`
                    for i in "$arr[@]"
                    do
                    echo "Installing $i..."
                    brew install $i
                    done


                    You could do it the easy way and just do this in a script:



                    brew install zsh
                    brew install zsh-completions
                    brew install ffmpeg --with-zimg --with-xz --with-theora --with-tools --with-rubberband --with-fontconfig --with-frei0r --with-game-music-emu --with-libass --with-libcaca --with-libssh --with-libvorbis --with-fdk-aac --with-ffplay --with-freetype --with-libass --with-libquvi --with-opencore-amr --with-openh264 --with-openjpeg --with-theora --with-snappy --with-two-lame --with-wavpack --with-webp --with-xz --with-libvorbis --with-libvpx --with-opus --with-x265
                    brew install asciidoc


                    Just add a new brew install ... line every time you add somthing so you can repeat it on a new machine...



                    I myself have two of these lists. One for the brew installs and one for the brew cask installs and it has served me just fine :-)






                    share|improve this answer






















                    • Thank you! what does the declare -a stand for?
                      – teo-gamba
                      Nov 11 at 13:24











                    • @teo-gamba It declares arr to be an array, but arr=( ... ) would do the same thing on its own, so it's redundant here.
                      – melpomene
                      Nov 11 at 13:26










                    • what @melpomene says. I like to be explicit though so there 😄
                      – Ivonet
                      Nov 11 at 13:30














                    0












                    0








                    0






                    The looping way like this:



                    ## declare an array variable
                    ## can be on the same line or on multi-lines
                    declare -a arr=("zsh" "zsh-completions"
                    "ffmpeg --with-zimg --with-xz --with-theora --with-tools --with-rubberband --with-fontconfig --with-frei0r --with-game-music-emu --with-libass --with-libcaca --with-libssh --with-libvorbis --with-fdk-aac --with-ffplay --with-freetype --with-libass --with-libquvi --with-opencore-amr --with-openh264 --with-openjpeg --with-theora --with-snappy --with-two-lame --with-wavpack --with-webp --with-xz --with-libvorbis --with-libvpx --with-opus --with-x265"
                    "asciidoc"
                    )

                    ## now loop through the above array with use of the loop-variable `i`
                    for i in "$arr[@]"
                    do
                    echo "Installing $i..."
                    brew install $i
                    done


                    You could do it the easy way and just do this in a script:



                    brew install zsh
                    brew install zsh-completions
                    brew install ffmpeg --with-zimg --with-xz --with-theora --with-tools --with-rubberband --with-fontconfig --with-frei0r --with-game-music-emu --with-libass --with-libcaca --with-libssh --with-libvorbis --with-fdk-aac --with-ffplay --with-freetype --with-libass --with-libquvi --with-opencore-amr --with-openh264 --with-openjpeg --with-theora --with-snappy --with-two-lame --with-wavpack --with-webp --with-xz --with-libvorbis --with-libvpx --with-opus --with-x265
                    brew install asciidoc


                    Just add a new brew install ... line every time you add somthing so you can repeat it on a new machine...



                    I myself have two of these lists. One for the brew installs and one for the brew cask installs and it has served me just fine :-)






                    share|improve this answer














                    The looping way like this:



                    ## declare an array variable
                    ## can be on the same line or on multi-lines
                    declare -a arr=("zsh" "zsh-completions"
                    "ffmpeg --with-zimg --with-xz --with-theora --with-tools --with-rubberband --with-fontconfig --with-frei0r --with-game-music-emu --with-libass --with-libcaca --with-libssh --with-libvorbis --with-fdk-aac --with-ffplay --with-freetype --with-libass --with-libquvi --with-opencore-amr --with-openh264 --with-openjpeg --with-theora --with-snappy --with-two-lame --with-wavpack --with-webp --with-xz --with-libvorbis --with-libvpx --with-opus --with-x265"
                    "asciidoc"
                    )

                    ## now loop through the above array with use of the loop-variable `i`
                    for i in "$arr[@]"
                    do
                    echo "Installing $i..."
                    brew install $i
                    done


                    You could do it the easy way and just do this in a script:



                    brew install zsh
                    brew install zsh-completions
                    brew install ffmpeg --with-zimg --with-xz --with-theora --with-tools --with-rubberband --with-fontconfig --with-frei0r --with-game-music-emu --with-libass --with-libcaca --with-libssh --with-libvorbis --with-fdk-aac --with-ffplay --with-freetype --with-libass --with-libquvi --with-opencore-amr --with-openh264 --with-openjpeg --with-theora --with-snappy --with-two-lame --with-wavpack --with-webp --with-xz --with-libvorbis --with-libvpx --with-opus --with-x265
                    brew install asciidoc


                    Just add a new brew install ... line every time you add somthing so you can repeat it on a new machine...



                    I myself have two of these lists. One for the brew installs and one for the brew cask installs and it has served me just fine :-)







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Nov 11 at 13:21

























                    answered Nov 11 at 13:16









                    Ivonet

                    1,167518




                    1,167518











                    • Thank you! what does the declare -a stand for?
                      – teo-gamba
                      Nov 11 at 13:24











                    • @teo-gamba It declares arr to be an array, but arr=( ... ) would do the same thing on its own, so it's redundant here.
                      – melpomene
                      Nov 11 at 13:26










                    • what @melpomene says. I like to be explicit though so there 😄
                      – Ivonet
                      Nov 11 at 13:30

















                    • Thank you! what does the declare -a stand for?
                      – teo-gamba
                      Nov 11 at 13:24











                    • @teo-gamba It declares arr to be an array, but arr=( ... ) would do the same thing on its own, so it's redundant here.
                      – melpomene
                      Nov 11 at 13:26










                    • what @melpomene says. I like to be explicit though so there 😄
                      – Ivonet
                      Nov 11 at 13:30
















                    Thank you! what does the declare -a stand for?
                    – teo-gamba
                    Nov 11 at 13:24





                    Thank you! what does the declare -a stand for?
                    – teo-gamba
                    Nov 11 at 13:24













                    @teo-gamba It declares arr to be an array, but arr=( ... ) would do the same thing on its own, so it's redundant here.
                    – melpomene
                    Nov 11 at 13:26




                    @teo-gamba It declares arr to be an array, but arr=( ... ) would do the same thing on its own, so it's redundant here.
                    – melpomene
                    Nov 11 at 13:26












                    what @melpomene says. I like to be explicit though so there 😄
                    – Ivonet
                    Nov 11 at 13:30





                    what @melpomene says. I like to be explicit though so there 😄
                    – Ivonet
                    Nov 11 at 13:30


















                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53248965%2finstall-multiple-casks-with-homebrew-looping-through-a-defined-list%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Darth Vader #20

                    How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

                    Ondo