Skip to content

Commit c1b9d5b

Browse files
committed
bump and fix: bash version to 5.2.15 and fix no file error in PATH (closes #2)
Signed-off-by: Andrés J. Díaz <ajdiaz@ajdiaz.me>
1 parent 17347d6 commit c1b9d5b

File tree

2 files changed

+359
-2
lines changed

2 files changed

+359
-2
lines changed

patch/hack-5.2.diff

Lines changed: 357 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,357 @@
1+
--- shell.c 2023-03-06 19:13:32.156646909 +0100
2+
+++ shell.c.orig 2023-03-06 19:15:25.839064720 +0100
3+
@@ -379,6 +379,7 @@
4+
#endif
5+
volatile int locally_skip_execution;
6+
volatile int arg_index, top_level_arg_index;
7+
+ char buf[21];
8+
#ifdef __OPENNT
9+
char **env;
10+
11+
@@ -469,37 +470,6 @@
12+
gettimeofday (&shellstart, 0);
13+
shell_start_time = shellstart.tv_sec;
14+
15+
- /* Parse argument flags from the input line. */
16+
-
17+
- /* Find full word arguments first. */
18+
- arg_index = parse_long_options (argv, arg_index, argc);
19+
-
20+
- if (want_initial_help)
21+
- {
22+
- show_shell_usage (stdout, 1);
23+
- exit (EXECUTION_SUCCESS);
24+
- }
25+
-
26+
- if (do_version)
27+
- {
28+
- show_shell_version (1);
29+
- exit (EXECUTION_SUCCESS);
30+
- }
31+
-
32+
- echo_input_at_read = verbose_flag; /* --verbose given */
33+
-
34+
- /* All done with full word options; do standard shell option parsing.*/
35+
- this_command_name = shell_name; /* for error reporting */
36+
- arg_index = parse_shell_options (argv, arg_index, argc);
37+
-
38+
- /* If user supplied the "--login" (or -l) flag, then set and invert
39+
- LOGIN_SHELL. */
40+
- if (make_login_shell)
41+
- {
42+
- login_shell++;
43+
- login_shell = -login_shell;
44+
- }
45+
-
46+
set_login_shell ("login_shell", login_shell != 0);
47+
48+
#if defined (TRANSLATABLE_STRINGS)
49+
@@ -513,19 +483,6 @@
50+
if (running_setuid && privileged_mode == 0)
51+
disable_priv_mode ();
52+
53+
- /* Need to get the argument to a -c option processed in the
54+
- above loop. The next arg is a command to execute, and the
55+
- following args are $0...$n respectively. */
56+
- if (want_pending_command)
57+
- {
58+
- command_execution_string = argv[arg_index];
59+
- if (command_execution_string == 0)
60+
- {
61+
- report_error (_("%s: option requires an argument"), "-c");
62+
- exit (EX_BADUSAGE);
63+
- }
64+
- arg_index++;
65+
- }
66+
this_command_name = (char *)NULL;
67+
68+
/* First, let the outside world know about our interactive status.
69+
@@ -536,7 +493,7 @@
70+
standard input is a terminal
71+
standard error is a terminal
72+
Refer to Posix.2, the description of the `sh' utility. */
73+
+#if 0
74+
-
75+
if (forced_interactive || /* -i flag */
76+
(!command_execution_string && /* No -c command and ... */
77+
wordexp_only == 0 && /* No --wordexp and ... */
78+
@@ -547,33 +504,8 @@
79+
init_interactive ();
80+
else
81+
init_noninteractive ();
82+
+#endif
83+
+ init_noninteractive();
84+
-
85+
- /*
86+
- * Some systems have the bad habit of starting login shells with lots of open
87+
- * file descriptors. For instance, most systems that have picked up the
88+
- * pre-4.0 Sun YP code leave a file descriptor open each time you call one
89+
- * of the getpw* functions, and it's set to be open across execs. That
90+
- * means one for login, one for xterm, one for shelltool, etc. There are
91+
- * also systems that open persistent FDs to other agents or files as part
92+
- * of process startup; these need to be set to be close-on-exec.
93+
- */
94+
- if (login_shell && interactive_shell)
95+
- {
96+
- for (i = 3; i < 20; i++)
97+
- SET_CLOSE_ON_EXEC (i);
98+
- }
99+
-
100+
- /* If we're in a strict Posix.2 mode, turn on interactive comments,
101+
- alias expansion in non-interactive shells, and other Posix.2 things. */
102+
- if (posixly_correct)
103+
- {
104+
- bind_variable ("POSIXLY_CORRECT", "y", 0);
105+
- sv_strict_posix ("POSIXLY_CORRECT");
106+
- }
107+
-
108+
- /* Now we run the shopt_alist and process the options. */
109+
- if (shopt_alist)
110+
- run_shopt_alist ();
111+
112+
/* From here on in, the shell must be a normal functioning shell.
113+
Variables from the environment are expected to be set, etc. */
114+
@@ -582,51 +514,6 @@
115+
set_default_lang ();
116+
set_default_locale_vars ();
117+
118+
- /*
119+
- * M-x term -> TERM=eterm-color INSIDE_EMACS='251,term:0.96' (eterm)
120+
- * M-x shell -> TERM='dumb' INSIDE_EMACS='25.1,comint' (no line editing)
121+
- *
122+
- * Older versions of Emacs may set EMACS to 't' or to something like
123+
- * '22.1 (term:0.96)' instead of (or in addition to) setting INSIDE_EMACS.
124+
- * They may set TERM to 'eterm' instead of 'eterm-color'. They may have
125+
- * a now-obsolete command that sets neither EMACS nor INSIDE_EMACS:
126+
- * M-x terminal -> TERM='emacs-em7955' (line editing)
127+
- */
128+
- if (interactive_shell)
129+
- {
130+
- char *term, *emacs, *inside_emacs;
131+
- int emacs_term, in_emacs;
132+
-
133+
- term = get_string_value ("TERM");
134+
- emacs = get_string_value ("EMACS");
135+
- inside_emacs = get_string_value ("INSIDE_EMACS");
136+
-
137+
- if (inside_emacs)
138+
- {
139+
- emacs_term = strstr (inside_emacs, ",term:") != 0;
140+
- in_emacs = 1;
141+
- }
142+
- else if (emacs)
143+
- {
144+
- /* Infer whether we are in an older Emacs. */
145+
- emacs_term = strstr (emacs, " (term:") != 0;
146+
- in_emacs = emacs_term || STREQ (emacs, "t");
147+
- }
148+
- else
149+
- in_emacs = emacs_term = 0;
150+
-
151+
- /* Not sure any emacs terminal emulator sets TERM=emacs any more */
152+
- no_line_editing |= STREQ (term, "emacs");
153+
- no_line_editing |= in_emacs && STREQ (term, "dumb");
154+
-
155+
- /* running_under_emacs == 2 for `eterm' */
156+
- running_under_emacs = in_emacs || STREQN (term, "emacs", 5);
157+
- running_under_emacs += emacs_term && STREQN (term, "eterm", 5);
158+
-
159+
- if (running_under_emacs)
160+
- gnu_error_format = 1;
161+
- }
162+
-
163+
top_level_arg_index = arg_index;
164+
old_errexit_flag = exit_immediately_on_error;
165+
166+
@@ -699,37 +586,6 @@
167+
else
168+
arg_index = bind_args (argv, arg_index, argc, 1); /* $1 ... $n */
169+
170+
- /* The startup files are run with `set -e' temporarily disabled. */
171+
- if (locally_skip_execution == 0 && running_setuid == 0)
172+
- {
173+
- char *t;
174+
-
175+
- old_errexit_flag = exit_immediately_on_error;
176+
- exit_immediately_on_error = 0;
177+
-
178+
- /* Temporarily set $0 while running startup files, then restore it so
179+
- we get better error messages when trying to open script files. */
180+
- if (shell_script_filename)
181+
- {
182+
- t = dollar_vars[0];
183+
- dollar_vars[0] = exec_argv0 ? savestring (exec_argv0) : savestring (shell_script_filename);
184+
- }
185+
- run_startup_files ();
186+
- if (shell_script_filename)
187+
- {
188+
- free (dollar_vars[0]);
189+
- dollar_vars[0] = t;
190+
- }
191+
- exit_immediately_on_error += old_errexit_flag;
192+
- }
193+
-
194+
- /* If we are invoked as `sh', turn on Posix mode. */
195+
- if (act_like_sh)
196+
- {
197+
- bind_variable ("POSIXLY_CORRECT", "y", 0);
198+
- sv_strict_posix ("POSIXLY_CORRECT");
199+
- }
200+
-
201+
#if defined (RESTRICTED_SHELL)
202+
/* Turn on the restrictions after executing the startup files. This
203+
means that `bash -r' or `set -r' invoked from a startup file will
204+
@@ -751,69 +607,14 @@
205+
cmd_init (); /* initialize the command object caches */
206+
uwp_init ();
207+
208+
- if (command_execution_string)
209+
- {
210+
- startup_state = 2;
211+
-
212+
- if (debugging_mode)
213+
- start_debugger ();
214+
-
215+
-#if defined (ONESHOT)
216+
- executing = 1;
217+
- run_one_command (command_execution_string);
218+
- exit_shell (last_command_exit_value);
219+
-#else /* ONESHOT */
220+
- with_input_from_string (command_execution_string, "-c");
221+
- goto read_and_execute;
222+
-#endif /* !ONESHOT */
223+
- }
224+
-
225+
/* Get possible input filename and set up default_buffered_input or
226+
default_input as appropriate. */
227+
- if (shell_script_filename)
228+
- open_shell_script (shell_script_filename);
229+
- else if (interactive == 0)
230+
- {
231+
- /* In this mode, bash is reading a script from stdin, which is a
232+
- pipe or redirected file. */
233+
-#if defined (BUFFERED_INPUT)
234+
- default_buffered_input = fileno (stdin); /* == 0 */
235+
-#else
236+
- setbuf (default_input, (char *)NULL);
237+
-#endif /* !BUFFERED_INPUT */
238+
- read_from_stdin = 1;
239+
- }
240+
- else if (top_level_arg_index == argc) /* arg index before startup files */
241+
- /* "If there are no operands and the -c option is not specified, the -s
242+
- option shall be assumed." */
243+
- read_from_stdin = 1;
244+
245+
+
246+
+ open_shell_script (argv[0]);
247+
set_bash_input ();
248+
249+
+ arg_index = bind_args (argv, 1, argc, 1);
250+
- if (debugging_mode && locally_skip_execution == 0 && running_setuid == 0 && (reading_shell_script || interactive_shell == 0))
251+
- start_debugger ();
252+
-
253+
- /* Do the things that should be done only for interactive shells. */
254+
- if (interactive_shell)
255+
- {
256+
- /* Set up for checking for presence of mail. */
257+
- reset_mail_timer ();
258+
- init_mail_dates ();
259+
-
260+
-#if defined (HISTORY)
261+
- /* Initialize the interactive history stuff. */
262+
- bash_initialize_history ();
263+
- /* Don't load the history from the history file if we've already
264+
- saved some lines in this session (e.g., by putting `history -s xx'
265+
- into one of the startup files). */
266+
- if (shell_initialized == 0 && history_lines_this_session == 0)
267+
- load_history ();
268+
-#endif /* HISTORY */
269+
-
270+
- /* Initialize terminal state for interactive shells after the
271+
- .bash_profile and .bashrc are interpreted. */
272+
- get_tty_state ();
273+
- }
274+
275+
#if !defined (ONESHOT)
276+
read_and_execute:
277+
@@ -1577,6 +1378,7 @@
278+
filename = savestring (script_name);
279+
280+
fd = open (filename, O_RDONLY);
281+
+
282+
if ((fd < 0) && (errno == ENOENT) && (absolute_program (filename) == 0))
283+
{
284+
e = errno;
285+
@@ -1649,6 +1451,8 @@
286+
/* Only do this with non-tty file descriptors we can seek on. */
287+
if (fd_is_tty == 0 && (lseek (fd, 0L, 1) != -1))
288+
{
289+
+ char buf[21];
290+
+ long long siz=0;
291+
/* Check to see if the `file' in `bash file' is a binary file
292+
according to the same tests done by execute_simple_command (),
293+
and report an error and exit if it is. */
294+
@@ -1661,7 +1465,7 @@
295+
#if defined (EISDIR)
296+
errno = EISDIR;
297+
file_error (filename);
298+
+#else
299+
-#else
300+
internal_error (_("%s: Is a directory"), filename);
301+
#endif
302+
}
303+
@@ -1675,16 +1479,24 @@
304+
#endif
305+
exit (EX_NOEXEC);
306+
}
307+
+ /*else if (sample_len > 0 && (check_binary_file (sample, sample_len)))
308+
+ {
309+
+ internal_error (_("%s: cannot execute binary file"), filename);
310+
+ exit (EX_BINARY_FILE);
311+
+ }*/
312+
+ lseek(fd, -20L, SEEK_END);
313+
+ if (read(fd, buf, 20) != 20) {
314+
+ internal_error(_("%s: unable to read size"), filename);
315+
+ exit (EX_BADUSAGE);
316+
+ }
317+
+ siz = atoll(buf);
318+
+ if (siz == 0) {
319+
+ internal_error(_("%s: unable to get script size"), filename);
320+
+ exit (EX_BADUSAGE);
321+
+ }
322+
+ lseek(fd, -21-siz, SEEK_END);
323+
+ /* Now rewind the file back to the beginning. */
324+
+ /*lseek (fd, 0L, 0);*/
325+
- else if (sample_len > 0 && (check_binary_file (sample, sample_len)))
326+
- {
327+
- internal_error (_("%s: cannot execute binary file"), filename);
328+
-#if defined (JOB_CONTROL)
329+
- end_job_control (); /* just in case we were run as bash -i script */
330+
-#endif
331+
- exit (EX_BINARY_FILE);
332+
- }
333+
- /* Now rewind the file back to the beginning. */
334+
- lseek (fd, 0L, 0);
335+
}
336+
337+
/* Open the script. But try to move the file descriptor to a randomly
338+
@@ -1783,7 +1595,7 @@
339+
}
340+
#endif /* !BUFFERED_INPUT */
341+
}
342+
+
343+
-
344+
345+
#if !defined (PROGRAM)
346+
# define PROGRAM "bash"
347+
--- configure.orig 2022-09-23 16:13:22.000000000 +0200
348+
+++ configure 2023-03-06 15:57:25.115512627 +0100
349+
@@ -20443,7 +20443,7 @@
350+
351+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_func_strtoimax" >&5
352+
printf "%s\n" "$bash_cv_func_strtoimax" >&6; }
353+
-if test $bash_cv_func_strtoimax = yes; then
354+
+if test $bash_cv_func_strtoimax = no; then
355+
case " $LIBOBJS " in
356+
*" strtoimax.$ac_objext "* ) ;;
357+
*) LIBOBJS="$LIBOBJS strtoimax.$ac_objext"

scripts/build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
#
66
# For Linux, also builds musl for truly static linking.
77

8-
bash_version="5.1.16"
9-
bash_patch_level="0"
8+
bash_version="5.2"
9+
bash_patch_level="15"
1010
musl_version="1.2.3"
1111

1212
platform=$(uname -s)

0 commit comments

Comments
 (0)