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
|
||||
# Copyrithgt (C) 2018 salt <salt@lap-th-e560-0>
|
||||
@ -6,6 +6,8 @@
|
||||
# Distributed under terms of the MIT license
|
||||
#
|
||||
|
||||
# shellcheck disable=1117
|
||||
|
||||
## Helper functions
|
||||
log() {
|
||||
[ -z ${1+x} ] && return 1
|
||||
@ -14,10 +16,13 @@ log() {
|
||||
col_message="\e[39m"
|
||||
[ "$out" -gt "1" ] && col_message="\e[31m"
|
||||
[ "$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() {
|
||||
if ! which $1 > /dev/null 2>&1; then
|
||||
if ! command -v "$1" > /dev/null 2>&1; then
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
@ -87,9 +92,11 @@ step_repo_move() {
|
||||
step_dot_update() {
|
||||
# Finish syncing
|
||||
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" config status.showUntrackedFiles no >> "$logfile" 2>&1
|
||||
{
|
||||
git --git-dir="$gitdir" --work-tree="$bootstrapdir" submodule update --init --recursive --remote --depth 50
|
||||
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
|
||||
@ -101,7 +108,7 @@ main() {
|
||||
gitdir="$PWD/.dotfiles"
|
||||
|
||||
# Parse out arguments
|
||||
while getopts ":d:r:h\?" opt; do
|
||||
while getopts ":d:r:lh\?" opt; do
|
||||
case $opt in
|
||||
d)
|
||||
if [ "$OPTARG" == "" ]; then
|
||||
@ -158,5 +165,5 @@ main() {
|
||||
exit 0
|
||||
}
|
||||
|
||||
main $@
|
||||
main "$@"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user