[C++] Store SHELL value in command result

$(shell ...) command lines are executed using $(SHELL). We need to use
the same shell during regeneration check instead of hard-coding /bin/sh
or otherwise the results might be different when $(SHELL) is redefined
in the makefile.

Fixes https://github.com/google/kati/issues/53

Change-Id: I1f9809106f29f7e806324a82e2323a2f8df64b63
diff --git a/regen.cc b/regen.cc
index 23151b4..3d03f67 100644
--- a/regen.cc
+++ b/regen.cc
@@ -52,6 +52,7 @@
   };
 
   struct ShellResult {
+    string shell;
     string cmd;
     string result;
     vector<string> missing_dirs;
@@ -230,6 +231,7 @@
     for (int i = 0; i < num_crs; i++) {
       ShellResult* sr = new ShellResult;
       commands_.push_back(sr);
+      LOAD_STRING(fp, &sr->shell);
       LOAD_STRING(fp, &sr->cmd);
       LOAD_STRING(fp, &sr->result);
       sr->has_condition = LOAD_INT(fp);
@@ -339,7 +341,7 @@
 
     COLLECT_STATS_WITH_SLOW_REPORT("shell time (regen)", sr->cmd.c_str());
     string result;
-    RunCommand("/bin/sh", sr->cmd, RedirectStderr::DEV_NULL, &result);
+    RunCommand(sr->shell, sr->cmd, RedirectStderr::DEV_NULL, &result);
     FormatForCommandSubstitution(&result);
     if (sr->result != result) {
       if (g_flags.dump_kati_stamp) {