462fb2
diff --git a/bashhist.c b/bashhist.c
462fb2
--- a/bashhist.c
462fb2
+++ b/bashhist.c
462fb2
@@ -702,6 +702,12 @@ check_add_history (line, force)
462fb2
 #if defined (SYSLOG_HISTORY)
462fb2
 #define SYSLOG_MAXLEN 600
462fb2
462fb2
+#if defined (SYSLOG_SHOPT)
462fb2
+int syslog_history = SYSLOG_SHOPT;
462fb2
+#else
462fb2
+int syslog_history = 1;
462fb2
+#endif
462fb2
+
462fb2
 void
462fb2
 bash_syslog_history (line)
462fb2
      const char *line;
462fb2
@@ -782,7 +788,8 @@ bash_add_history (line)
462fb2
     really_add_history (line);
462fb2
462fb2
 #if defined (SYSLOG_HISTORY)
462fb2
-  bash_syslog_history (line);
462fb2
+  if (syslog_history)
462fb2
+    bash_syslog_history (line);
462fb2
 #endif
462fb2
462fb2
   using_history ();
462fb2
diff --git a/builtins/shopt.def b/builtins/shopt.def
462fb2
--- a/builtins/shopt.def
462fb2
+++ b/builtins/shopt.def
462fb2
@@ -115,6 +115,10 @@ extern char *shell_name;
462fb2
 extern int debugging_mode;
462fb2
 #endif
462fb2
462fb2
+#if defined (SYSLOG_HISTORY) && defined (SYSLOG_SHOPT)
462fb2
+extern int syslog_history;
462fb2
+#endif
462fb2
+
462fb2
 static void shopt_error __P((char *));
462fb2
462fb2
 static int set_shellopts_after_change __P((char *, int));
462fb2
@@ -208,6 +212,9 @@ static struct {
462fb2
 #endif
462fb2
   { "shift_verbose", &print_shift_error, (shopt_set_func_t *)NULL },
462fb2
   { "sourcepath", &source_uses_path, (shopt_set_func_t *)NULL },
462fb2
+#if defined (SYSLOG_HISTORY) && defined (SYSLOG_SHOPT)
462fb2
+  { "syslog_history", &syslog_history, (shopt_set_func_t *)NULL },
462fb2
+#endif
462fb2
   { "xpg_echo", &xpg_echo, (shopt_set_func_t *)NULL },
462fb2
   { (char *)0, (int *)0, (shopt_set_func_t *)NULL }
462fb2
 };
462fb2
diff --git a/config-top.h b/config-top.h
462fb2
--- a/config-top.h
462fb2
+++ b/config-top.h
462fb2
@@ -109,5 +109,12 @@
462fb2
 #  define SYSLOG_LEVEL LOG_INFO
462fb2
 #endif
462fb2
462fb2
+/* Define if you want syslogging history to be controllable at runtime via a
462fb2
+   shell option; if defined, the value is the default for the syslog_history
462fb2
+   shopt option */
462fb2
+#if defined (SYSLOG_HISTORY)
462fb2
+#define SYSLOG_SHOPT 0
462fb2
+#endif
462fb2
+
462fb2
 /* Define if you want to include code in shell.c to support wordexp(3) */
462fb2
 /* #define WORDEXP_OPTION */
462fb2
diff --git a/doc/bash.1 b/doc/bash.1
462fb2
--- a/doc/bash.1
462fb2
+++ b/doc/bash.1
462fb2
@@ -9224,6 +9224,9 @@ If set, the
462fb2
 to find the directory containing the file supplied as an argument.
462fb2
 This option is enabled by default.
462fb2
 .TP 8
462fb2
+.B syslog_history
462fb2
+If set, command history is logged to syslog.
462fb2
+.TP 8
462fb2
 .B xpg_echo
462fb2
 If set, the \fBecho\fP builtin expands backslash-escape sequences
462fb2
 by default.