shell script - don't add quotes
Clash 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?
bash shell-script
add a comment |Â
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?
bash shell-script
add a comment |Â
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?
bash shell-script
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?
bash shell-script
asked Mar 14 at 16:47
Dustin
1184
1184
add a comment |Â
add a comment |Â
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
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 theshopt -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 isfind
.
â frostschutz
Mar 14 at 17:51
add a comment |Â
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
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 theshopt -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 isfind
.
â frostschutz
Mar 14 at 17:51
add a comment |Â
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
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 theshopt -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 isfind
.
â frostschutz
Mar 14 at 17:51
add a comment |Â
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
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
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 theshopt -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 isfind
.
â frostschutz
Mar 14 at 17:51
add a comment |Â
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 theshopt -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 isfind
.
â 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
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password