replace all "function foo" with "foo()"

This commit is contained in:
2022-06-23 19:20:47 +02:00
parent 54e9308268
commit 05e7ecb5e1

View File

@@ -152,11 +152,11 @@ CMD="${0##*/}"
# shellcheck disable=2034 # shellcheck disable=2034
VALIDFS=(ext3 ext4 btrfs vfat reiserfs xfs zfs) VALIDFS=(ext3 ext4 btrfs vfat reiserfs xfs zfs)
function man { man() {
sed -n '/^#%MAN_BEGIN%/,/^#%MAN_END%$/{//!s/^#[ ]\{0,1\}//p}' "$SCRIPT" | more sed -n '/^#%MAN_BEGIN%/,/^#%MAN_END%$/{//!s/^#[ ]\{0,1\}//p}' "$SCRIPT" | more
} }
function usage { usage() {
cat <<_EOF cat <<_EOF
Usage: $CMD [OPTIONS] [SRC] DST Usage: $CMD [OPTIONS] [SRC] DST
Duplicate SRC (or live system) disk partitions to DST disk partitions. Duplicate SRC (or live system) disk partitions to DST disk partitions.
@@ -211,7 +211,7 @@ log() {
} }
# prints out and run (maybe) a command. # prints out and run (maybe) a command.
function echorun_maybe { echorun_maybe() {
if [[ "$DRYRUN" == 'yes' ]]; then if [[ "$DRYRUN" == 'yes' ]]; then
log "dry-run: %s" "$*" log "dry-run: %s" "$*"
else else
@@ -246,7 +246,7 @@ yesno() {
} }
# mariadb start/stop # mariadb start/stop
function mariadb_maybe_stop { mariadb_maybe_stop() {
[[ $MARIADBSTOPPED == yes ]] && return 0 [[ $MARIADBSTOPPED == yes ]] && return 0
if systemctl is-active --quiet mysql; then if systemctl is-active --quiet mysql; then
if [[ $MARIADB == ask ]]; then if [[ $MARIADB == ask ]]; then
@@ -268,7 +268,7 @@ function mariadb_maybe_stop {
fi fi
} }
function mariadb_maybe_start { mariadb_maybe_start() {
if [[ $MARIADB == yes && $MARIADBSTOPPED == yes ]]; then if [[ $MARIADB == yes && $MARIADBSTOPPED == yes ]]; then
#log -n "restarting mariadb/mysql... " #log -n "restarting mariadb/mysql... "
echorun_maybe systemctl start mariadb echorun_maybe systemctl start mariadb
@@ -277,14 +277,14 @@ function mariadb_maybe_start {
fi fi
} }
function error_handler { error_handler() {
local ERROR=$2 local ERROR=$2
log "FATAL: Error line $1, exit code $2. Aborting." log "FATAL: Error line $1, exit code $2. Aborting."
exit "$ERROR" exit "$ERROR"
} }
trap 'error_handler $LINENO $?' ERR SIGHUP SIGINT SIGTERM trap 'error_handler $LINENO $?' ERR SIGHUP SIGINT SIGTERM
function exit_handler { exit_handler() {
local mnt local mnt
# log "exit handler (at line $1)" # log "exit handler (at line $1)"
@@ -327,7 +327,7 @@ check_block_device() {
} }
# check that /etc/fstab.DESTLABEL exists in SRC disk. # check that /etc/fstab.DESTLABEL exists in SRC disk.
function check_fstab { check_fstab() {
local etc="${AUTOFS_DIR}/$SRCROOTLABEL/etc" local etc="${AUTOFS_DIR}/$SRCROOTLABEL/etc"
local fstab="fstab.$DSTROOTLABEL" local fstab="fstab.$DSTROOTLABEL"
#if [[ "$FSTAB" != no ]]; then #if [[ "$FSTAB" != no ]]; then
@@ -340,7 +340,7 @@ function check_fstab {
return 0 return 0
} }
function fix_fstab { fix_fstab() {
local fstab="${AUTOFS_DIR}/$DSTROOTLABEL/etc/fstab" local fstab="${AUTOFS_DIR}/$DSTROOTLABEL/etc/fstab"
#[[ ! -f "$fstab" ]] && log "Warning: DST fstab will be wrong !" && FSTAB=no #[[ ! -f "$fstab" ]] && log "Warning: DST fstab will be wrong !" && FSTAB=no
@@ -356,7 +356,7 @@ function fix_fstab {
} }
# check if $1 is in array $2 ($2 is by reference) # check if $1 is in array $2 ($2 is by reference)
function in_array { in_array() {
local elt=$1 i local elt=$1 i
local -n arr=$2 local -n arr=$2
for ((i=0; i<${#arr[@]}; ++i)); do for ((i=0; i<${#arr[@]}; ++i)); do