Merge lp:~nuclearbob/utah/posix-shell-scripts into lp:utah

Proposed by Max Brustkern
Status: Merged
Merged at revision: 837
Proposed branch: lp:~nuclearbob/utah/posix-shell-scripts
Merge into: lp:utah
Diff against target: 153 lines (+32/-20)
7 files modified
conf/utah/dns (+1/-1)
debian/changelog (+6/-0)
debian/utah-client.postinst (+6/-4)
debian/utah.postinst (+8/-6)
debian/utah.postrm (+6/-4)
examples/utah-user-setup.sh (+4/-4)
examples/utah_logs.sh (+1/-1)
To merge this branch: bzr merge lp:~nuclearbob/utah/posix-shell-scripts
Reviewer Review Type Date Requested Status
Max Brustkern (community) Needs Resubmitting
Javier Collado (community) Approve
Review via email: mp+153611@code.launchpad.net

Description of the change

After Oli's email, I thought it would be wise to remove bashisms from our scripts and make sure they're using sh in the bang line. We certainly don't have to stick to the indefinitely if we need bash, but all these changes were easy and should make us more in line with standards.

To post a comment you must log in.
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

On 15 March 2013 17:58, Max Brustkern <email address hidden> wrote:
> Max Brustkern has proposed merging lp:~nuclearbob/utah/posix-shell-scripts into lp:utah.
> echo "$@"
> @@ -28,7 +28,7 @@
> export AUTO=""
> fi
>
> -VMDIR=$(echo -e "import utah.config\nprint(utah.config.vmpath)" | python)
> +VMDIR=$(printf "import utah.config\nprint(utah.config.vmpath)" | python)

Although this is POSIX compliant, it's not "pythonic". What about this:

VMDIR=$(python -c "import utah.config; print(utah.config.vmpath)")

Despite python being whitespace significant language ';' still works
to bundles commands on the same line.

Unless I am missing something and python in the above pipe is something else...

Revision history for this message
Javier Collado (javier.collado) wrote :

I've run checkbashims against the modified scripts and didn't get any
error/warning, so everything should be fine.

Anyway, I second Dmitrijs comment.

review: Approve
836. By Max Brustkern

Using more pythonic commands per xnox

Revision history for this message
Max Brustkern (nuclearbob) wrote :

That should be addressed now. If nobody objects shortly, I'll go ahead and merge.

review: Needs Resubmitting
Revision history for this message
Andy Doan (doanac) wrote :

