From 86a8e9767912ae957cbbf6ea20a08106011a7728 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Tue, 4 Feb 2014 15:20:15 +0100 Subject: [PATCH] Add while/until to the for/do rule Like 'for/do' check that the while/until operator are on the same line with the do. Fixes some pep8 error along the way. Change-Id: I440afe60691263365bf35310bf4212d94f30c339 --- tools/bash8.py | 10 +++++++--- tools/create_userrc.sh | 3 +-- tools/xen/install_os_domU.sh | 3 +-- tools/xen/scripts/install-os-vpx.sh | 3 +-- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/tools/bash8.py b/tools/bash8.py index 9fb51ecc9e..7552e0d642 100755 --- a/tools/bash8.py +++ b/tools/bash8.py @@ -47,7 +47,7 @@ IGNORE = None def register_ignores(ignores): global IGNORE if ignores: - IGNORE='^(' + '|'.join(ignores.split(',')) + ')' + IGNORE = '^(' + '|'.join(ignores.split(',')) + ')' def should_ignore(error): @@ -64,11 +64,15 @@ def print_error(error, line): def not_continuation(line): return not re.search('\\\\$', line) + def check_for_do(line): if not_continuation(line): - if re.search('^\s*for ', line): + match = re.match('^\s*(for|while|until)\s', line) + if match: + operator = match.group(1).strip() if not re.search(';\s*do(\b|$)', line): - print_error('E010: Do not on same line as for', line) + print_error('E010: Do not on same line as %s' % operator, + line) def check_if_then(line): diff --git a/tools/create_userrc.sh b/tools/create_userrc.sh index 5f4c48660b..e2d855c4df 100755 --- a/tools/create_userrc.sh +++ b/tools/create_userrc.sh @@ -71,8 +71,7 @@ MODE="" ROLE=Member USER_NAME="" USER_PASS="" -while [ $# -gt 0 ] -do +while [ $# -gt 0 ]; do case "$1" in -h|--help) display_help; exit 0 ;; --os-username) export OS_USERNAME=$2; shift ;; diff --git a/tools/xen/install_os_domU.sh b/tools/xen/install_os_domU.sh index d172c7ba1b..d0d81a2d7e 100755 --- a/tools/xen/install_os_domU.sh +++ b/tools/xen/install_os_domU.sh @@ -191,8 +191,7 @@ function wait_for_VM_to_halt() { domid=$(xe vm-list name-label="$GUEST_NAME" params=dom-id minimal=true) port=$(xenstore-read /local/domain/$domid/console/vnc-port) echo "vncviewer -via root@$mgmt_ip localhost:${port:2}" - while true - do + while true; do state=$(xe_min vm-list name-label="$GUEST_NAME" power-state=halted) if [ -n "$state" ]; then break diff --git a/tools/xen/scripts/install-os-vpx.sh b/tools/xen/scripts/install-os-vpx.sh index 8412fdc3ca..b9b65fdce2 100755 --- a/tools/xen/scripts/install-os-vpx.sh +++ b/tools/xen/scripts/install-os-vpx.sh @@ -42,8 +42,7 @@ EOF get_params() { - while getopts "hbn:r:l:t:" OPTION; - do + while getopts "hbn:r:l:t:" OPTION; do case $OPTION in h) usage exit 1