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
1=== modified file 'conf/utah/dns'
2--- conf/utah/dns 2012-07-11 17:43:36 +0000
3+++ conf/utah/dns 2013-03-18 12:28:26 +0000
4@@ -1,4 +1,4 @@
5-#!/bin/bash
6+#!/bin/sh
7
8 if [ -f /etc/default/qemu-kvm ]; then
9 . /etc/default/qemu-kvm
10
11=== modified file 'debian/changelog'
12--- debian/changelog 2013-03-01 14:18:10 +0000
13+++ debian/changelog 2013-03-18 12:28:26 +0000
14@@ -1,3 +1,9 @@
15+utah (0.9ubuntu2) precise; urgency=low
16+
17+ * Made all shell scripts POSIX-compliant
18+
19+ -- Max Brustkern <max@canonical.com> Fri, 15 Mar 2013 13:55:24 -0400
20+
21 utah (0.9ubuntu1) UNRELEASED; urgency=low
22
23 [ Javier Collado ]
24
25=== modified file 'debian/utah-client.postinst'
26--- debian/utah-client.postinst 2012-08-15 11:09:03 +0000
27+++ debian/utah-client.postinst 2013-03-18 12:28:26 +0000
28@@ -1,8 +1,10 @@
29-#!/bin/bash -e
30-
31-function configure
32+#!/bin/sh
33+
34+set -e
35+
36+configure()
37 {
38- function usersetup
39+ usersetup()
40 {
41 # Sane defaults:
42
43
44=== modified file 'debian/utah.postinst'
45--- debian/utah.postinst 2012-12-12 19:05:59 +0000
46+++ debian/utah.postinst 2013-03-18 12:28:26 +0000
47@@ -1,6 +1,8 @@
48-#!/bin/bash -e
49-
50-function configure
51+#!/bin/sh
52+
53+set -e
54+
55+configure()
56 {
57 if [ -f "/etc/utah/dns" ]
58 then
59@@ -12,7 +14,7 @@
60
61 if ! type -t dnssetup >/dev/null 2>&1
62 then
63- function dnssetup
64+ dnssetup()
65 {
66 # Check that interface is up and has address assigned to it
67 interface_up=$(python<<EOD
68@@ -25,7 +27,7 @@
69
70 EOD
71 )
72- if [ "${interface_up}" == "True" ]
73+ if [ "${interface_up}" = "True" ]
74 then
75 # Get address assigned to the interface
76 IP=$(python -c "import netifaces; \
77@@ -45,7 +47,7 @@
78 }
79 fi
80
81- function usersetup
82+ usersetup()
83 {
84 # Sane defaults:
85
86
87=== modified file 'debian/utah.postrm'
88--- debian/utah.postrm 2012-08-14 15:09:17 +0000
89+++ debian/utah.postrm 2013-03-18 12:28:26 +0000
90@@ -1,6 +1,8 @@
91-#!/bin/bash -e
92-
93-function cleanup
94+#!/bin/sh
95+
96+set -e
97+
98+cleanup()
99 {
100 if [ -f "/etc/utah/dns" ]
101 then
102@@ -9,7 +11,7 @@
103
104 if ! type -t dnsteardown >/dev/null 2>&1
105 then
106- function dnsteardown
107+ dnsteardown()
108 {
109 if dpkg -s resolvconf >/dev/null 2>&1
110 then
111
112=== modified file 'examples/utah-user-setup.sh'
113--- examples/utah-user-setup.sh 2012-12-12 19:05:59 +0000
114+++ examples/utah-user-setup.sh 2013-03-18 12:28:26 +0000
115@@ -1,8 +1,8 @@
116-#!/bin/bash
117+#!/bin/sh
118
119 set -e
120
121-function keepgoing
122+keepgoing()
123 {
124 echo "Going to run:"
125 echo "$@"
126@@ -28,7 +28,7 @@
127 export AUTO=""
128 fi
129
130-VMDIR=$(echo -e "import utah.config\nprint(utah.config.vmpath)" | python)
131+VMDIR=$(python -c "import utah.config; print(utah.config.vmpath)")
132 if ! [ -d "$VMDIR" ]
133 then
134 CMD="mkdir -p \"$VMDIR\""
135@@ -36,7 +36,7 @@
136 keepgoing $CMD
137 fi
138
139-SSHKEY=$(echo -e "import utah.config\nprint(utah.config.sshprivatekey)" | python)
140+SSHKEY=$(python -c "import utah.config; print(utah.config.sshprivatekey)")
141 if ! [ -d "$(dirname "$SSHKEY")" ]
142 then
143 CMD="mkdir -p \"$(dirname "$SSHKEY")\""
144
145=== modified file 'examples/utah_logs.sh'
146--- examples/utah_logs.sh 2012-11-29 16:38:37 +0000
147+++ examples/utah_logs.sh 2013-03-18 12:28:26 +0000
148@@ -1,4 +1,4 @@
149-#!/bin/bash
150+#!/bin/sh
151
152 set +e
153 NAME=$(grep "^Running on machine:" log | sed 's/^Running on machine: //')

Subscribers

People subscribed via source and target branches