bug-bash
[Top][All Lists]
Advanced

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

Re: readline: How to unbind _all_ keys


From: Henning
Subject: Re: readline: How to unbind _all_ keys
Date: Fri, 24 May 2019 16:51:04 +0200
User-agent: Mozilla/5.0 (Windows NT 6.3; rv:56.0) Gecko/20100101 Thunderbird/56.0

On 22/05/2019 15:30, Chet Ramey wrote:

What error message did you get when trying to compile bash-5.0? I don't
have or use cygwin, so you'll probably have to go to the cygwin bash
maintainer, but we can at least try to point him in the right direction.


I tried to compile several times, but always failed with
builtins/set.def:

-------------------------
./mkbuiltins.exe -D . set.def
gcc -c -DHAVE_CONFIG_H -DSHELL -I. -I.. -I.. -I../include -I../lib -I. -DRECYCLES_PIDS -g -O2 -Wno-parentheses -Wno-format-security set.c || ( rm -f set.c ; exit 1 ) ./set.def:219:21: error: 'igncr' undeclared here (not in a function); did you mean 'signal'?
   { "igncr", '\0', &igncr, NULL, (setopt_get_func_t *)NULL },
                     ^~~~~
                     signal
./set.def: In function 'set_minus_o_option_maybe':
./set.def:504:28: warning: passing argument 1 of 'find_minus_o_option' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
   i = find_minus_o_option (option_name);
                            ^~~~~~~~~~~
./set.def:262:12: note: expected 'char *' but argument is of type 'const char *'
      char *name;
            ^~~~
./set.def:507:26: warning: passing argument 1 of 'sh_invalidoptname' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
       sh_invalidoptname (option_name);
                          ^~~~~~~~~~~
In file included from /usr/include/wchar.h:16,
                 from ../config-bot.h:144,
                 from ../config.h:1206,
                 from ./set.def:23:
common.h:94:36: note: expected 'char *' but argument is of type 'const char *'
 extern void sh_invalidoptname __P((char *));
                                    ^~~~~~
./set.def:514:48: warning: passing argument 2 of 'o_options[i].set_func' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
       SET_BINARY_O_OPTION_VALUE (i, on_or_off, option_name);
                                                ^~~~~~~~~~~
