File Fix-capture_combined_spec-with-new-shell.patch of Package lua-shell-games

From 8bbb1fb233b4ff9075078a626ec8541223c9edf0 Mon Sep 17 00:00:00 2001
From: Michal Suchanek <msuchanek@suse.de>
Date: Tue, 22 Nov 2022 11:30:00 +0100
Subject: [PATCH] Fix capture_combined_spec with new shell

/bin/sh --version
GNU bash, version 5.2.2(1)-release (x86_64-suse-linux)
---
 spec/capture_combined_spec.lua | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/spec/capture_combined_spec.lua b/spec/capture_combined_spec.lua
index 9ba4f34..20bb6be 100644
--- a/spec/capture_combined_spec.lua
+++ b/spec/capture_combined_spec.lua
@@ -74,13 +74,20 @@ describe("capture_combined", function()
     assert.are.equal(nil, err)
 
     result, err = shell.capture_combined({ "ls", "-1", "chdir.txt" }, { chdir = "spec/tmp/not existent with spaces" })
-    if string.match(result["output"], "line 1") then
+    if string.match(result["output"], "cd: line 1") then
       assert.are.same({
         command = [[sh -c 'cd '"'"'spec/tmp/not existent with spaces'"'"' && ls -1 chdir.txt' 2>&1]],
         status = 2,
         output = "sh: cd: line 1: can't cd to spec/tmp/not existent with spaces: No such file or directory\n",
       }, result)
       assert.are.equal("Executing command failed (exit code 2): sh -c 'cd '\"'\"'spec/tmp/not existent with spaces'\"'\"' && ls -1 chdir.txt' 2>&1\nOutput: sh: cd: line 1: can't cd to spec/tmp/not existent with spaces: No such file or directory\n", err)
+    elseif string.match(result["output"], "sh: line 1") then
+      assert.are.same({
+        command = [[sh -c 'cd '"'"'spec/tmp/not existent with spaces'"'"' && ls -1 chdir.txt' 2>&1]],
+        status = 1,
+        output = "sh: line 1: cd: spec/tmp/not existent with spaces: No such file or directory\n",
+      }, result)
+      assert.are.equal("Executing command failed (exit code 1): sh -c 'cd '\"'\"'spec/tmp/not existent with spaces'\"'\"' && ls -1 chdir.txt' 2>&1\nOutput: sh: line 1: cd: spec/tmp/not existent with spaces: No such file or directory\n", err)
     else
       assert.are.same({
         command = [[sh -c 'cd '"'"'spec/tmp/not existent with spaces'"'"' && ls -1 chdir.txt' 2>&1]],
-- 
2.38.0

openSUSE Build Service is sponsored by