簡體   English   中英

如何在bash腳本中傳遞參數以檢查git存儲庫的狀態?

[英]How to pass argument in bash script to check the status of git repository?

到目前為止,我已經完成了以下代碼,以及如何將文件路徑作為參數(在bash腳本中進行設置)傳遞給bash腳本,它將檢查git存儲庫的狀態。

#!/bin/bash

repos=( 
  "/home/jeff/github/workshop1"
  "/home/jeff/github/workshop2"
  "/home/jeff/github/workshop3"
)

echo ""
echo "Checking" ${#repos[@]} "repositories for status"

for repo in "${repos[@]}"
do
  echo ""
  echo "****** Checking status for" ${repo} "******"
  cd "${repo}"
  git status
  git log
  echo "******************************************"
done

$@提供給您傳遞給腳本的所有參數的列表。

因此,您需要設置repos=("$@")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM