Merge ~smoser/cloud-init:fix/1784713-ksh-does-not-have-local into cloud-init:master

Proposed by Scott Moser
Status: Merged
Approved by: Chad Smith
Approved revision: 4407720ae69f784d01db5c5d035b3be93b6a4441
Merge reported by: Server Team CI bot
Merged at revision: not available
Proposed branch: ~smoser/cloud-init:fix/1784713-ksh-does-not-have-local
Merge into: cloud-init:master
Diff against target: 57 lines (+13/-8)
2 files modified
tools/Z99-cloud-locale-test.sh (+8/-5)
tools/Z99-cloudinit-warnings.sh (+5/-3)
Reviewer Review Type Date Requested Status
Chad Smith Approve
Server Team CI bot continuous-integration Approve
Merlie Allen Pending
Review via email: mp+352010@code.launchpad.net

Commit message

Use typeset or local in profile.d scripts.

Bash and most other "bourne-like" shells allow declaring function
local variables via 'local'. ksh does not. Instead of using 'local'
always, use 'typeset' when the KSH_VERSION variable is present in
environment.

LP: #1784713

Description of the change

see commit message

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:0674c305d20aaa8dc283612c108d8b156c5694f4
https://jenkins.ubuntu.com/server/job/cloud-init-ci/183/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    SUCCESS: MAAS Compatability Testing
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/183/rebuild

review: Approve (continuous-integration)
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:61708c0f356dd090b5547b90c381a93b61e249c7
https://jenkins.ubuntu.com/server/job/cloud-init-ci/188/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    SUCCESS: MAAS Compatability Testing
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/188/rebuild

review: Approve (continuous-integration)
Revision history for this message
Chad Smith (chad.smith) :
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:7f5a15ed3ff4ed51df67ad426ee545c962260ee3
https://jenkins.ubuntu.com/server/job/cloud-init-ci/195/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    SUCCESS: MAAS Compatability Testing
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/195/rebuild

review: Approve (continuous-integration)
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:4407720ae69f784d01db5c5d035b3be93b6a4441
https://jenkins.ubuntu.com/server/job/cloud-init-ci/198/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    SUCCESS: MAAS Compatability Testing
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/198/rebuild

review: Approve (continuous-integration)
Revision history for this message
Chad Smith (chad.smith) wrote :

tested on both ksh and bash. LGTM!

review: Approve

There was an error fetching revisions from git servers. Please try again in a few minutes. If the problem persists, contact Launchpad support.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/tools/Z99-cloud-locale-test.sh b/tools/Z99-cloud-locale-test.sh
2index 4978d87..9ee44bd 100644
3--- a/tools/Z99-cloud-locale-test.sh
4+++ b/tools/Z99-cloud-locale-test.sh
5@@ -11,8 +11,11 @@
6 # of how to fix them.
7
8 locale_warn() {
9- local bad_names="" bad_lcs="" key="" val="" var="" vars="" bad_kv=""
10- local w1 w2 w3 w4 remain
11+ command -v local >/dev/null && local _local="local" ||
12+ typeset _local="typeset"
13+
14+ $_local bad_names="" bad_lcs="" key="" val="" var="" vars="" bad_kv=""
15+ $_local w1 w2 w3 w4 remain
16
17 # if shell is zsh, act like sh only for this function (-L).
18 # The behavior change will not permenently affect user's shell.
19@@ -53,8 +56,8 @@ locale_warn() {
20 printf " This can affect your user experience significantly, including the\n"
21 printf " ability to manage packages. You may install the locales by running:\n\n"
22
23- local bad invalid="" to_gen="" sfile="/usr/share/i18n/SUPPORTED"
24- local pkgs=""
25+ $_local bad invalid="" to_gen="" sfile="/usr/share/i18n/SUPPORTED"
26+ $_local local pkgs=""
27 if [ -e "$sfile" ]; then
28 for bad in ${bad_lcs}; do
29 grep -q -i "${bad}" "$sfile" &&
30@@ -67,7 +70,7 @@ locale_warn() {
31 fi
32 to_gen=${to_gen# }
33
34- local pkgs=""
35+ $_local pkgs=""
36 for bad in ${to_gen}; do
37 pkgs="${pkgs} language-pack-${bad%%_*}"
38 done
39diff --git a/tools/Z99-cloudinit-warnings.sh b/tools/Z99-cloudinit-warnings.sh
40index 1d41337..cb8b463 100644
41--- a/tools/Z99-cloudinit-warnings.sh
42+++ b/tools/Z99-cloudinit-warnings.sh
43@@ -4,9 +4,11 @@
44 # Purpose: show user warnings on login.
45
46 cloud_init_warnings() {
47- local warning="" idir="/var/lib/cloud/instance" n=0
48- local warndir="$idir/warnings"
49- local ufile="$HOME/.cloud-warnings.skip" sfile="$warndir/.skip"
50+ command -v local >/dev/null && local _local="local" ||
51+ typeset _local="typeset"
52+ $_local warning="" idir="/var/lib/cloud/instance" n=0
53+ $_local warndir="$idir/warnings"
54+ $_local ufile="$HOME/.cloud-warnings.skip" sfile="$warndir/.skip"
55 [ -d "$warndir" ] || return 0
56 [ ! -f "$ufile" ] || return 0
57 [ ! -f "$sfile" ] || return 0

Subscribers

People subscribed via source and target branches