aboutsummaryrefslogtreecommitdiff
path: root/files
diff options
context:
space:
mode:
authorAndré Erdmann <dywi@mailerd.de>2013-09-06 11:49:58 +0200
committerAndré Erdmann <dywi@mailerd.de>2013-09-06 11:52:09 +0200
commita109373ccef7a6cd6ed6363e1d70905f6ef55dd5 (patch)
tree7c7fa7fe04c7fe3af5c91f5bc35060d2bd601091 /files
parentfix 014240b7155c2fede9931f83e0bb22fb292d83c0 (diff)
downloadR_overlay-a109373ccef7a6cd6ed6363e1d70905f6ef55dd5.tar.gz
R_overlay-a109373ccef7a6cd6ed6363e1d70905f6ef55dd5.tar.bz2
R_overlay-a109373ccef7a6cd6ed6363e1d70905f6ef55dd5.zip
files/shlib/functions: sync_allowed(), $this
Diffstat (limited to 'files')
-rw-r--r--files/shlib/functions.sh31
1 files changed, 31 insertions, 0 deletions
diff --git a/files/shlib/functions.sh b/files/shlib/functions.sh
index 14dab08..405ed3a 100644
--- a/files/shlib/functions.sh
+++ b/files/shlib/functions.sh
@@ -29,6 +29,7 @@
# void dont_run_as_root(), raises die()
# int list_has ( word, *list_items )
# int qwhich ( *command )
+# int sync_allowed ( action_name, [msg_nosync], [msg_sync] )
#
# fs util:
# int dodir ( *dir )
@@ -65,6 +66,9 @@
# SCRIPT_FILENAME
# SCRIPT_NAME
#
+# this
+# initially identical to SCRIPT_NAME, but can be modified (not readonly)
+#
# lf
# "reference" to load_functions()
#
@@ -113,6 +117,7 @@ readonly EX_GIT_PUSH_ERR=37
readonly SCRIPT_FILENAME="${0##*/}"
readonly SCRIPT_NAME="${SCRIPT_FILENAME%.*}"
+this="${SCRIPT_NAME}"
readonly lf=load_functions
@@ -281,6 +286,32 @@ qwhich() {
return 0
}
+# int sync_allowed ( action_name, [msg_nosync], [msg_sync] )
+#
+# Returns true if syncing is allowed, else false.
+# Also prints an info message (if given).
+# Always prints a message if sync is disabled unless msg_nosync is
+# explicitly set to the empty string.
+#
+sync_allowed() {
+ : ${1:?}
+ if yesno "${NOSYNC:?}"; then
+
+ if [ -n "${2-}" ]; then
+ einfo "${2}"
+ elif [ -z "${2+X}" ]; then
+ einfo "${1}: sync is disabled."
+ fi
+
+ return 1
+
+ else
+ [ -z "${3-}" ] || einfo "${1}"
+ return 0
+ fi
+}
+
+
## fs util functions
# int dodir ( *dir )