bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Hard-copy terminals


From: Ryan Cunningham
Subject: Hard-copy terminals
Date: Thu, 6 Nov 2014 16:42:01 -0800

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: darwin14.0.0
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' 
-DCONF_OSTYPE='darwin14.0.0' -DCONF_MACHTYPE='x86_64-apple-darwin14.0.0' 
-DCONF_VENDOR='apple' -DLOCALEDIR='/usr/local/share/locale' -DPACKAGE='bash' 
-DSHELL -DHAVE_CONFIG_H -DMACOSX   -I.  -I. -I./include -I./lib -I./lib/intl 
-I/Users/reeves/Downloads/bash-4.3/lib/intl  -g -O2
uname output: Darwin Kimberly-Reevess-MacBook-7.local 14.0.0 Darwin Kernel 
Version 14.0.0: Sat Sep 27 03:58:47 PDT 2014; 
root:xnu-2782.1.97~11/RELEASE_X86_64 x86_64
Machine Type: x86_64-apple-darwin14.0.0

Bash Version: 4.3
Patch Level: 30
Release Status: release

Description:
        Some features of Bash don't recognize hard-copy terminals.

Repeat-By:
        If you're on a hard-copy terminal, and you invoke Bash,
        history recall and "readline" support will be invoked anyway
        unless the compiler was told for some other reason not to
        enable them.

        This patch will adjust "configure" so that it disables those
        features by default on hard-copy hosts. (Whether to disable
        these features is dependent on the host's attributes---not
        the guest's attributes, for cross-compiling purposes.)

Fix:
        A patch against the Git HEAD is included below.

diff --git a/bash-master/builtins/fc.def b/bash-master/builtins/fc.def
index cf6b72c..801ede9 100644
--- a/bash-master/builtins/fc.def
+++ b/bash-master/builtins/fc.def
@@ -165,6 +165,13 @@ static void fc_addhist __P((char *));
 #else
 #  define POSIX_FC_EDIT_COMMAND "${FCEDIT:-${EDITOR:-ed}}"
 #endif
+/* "vi" is bad for hard-copy terminals. Use "ed" instead if we find that we
+   are running on a hard-copy terminal. */
+#include "strstr.h"
+if (reg_strstr(getenv(TERM), "^tty")) {
+#  define FC_EDIT_COMMAND "ed"
+#  define POSIX_FC_EDIT_COMMAND "${FCEDIT:-ed}"
+}
 
 int
 fc_builtin (list)
diff --git a/bash-master/configure b/bash-master/configure
index 98bf890..47c3e54 100755
--- a/bash-master/configure
+++ b/bash-master/configure
@@ -2970,8 +2970,10 @@ opt_minimal_config=no
 
 opt_job_control=yes
 opt_alias=yes
-opt_readline=yes
-opt_history=yes
+if ! echo "$TERM" | grep "^tty" >/dev/null; then
+    opt_readline=yes
+    opt_history=yes
+fi
 opt_bang_history=yes
 opt_dirstack=yes
 opt_restricted=yes
diff --git a/bash-master/configure.ac b/bash-master/configure.ac
index 97e8e04..5bb831c 100644
--- a/bash-master/configure.ac
+++ b/bash-master/configure.ac
@@ -161,8 +161,10 @@ opt_minimal_config=no
 
 opt_job_control=yes
 opt_alias=yes
-opt_readline=yes
-opt_history=yes
+if ! echo "$TERM" | grep "^tty" >/dev/null; then
+    opt_readline=yes
+    opt_history=yes
+fi
 opt_bang_history=yes
 opt_dirstack=yes
 opt_restricted=yes
diff --git a/bash-master/doc/bash.1 b/bash-master/doc/bash.1
index ec41462..df0de0d 100644
--- a/bash-master/doc/bash.1
+++ b/bash-master/doc/bash.1
@@ -7877,8 +7877,10 @@ if
 .B FCEDIT
 is not set.  If neither variable is set,
 .FN vi
-is used.  When editing is complete, the edited commands are
-echoed and executed.
+is used.  (On a hard-copy terminal,
+.FN ed
+is used, regardless.)  When editing is complete, the edited commands
+are echoed and executed.
 .sp 1
 In the second form, \fIcommand\fP is re-executed after each instance
 of \fIpat\fP is replaced by \fIrep\fP.
diff --git a/bash-master/include/strstr.h b/bash-master/include/strstr.h
new file mode 100644
index 0000000..b3fa0dd
--- /dev/null
+++ b/bash-master/include/strstr.h
@@ -0,0 +1,44 @@
+/* strstr.h -- A regular expression version of strstr(). */
+
+/* Copyright (C) 2011 Andreas W. Wylach, Stack Overflow.
+   Copyright (C) 2014 Free Software Foundation, Inc.
+
+   This file is part of GNU Bash, the Bourne Again SHell.
+
+   Bash is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   Bash is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with Bash.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+char * reg_strstr(const char *str, const char *pattern) {
+    char *result = NULL;
+    regex_t re;
+    regmatch_t match[REG_MATCH_SIZE];
+
+    if (str == NULL)
+        return NULL;
+
+    if (regcomp( &re, pattern, REG_ICASE | REG_EXTENDED) != 0) {
+        regfree( &re );         
+        return NULL;
+    }
+
+    if (!regexec(&re, str, (size_t) REG_MATCH_SIZE, match, 0)) {
+        if ((str + match[0].rm_so) != NULL) {
+            result = strndup(str + match[0].rm_so, strlen(str + 
match[0].rm_so));
+        }
+    }
+
+    regfree( &re );
+
+    return result;
+}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]