Skip to content

Commit 29e4f14

Browse files
committed
subprocess_run: add echo= option
1 parent a86adfc commit 29e4f14

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

+stdlib/subprocess_run.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
opt.stdin {mustBeTextScalar} = ''
3434
opt.stdout (1,1) logical = true
3535
opt.stderr (1,1) logical = true
36+
opt.echo (1,1) logical = false
3637
end
3738

3839

@@ -85,6 +86,10 @@
8586
inold = getenv("GFORTRAN_STDIN_UNIT");
8687
setenv("GFORTRAN_STDIN_UNIT", "5");
8788

89+
if opt.echo
90+
disp(cmd)
91+
end
92+
8893
[status, msg] = system(join(cmd), env_pairs{:});
8994

9095
setenv("GFORTRAN_STDOUT_UNIT", outold);

test/TestSubprocess.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ function test_cwd(tc)
5050
c = 'ls -l';
5151
end
5252

53-
[s, m] = stdlib.subprocess_run(c);
53+
[s, m] = stdlib.subprocess_run(c, echo=true);
5454
tc.assertEqual(s, 0, "status non-zero")
5555
tc.verifyGreaterThan(strlength(m), 0, "empty directory not expected")
5656

5757
td = tc.createTemporaryFolder();
5858

59-
[s, mc] = stdlib.subprocess_run(c, cwd=td);
59+
[s, mc] = stdlib.subprocess_run(c, cwd=td, echo=true);
6060
tc.assertEqual(s, 0, "status non-zero")
6161
tc.verifyNotEqual(m, mc, "expected different directory to have different contents")
6262

0 commit comments

Comments
 (0)