I am getting crazy, while trying to write a companion script to help developers in my team to look up for changes in master branch.
My goal is to create a bahs/sh script to seek for ALL git repos on the developer machine, check if they were related to a certain client and them, aply some automatic updating to master branch and alerting the dev , that he should be aware of those changes when packaging their work for deployment.
Here's what I got so far:
find /c -type d -name .git -exec cygpath -U {} \; 2>/dev/null | sed 's@ @\\\\ @g' | while read eachGit
do
cd \""$eachGit"/..\"; ##This line is failing
pwd;
for eachBranch in $(git branch --no-merged master)
do
#do some stuff for each Branch (which already works if I cd manually)
done;
done;
When I tryed to do that cd
command, it says:
bash: cd: "/c/Users/MyUser/.SomeSw/subDir/.git/..": No such file or directory
~
bash: cd: "/c/Users/MyUser/my\ repo\ folder/some\ project/.git/..": No such file or directory
~
If I copy the directory from the error message and try to cd to it, it works perfectly
And I am running it from a normal git bash although my plan is to run it from windows task scheduler as soon as it became ready to go
As suggested by @torek, I was misunderstanding how to quote variables.
The following cod works
find /c -type d -name .git -exec cygpath -U {} \; 2>/dev/null | while read eachGit
do
cd "${eachGit}/.."; ##This line is failing
pwd;
for eachBranch in $(git branch --no-merged master)
do
#do some stuff for each Branch (which already works if I cd manually)
done;
done;
I am pretty sure that I used something closely related to this before, but somewhat I got a wrong direction.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.