shell脚本书写规则
Published:
·
LastMod: July 12, 2022
·
145 words
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
| #!/usr/bin/bash
dirs=("ba" "crew" "file" "knowledge" "main" "oils" "system" "voyageno" "certificate")
function toggleRef() {
for dir in ${dirs[@]}
do
cd "./packages/shoreside-${dir}"
# if ( $1 )
# then
if [ $1 = 'branch' ]
then
currentBranch=$(git rev-parse --abbrev-ref HEAD)
if [ $currentBranch = $2 ]
then
git pull
cd ../../
continue
else
git checkout $2
git pull
fi
elif [ $1 = "build" ]
then
yarn install && yarn build
else
pwd;
fi
# else
# echo "参数缺失!"
# break
# fi
cd ../../
done
}
toggleRef $1 $2
|