Skip to content

Instantly share code, notes, and snippets.

@klange
Last active September 19, 2026 06:17
Show Gist options
  • Select an option

  • Save klange/00bdf8271abf58f50fcc40da37cd0745 to your computer and use it in GitHub Desktop.

Select an option

Save klange/00bdf8271abf58f50fcc40da37cd0745 to your computer and use it in GitHub Desktop.
toaru bash patch

Build with:

./configure bash_cv_getenv_redef=no bash_cv_getcwd_malloc=yes bash_cv_func_sigsetjmp=missing --without-bash-malloc --host=aarch64-unknown-toaru
diff -ur /tmp/bash-5.3/bashline.c ./bashline.c
--- /tmp/bash-5.3/bashline.c 2025-06-26 04:53:44
+++ ./bashline.c 2026-09-18 14:32:26
@@ -4142,7 +4142,7 @@
}
}
#else
- rl_point++:
+ rl_point++;
#endif
return point;
}
diff -ur /tmp/bash-5.3/builtins/printf.def ./builtins/printf.def
--- /tmp/bash-5.3/builtins/printf.def 2025-03-18 00:49:35
+++ ./builtins/printf.def 2026-09-18 14:43:13
@@ -355,7 +355,9 @@
garglist = orig_arglist = list->next;
+#if defined (HANDLE_MULTIBYTE)
mb_cur_max = MB_CUR_MAX;
+#endif
/* Basic algorithm is to scan the format string for conversion
specifications -- once one is found, find out if the field
@@ -1175,8 +1177,8 @@
static char *
bexpand (char *string, size_t len, int *sawc, size_t *lenp)
{
- int temp, c;
- char *ret, *r, *s, *send;
+ int temp;
+ char *ret, *r, *s, *send, c;
#if defined (HANDLE_MULTIBYTE)
char mbch[25];
int mbind, mblen;
diff -ur /tmp/bash-5.3/configure ./configure
--- /tmp/bash-5.3/configure 2025-06-30 23:05:30
+++ ./configure 2026-09-18 13:57:56
@@ -23143,6 +23143,7 @@
solaris2.9*) LOCAL_CFLAGS=-DSOLARIS ;;
solaris2.10*) LOCAL_CFLAGS=-DSOLARIS ;;
solaris2*) LOCAL_CFLAGS=-DSOLARIS ;;
+toaru*) LOCAL_LDFLAGS=-rdynamic ;;
lynxos*) LOCAL_CFLAGS=-DRECYCLES_PIDS ;;
linux*) LOCAL_LDFLAGS=-rdynamic # allow dynamic loading
case "`uname -r`" in
diff -ur /tmp/bash-5.3/execute_cmd.c ./execute_cmd.c
--- /tmp/bash-5.3/execute_cmd.c 2025-06-06 00:02:01
+++ ./execute_cmd.c 2026-09-18 14:31:51
@@ -2313,8 +2313,10 @@
return COPROC_DEAD;
else if (WIFSTOPPED (status))
return (COPROC_STOPPED|COPROC_RUNNING);
+#if defined(WIFCONTINUED)
else if (WIFCONTINUED (status))
return COPROC_RUNNING;
+#endif
else
return COPROC_DEAD; /* defaults to terminated */
}
diff -ur /tmp/bash-5.3/lib/glob/glob.c ./lib/glob/glob.c
--- /tmp/bash-5.3/lib/glob/glob.c 2023-07-21 00:28:53
+++ ./lib/glob/glob.c 2026-09-18 14:46:03
@@ -23,6 +23,7 @@
based on specifications for the pattern matching. --RMS. */
#include <config.h>
+#include <wchar.h>
#if !defined (__GNUC__) && !defined (HAVE_ALLOCA_H) && defined (_AIX)
#pragma alloca
diff -ur /tmp/bash-5.3/lib/glob/sm_loop.c ./lib/glob/sm_loop.c
--- /tmp/bash-5.3/lib/glob/sm_loop.c 2023-03-18 05:11:09
+++ ./lib/glob/sm_loop.c 2026-09-18 14:49:34
@@ -393,6 +393,10 @@
return NULL;
}
+#if !defined (HAVE_BCOPY)
+void bcopy(const void *src, void *dst, size_t len);
+#endif
+
/* Use prototype definition here because of type promotion. */
static CHAR *
BRACKMATCH (CHAR *p, U_CHAR test, int flags)
diff -ur /tmp/bash-5.3/lib/glob/smatch.c ./lib/glob/smatch.c
--- /tmp/bash-5.3/lib/glob/smatch.c 2023-05-30 03:15:17
+++ ./lib/glob/smatch.c 2026-09-18 14:47:30
@@ -20,6 +20,7 @@
*/
#include <config.h>
+#include <wchar.h>
#include <stdio.h> /* for debugging */
@@ -285,8 +286,10 @@
enum char_class char_class;
int result;
+#if HANDLE_MULTIBYTE
if (locale_utf8locale && UTF8_SINGLEBYTE (c) == 0)
return -1;
+#endif
char_class = is_valid_cclass (name);
if (char_class == CC_NO_CLASS)
@@ -298,10 +301,18 @@
/* Now include `sm_loop.c' for single-byte characters. */
/* The result of FOLD is an `unsigned char' */
+
+#if HANDLE_MULTIBYTE
# define FOLD(c) \
(((flags & FNM_CASEFOLD) && (locale_utf8locale == 0 || UTF8_SINGLEBYTE (c))) \
? TOLOWER ((unsigned char)c) \
: ((unsigned char)c))
+#else
+# define FOLD(c) \
+ ((flags & FNM_CASEFOLD) \
+ ? TOLOWER((unsigned char)c) \
+ : ((unsigned char)c))
+#endif
#if !defined (__CYGWIN__)
# define ISDIRSEP(c) ((c) == '/')
diff -ur /tmp/bash-5.3/lib/intl/dcigettext.c ./lib/intl/dcigettext.c
--- /tmp/bash-5.3/lib/intl/dcigettext.c 2023-07-14 00:17:00
+++ ./lib/intl/dcigettext.c 2026-09-18 14:01:19
@@ -138,7 +138,7 @@
# define tfind __tfind
#else
# if !defined HAVE_GETCWD
-char *getwd ();
+char *getwd (char*);
# define getcwd(buf, max) getwd (buf)
# else
# if VMS
diff -ur /tmp/bash-5.3/lib/readline/mbutil.c ./lib/readline/mbutil.c
--- /tmp/bash-5.3/lib/readline/mbutil.c 2024-08-14 23:57:57
+++ ./lib/readline/mbutil.c 2026-09-18 15:09:34
@@ -584,6 +584,7 @@
#endif
}
+#if HANDLE_MULTIBYTE
/* Compare the first N characters of S1 and S2 without regard to case. If
FLAGS&1, apply the mapping specified by completion-map-case and make
`-' and `_' equivalent. Returns 1 if the strings are equal. */
@@ -658,3 +659,4 @@
return 1;
return (wc1 == wc2);
}
+#endif
diff -ur /tmp/bash-5.3/lib/readline/terminal.c ./lib/readline/terminal.c
--- /tmp/bash-5.3/lib/readline/terminal.c 2025-06-12 00:05:41
+++ ./lib/readline/terminal.c 2026-09-18 15:13:01
@@ -104,7 +104,7 @@
/* Systems for which PC/BC/UP are defined in the curses library and need an
extern definition here. */
-#if !defined (__linux__) && !defined (__gnu_hurd__) && !defined (NCURSES_VERSION)
+#if !defined (__linux__) && !defined (__gnu_hurd__) && !defined (NCURSES_VERSION) && !defined(__toaru__)
# if defined (__EMX__) || defined (NEED_EXTERN_PC)
extern
# endif /* __EMX__ || NEED_EXTERN_PC */
diff -ur /tmp/bash-5.3/lib/sh/oslib.c ./lib/sh/oslib.c
--- /tmp/bash-5.3/lib/sh/oslib.c 2025-03-04 03:18:42
+++ ./lib/sh/oslib.c 2026-09-18 14:50:18
@@ -222,7 +222,7 @@
int
mkfifo (char *path, mode_t mode)
{
-#if defined (S_IFIFO)
+#if defined (S_IFIFO) && !defined(__toaru__)
return (mknod (path, (mode | S_IFIFO), 0));
#else /* !S_IFIFO */
return (-1);
diff -ur /tmp/bash-5.3/support/config.sub ./support/config.sub
--- /tmp/bash-5.3/support/config.sub 2024-12-13 23:06:05
+++ ./support/config.sub 2026-09-18 13:59:17
@@ -2118,6 +2118,7 @@
| sysv* \
| tenex* \
| tirtos* \
+ | toaru* \
| toppers* \
| tops10* \
| tops20* \
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment