我正在使用 Nitrous.io 进行一些基本的开发,代码由git管理。我想使用脚本在我的开发机器上设置 git 项目(几个介于 Nitrous、工作和家庭之间)。[编辑: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
有人知道为什么吗?
问候
shell 脚本
CD 中的cd
是运行脚本的 shell,而不是交互式 shell。
除非你用.
执行,否则你不能做你想做的事。
编辑,这对我有用:
res="$( find $current -mindepth 1 -maxdepth 1 -type d -name '[!.]*' )"
for dir in $res
do
echo "$dir"
ls -la
done