From 725a7f7f19eb39b472e1f24b447fc9a596bf1748 Mon Sep 17 00:00:00 2001 From: Brett Holman Date: Thu, 7 Oct 2021 14:08:13 -0600 Subject: Allow comments in runcmd and report failed commands correctly (#1049) Allow comments in runcmd and report failed commands correctly A `runcmd` script may fail to parse properly, but does not mark `runcmd` as failed when that occurs. Additionally `shellify()` fails to correctly parse scripts that contain a comment line. Rectify both issues and add unit tests to verify correct behavior. LP: #1853146 --- cloudinit/tests/test_util.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'cloudinit/tests/test_util.py') diff --git a/cloudinit/tests/test_util.py b/cloudinit/tests/test_util.py index 977ad8e0..ab5eb35c 100644 --- a/cloudinit/tests/test_util.py +++ b/cloudinit/tests/test_util.py @@ -349,6 +349,11 @@ class TestShellify(CiTestCase): util.shellify(["echo hi mom", ["echo", "hi dad"], ('echo', 'hi', 'sis')])) + def test_supports_comments(self): + self.assertEqual( + '\n'.join(["#!/bin/sh", "echo start", "echo end", ""]), + util.shellify(["echo start", None, "echo end"])) + class TestGetHostnameFqdn(CiTestCase): -- cgit v1.2.3