shell script - don't add quotes

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I have created an npm script to run a single jest test file. To run the file I would type:



> npm start test:1 **/unit-test-filename.test.js


I want to make that even easier and type something like:



> jt unit-test-filename


So I've tried creating a bash script that looks like this:



#!/bin/bash -x
npm run test:1 **/$1.test.js


Unfortunately when I try running it it puts a single quote around last parameter and it make it so that npm script can't find the file. I get an output like this:



╰─± jt unit-test-filename 
+ npm run test:1 '**/unit-test-filename.test.js'

> cms2@0.1.2 test:1 /Users/path/to/my/current/dir
> cross-env NODE_ENV=dev node ./etc/jest1 "**/unit-test-filename.test.js"

Error!! Test file: **/unit-test-filename.test.js doesn't exist.


I've tried escaping the asterisk and tried a number of other things. Is this even possible with bash scripting?







share|improve this question
























    up vote
    1
    down vote

    favorite












    I have created an npm script to run a single jest test file. To run the file I would type:



    > npm start test:1 **/unit-test-filename.test.js


    I want to make that even easier and type something like:



    > jt unit-test-filename


    So I've tried creating a bash script that looks like this:



    #!/bin/bash -x
    npm run test:1 **/$1.test.js


    Unfortunately when I try running it it puts a single quote around last parameter and it make it so that npm script can't find the file. I get an output like this:



    ╰─± jt unit-test-filename 
    + npm run test:1 '**/unit-test-filename.test.js'

    > cms2@0.1.2 test:1 /Users/path/to/my/current/dir
    > cross-env NODE_ENV=dev node ./etc/jest1 "**/unit-test-filename.test.js"

    Error!! Test file: **/unit-test-filename.test.js doesn't exist.


    I've tried escaping the asterisk and tried a number of other things. Is this even possible with bash scripting?







    share|improve this question






















      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I have created an npm script to run a single jest test file. To run the file I would type:



      > npm start test:1 **/unit-test-filename.test.js


      I want to make that even easier and type something like:



      > jt unit-test-filename


      So I've tried creating a bash script that looks like this:



      #!/bin/bash -x
      npm run test:1 **/$1.test.js


      Unfortunately when I try running it it puts a single quote around last parameter and it make it so that npm script can't find the file. I get an output like this:



      ╰─± jt unit-test-filename 
      + npm run test:1 '**/unit-test-filename.test.js'

      > cms2@0.1.2 test:1 /Users/path/to/my/current/dir
      > cross-env NODE_ENV=dev node ./etc/jest1 "**/unit-test-filename.test.js"

      Error!! Test file: **/unit-test-filename.test.js doesn't exist.


      I've tried escaping the asterisk and tried a number of other things. Is this even possible with bash scripting?







      share|improve this question












      I have created an npm script to run a single jest test file. To run the file I would type:



      > npm start test:1 **/unit-test-filename.test.js


      I want to make that even easier and type something like:



      > jt unit-test-filename


      So I've tried creating a bash script that looks like this:



      #!/bin/bash -x
      npm run test:1 **/$1.test.js


      Unfortunately when I try running it it puts a single quote around last parameter and it make it so that npm script can't find the file. I get an output like this:



      ╰─± jt unit-test-filename 
      + npm run test:1 '**/unit-test-filename.test.js'

      > cms2@0.1.2 test:1 /Users/path/to/my/current/dir
      > cross-env NODE_ENV=dev node ./etc/jest1 "**/unit-test-filename.test.js"

      Error!! Test file: **/unit-test-filename.test.js doesn't exist.


      I've tried escaping the asterisk and tried a number of other things. Is this even possible with bash scripting?









      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 14 at 16:47









      Dustin

      1184




      1184




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          5
          down vote



          accepted










          You probably don't have globstar set in a shell script.



          You can enable it with shopt -s globstar.



          #!/bin/bash
          set -x
          shopt -s globstar
          npm run test:1 **/"$1".test.js





          share|improve this answer




















          • Thank you! It is working now and I realized it was zsh that was making it work in my npm script so I had to change it to #!/bin/zsh to get it to work
            – Dustin
            Mar 14 at 17:03










          • I guess I don't need the shopt -s globstar command either since it doesn't work in zsh. I was told that this doesn't work for mac users since mac has bash 3 and bash 4 is required.
            – Dustin
            Mar 14 at 17:32










          • Yes, it's bash specific. You can write */*/* but that will only work for a specific directory depth. For arbitrary depths, there is find.
            – frostschutz
            Mar 14 at 17:51










          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          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',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );








           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f430223%2fshell-script-dont-add-quotes%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          5
          down vote



          accepted










          You probably don't have globstar set in a shell script.



          You can enable it with shopt -s globstar.



          #!/bin/bash
          set -x
          shopt -s globstar
          npm run test:1 **/"$1".test.js





          share|improve this answer




















          • Thank you! It is working now and I realized it was zsh that was making it work in my npm script so I had to change it to #!/bin/zsh to get it to work
            – Dustin
            Mar 14 at 17:03










          • I guess I don't need the shopt -s globstar command either since it doesn't work in zsh. I was told that this doesn't work for mac users since mac has bash 3 and bash 4 is required.
            – Dustin
            Mar 14 at 17:32










          • Yes, it's bash specific. You can write */*/* but that will only work for a specific directory depth. For arbitrary depths, there is find.
            – frostschutz
            Mar 14 at 17:51














          up vote
          5
          down vote



          accepted










          You probably don't have globstar set in a shell script.



          You can enable it with shopt -s globstar.



          #!/bin/bash
          set -x
          shopt -s globstar
          npm run test:1 **/"$1".test.js





          share|improve this answer




















          • Thank you! It is working now and I realized it was zsh that was making it work in my npm script so I had to change it to #!/bin/zsh to get it to work
            – Dustin
            Mar 14 at 17:03










          • I guess I don't need the shopt -s globstar command either since it doesn't work in zsh. I was told that this doesn't work for mac users since mac has bash 3 and bash 4 is required.
            – Dustin
            Mar 14 at 17:32










          • Yes, it's bash specific. You can write */*/* but that will only work for a specific directory depth. For arbitrary depths, there is find.
            – frostschutz
            Mar 14 at 17:51












          up vote
          5
          down vote



          accepted







          up vote
          5
          down vote



          accepted






          You probably don't have globstar set in a shell script.



          You can enable it with shopt -s globstar.



          #!/bin/bash
          set -x
          shopt -s globstar
          npm run test:1 **/"$1".test.js





          share|improve this answer












          You probably don't have globstar set in a shell script.



          You can enable it with shopt -s globstar.



          #!/bin/bash
          set -x
          shopt -s globstar
          npm run test:1 **/"$1".test.js






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 14 at 16:52









          frostschutz

          24.5k14774




          24.5k14774











          • Thank you! It is working now and I realized it was zsh that was making it work in my npm script so I had to change it to #!/bin/zsh to get it to work
            – Dustin
            Mar 14 at 17:03










          • I guess I don't need the shopt -s globstar command either since it doesn't work in zsh. I was told that this doesn't work for mac users since mac has bash 3 and bash 4 is required.
            – Dustin
            Mar 14 at 17:32










          • Yes, it's bash specific. You can write */*/* but that will only work for a specific directory depth. For arbitrary depths, there is find.
            – frostschutz
            Mar 14 at 17:51
















          • Thank you! It is working now and I realized it was zsh that was making it work in my npm script so I had to change it to #!/bin/zsh to get it to work
            – Dustin
            Mar 14 at 17:03










          • I guess I don't need the shopt -s globstar command either since it doesn't work in zsh. I was told that this doesn't work for mac users since mac has bash 3 and bash 4 is required.
            – Dustin
            Mar 14 at 17:32










          • Yes, it's bash specific. You can write */*/* but that will only work for a specific directory depth. For arbitrary depths, there is find.
            – frostschutz
            Mar 14 at 17:51















          Thank you! It is working now and I realized it was zsh that was making it work in my npm script so I had to change it to #!/bin/zsh to get it to work
          – Dustin
          Mar 14 at 17:03




          Thank you! It is working now and I realized it was zsh that was making it work in my npm script so I had to change it to #!/bin/zsh to get it to work
          – Dustin
          Mar 14 at 17:03












          I guess I don't need the shopt -s globstar command either since it doesn't work in zsh. I was told that this doesn't work for mac users since mac has bash 3 and bash 4 is required.
          – Dustin
          Mar 14 at 17:32




          I guess I don't need the shopt -s globstar command either since it doesn't work in zsh. I was told that this doesn't work for mac users since mac has bash 3 and bash 4 is required.
          – Dustin
          Mar 14 at 17:32












          Yes, it's bash specific. You can write */*/* but that will only work for a specific directory depth. For arbitrary depths, there is find.
          – frostschutz
          Mar 14 at 17:51




          Yes, it's bash specific. You can write */*/* but that will only work for a specific directory depth. For arbitrary depths, there is find.
          – frostschutz
          Mar 14 at 17:51












           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f430223%2fshell-script-dont-add-quotes%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Bahrain

          Postfix configuration issue with fips on centos 7; mailgun relay