开发者

How to use a variable from `read` as an argument to another program?

开发者 https://www.devze.com 2023-03-22 20:05 出处:网络
Here\'s my script: read -p \'commit message: \' msg svn status | grep ^\\? | awk \'{ print $2 }\'| egrep \"\\.(py|js|html|png|jpg)$\" | xargs svn add

Here's my script:

read -p 'commit message: ' msg
svn status | grep ^\? | awk '{ print $2 }'  | egrep "\.(py|js|html|png|jpg)$" | xargs svn add
svn ci -m "$msg"

When I run it, however, I get this error:

mark@mark-ubuntu:~/myproject$ ./commit.sh 
commit message: test
svn: Try 'svn help' for more info
svn: Not enough arguments provided

I really don't know much about shell programming. Is the message not being passed to svn ci properly or what? How can I make it work?


mark@mark-ubuntu:~/myproject$ bash -x commit.sh 
+ read -p 'commit message: ' msg开发者_运维问答
commit message: hello world
+ egrep '\.(py|js|html|png|jpg)$'
+ xargs svn add
+ awk '{ print $2 }'
+ grep '^?'
+ svn status
svn: Try 'svn help' for more info
svn: Not enough arguments provided
+ svn ci -m 'hello world'


The svn ci line seems fine. You can try running it with bash -x to see where the error is:

$ bash -x commit.sh
0

精彩评论

暂无评论...
验证码 换一张
取 消