Fix internal uses of _PATH_BSHELL.

We regressed on this recently: code under the upstream-* directories has
_PATH_BSHELL defined as a call to __bionic_get_shell_path(). In our own
code, we may as well just call it directly.

Bug: https://issuetracker.google.com/129030706
Test: ran tests
Change-Id: Ic2423f521272be95e67f94771772fe8072636ef0
diff --git a/libc/bionic/__bionic_get_shell_path.cpp b/libc/bionic/__bionic_get_shell_path.cpp
index 1352815..7aeed18 100644
--- a/libc/bionic/__bionic_get_shell_path.cpp
+++ b/libc/bionic/__bionic_get_shell_path.cpp
@@ -26,6 +26,8 @@
  * SUCH DAMAGE.
  */
 
+#include "private/__bionic_get_shell_path.h"
+
 #include <errno.h>
 #include <string.h>
 #include <sys/cdefs.h>
@@ -51,7 +53,7 @@
   return "/system/bin/sh";
 }
 
-__LIBC_HIDDEN__ extern "C" const char* __bionic_get_shell_path() {
+const char* __bionic_get_shell_path() {
   static const char* sh_path = init_sh_path();
   return sh_path;
 }
diff --git a/libc/bionic/exec.cpp b/libc/bionic/exec.cpp
index 1cf3a58..3309585 100644
--- a/libc/bionic/exec.cpp
+++ b/libc/bionic/exec.cpp
@@ -39,6 +39,7 @@
 #include <string.h>
 #include <unistd.h>
 
+#include "private/__bionic_get_shell_path.h"
 #include "private/FdPath.h"
 
 extern "C" char** environ;
@@ -111,7 +112,7 @@
   script_argv[0] = "sh";
   script_argv[1] = buf;
   memcpy(script_argv + 2, argv + 1, arg_count * sizeof(char*));
-  return execve(_PATH_BSHELL, const_cast<char**>(script_argv), envp);
+  return execve(__bionic_get_shell_path(), const_cast<char**>(script_argv), envp);
 }
 
 int execvpe(const char* name, char* const* argv, char* const* envp) {
diff --git a/libc/bionic/system.cpp b/libc/bionic/system.cpp
index 7411ae5..950f05c 100644
--- a/libc/bionic/system.cpp
+++ b/libc/bionic/system.cpp
@@ -27,12 +27,12 @@
  */
 
 #include <errno.h>
-#include <paths.h>
 #include <stdlib.h>
 #include <spawn.h>
 #include <sys/wait.h>
 #include <unistd.h>
 
+#include "private/__bionic_get_shell_path.h"
 #include "private/ScopedSignalBlocker.h"
 #include "private/ScopedSignalHandler.h"
 
@@ -58,7 +58,7 @@
 
   const char* argv[] = { "sh", "-c", command, nullptr };
   pid_t child;
-  if ((errno = posix_spawn(&child, _PATH_BSHELL, nullptr, &attributes,
+  if ((errno = posix_spawn(&child, __bionic_get_shell_path(), nullptr, &attributes,
                            const_cast<char**>(argv), environ)) != 0) {
     return -1;
   }
diff --git a/libc/private/__bionic_get_shell_path.h b/libc/private/__bionic_get_shell_path.h
new file mode 100644
index 0000000..171c14a
--- /dev/null
+++ b/libc/private/__bionic_get_shell_path.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#pragma once
+
+extern "C" const char* __bionic_get_shell_path();
diff --git a/libc/stdio/stdio.cpp b/libc/stdio/stdio.cpp
index d7b69dc..d482a91 100644
--- a/libc/stdio/stdio.cpp
+++ b/libc/stdio/stdio.cpp
@@ -52,6 +52,7 @@
 
 #include "local.h"
 #include "glue.h"
+#include "private/__bionic_get_shell_path.h"
 #include "private/bionic_fortify.h"
 #include "private/ErrnoRestorer.h"
 #include "private/thread_private.h"
@@ -1226,7 +1227,7 @@
     if (dup2(fds[child], desired_child_fd) == -1) _exit(127);
     close(fds[child]);
     if (bidirectional) dup2(STDOUT_FILENO, STDIN_FILENO);
-    execl(_PATH_BSHELL, "sh", "-c", cmd, nullptr);
+    execl(__bionic_get_shell_path(), "sh", "-c", cmd, nullptr);
     _exit(127);
   }