[X2Go-Commits] [buildscripts] 01/04: bin/common.sh: add shared file for common functions.
git-admin at x2go.org
git-admin at x2go.org
Sun May 10 05:52:31 CEST 2015
This is an automated email from the git hooks/post-receive script.
x2go pushed a commit to branch master
in repository buildscripts.
commit 9be82e1b31062cc82f44a38775b6f6b6b4c89ad0
Author: Mihai Moldovan <ionic at ionic.de>
Date: Sun May 10 05:32:16 2015 +0200
bin/common.sh: add shared file for common functions.
---
bin/common.sh | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
diff --git a/bin/common.sh b/bin/common.sh
new file mode 100644
index 0000000..946ae58
--- /dev/null
+++ b/bin/common.sh
@@ -0,0 +1,51 @@
+#!/bin/bash
+
+# Copyright (C) 2015 by Mihai Moldovan <ionic at ionic.de>
+#
+# This programme is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This programme is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the
+# Free Software Foundation, Inc.,
+# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+export PATH="${HOME}/bin:${PATH}"
+
+function make_boolean () {
+ typeset -l OPTION="${1}"
+
+ case "${OPTION}" in
+ ("0"|"no"|"false"|"") OPTION="0";;
+ (*) OPTION="1";;
+ esac
+
+ printf "${OPTION}"
+
+ return 0
+}
+
+# Repeats an input string.
+# Returns the repeated input string.
+repeat_str () { # INPUT COUNT
+ typeset INPUT="${1:?"Error: no input string passed to ${FUNCNAME}()."}"
+ typeset COUNT="${2:?"Error: no count passed to ${FUNCNAME}()."}"
+
+ typeset ret=""
+ typeset -i i=0
+ while [ "${i}" -lt "${COUNT}" ]; do
+ ret="${ret}$(printf "${INPUT}")"
+ i=$(($i + 1))
+ done
+
+ printf "${ret}"
+
+ return 0
+}
--
Alioth's /srv/git/code.x2go.org/buildscripts.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/buildscripts.git
More information about the x2go-commits
mailing list