[SOLVED] Kitchen Inspec Resource Command not supporting linux piping


#1

Currently I tried to run the below test in my kitchen test but if failed due to command was broken after the “|” piping symbol.

describe command("history | awk '{print $2}' | head -n1") do
  its("stdout") { should match /^[0-9]{4}-[0-9]{2}-[0-9]{2}$/ }
end

Is there a way to let the above test command works? I am intended to test the history command output format contains YYYY-MM-DD date format. Thanks.


#2

Answered on Slack but for the future: piping should work fine with InSpec AFAIK, the issue is more likely that this would run with /bin/sh which these days is generally not bash, and history is not usually a command, it’s a shell builtin.