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
diff --git a/tools/cloud-init-per b/tools/cloud-init-per
index eae3e93..fcd1ea7 100755
--- a/tools/cloud-init-per
+++ b/tools/cloud-init-per
@@ -38,7 +38,7 @@ fi
38[ "$1" = "-h" -o "$1" = "--help" ] && { Usage ; exit 0; }38[ "$1" = "-h" -o "$1" = "--help" ] && { Usage ; exit 0; }
39[ $# -ge 3 ] || { Usage 1>&2; exit 1; }39[ $# -ge 3 ] || { Usage 1>&2; exit 1; }
40freq=$140freq=$1
41name=${2/-/_}41name=$(echo $2 | sed 's/-/_/g')
42shift 2;42shift 2;
4343
44[ "${name#*/}" = "${name}" ] || fail "name cannot contain a /"44[ "${name#*/}" = "${name}" ] || fail "name cannot contain a /"
@@ -56,7 +56,7 @@ esac
56# Rename legacy sem files with dashes in their names. Do not overwrite existing56# Rename legacy sem files with dashes in their names. Do not overwrite existing
57# sem files to prevent clobbering those which may have been created from calls57# sem files to prevent clobbering those which may have been created from calls
58# outside of cloud-init.58# outside of cloud-init.
59sem_legacy="${sem/_/-}"59sem_legacy=$(echo $sem | sed 's/_/-/g')
60[ "$sem" != "$sem_legacy" -a -e "$sem_legacy" ] && mv -n "$sem_legacy" "$sem"60[ "$sem" != "$sem_legacy" -a -e "$sem_legacy" ] && mv -n "$sem_legacy" "$sem"
6161
62[ "$freq" != "always" -a -e "$sem" ] && exit 062[ "$freq" != "always" -a -e "$sem" ] && exit 0

Subscribers

People subscribed via source and target branches