extern time_t shell_start_time;
#if defined (READLINE)
+extern int no_line_editing;
extern int perform_hostname_completion;
#endif
static int export_env_index;
static int export_env_size;
+#if defined (READLINE)
+static int winsize_assignment; /* currently assigning to LINES or COLUMNS */
+static int winsize_assigned; /* assigned to LINES or COLUMNS */
+#endif
+
/* Non-zero means that we have to remake EXPORT_ENV. */
int array_needs_making = 1;
}
#endif /* HISTORY */
+#if defined (READLINE)
+ /* POSIXLY_CORRECT will only be 1 here if the shell was compiled
+ -DSTRICT_POSIX */
+ if (interactive_shell && /*posixly_correct && */no_line_editing == 0)
+ rl_prefer_env_winsize = 1;
+#endif /* READLINE && STRICT_POSIX */
+
/*
* 24 October 2001
*
{
char val[INT_STRLEN_BOUND(int) + 1], *v;
+ /* If we are currently assigning to LINES or COLUMNS, don't do anything. */
+ if (winsize_assignment)
+ return;
+
v = inttostr (lines, val, sizeof (val));
bind_variable ("LINES", v, 0);
extern int eof_encountered, eof_encountered_limit, ignoreeof;
#if defined (READLINE)
-extern int no_line_editing;
extern int hostname_list_initialized;
#endif
static struct name_and_function special_vars[] = {
#if defined (READLINE)
+# if defined (STRICT_POSIX)
+ { "COLUMNS", sv_winsize },
+# endif
{ "COMP_WORDBREAKS", sv_comp_wordbreaks },
#endif
{ "HISTTIMEFORMAT", sv_histtimefmt },
#endif
-#if defined (READLINE)
+#if defined (__CYGWIN__)
{ "HOME", sv_home },
#endif
{ "LC_NUMERIC", sv_locale },
{ "LC_TIME", sv_locale },
+#if defined (READLINE) && defined (STRICT_POSIX)
+ { "LINES", sv_winsize },
+#endif
+
{ "MAIL", sv_mail },
{ "MAILCHECK", sv_mail },
{ "MAILPATH", sv_mail },
}
}
+/* What to do when GLOBIGNORE changes. */
+void
+sv_globignore (name)
+ char *name;
+{
+ setup_glob_ignore (name);
+}
+
#if defined (READLINE)
void
sv_comp_wordbreaks (name)
if (sv == 0)
rl_completer_word_break_characters = (char *)NULL;
}
-#endif
-
-/* What to do when GLOBIGNORE changes. */
-void
-sv_globignore (name)
- char *name;
-{
- setup_glob_ignore (name);
-}
-#if defined (READLINE)
/* What to do just after one of the TERMxxx variables has changed.
If we are an interactive shell, then try to reset the terminal
information in readline. */
rl_reset_terminal (get_string_value ("TERM"));
}
-/* Update the value of HOME in the export environment so tilde expansion will
- work on cygwin. */
-sv_home (name)
- char *name;
-{
- if (interactive_shell && no_line_editing == 0)
- {
- array_needs_making = 1;
- maybe_make_export_env ();
- }
-}
-
void
sv_hostfile (name)
char *name;
else
hostname_list_initialized = 0;
}
+
+#if defined (STRICT_POSIX)
+/* In strict posix mode, we allow assignments to LINES and COLUMNS (and values
+ found in the initial environment) to override the terminal size reported by
+ the kernel. */
+void
+sv_winsize (name)
+ char *name;
+{
+ SHELL_VAR *v;
+ intmax_t xd;
+ int d;
+
+ if (posixly_correct == 0 || interactive_shell == 0 || no_line_editing)
+ return;
+
+ v = find_variable (name);
+ if (v == 0 || var_isnull (v))
+ rl_reset_screen_size ();
+ else
+ {
+ if (legal_number (value_cell (v), &xd) == 0)
+ return;
+ winsize_assignment = winsize_assigned = 1;
+ d = xd; /* truncate */
+ if (name[0] == 'L') /* LINES */
+ rl_set_screen_size (d, -1);
+ else /* COLUMNS */
+ rl_set_screen_size (-1, d);
+ winsize_assignment = 0;
+ }
+}
+#endif /* STRICT_POSIX */
#endif /* READLINE */
+/* Update the value of HOME in the export environment so tilde expansion will
+ work on cygwin. */
+#if defined (__CYGWIN__)
+sv_home (name)
+ char *name;
+{
+ array_needs_making = 1;
+ maybe_make_export_env ();
+}
+#endif
+
#if defined (HISTORY)
/* What to do after the HISTSIZE or HISTFILESIZE variables change.
If there is a value for this HISTSIZE (and it is numeric), then stifle