We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6ef49d8 commit f06ef64Copy full SHA for f06ef64
lib/kernel/src/os.erl
@@ -557,7 +557,9 @@ The possible options are:
557
_Example_:
558
559
```erlang
560
- > catch os:cmd("true && false", #{ exception_on_failure => true }).
+ > catch os:cmd("echo hello && exit 123", #{ exception_on_failure => true }).
561
+ {'EXIT',{{command_failed,"hello\n",123},
562
+ [{os,cmd,2,[{file,"os.erl"},{line,579}]},
563
...
564
```
565
@@ -573,6 +575,8 @@ cmd(Cmd, Opts) ->
573
575
try
574
576
do_cmd(Cmd, Opts)
577
catch
578
+ throw:{command_failed, Result, ExitStatus} ->
579
+ error({command_failed, Result, ExitStatus});
580
throw:badopt ->
581
badarg_with_cause([Cmd, Opts], badopt);
582
throw:{open_port, Reason} ->
@@ -601,7 +605,7 @@ do_cmd(Cmd, Opts) ->
601
605
true -> binary_to_list(iolist_to_binary(Bytes))
602
606
end,
603
607
if ExceptionOnFailure, ExitStatus =/= 0 ->
604
- error({command_failed, Result, ExitStatus});
608
+ throw({command_failed, Result, ExitStatus});
609
true -> Result
610
end.
611
0 commit comments