Merge ~raharper/cloud-init:fix/cloud-init-per-bad-sub into cloud-init:master

Proposed by Ryan Harper
Status: Merged
Approved by: Dan Watkins
Approved revision: 44037f7920216a3fc44192e057ef36b916ea2902
Merge reported by: Server Team CI bot
Merged at revision: not available
Proposed branch: ~raharper/cloud-init:fix/cloud-init-per-bad-sub
Merge into: cloud-init:master
Diff against target: 22 lines (+2/-2)
1 file modified
tools/cloud-init-per (+2/-2)
Reviewer Review Type Date Requested Status
Dan Watkins Approve
Server Team CI bot continuous-integration Approve
Review via email: mp+364190@code.launchpad.net

Commit message

cloud-init-per: POSIX sh does not support string subst, use sed

cloud-init-per is run via /bin/sh which requires POSIX shell
compliance and does not implement string substitution like
bash. Replace these calls with use of sed.

LP: #1819222

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:44037f7920216a3fc44192e057ef36b916ea2902
https://jenkins.ubuntu.com/server/job/cloud-init-ci/630/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    IN_PROGRESS: Declarative: Post Actions

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

review: Approve (continuous-integration)
Revision history for this message
Dan Watkins (oddbloke) wrote :

I've tested locally and this is now working as expected.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/tools/cloud-init-per b/tools/cloud-init-per
2index eae3e93..fcd1ea7 100755
3--- a/tools/cloud-init-per
4+++ b/tools/cloud-init-per
5@@ -38,7 +38,7 @@ fi
6 [ "$1" = "-h" -o "$1" = "--help" ] && { Usage ; exit 0; }
7 [ $# -ge 3 ] || { Usage 1>&2; exit 1; }
8 freq=$1
9-name=${2/-/_}
10+name=$(echo $2 | sed 's/-/_/g')
11 shift 2;
12
13 [ "${name#*/}" = "${name}" ] || fail "name cannot contain a /"
14@@ -56,7 +56,7 @@ esac
15 # Rename legacy sem files with dashes in their names. Do not overwrite existing
16 # sem files to prevent clobbering those which may have been created from calls
17 # outside of cloud-init.
18-sem_legacy="${sem/_/-}"
19+sem_legacy=$(echo $sem | sed 's/_/-/g')
20 [ "$sem" != "$sem_legacy" -a -e "$sem_legacy" ] && mv -n "$sem_legacy" "$sem"
21
22 [ "$freq" != "always" -a -e "$sem" ] && exit 0

Subscribers

People subscribed via source and target branches