我正在使用Nitrous.io作为一些基本的开发,代码是用git管理的。 我想用一个脚本在我的开发机器上设置git项目(几个在Nitrous,work和home之间)。 [编辑:Git repo下面有两个rails项目,可能有更多]
我有以下内容:
#!/bin/bash
current=${1-`pwd`}
echo "Starting directory is $current"
cd $current
read -p "Press [Enter] key to start install..."
git init
git remote add nitrous https://github.com/[user]/[project].git
git pull nitrous master
for dir in "$( find $current -mindepth 1 -maxdepth 1 -type d -name '[!.]*' )";
do
echo "Setting up $dir"
#cd $dir
#bundle install
#rake db:migrate
done
cd $current
exit 0
但它无法更改目录。 (我暂时评论了导轨动作)
action@testlog-xxxx:~/workspace$ ../setup.sh
Starting directory is /home/action/workspace
Press [Enter] key to start install...
Initialized empty Git repository in /home/action/workspace/.git/
remote: Counting objects: 175, done.
remote: Compressing objects: 100% (128/128), done.
remote: Total 175 (delta 31), reused 175 (delta 31)
Receiving objects: 100% (175/175), 29.44 KiB | 0 bytes/s, done.
Resolving deltas: 100% (31/31), done.
From https://github.com/[user]/[project]
* branch master -> FETCH_HEAD
* [new branch] master -> nitrous/master
Setting up /home/action/workspace/testlog
/home/action/workspace/testembedded
任何人都知道为什么?
此致
答案 0 :(得分:0)
cd
cd是运行脚本的shell,而不是交互式shell。
除非您使用.
执行,否则无法执行您想要的操作。
答案 1 :(得分:0)
res="$( find $current -mindepth 1 -maxdepth 1 -type d -name '[!.]*' )"
for dir in $res
do
echo "$dir"
ls -la
done