When running sh.exec('whoami')
I am trying to compare the stdout but it doesn't work.
What I want to do is that after running the whoami
command if the results turns to be an specific user then I would like to trigger an action.
When running,
sh.exec('whoami', (code, output) => {
sh.echo(output == 'myusername'); // False
console.log(output == 'myusername'); // False
});
The condition output == 'myusername'
evaluates to false even though I am completely sure it is true since I've copied the username and place it as the compared string.
The expected result would be that the condition evaluates to true.