Browse files

Strip trailing newlines from shell output

  • Loading branch information...
1 parent d4e2a59 commit b072e50f5bd78d2b3c15413c0f4b7f2b458ba53e Yurii Rashkovskii committed with Feb 4, 2012
Showing with 3 additions and 3 deletions.
  1. +3 −3 apps/htoad/src/htoad_shell.erl
View
6 apps/htoad/src/htoad_shell.erl
@@ -28,14 +28,14 @@ command_run_as_superuser(Engine, #shell{ cmd = Cmd, run_as = superuser } = Shell
#file{ path = "/usr/bin/sudo", producer = fs,
content = dontread }) when not {rule, [{?MODULE, superuser}]} ->
lager:debug("Executing shell command as a super user (via sudo): ~s", [Cmd]),
- Result = os:cmd("/usr/bin/sudo -n " ++ Cmd),
- lager:debug("Shell output for `~s`: ~s", [Cmd, Result]),
+ Result = string:strip(os:cmd("/usr/bin/sudo -n " ++ Cmd), right, $\n),
+ lager:debug("Shell output for `~s` (sudo): ~s", [Cmd,Result]),
htoad:assert(Engine, {output, Shell, Result}).
command(Engine, #shell{ cmd = Cmd, run_as = undefined } = Shell) ->
lager:debug("Executing shell command: ~s", [Cmd]),
- Result = os:cmd(Cmd),
+ Result = string:strip(os:cmd(Cmd), right, $\n),
lager:debug("Shell output for `~s`: ~s", [Cmd, Result]),
htoad:assert(Engine, {output, Shell, Result}).

0 comments on commit b072e50

Please sign in to comment.