Bug 10104 - Followup: fix param check
[koha.git] / debian / scripts / koha-foreach
index 80152bc..6bda414 100755 (executable)
 
 set -e
 
-
 listopts=""
-if [ "$1" = --enabled ]
-then
-    listopts="--enabled"
+while [ ! -z "$1" ]
+do
+    case "$1" in
+        --email) listopts="$listopts --email";;
+      --noemail) listopts="$listopts --noemail";;
+      --enabled) listopts="$listopts --enabled";;
+              *) break;;
+    esac
     shift
-fi
-
-
+done
+            
 for name in $(koha-list $listopts)
 do
+    (
+    exec 3>&1
     sudo -u "$name-koha" \
     env PERL5LIB=/usr/share/koha/lib \
         KOHA_CONF="/etc/koha/sites/$name/koha-conf.xml" \
-        "$@"
+        "$@" 2>&1 >&3 | sed -e "s/^/$name: /" >&2 3>&-
+    exec 3>&-
+    ) | sed -e "s/^/$name: /"
+
 done