the CoreFoundation framework. */
#undef HAVE_CFPREFERENCESCOPYAPPVALUE
+/* Define to 1 if you have the `clearenv' function. */
+#undef HAVE_CLEARENV
+
/* Define if compiling support to gdb compile. */
#undef HAVE_COMPILE
{
if (var == 0)
{
+ /* If there is no clearenv, don't bother asking the question. */
+#ifndef HAVE_CLEARENV
+ if (env == nullptr)
+ from_tty = 0;
+#endif
+
/* If there is no argument, delete all environment variables.
Ask for confirmation if reading from the terminal. */
if (!from_tty || query (_("Delete all environment variables? ")))
{
+ /* This was handled above. */
if (env == nullptr)
- clearenv ();
+ {
+#ifdef HAVE_CLEARENV
+ clearenv ();
+#else
+ error (_("Cannot clear the local environment on this host."));
+#endif
+ }
else
env->clear ();
}
"confirm unset environment variable worked"
# Verify that we can unset all environment variables.
-gdb_test "unset local-environment" "" "unset all environment variables" \
- "Delete all environment variables. .y or n. $" \
- "y"
+# Note that on some platforms this is not possible.
+set can_unset_all 0
+# Disable confirmation so we don't have to deal with the question.
+gdb_test_multiple "with confirm off -- unset local-environment" \
+ "unset all environment variables" {
+ -re -wrap "Cannot clear the local environment on this host." {
+ # Nothing.
+ pass $gdb_test_name
+ }
+
+ -re -wrap "" {
+ set can_unset_all 1
+ pass $gdb_test_name
+ }
+ }
-gdb_test_no_output "show local-environment" \
- "all environment variables have been unset"
+if {$can_unset_all} {
+ gdb_test_no_output "show local-environment" \
+ "all environment variables have been unset"
+}
# Verify that we can set a specific environment variable.
test_set_show_env_var "EDITOR" "emacs" "set environment variable"