+1

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'conf/utah/dns'
--- conf/utah/dns 2012-07-11 17:43:36 +0000
+++ conf/utah/dns 2013-03-18 12:28:26 +0000
@@ -1,4 +1,4 @@
1#!/bin/bash1#!/bin/sh
22
3if [ -f /etc/default/qemu-kvm ]; then3if [ -f /etc/default/qemu-kvm ]; then
4 . /etc/default/qemu-kvm4 . /etc/default/qemu-kvm
55
=== modified file 'debian/changelog'
--- debian/changelog 2013-03-01 14:18:10 +0000
+++ debian/changelog 2013-03-18 12:28:26 +0000
@@ -1,3 +1,9 @@
1utah (0.9ubuntu2) precise; urgency=low
2
3 * Made all shell scripts POSIX-compliant
4
5 -- Max Brustkern <max@canonical.com> Fri, 15 Mar 2013 13:55:24 -0400
6
1utah (0.9ubuntu1) UNRELEASED; urgency=low7utah (0.9ubuntu1) UNRELEASED; urgency=low
28
3 [ Javier Collado ]9 [ Javier Collado ]
410
=== modified file 'debian/utah-client.postinst'
--- debian/utah-client.postinst 2012-08-15 11:09:03 +0000
+++ debian/utah-client.postinst 2013-03-18 12:28:26 +0000
@@ -1,8 +1,10 @@
1#!/bin/bash -e1#!/bin/sh
22
3function configure3set -e
4
5configure()
4{6{
5 function usersetup7 usersetup()
6 {8 {
7 # Sane defaults:9 # Sane defaults:
810
911
=== modified file 'debian/utah.postinst'
--- debian/utah.postinst 2012-12-12 19:05:59 +0000
+++ debian/utah.postinst 2013-03-18 12:28:26 +0000
@@ -1,6 +1,8 @@
1#!/bin/bash -e1#!/bin/sh
22
3function configure3set -e
4
5configure()
4{6{
5 if [ -f "/etc/utah/dns" ]7 if [ -f "/etc/utah/dns" ]
6 then8 then
@@ -12,7 +14,7 @@
1214
13 if ! type -t dnssetup >/dev/null 2>&115 if ! type -t dnssetup >/dev/null 2>&1
14 then16 then
15 function dnssetup17 dnssetup()
16 {18 {
17 # Check that interface is up and has address assigned to it19 # Check that interface is up and has address assigned to it
18 interface_up=$(python<<EOD20 interface_up=$(python<<EOD
@@ -25,7 +27,7 @@
2527
26EOD28EOD
27)29)
28 if [ "${interface_up}" == "True" ]30 if [ "${interface_up}" = "True" ]
29 then31 then
30 # Get address assigned to the interface32 # Get address assigned to the interface
31 IP=$(python -c "import netifaces; \33 IP=$(python -c "import netifaces; \
@@ -45,7 +47,7 @@
45 }47 }
46 fi48 fi
4749
48 function usersetup50 usersetup()
49 {51 {
50 # Sane defaults:52 # Sane defaults:
5153
5254
=== modified file 'debian/utah.postrm'
--- debian/utah.postrm 2012-08-14 15:09:17 +0000
+++ debian/utah.postrm 2013-03-18 12:28:26 +0000
@@ -1,6 +1,8 @@
1#!/bin/bash -e1#!/bin/sh
22
3function cleanup3set -e
4
5cleanup()
4{6{
5 if [ -f "/etc/utah/dns" ]7 if [ -f "/etc/utah/dns" ]
6 then8 then
@@ -9,7 +11,7 @@
911
10 if ! type -t dnsteardown >/dev/null 2>&112 if ! type -t dnsteardown >/dev/null 2>&1
11 then13 then
12 function dnsteardown14 dnsteardown()
13 {15 {
14 if dpkg -s resolvconf >/dev/null 2>&116 if dpkg -s resolvconf >/dev/null 2>&1
15 then17 then
1618
=== modified file 'examples/utah-user-setup.sh'
--- examples/utah-user-setup.sh 2012-12-12 19:05:59 +0000
+++ examples/utah-user-setup.sh 2013-03-18 12:28:26 +0000
@@ -1,8 +1,8 @@
1#!/bin/bash1#!/bin/sh
22
3set -e3set -e
44
5function keepgoing5keepgoing()
6{6{
7 echo "Going to run:"7 echo "Going to run:"
8 echo "$@"8 echo "$@"
@@ -28,7 +28,7 @@
28 export AUTO=""28 export AUTO=""
29fi29fi
3030
31VMDIR=$(echo -e "import utah.config\nprint(utah.config.vmpath)" | python)31VMDIR=$(python -c "import utah.config; print(utah.config.vmpath)")
32if ! [ -d "$VMDIR" ]32if ! [ -d "$VMDIR" ]
33then33then
34 CMD="mkdir -p \"$VMDIR\""34 CMD="mkdir -p \"$VMDIR\""
@@ -36,7 +36,7 @@
36 keepgoing $CMD36 keepgoing $CMD
37fi37fi
3838
39SSHKEY=$(echo -e "import utah.config\nprint(utah.config.sshprivatekey)" | python)39SSHKEY=$(python -c "import utah.config; print(utah.config.sshprivatekey)")
40if ! [ -d "$(dirname "$SSHKEY")" ]40if ! [ -d "$(dirname "$SSHKEY")" ]
41then41then
42 CMD="mkdir -p \"$(dirname "$SSHKEY")\""42 CMD="mkdir -p \"$(dirname "$SSHKEY")\""
4343
=== modified file 'examples/utah_logs.sh'
--- examples/utah_logs.sh 2012-11-29 16:38:37 +0000
+++ examples/utah_logs.sh 2013-03-18 12:28:26 +0000
@@ -1,4 +1,4 @@
1#!/bin/bash1#!/bin/sh
22
3set +e3set +e
4NAME=$(grep "^Running on machine:" log | sed 's/^Running on machine: //')4NAME=$(grep "^Running on machine:" log | sed 's/^Running on machine: //')

Subscribers

People subscribed via source and target branches