3fb13f
diff --git a/bashhist.c b/bashhist.c
3fb13f
index 9979f99..793c81f 100644
3fb13f
--- a/bashhist.c
3fb13f
+++ b/bashhist.c
3fb13f
@@ -754,6 +754,12 @@ extern char *shell_name;
3fb13f
 #define OPENLOG_OPTS 0
3fb13f
 #endif
3fb13f
 
3fb13f
+#if defined (SYSLOG_SHOPT)
3fb13f
+int syslog_history = SYSLOG_SHOPT;
3fb13f
+#else
3fb13f
+int syslog_history = 1;
3fb13f
+#endif
3fb13f
+
3fb13f
 void
3fb13f
 bash_syslog_history (line)
3fb13f
      const char *line;
3fb13f
@@ -851,7 +857,8 @@ bash_add_history (line)
3fb13f
     really_add_history (line);
3fb13f
 
3fb13f
 #if defined (SYSLOG_HISTORY)
3fb13f
-  bash_syslog_history (line);
3fb13f
+  if (syslog_history)
3fb13f
+    bash_syslog_history (line);
3fb13f
 #endif
3fb13f
 
3fb13f
   using_history ();
3fb13f
diff --git a/builtins/shopt.def b/builtins/shopt.def
3fb13f
index 2febb7e..38c398e 100644
3fb13f
--- a/builtins/shopt.def
3fb13f
+++ b/builtins/shopt.def
3fb13f
@@ -118,6 +118,10 @@ extern char *shell_name;
3fb13f
 extern int debugging_mode;
3fb13f
 #endif
3fb13f
 
3fb13f
+#if defined (SYSLOG_HISTORY) && defined (SYSLOG_SHOPT)
3fb13f
+extern int syslog_history;
3fb13f
+#endif
3fb13f
+
3fb13f
 static void shopt_error __P((char *));
3fb13f
 
3fb13f
 static int set_shellopts_after_change __P((char *, int));
3fb13f
@@ -223,6 +227,9 @@ static struct {
3fb13f
 #endif
3fb13f
   { "shift_verbose", &print_shift_error, (shopt_set_func_t *)NULL },
3fb13f
   { "sourcepath", &source_uses_path, (shopt_set_func_t *)NULL },
3fb13f
+#if defined (SYSLOG_HISTORY) && defined (SYSLOG_SHOPT)
3fb13f
+  { "syslog_history", &syslog_history, (shopt_set_func_t *)NULL },
3fb13f
+#endif
3fb13f
   { "xpg_echo", &xpg_echo, (shopt_set_func_t *)NULL },
3fb13f
   { (char *)0, (int *)0, (shopt_set_func_t *)NULL }
3fb13f
 };
3fb13f
diff --git a/config-top.h b/config-top.h
3fb13f
index cb0e002..39cf6b5 100644
3fb13f
--- a/config-top.h
3fb13f
+++ b/config-top.h
3fb13f
@@ -122,6 +122,13 @@
3fb13f
 #  define OPENLOG_OPTS LOG_PID
3fb13f
 #endif
3fb13f
 
3fb13f
+/* Define if you want syslogging history to be controllable at runtime via a
3fb13f
+   shell option; if defined, the value is the default for the syslog_history
3fb13f
+   shopt option */
3fb13f
+#if defined (SYSLOG_HISTORY)
3fb13f
+#define SYSLOG_SHOPT 0
3fb13f
+#endif
3fb13f
+
3fb13f
 /* Define if you want to include code in shell.c to support wordexp(3) */
3fb13f
 /* #define WORDEXP_OPTION */
3fb13f
 
3fb13f
diff --git a/doc/bash.1 b/doc/bash.1
3fb13f
index d6cee1d..9dfa0b3 100644
3fb13f
--- a/doc/bash.1
3fb13f
+++ b/doc/bash.1
3fb13f
@@ -9889,6 +9889,9 @@ If set, the
3fb13f
 to find the directory containing the file supplied as an argument.
3fb13f
 This option is enabled by default.
3fb13f
 .TP 8
3fb13f
+.B syslog_history
3fb13f
+If set, command history is logged to syslog.
3fb13f
+.TP 8
3fb13f
 .B xpg_echo
3fb13f
 If set, the \fBecho\fP builtin expands backslash-escape sequences
3fb13f
 by default.