./set.def:257:63: note: in definition of macro 'SET_BINARY_O_OPTION_VALUE'
   ((o_options[i].set_func) ? (*o_options[i].set_func) (onoff, name) \
                                                               ^~~~
./set.def:514:48: note: expected 'char *' but argument is of type 'const char *'
       SET_BINARY_O_OPTION_VALUE (i, on_or_off, option_name);
                                                ^~~~~~~~~~~
./set.def:257:63: note: in definition of macro 'SET_BINARY_O_OPTION_VALUE'
   ((o_options[i].set_func) ? (*o_options[i].set_func) (onoff, name) \
                                                               ^~~~
./set.def:521:23: warning: passing argument 1 of 'sh_invalidoptname' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
    sh_invalidoptname (option_name);
                       ^~~~~~~~~~~
In file included from /usr/include/wchar.h:16,
                 from ../config-bot.h:144,
                 from ../config.h:1206,
                 from ./set.def:23:
common.h:94:36: note: expected 'char *' but argument is of type 'const char *'
 extern void sh_invalidoptname __P((char *));
                                    ^~~~~~
make[1]: *** [Makefile:119: set.o] Error 1
make[1]: Leaving directory '/usr/src/bash/5.0/bash-5.0/builtins'
make: *** [Makefile:733: builtins/libbuiltins.a] Error 1
-------------------------------

I think, the "'igncr' undeclared here" indicates that this is cygwin
related. As there is no bash-5.0 cygwin patch I reused the 4.4.12
one. It applied with rejects in builtins/set.def.

The relevant part of the cygwin patch is as follows:

--- origsrc/bash-4.4/builtins/set.def   2016-06-02 19:10:10.000000000 -0500
+++ src/bash-4.4/builtins/set.def       2017-01-27 12:22:17.633133400 -0600
@@ -56,6 +56,13 @@ extern int dont_save_function_defs;
 #if defined (READLINE)
 extern int no_line_editing;
 #endif /* READLINE */
+#ifdef __CYGWIN__
+extern int igncr;
+static int set_minus_o_option_maybe (int, const char *, int);
+#  define INTERACTIVE_ONLY ,1
+#else
+#  define INTERACTIVE_ONLY
+#endif

 $BUILTIN set
 $FUNCTION set_builtin
@@ -92,6 +99,9 @@ Options:
 #if defined (HISTORY)
           history      enable command history
 #endif
+#ifdef __CYGWIN__
+          igncr        on Cygwin, ignore \r in line endings
+#endif
           ignoreeof    the shell will not exit upon reading EOF
           interactive-comments
                        allow comments to appear in interactive commands
@@ -192,29 +202,39 @@ const struct {
   int *variable;
   setopt_set_func_t *set_func;
   setopt_get_func_t *get_func;
+#ifdef __CYGWIN__
+  /* Cygwin users have taken to exporting SHELLOPTS for the cygwin-specific
+     igncr. As a result, we want to ensure SHELLOPTS parsing does not turn
+     on interactive options when exported from an interactive shell, but
+ parse in a non-interactive setting, so as not to break POSIX /bin/sh */
+  int interactive_only;
+#endif
 } o_options[] = {
{ "allexport", 'a', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL },
 #if defined (BRACE_EXPANSION)
{ "braceexpand",'B', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL },
 #endif
 #if defined (READLINE)
-  { "emacs",     '\0', (int *)NULL, set_edit_mode, get_edit_mode },
+ { "emacs", '\0', (int *)NULL, set_edit_mode, get_edit_mode INTERACTIVE_ONLY },
 #endif
{ "errexit", 'e', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, { "errtrace", 'E', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, { "functrace", 'T', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, { "hashall", 'h', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL },
 #if defined (BANG_HISTORY)
- { "histexpand", 'H', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, + { "histexpand", 'H', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL INTERACTIVE_ONLY },
 #endif /* BANG_HISTORY */
 #if defined (HISTORY)
- { "history", '\0', &enable_history_list, bash_set_history, (setopt_get_func_t *)NULL }, + { "history", '\0', &enable_history_list, bash_set_history, (setopt_get_func_t *)NULL INTERACTIVE_ONLY },
+#endif
+#ifdef __CYGWIN__
+  { "igncr", '\0', &igncr, NULL, (setopt_get_func_t *)NULL },
 #endif
{ "ignoreeof", '\0', &ignoreeof, set_ignoreeof, (setopt_get_func_t *)NULL }, { "interactive-comments", '\0', &interactive_comments, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, { "keyword", 'k', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL },
 #if defined (JOB_CONTROL)
- { "monitor", 'm', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, + { "monitor", 'm', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL INTERACTIVE_ONLY },
 #endif
{ "noclobber", 'C', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, { "noexec", 'n', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL },
@@ -233,7 +253,7 @@ const struct {
{ "privileged", 'p', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, { "verbose", 'v', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL },
 #if defined (READLINE)
-  { "vi",        '\0', (int *)NULL, set_edit_mode, get_edit_mode },
+ { "vi", '\0', (int *)NULL, set_edit_mode, get_edit_mode INTERACTIVE_ONLY },
 #endif
{ "xtrace", 'x', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, {(char *)NULL, 0 , (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL },
@@ -455,6 +475,15 @@ int
 set_minus_o_option (on_or_off, option_name)
      int on_or_off;
      char *option_name;
+#ifdef __CYGWIN__
+{
+  /* See Cygwin comments above. */
+  return set_minus_o_option_maybe (on_or_off, option_name, 0);
+}
+static int
+set_minus_o_option_maybe (int on_or_off, const char *option_name,
+                          int avoid_interactive)
+#endif /* __CYGWIN__ */
 {
   register int i;

@@ -462,6 +491,10 @@ set_minus_o_option (on_or_off, option_na
     {
       if (STREQ (option_name, o_options[i].name))
        {
+#ifdef __CYGWIN__
+         if (o_options[i].interactive_only && avoid_interactive)
+           return EXECUTION_SUCCESS;
+#endif
          if (o_options[i].letter == 0)
            {
previous_option_value = GET_BINARY_O_OPTION_VALUE (i, o_options[i].name);
@@ -588,7 +621,11 @@ parse_shellopts (value)
   vptr = 0;
   while (vname = extract_colon_unit (value, &vptr))
     {
+#ifdef __CYGWIN__
+      set_minus_o_option_maybe (FLAG_ON, vname, !interactive_shell);
+#else
       set_minus_o_option (FLAG_ON, vname);
+#endif
       free (vname);
     }
 }
------------------------------

Several hunks applied, others could be applied manually. But the lines
where INTERACTIVE_ONLY was added, produced an error message like

        expected } before INTERACTIVE_ONLY

All this is of course far beyond my knowledge and I wouldn't mind you
asking me to be patient and wait for cygwin ...

Thanks for your efforts

Henning




reply via email to

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