aboutsummaryrefslogtreecommitdiffstats
path: root/modules/buildsystem/templates
diff options
context:
space:
mode:
authorColin Guthrie <colin@mageia.org>2014-09-15 19:46:14 +0100
committerColin Guthrie <colin@mageia.org>2014-09-19 09:58:25 +0100
commit9cf2957242c572a332f732d359ea55c66f3964be (patch)
tree90f16642257bc8f24406aeebb1cce42e5986689e /modules/buildsystem/templates
parent844d375887333f5ac14c36fef37b5598535c2de5 (diff)
downloadpuppet-9cf2957242c572a332f732d359ea55c66f3964be.tar
puppet-9cf2957242c572a332f732d359ea55c66f3964be.tar.gz
puppet-9cf2957242c572a332f732d359ea55c66f3964be.tar.bz2
puppet-9cf2957242c572a332f732d359ea55c66f3964be.tar.xz
puppet-9cf2957242c572a332f732d359ea55c66f3964be.zip
buildsystem: maintdb slight modernisation+use bash explicitly.
This is slightly subjective but most scripts do it this way these days without the extra letters on string comparisons and collapsing the if+then onto one line.
Diffstat (limited to 'modules/buildsystem/templates')
-rwxr-xr-xmodules/buildsystem/templates/maintdb/maintdb.bin43
1 files changed, 15 insertions, 28 deletions
diff --git a/modules/buildsystem/templates/maintdb/maintdb.bin b/modules/buildsystem/templates/maintdb/maintdb.bin
index 9fef3c64..6c40046c 100755
--- a/modules/buildsystem/templates/maintdb/maintdb.bin
+++ b/modules/buildsystem/templates/maintdb/maintdb.bin
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
MAINTDBDIR="<%= scope.lookupvar('buildsystem::var::maintdb::dbdir') %>"
@@ -15,15 +15,13 @@ function checkname()
function maintnew()
{
- if [ a"$user" != "aroot" ]
- then
+ if [ "$user" != "root" ]; then
echo "Error: new is only allowed to root." >&2
exit 1
fi
checkname "$1"
maintfile="$MAINTDBDIR/$1"
- if [ -f "$maintfile" ]
- then
+ if [ -f "$maintfile" ]; then
exit 0
fi
echo "$2" > "$maintfile"
@@ -34,26 +32,21 @@ function maintset()
checkname "$1"
maintfile="$MAINTDBDIR/$1"
newmaint="$2"
- if ! [ -f "$maintfile" ]
- then
+ if [ ! -f "$maintfile" ]; then
echo "Error: package $1 does not exist in maintdb." >&2
exit 1
fi
curmaint=$(cat "$maintfile")
- if [ a"$newmaint" = "anobody" ]
- then
- if [ a"$curmaint" = a"$user" ]
- then
+ if [ "$newmaint" = "nobody" ]; then
+ if [ "$curmaint" = "$user" ]; then
echo "$newmaint" > "$maintfile"
exit 0
else
echo "Error: cannot set maintainer for $1." >&2
exit 1
fi
- elif [ a"$newmaint" = a"$user" ]
- then
- if [ a"$curmaint" = "anobody" ]
- then
+ elif [ "$newmaint" = "$user" ]; then
+ if [ "$curmaint" = "nobody" ]; then
echo "$newmaint" > "$maintfile"
exit 0
else
@@ -69,8 +62,7 @@ function maintset()
function maintgetall()
{
cd "$MAINTDBDIR"
- for file in *
- do
+ for file in *; do
echo "$file $(cat $file)"
done
exit 0
@@ -78,14 +70,12 @@ function maintgetall()
function maintget()
{
- if [ -z "$1" ]
- then
+ if [ -z "$1" ]; then
maintgetall
fi
checkname "$1"
maintfile="$MAINTDBDIR/$1"
- if [ -f "$maintfile" ]
- then
+ if [ -f "$maintfile" ]; then
cat "$maintfile"
else
echo "Error: package $1 does not exist in maintdb." >&2
@@ -96,16 +86,13 @@ function maintget()
user="$1"
action="$2"
-if [ a"$action" = "anew" ]
-then
+if [ "$action" = "new" ]; then
maintnew "$3" "$4"
-elif [ a"$action" = "aset" ]
-then
+elif [ "$action" = "set" ]; then
maintset "$3" "$4"
-elif [ a"$action" = "aget" ]
-then
+elif [ "$action" = "get" ]; then
maintget "$3"
else
- echo "Error: unknow command." >&2
+ echo "Error: unknown command." >&2
exit 2
fi