我在Linux服務器上設置了Mercurial存儲庫,並且有些(但不是全部)用戶有權推送到它。他們通過ssh連接到版本庫。爲unix組的成員設置Mercurial
這些用戶是unix組的成員。以下是我正在使用的腳本來更改存儲庫以允許它從它們接收推送。
這可以改進嗎?這裏有沒有不必要的操作? bash
腳本有什麼不好的風格?
#!/bin/bash
if [[ $# -lt 2 ]]; then
echo Usage: $0 directory groupname
exit 1
fi
if ! chown -R :$2 $1; then
echo chown failure
exit 2
fi
if ! find $1/.hg -type d -exec chmod g+s {} \;; then
echo chmod failure
exit 3
fi
if ! find $1 -perm -u+r -exec chmod g+r {} \;; then
echo chmod failure 2
exit 4
fi
if ! find $1 -perm -u+w -exec chmod g+w {} \;; then
echo chmod failure 3
exit 5
fi
if ! find $1 -perm -u+x -exec chmod g+x {} \;; then
echo chmod failure 4
exit 6
fi
較新的GNU發現(他們實現它相對較晚,它在POSIX年代以來......)知道「-exec .... {} +」,它將使用盡可能多的參數生成進程,以適應環境空間,有效地做xargs會做的事情。 – TheBonsai 2009-07-10 04:58:59