mirror of
https://github.com/cotes2020/jekyll-theme-chirpy.git
synced 2025-12-18 05:41:31 +00:00
Improve the Shell code style.
This commit is contained in:
32
tools/run.sh
32
tools/run.sh
@@ -41,21 +41,21 @@ _cleanup() {
|
||||
jekyll clean
|
||||
fi
|
||||
|
||||
rm -rf ${WORK_DIR}/${CONTAINER}
|
||||
rm -rf "${WORK_DIR}/${CONTAINER}"
|
||||
ps aux | grep fswatch | awk '{print $2}' | xargs kill -9 > /dev/null 2>&1
|
||||
}
|
||||
|
||||
|
||||
_init() {
|
||||
|
||||
if [[ -d ${WORK_DIR}/${CONTAINER} ]]; then
|
||||
rm -rf ${WORK_DIR}/${CONTAINER}
|
||||
if [[ -d "${WORK_DIR}/${CONTAINER}" ]]; then
|
||||
rm -rf "${WORK_DIR}/${CONTAINER}"
|
||||
fi
|
||||
|
||||
temp=$(mktemp -d)
|
||||
cp -r ${WORK_DIR}/* $temp
|
||||
cp -r ${WORK_DIR}/.git $temp
|
||||
mv $temp ${WORK_DIR}/${CONTAINER}
|
||||
temp="$(mktemp -d)"
|
||||
cp -r "$WORK_DIR"/* "$temp"
|
||||
cp -r "${WORK_DIR}/.git" "$temp"
|
||||
mv "$temp" "${WORK_DIR}/${CONTAINER}"
|
||||
|
||||
trap _cleanup INT
|
||||
}
|
||||
@@ -70,7 +70,7 @@ _check_unset() {
|
||||
|
||||
|
||||
_check_command() {
|
||||
if [[ -z $(command -v $1) ]]; then
|
||||
if [[ -z $(command -v "$1") ]]; then
|
||||
echo "Error: command '$1' not found !"
|
||||
echo "Hint: Get '$1' on <$2>"
|
||||
exit 1
|
||||
@@ -81,16 +81,16 @@ _check_command() {
|
||||
main() {
|
||||
_init
|
||||
|
||||
cd ${WORK_DIR}/${CONTAINER}
|
||||
cd "${WORK_DIR}/${CONTAINER}"
|
||||
bash _scripts/sh/create_pages.sh
|
||||
bash _scripts/sh/dump_lastmod.sh
|
||||
|
||||
if [[ $realtime = true ]]; then
|
||||
fswatch -0 -e "\\$CONTAINER" -e "\.git" ${WORK_DIR} | xargs -0 -I {} bash ./${SYNC_TOOL} {} $WORK_DIR . &
|
||||
fswatch -0 -e "\\$CONTAINER" -e "\.git" "$WORK_DIR" | xargs -0 -I {} bash "./${SYNC_TOOL}" {} "$WORK_DIR" . &
|
||||
fi
|
||||
|
||||
echo "\$ $cmd"
|
||||
eval $cmd
|
||||
eval "$cmd"
|
||||
}
|
||||
|
||||
|
||||
@@ -99,20 +99,20 @@ do
|
||||
opt="$1"
|
||||
case $opt in
|
||||
-H|--host)
|
||||
_check_unset $2
|
||||
_check_unset "$2"
|
||||
cmd+=" -H $2"
|
||||
shift # past argument
|
||||
shift # past value
|
||||
;;
|
||||
-P|--port)
|
||||
_check_unset $2
|
||||
_check_unset "$2"
|
||||
cmd+=" -P $2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
-b|--baseurl)
|
||||
_check_unset $2
|
||||
if [[ $2 == \/* ]]
|
||||
_check_unset "$2"
|
||||
if [[ "$2" == \/* ]]
|
||||
then
|
||||
cmd+=" -b $2"
|
||||
else
|
||||
@@ -127,7 +127,7 @@ do
|
||||
shift
|
||||
;;
|
||||
-r|--realtime)
|
||||
_check_command fswatch 'http://emcrisostomo.github.io/fswatch/'
|
||||
_check_command fswatch "http://emcrisostomo.github.io/fswatch/"
|
||||
realtime=true
|
||||
shift
|
||||
;;
|
||||
|
||||
Reference in New Issue
Block a user