Code quality improvements
Thanks shellcheck
This commit is contained in:
parent
635fdc855a
commit
3168e47b1b
23
replicate.sh
23
replicate.sh
@ -1,4 +1,4 @@
|
|||||||
#!/bin/sh
|
#! /usr/bin/env bash
|
||||||
#
|
#
|
||||||
# Salt's bootstrap script
|
# Salt's bootstrap script
|
||||||
# Copyrithgt (C) 2018 salt <salt@lap-th-e560-0>
|
# Copyrithgt (C) 2018 salt <salt@lap-th-e560-0>
|
||||||
@ -6,6 +6,8 @@
|
|||||||
# Distributed under terms of the MIT license
|
# Distributed under terms of the MIT license
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# shellcheck disable=1117
|
||||||
|
|
||||||
## Helper functions
|
## Helper functions
|
||||||
log() {
|
log() {
|
||||||
[ -z ${1+x} ] && return 1
|
[ -z ${1+x} ] && return 1
|
||||||
@ -14,10 +16,13 @@ log() {
|
|||||||
col_message="\e[39m"
|
col_message="\e[39m"
|
||||||
[ "$out" -gt "1" ] && col_message="\e[31m"
|
[ "$out" -gt "1" ] && col_message="\e[31m"
|
||||||
[ "$out" -lt "1" ] && out=1 && col_message="\e[37m"
|
[ "$out" -lt "1" ] && out=1 && col_message="\e[37m"
|
||||||
printf "\e[94m${name}\e[0m: $col_message$1\e[0m\n" >&${out}
|
printf "\e[94m%s\e[0m: %b%s\e[0m\n" \
|
||||||
|
"$name" \
|
||||||
|
"$col_message" \
|
||||||
|
"$1" >&${out}
|
||||||
}
|
}
|
||||||
validatedep() {
|
validatedep() {
|
||||||
if ! which $1 > /dev/null 2>&1; then
|
if ! command -v "$1" > /dev/null 2>&1; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
@ -87,9 +92,11 @@ step_repo_move() {
|
|||||||
step_dot_update() {
|
step_dot_update() {
|
||||||
# Finish syncing
|
# Finish syncing
|
||||||
log "Updating submodules and performing basic configuration"
|
log "Updating submodules and performing basic configuration"
|
||||||
git --git-dir="$gitdir" --work-tree="$bootstrapdir" submodule update --init --recursive --remote --depth 50 >> "$logfile" 2>&1
|
{
|
||||||
git --git-dir="$gitdir" --work-tree="$bootstrapdir" submodule foreach 'git checkout master && git pull' >> "$logfile" 2>&1
|
git --git-dir="$gitdir" --work-tree="$bootstrapdir" submodule update --init --recursive --remote --depth 50
|
||||||
git --git-dir="$gitdir" --work-tree="$bootstrapdir" config status.showUntrackedFiles no >> "$logfile" 2>&1
|
git --git-dir="$gitdir" --work-tree="$bootstrapdir" submodule foreach 'git checkout master && git pull'
|
||||||
|
git --git-dir="$gitdir" --work-tree="$bootstrapdir" config status.showUntrackedFiles no >> "$logfile"
|
||||||
|
} >> "$logfile" 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
## Main
|
## Main
|
||||||
@ -101,7 +108,7 @@ main() {
|
|||||||
gitdir="$PWD/.dotfiles"
|
gitdir="$PWD/.dotfiles"
|
||||||
|
|
||||||
# Parse out arguments
|
# Parse out arguments
|
||||||
while getopts ":d:r:h\?" opt; do
|
while getopts ":d:r:lh\?" opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
d)
|
d)
|
||||||
if [ "$OPTARG" == "" ]; then
|
if [ "$OPTARG" == "" ]; then
|
||||||
@ -158,5 +165,5 @@ main() {
|
|||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
main $@
|
main "$@"
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user