Skip to content

Commit aafea63

Browse files
committed
bump: version 4.1.8
Signed-off-by: Andrés J. Díaz <ajdiaz@ajdiaz.me>
1 parent 8a7eb8d commit aafea63

File tree

2 files changed

+336
-3
lines changed

2 files changed

+336
-3
lines changed

patch/hack-5.1.8.diff

Lines changed: 333 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,333 @@
1+
--- shell.c.orig 2018-12-06 17:28:21.000000000 +0100
2+
+++ shell.c 2020-09-09 22:16:54.394352578 +0200
3+
@@ -369,6 +369,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+
@@ -457,61 +458,11 @@
12+
set_shell_name (argv[0]);
13+
shell_start_time = NOW; /* NOW now defined in general.h */
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 (dump_po_strings)
49+
- dump_translatable_strings = 1;
50+
-
51+
- if (dump_translatable_strings)
52+
- read_but_dont_execute = 1;
53+
-
54+
if (running_setuid && privileged_mode == 0)
55+
disable_priv_mode ();
56+
57+
- /* Need to get the argument to a -c option processed in the
58+
- above loop. The next arg is a command to execute, and the
59+
- following args are $0...$n respectively. */
60+
- if (want_pending_command)
61+
- {
62+
- command_execution_string = argv[arg_index];
63+
- if (command_execution_string == 0)
64+
- {
65+
- report_error (_("%s: option requires an argument"), "-c");
66+
- exit (EX_BADUSAGE);
67+
- }
68+
- arg_index++;
69+
- }
70+
this_command_name = (char *)NULL;
71+
72+
/* First, let the outside world know about our interactive status.
73+
@@ -522,7 +473,7 @@
74+
standard input is a terminal
75+
standard error is a terminal
76+
Refer to Posix.2, the description of the `sh' utility. */
77+
-
78+
+#if 0
79+
if (forced_interactive || /* -i flag */
80+
(!command_execution_string && /* No -c command and ... */
81+
wordexp_only == 0 && /* No --wordexp and ... */
82+
@@ -533,33 +484,8 @@
83+
init_interactive ();
84+
else
85+
init_noninteractive ();
86+
-
87+
- /*
88+
- * Some systems have the bad habit of starting login shells with lots of open
89+
- * file descriptors. For instance, most systems that have picked up the
90+
- * pre-4.0 Sun YP code leave a file descriptor open each time you call one
91+
- * of the getpw* functions, and it's set to be open across execs. That
92+
- * means one for login, one for xterm, one for shelltool, etc. There are
93+
- * also systems that open persistent FDs to other agents or files as part
94+
- * of process startup; these need to be set to be close-on-exec.
95+
- */
96+
- if (login_shell && interactive_shell)
97+
- {
98+
- for (i = 3; i < 20; i++)
99+
- SET_CLOSE_ON_EXEC (i);
100+
- }
101+
-
102+
- /* If we're in a strict Posix.2 mode, turn on interactive comments,
103+
- alias expansion in non-interactive shells, and other Posix.2 things. */
104+
- if (posixly_correct)
105+
- {
106+
- bind_variable ("POSIXLY_CORRECT", "y", 0);
107+
- sv_strict_posix ("POSIXLY_CORRECT");
108+
- }
109+
-
110+
- /* Now we run the shopt_alist and process the options. */
111+
- if (shopt_alist)
112+
- run_shopt_alist ();
113+
+#endif
114+
+ init_noninteractive();
115+
116+
/* From here on in, the shell must be a normal functioning shell.
117+
Variables from the environment are expected to be set, etc. */
118+
@@ -568,51 +494,6 @@
119+
set_default_lang ();
120+
set_default_locale_vars ();
121+
122+
- /*
123+
- * M-x term -> TERM=eterm-color INSIDE_EMACS='251,term:0.96' (eterm)
124+
- * M-x shell -> TERM='dumb' INSIDE_EMACS='25.1,comint' (no line editing)
125+
- *
126+
- * Older versions of Emacs may set EMACS to 't' or to something like
127+
- * '22.1 (term:0.96)' instead of (or in addition to) setting INSIDE_EMACS.
128+
- * They may set TERM to 'eterm' instead of 'eterm-color'. They may have
129+
- * a now-obsolete command that sets neither EMACS nor INSIDE_EMACS:
130+
- * M-x terminal -> TERM='emacs-em7955' (line editing)
131+
- */
132+
- if (interactive_shell)
133+
- {
134+
- char *term, *emacs, *inside_emacs;
135+
- int emacs_term, in_emacs;
136+
-
137+
- term = get_string_value ("TERM");
138+
- emacs = get_string_value ("EMACS");
139+
- inside_emacs = get_string_value ("INSIDE_EMACS");
140+
-
141+
- if (inside_emacs)
142+
- {
143+
- emacs_term = strstr (inside_emacs, ",term:") != 0;
144+
- in_emacs = 1;
145+
- }
146+
- else if (emacs)
147+
- {
148+
- /* Infer whether we are in an older Emacs. */
149+
- emacs_term = strstr (emacs, " (term:") != 0;
150+
- in_emacs = emacs_term || STREQ (emacs, "t");
151+
- }
152+
- else
153+
- in_emacs = emacs_term = 0;
154+
-
155+
- /* Not sure any emacs terminal emulator sets TERM=emacs any more */
156+
- no_line_editing |= STREQ (term, "emacs");
157+
- no_line_editing |= in_emacs && STREQ (term, "dumb");
158+
-
159+
- /* running_under_emacs == 2 for `eterm' */
160+
- running_under_emacs = in_emacs || STREQN (term, "emacs", 5);
161+
- running_under_emacs += emacs_term && STREQN (term, "eterm", 5);
162+
-
163+
- if (running_under_emacs)
164+
- gnu_error_format = 1;
165+
- }
166+
-
167+
top_level_arg_index = arg_index;
168+
old_errexit_flag = exit_immediately_on_error;
169+
170+
@@ -686,21 +567,15 @@
171+
arg_index = bind_args (argv, arg_index, argc, 1); /* $1 ... $n */
172+
173+
/* The startup files are run with `set -e' temporarily disabled. */
174+
- if (locally_skip_execution == 0 && running_setuid == 0)
175+
+ /*if (locally_skip_execution == 0 && running_setuid == 0)
176+
{
177+
old_errexit_flag = exit_immediately_on_error;
178+
exit_immediately_on_error = 0;
179+
180+
run_startup_files ();
181+
exit_immediately_on_error += old_errexit_flag;
182+
- }
183+
+ }*/
184+
185+
- /* If we are invoked as `sh', turn on Posix mode. */
186+
- if (act_like_sh)
187+
- {
188+
- bind_variable ("POSIXLY_CORRECT", "y", 0);
189+
- sv_strict_posix ("POSIXLY_CORRECT");
190+
- }
191+
192+
#if defined (RESTRICTED_SHELL)
193+
/* Turn on the restrictions after executing the startup files. This
194+
@@ -723,69 +598,14 @@
195+
cmd_init (); /* initialize the command object caches */
196+
uwp_init ();
197+
198+
- if (command_execution_string)
199+
- {
200+
- startup_state = 2;
201+
-
202+
- if (debugging_mode)
203+
- start_debugger ();
204+
-
205+
-#if defined (ONESHOT)
206+
- executing = 1;
207+
- run_one_command (command_execution_string);
208+
- exit_shell (last_command_exit_value);
209+
-#else /* ONESHOT */
210+
- with_input_from_string (command_execution_string, "-c");
211+
- goto read_and_execute;
212+
-#endif /* !ONESHOT */
213+
- }
214+
-
215+
/* Get possible input filename and set up default_buffered_input or
216+
default_input as appropriate. */
217+
- if (shell_script_filename)
218+
- open_shell_script (shell_script_filename);
219+
- else if (interactive == 0)
220+
- {
221+
- /* In this mode, bash is reading a script from stdin, which is a
222+
- pipe or redirected file. */
223+
-#if defined (BUFFERED_INPUT)
224+
- default_buffered_input = fileno (stdin); /* == 0 */
225+
-#else
226+
- setbuf (default_input, (char *)NULL);
227+
-#endif /* !BUFFERED_INPUT */
228+
- read_from_stdin = 1;
229+
- }
230+
- else if (top_level_arg_index == argc) /* arg index before startup files */
231+
- /* "If there are no operands and the -c option is not specified, the -s
232+
- option shall be assumed." */
233+
- read_from_stdin = 1;
234+
235+
+
236+
+ open_shell_script (argv[0]);
237+
set_bash_input ();
238+
239+
- if (debugging_mode && locally_skip_execution == 0 && running_setuid == 0 && (reading_shell_script || interactive_shell == 0))
240+
- start_debugger ();
241+
-
242+
- /* Do the things that should be done only for interactive shells. */
243+
- if (interactive_shell)
244+
- {
245+
- /* Set up for checking for presence of mail. */
246+
- reset_mail_timer ();
247+
- init_mail_dates ();
248+
-
249+
-#if defined (HISTORY)
250+
- /* Initialize the interactive history stuff. */
251+
- bash_initialize_history ();
252+
- /* Don't load the history from the history file if we've already
253+
- saved some lines in this session (e.g., by putting `history -s xx'
254+
- into one of the startup files). */
255+
- if (shell_initialized == 0 && history_lines_this_session == 0)
256+
- load_history ();
257+
-#endif /* HISTORY */
258+
-
259+
- /* Initialize terminal state for interactive shells after the
260+
- .bash_profile and .bashrc are interpreted. */
261+
- get_tty_state ();
262+
- }
263+
+ arg_index = bind_args (argv, 1, argc, 1);
264+
265+
#if !defined (ONESHOT)
266+
read_and_execute:
267+
@@ -1520,22 +1340,6 @@
268+
filename = savestring (script_name);
269+
270+
fd = open (filename, O_RDONLY);
271+
- if ((fd < 0) && (errno == ENOENT) && (absolute_program (filename) == 0))
272+
- {
273+
- e = errno;
274+
- /* If it's not in the current directory, try looking through PATH
275+
- for it. */
276+
- path_filename = find_path_file (script_name);
277+
- if (path_filename)
278+
- {
279+
- free (filename);
280+
- filename = path_filename;
281+
- fd = open (filename, O_RDONLY);
282+
- }
283+
- else
284+
- errno = e;
285+
- }
286+
-
287+
if (fd < 0)
288+
{
289+
e = errno;
290+
@@ -1592,6 +1396,8 @@
291+
/* Only do this with non-tty file descriptors we can seek on. */
292+
if (fd_is_tty == 0 && (lseek (fd, 0L, 1) != -1))
293+
{
294+
+ char buf[21];
295+
+ long long siz=0;
296+
/* Check to see if the `file' in `bash file' is a binary file
297+
according to the same tests done by execute_simple_command (),
298+
and report an error and exit if it is. */
299+
@@ -1618,16 +1424,24 @@
300+
#endif
301+
exit (EX_NOEXEC);
302+
}
303+
- else if (sample_len > 0 && (check_binary_file (sample, sample_len)))
304+
- {
305+
- internal_error (_("%s: cannot execute binary file"), filename);
306+
-#if defined (JOB_CONTROL)
307+
- end_job_control (); /* just in case we were run as bash -i script */
308+
-#endif
309+
- exit (EX_BINARY_FILE);
310+
- }
311+
- /* Now rewind the file back to the beginning. */
312+
- lseek (fd, 0L, 0);
313+
+ /*else if (sample_len > 0 && (check_binary_file (sample, sample_len)))
314+
+ {
315+
+ internal_error (_("%s: cannot execute binary file"), filename);
316+
+ exit (EX_BINARY_FILE);
317+
+ }*/
318+
+ lseek(fd, -20L, SEEK_END);
319+
+ if (read(fd, buf, 20) != 20) {
320+
+ internal_error(_("%s: unable to read size"), filename);
321+
+ exit (EX_BADUSAGE);
322+
+ }
323+
+ siz = atoll(buf);
324+
+ if (siz == 0) {
325+
+ internal_error(_("%s: unable to get script size"), filename);
326+
+ exit (EX_BADUSAGE);
327+
+ }
328+
+ lseek(fd, -21-siz, SEEK_END);
329+
+ /* Now rewind the file back to the beginning. */
330+
+ /*lseek (fd, 0L, 0);*/
331+
}
332+
333+
/* Open the script. But try to move the file descriptor to a randomly

scripts/build.sh

Lines changed: 3 additions & 3 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"
9-
bash_patch_level=4
8+
bash_version="5.1.8"
9+
bash_patch_level="0"
1010
musl_version="1.2.2"
1111

1212
platform=$(uname -s)
@@ -32,7 +32,7 @@ tar -xf bash-${bash_version}.tar.gz
3232
echo "= patching bash"
3333
bash_patch_prefix=$(echo "bash${bash_version}" | sed -e 's/\.//g')
3434
pushd bash-${bash_version} || exit 1
35-
for lvl in $(seq $bash_patch_level); do
35+
for lvl in $(seq "$bash_patch_level"); do
3636
curl -L "http://ftp.gnu.org/gnu/bash/bash-${bash_version}-patches/${bash_patch_prefix}-$(printf '%03d' "$lvl")" | patch -p0
3737
done
3838
patch -p0 < "../../patch/hack-${bash_version}.diff" || exit 1

0 commit comments

Comments
 (0)