mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-06-27 23:53:18 +02:00
commit bash-20080515 snapshot
This commit is contained in:
@@ -15783,3 +15783,54 @@ variables.c
|
||||
- when reading the initial environment, don't create variables with
|
||||
names that are not valid shell identifiers. Fixes bug reported by
|
||||
Stephane Chazleas <stephane_chazelas@yahoo.fr>
|
||||
|
||||
5/13
|
||||
----
|
||||
subst.c
|
||||
- fix string_quote_removal to gracefully handle the case where a
|
||||
backslash is the final character in the string (leaves the backslash
|
||||
in place). Fixes bug reported by Ian Robertson
|
||||
<iroberts@u.washington.edu>
|
||||
|
||||
5/16
|
||||
----
|
||||
support/checkbashisms
|
||||
- Perl script that purports to check for bash-specific features in a
|
||||
shell script. Lifted from Debian via ubuntu
|
||||
|
||||
5/20
|
||||
----
|
||||
lib/readline/display.c
|
||||
- in update_line, when deciding whether or not to adjust _rl_last_c_pos
|
||||
in a multibyte environment after printing the last line of a multiline
|
||||
prompt with invisible characters on the first and last lines, use
|
||||
the number of inivisible chars on the first line in the calculation
|
||||
deciding whether or not we're past the last invisible character and
|
||||
need to adjust the cursor position. Old code used the number of
|
||||
invisible chars on the last prompt line. Fixes bug reported by
|
||||
stuff@slinkp.com.
|
||||
- in update_line, when fixing _rl_last_c_pos after drawing the first
|
||||
line of the prompt, use the number of invisible chars on the first
|
||||
line as the offset, instead of the total number of invisible chars
|
||||
|
||||
5/21
|
||||
----
|
||||
variables.c
|
||||
- new function, reinit_special_variables(), a hook for special
|
||||
vars that need their hook functions called when they're unset as
|
||||
a result of the shell reinitializing itself to run a script
|
||||
|
||||
shell.c
|
||||
- shell_reinitialize now calls reinit_special_variables
|
||||
- shell_reinitialize now calls bashline_reset
|
||||
|
||||
variables.h
|
||||
- new extern declaration for reinit_special_variables
|
||||
|
||||
bashline.c
|
||||
- new function, bashline_reset(), called when the shell reinitializes
|
||||
in shell_reinitialize. Right now, just resets
|
||||
bash_readline_initialized to 0.
|
||||
|
||||
bashline.h
|
||||
- new extern declaration for bashline_reset()
|
||||
|
||||
@@ -15776,3 +15776,52 @@ execute_cmd.c
|
||||
executed by the `command' or `source/.' builtins if we are supposed
|
||||
to be ignoring the return value. This is like `eval'. Fixes bug
|
||||
reported by Hiroshi Fujishima <hirobo@tonteki.org>
|
||||
|
||||
5/10
|
||||
----
|
||||
variables.c
|
||||
- when reading the initial environment, don't create variables with
|
||||
names that are not valid shell identifiers. Fixes bug reported by
|
||||
Stephane Chazleas <stephane_chazelas@yahoo.fr>
|
||||
|
||||
5/13
|
||||
----
|
||||
subst.c
|
||||
- fix string_quote_removal to gracefully handle the case where a
|
||||
backslash is the final character in the string (leaves the backslash
|
||||
in place). Fixes bug reported by Ian Robertson
|
||||
<iroberts@u.washington.edu>
|
||||
|
||||
5/16
|
||||
----
|
||||
support/checkbashisms
|
||||
- Perl script that purports to check for bash-specific features in a
|
||||
shell script. Lifted from Debian via ubuntu
|
||||
|
||||
5/20
|
||||
----
|
||||
lib/readline/display.c
|
||||
- in update_line, when deciding whether or not to adjust _rl_last_c_pos
|
||||
in a multibyte environment after printing the last line of a multiline
|
||||
prompt with invisible characters on the first and last lines, use
|
||||
the number of inivisible chars on the first line in the calculation
|
||||
deciding whether or not we're past the last invisible character and
|
||||
need to adjust the cursor position. Old code used the number of
|
||||
invisible chars on the last prompt line. Fixes bug reported by
|
||||
stuff@slinkp.com.
|
||||
- in update_line, when fixing _rl_last_c_pos after drawing the first
|
||||
line of the prompt, use the number of invisible chars on the first
|
||||
line as the offset, instead of the total number of invisible chars
|
||||
|
||||
5/21
|
||||
----
|
||||
variables.c
|
||||
- new function, reinit_special_variables(), a hook for special
|
||||
vars that need their hook functions called when they're unset as
|
||||
a result of the shell reinitializing itself to run a script
|
||||
|
||||
shell.c
|
||||
- shell_reinitialize now calls reinit_special_variables
|
||||
|
||||
variables.h
|
||||
- new extern declaration for reinit_special_variables
|
||||
|
||||
@@ -498,6 +498,8 @@ po/hu.gmo f
|
||||
po/hu.po f
|
||||
po/ja.gmo f
|
||||
po/ja.po f
|
||||
po/lt.gmo f
|
||||
po/lt.po f
|
||||
po/nl.gmo f
|
||||
po/nl.po f
|
||||
po/pl.gmo f
|
||||
@@ -550,6 +552,7 @@ doc/fdl.texi f
|
||||
doc/fdl.txt f
|
||||
support/Makefile.in f
|
||||
support/bashversion.c f
|
||||
support/checkbashisms f 755
|
||||
support/config.guess f
|
||||
support/config.rpath f 755
|
||||
support/config.sub f
|
||||
|
||||
@@ -498,6 +498,8 @@ po/hu.gmo f
|
||||
po/hu.po f
|
||||
po/ja.gmo f
|
||||
po/ja.po f
|
||||
po/lt.gmo f
|
||||
po/lt.po f
|
||||
po/nl.gmo f
|
||||
po/nl.po f
|
||||
po/pl.gmo f
|
||||
@@ -806,7 +808,6 @@ tests/func.right f
|
||||
tests/func1.sub f
|
||||
tests/func2.sub f
|
||||
tests/func3.sub f
|
||||
tests/func4.sub f
|
||||
tests/getopts.tests f
|
||||
tests/getopts.right f
|
||||
tests/getopts1.sub f
|
||||
@@ -860,6 +861,7 @@ tests/new-exp3.sub f
|
||||
tests/new-exp4.sub f
|
||||
tests/new-exp5.sub f
|
||||
tests/new-exp6.sub f
|
||||
tests/new-exp7.sub f
|
||||
tests/new-exp.right f
|
||||
tests/nquote.tests f
|
||||
tests/nquote.right f
|
||||
|
||||
+1
-1
@@ -993,7 +993,7 @@ shell.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h arr
|
||||
shell.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
|
||||
shell.o: make_cmd.h subst.h sig.h pathnames.h externs.h
|
||||
shell.o: flags.h trap.h mailcheck.h builtins.h $(DEFSRC)/common.h
|
||||
shell.o: jobs.h siglist.h input.h execute_cmd.h findcmd.h bashhist.h
|
||||
shell.o: jobs.h siglist.h input.h execute_cmd.h findcmd.h bashhist.h bashline.h
|
||||
shell.o: ${GLOB_LIBSRC}/strmatch.h ${BASHINCDIR}/posixtime.h
|
||||
sig.o: config.h bashtypes.h
|
||||
sig.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
|
||||
|
||||
@@ -1076,6 +1076,14 @@ arrayfunc.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
|
||||
arrayfunc.o: make_cmd.h subst.h sig.h pathnames.h externs.h
|
||||
arrayfunc.o: $(DEFSRC)/common.h
|
||||
arrayfunc.o: ${BASHINCDIR}/shmbutil.h
|
||||
assoc.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
|
||||
assoc.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h
|
||||
assoc.o: command.h ${BASHINCDIR}/stdc.h error.h
|
||||
assoc.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h
|
||||
assoc.o: assoc.h hashlib.h
|
||||
assoc.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
|
||||
assoc.o: make_cmd.h subst.h sig.h pathnames.h externs.h
|
||||
assoc.o: $(DEFSRC)/common.h
|
||||
braces.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
|
||||
braces.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
|
||||
braces.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
|
||||
|
||||
+7
-1
@@ -331,7 +331,7 @@ enable_hostname_completion (on_or_off)
|
||||
free (rl_completer_word_break_characters);
|
||||
rl_completer_word_break_characters = nval;
|
||||
}
|
||||
|
||||
itrace("enable_hostname_completion: rl_completer_word_break_characters = %s", rl_completer_word_break_characters);
|
||||
return (old_value);
|
||||
}
|
||||
|
||||
@@ -513,6 +513,12 @@ initialize_readline ()
|
||||
bash_readline_initialized = 1;
|
||||
}
|
||||
|
||||
void
|
||||
bashline_reset ()
|
||||
{
|
||||
bash_readline_initialized = 0;
|
||||
}
|
||||
|
||||
/* On Sun systems at least, rl_attempted_completion_function can end up
|
||||
getting set to NULL, and rl_completion_entry_function set to do command
|
||||
word completion if Bash is interrupted while trying to complete a command
|
||||
|
||||
+2
-2
@@ -225,7 +225,7 @@ int no_empty_command_completion;
|
||||
int force_fignore = 1;
|
||||
|
||||
/* Perform spelling correction on directory names during word completion */
|
||||
int dircomplete_spelling = 1;
|
||||
int dircomplete_spelling = 0;
|
||||
|
||||
static char *bash_completer_word_break_characters = " \t\n\"'@><=;|&(:";
|
||||
static char *bash_nohostname_word_break_characters = " \t\n\"'><=;|&(:";
|
||||
@@ -331,7 +331,7 @@ enable_hostname_completion (on_or_off)
|
||||
free (rl_completer_word_break_characters);
|
||||
rl_completer_word_break_characters = nval;
|
||||
}
|
||||
|
||||
itrace("enable_hostname_completion: rl_completer_word_break_characters = %s", rl_completer_word_break_characters);
|
||||
return (old_value);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ extern int bash_readline_initialized;
|
||||
extern void posix_readline_initialize __P((int));
|
||||
extern int enable_hostname_completion __P((int));
|
||||
extern void initialize_readline __P((void));
|
||||
extern void bashline_reset __P((void));
|
||||
extern void bashline_reinitialize __P((void));
|
||||
extern int bash_re_edit __P((char *));
|
||||
|
||||
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/* bashline.h -- interface to the bash readline functions in bashline.c. */
|
||||
|
||||
/* Copyright (C) 1993 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 2, 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; see the file COPYING. If not, write to the Free Software
|
||||
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
|
||||
#if !defined (_BASHLINE_H_)
|
||||
#define _BASHLINE_H_
|
||||
|
||||
#include "stdc.h"
|
||||
|
||||
extern int bash_readline_initialized;
|
||||
|
||||
extern void posix_readline_initialize __P((int));
|
||||
extern int enable_hostname_completion __P((int));
|
||||
extern void initialize_readline __P((void));
|
||||
extern void bashline_reinitialize __P((void));
|
||||
extern int bash_re_edit __P((char *));
|
||||
|
||||
extern int bind_keyseq_to_unix_command __P((char *));
|
||||
|
||||
extern char **bash_default_completion __P((const char *, int, int, int, int));
|
||||
|
||||
/* Used by programmable completion code. */
|
||||
extern char *command_word_completion_function __P((const char *, int));
|
||||
extern char *bash_groupname_completion_function __P((const char *, int));
|
||||
extern char *bash_servicename_completion_function __P((const char *, int));
|
||||
|
||||
extern char **get_hostname_list __P((void));
|
||||
extern void clear_hostname_list __P((void));
|
||||
|
||||
extern char **bash_directory_completion_matches __P((const char *));
|
||||
extern char *bash_dequote_text __P((const char *));
|
||||
|
||||
#endif /* _BASHLINE_H_ */
|
||||
+2
-2
@@ -30,7 +30,7 @@ Exit a FOR, WHILE or UNTIL loop. If N is specified, break N enclosing
|
||||
loops.
|
||||
|
||||
Exit Status:
|
||||
The exit status is 0 unless the shell is not executing a loop.
|
||||
The exit status is 0 unless N is not greater than or equal to 1.
|
||||
$END
|
||||
#include <config.h>
|
||||
|
||||
@@ -97,7 +97,7 @@ Resumes the next iteration of the enclosing FOR, WHILE or UNTIL loop.
|
||||
If N is specified, resumes the Nth enclosing loop.
|
||||
|
||||
Exit Status:
|
||||
The exit status is 0 unless the shell is not executing a loop.
|
||||
The exit status is 0 unless N is not greater than or equal to 1.
|
||||
$END
|
||||
|
||||
/* Set up to continue x levels, where x defaults to 1, but can be specified
|
||||
|
||||
@@ -28,6 +28,9 @@ Exit for, while, or until loops.
|
||||
|
||||
Exit a FOR, WHILE or UNTIL loop. If N is specified, break N enclosing
|
||||
loops.
|
||||
|
||||
Exit Status:
|
||||
The exit status is 0 unless N is not greater than or equal to 1.
|
||||
$END
|
||||
#include <config.h>
|
||||
|
||||
@@ -92,6 +95,9 @@ Resume for, while, or until loops.
|
||||
|
||||
Resumes the next iteration of the enclosing FOR, WHILE or UNTIL loop.
|
||||
If N is specified, resumes the Nth enclosing loop.
|
||||
|
||||
Exit Status:
|
||||
The exit status is 0 unless the shell is not executing a loop.
|
||||
$END
|
||||
|
||||
/* Set up to continue x levels, where x defaults to 1, but can be specified
|
||||
|
||||
+4
-8
@@ -6193,10 +6193,8 @@ loop. If \fIn\fP is specified, break \fIn\fP levels.
|
||||
must be \(>= 1. If
|
||||
.I n
|
||||
is greater than the number of enclosing loops, all enclosing loops
|
||||
are exited. The return value is 0 unless the shell is not executing
|
||||
a loop when
|
||||
.B break
|
||||
is executed.
|
||||
are exited.
|
||||
The return value is 0 unless \fIn\fP is not greater than or equal to 1.
|
||||
.TP
|
||||
\fBbuiltin\fP \fIshell\-builtin\fP [\fIarguments\fP]
|
||||
Execute the specified shell builtin, passing it
|
||||
@@ -6552,10 +6550,8 @@ is specified, resume at the \fIn\fPth enclosing loop.
|
||||
must be \(>= 1. If
|
||||
.I n
|
||||
is greater than the number of enclosing loops, the last enclosing loop
|
||||
(the ``top-level'' loop) is resumed. The return value is 0 unless the
|
||||
shell is not executing a loop when
|
||||
.B continue
|
||||
is executed.
|
||||
(the ``top-level'' loop) is resumed.
|
||||
The return value is 0 unless \fIn\fP is not greater than or equal to 1.
|
||||
.TP
|
||||
\fBdeclare\fP [\fB\-afFirtx\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...]
|
||||
.PD 0
|
||||
|
||||
@@ -4793,6 +4793,12 @@ to display a screenful of possible completions at a time.
|
||||
.B print\-completions\-horizontally (Off)
|
||||
If set to \fBOn\fP, readline will display completions with matches
|
||||
sorted horizontally in alphabetical order, rather than down the screen.
|
||||
.TP
|
||||
.B revert\-all\-at\-newline (Off)
|
||||
If set to \fBon\fP, readline will undo all changes to history lines
|
||||
before returning when \fBaccept\-line\fP is executed. By default,
|
||||
history lines may be modified and retain individual undo lists across
|
||||
calls to \fBreadline\fP.
|
||||
.TP
|
||||
.B show\-all\-if\-ambiguous (Off)
|
||||
This alters the default behavior of the completion functions. If
|
||||
|
||||
@@ -682,7 +682,7 @@ rl_redisplay ()
|
||||
prompts that exceed two physical lines?
|
||||
Additional logic fix from Edward Catmur <ed@catmur.co.uk> */
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0 && prompt_multibyte_chars > 0)
|
||||
{
|
||||
n0 = num;
|
||||
temp = local_prompt_len;
|
||||
@@ -713,7 +713,7 @@ rl_redisplay ()
|
||||
|
||||
inv_lbreaks[++newlines] = temp;
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0 && prompt_multibyte_chars > 0)
|
||||
lpos -= _rl_col_width (local_prompt, n0, num);
|
||||
else
|
||||
#endif
|
||||
@@ -985,13 +985,17 @@ rl_redisplay ()
|
||||
_rl_last_c_pos != o_cpos &&
|
||||
_rl_last_c_pos > wrap_offset &&
|
||||
o_cpos < prompt_last_invisible)
|
||||
_rl_last_c_pos -= wrap_offset;
|
||||
_rl_last_c_pos -= prompt_invis_chars_first_line; /* XXX - was wrap_offset */
|
||||
|
||||
else if (linenum == prompt_last_screen_line && prompt_physical_chars > _rl_screenwidth &&
|
||||
(MB_CUR_MAX > 1 && rl_byte_oriented == 0) &&
|
||||
cpos_adjusted == 0 &&
|
||||
_rl_last_c_pos != o_cpos &&
|
||||
#if 0
|
||||
_rl_last_c_pos > (prompt_last_invisible - _rl_screenwidth - (wrap_offset-prompt_invis_chars_first_line)))
|
||||
#else
|
||||
_rl_last_c_pos > (prompt_last_invisible - _rl_screenwidth - prompt_invis_chars_first_line))
|
||||
#endif
|
||||
_rl_last_c_pos -= (wrap_offset-prompt_invis_chars_first_line);
|
||||
|
||||
/* If this is the line with the prompt, we might need to
|
||||
|
||||
+16
-6
@@ -506,9 +506,13 @@ rl_redisplay ()
|
||||
int _rl_wrapped_multicolumn = 0;
|
||||
#endif
|
||||
|
||||
if (!readline_echoing_p)
|
||||
if (_rl_echoing_p == 0)
|
||||
return;
|
||||
|
||||
/* Block keyboard interrupts because this function manipulates global
|
||||
data structures. */
|
||||
_rl_block_sigint ();
|
||||
|
||||
if (!rl_display_prompt)
|
||||
rl_display_prompt = "";
|
||||
|
||||
@@ -678,7 +682,7 @@ rl_redisplay ()
|
||||
prompts that exceed two physical lines?
|
||||
Additional logic fix from Edward Catmur <ed@catmur.co.uk> */
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0 && prompt_multibyte_chars > 0)
|
||||
{
|
||||
n0 = num;
|
||||
temp = local_prompt_len;
|
||||
@@ -709,7 +713,7 @@ rl_redisplay ()
|
||||
|
||||
inv_lbreaks[++newlines] = temp;
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0 && prompt_multibyte_chars > 0)
|
||||
lpos -= _rl_col_width (local_prompt, n0, num);
|
||||
else
|
||||
#endif
|
||||
@@ -981,13 +985,17 @@ rl_redisplay ()
|
||||
_rl_last_c_pos != o_cpos &&
|
||||
_rl_last_c_pos > wrap_offset &&
|
||||
o_cpos < prompt_last_invisible)
|
||||
_rl_last_c_pos -= wrap_offset;
|
||||
_rl_last_c_pos -= prompt_invis_chars_first_line; /* XXX - was wrap_offset */
|
||||
|
||||
else if (linenum == prompt_last_screen_line && prompt_physical_chars > _rl_screenwidth &&
|
||||
(MB_CUR_MAX > 1 && rl_byte_oriented == 0) &&
|
||||
cpos_adjusted == 0 &&
|
||||
_rl_last_c_pos != o_cpos &&
|
||||
_rl_last_c_pos > (prompt_last_invisible - _rl_screenwidth - (wrap_offset-prompt_invis_chars_first_line)))
|
||||
#if 0
|
||||
_rl_last_c_pos > (prompt_last_invisible - _rl_screenwidth - (wrap_offset-prompt_invis_chars_first_line)))
|
||||
#else
|
||||
_rl_last_c_pos > (prompt_last_invisible - _rl_screenwidth - prompt_invis_chars_first_line))
|
||||
#endif
|
||||
_rl_last_c_pos -= (wrap_offset-prompt_invis_chars_first_line);
|
||||
|
||||
/* If this is the line with the prompt, we might need to
|
||||
@@ -1233,6 +1241,8 @@ rl_redisplay ()
|
||||
else
|
||||
visible_wrap_offset = wrap_offset;
|
||||
}
|
||||
|
||||
_rl_release_sigint ();
|
||||
}
|
||||
|
||||
/* PWP: update_line() is based on finding the middle difference of each
|
||||
@@ -2458,7 +2468,7 @@ _rl_redisplay_after_sigwinch ()
|
||||
void
|
||||
_rl_clean_up_for_exit ()
|
||||
{
|
||||
if (readline_echoing_p)
|
||||
if (_rl_echoing_p)
|
||||
{
|
||||
_rl_move_vert (_rl_vis_botlin);
|
||||
_rl_vis_botlin = 0;
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
# Set of available languages.
|
||||
en@quot en@boldquot af bg ca de eo es et fr hu ja nl pl pt_BR ro ru sk sv tr vi
|
||||
en@quot en@boldquot af bg ca de eo es et fr hu ja lt nl pl pt_BR ro ru sk sv tr vi
|
||||
|
||||
@@ -71,6 +71,10 @@
|
||||
# include <readline/history.h>
|
||||
#endif
|
||||
|
||||
#if defined (READLINE)
|
||||
# include "bashline.h"
|
||||
#endif
|
||||
|
||||
#include <tilde/tilde.h>
|
||||
#include <glob/strmatch.h>
|
||||
|
||||
@@ -1740,6 +1744,12 @@ shell_reinitialize ()
|
||||
delete_all_contexts (shell_variables);
|
||||
delete_all_variables (shell_functions);
|
||||
|
||||
reinit_special_variables ();
|
||||
|
||||
#if defined (READLINE)
|
||||
bashline_reset ();
|
||||
#endif
|
||||
|
||||
shell_reinitialized = 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -71,6 +71,10 @@
|
||||
# include <readline/history.h>
|
||||
#endif
|
||||
|
||||
#if defined (READLINE)
|
||||
# include "bashline.h"
|
||||
#endif
|
||||
|
||||
#include <tilde/tilde.h>
|
||||
#include <glob/strmatch.h>
|
||||
|
||||
@@ -185,9 +189,6 @@ int have_devfd = HAVE_DEV_FD;
|
||||
int have_devfd = 0;
|
||||
#endif
|
||||
|
||||
/* If == 31, shell compatible with bash-3.1, = =32 with bash-3.2, and so on */
|
||||
int shell_compatibility_level = DEFAULT_COMPAT_LEVEL;
|
||||
|
||||
/* The name of the .(shell)rc file. */
|
||||
static char *bashrc_file = "~/.bashrc";
|
||||
|
||||
@@ -1743,6 +1744,12 @@ shell_reinitialize ()
|
||||
delete_all_contexts (shell_variables);
|
||||
delete_all_variables (shell_functions);
|
||||
|
||||
reinit_special_variables ();
|
||||
|
||||
#if defined (READLINE)
|
||||
bash_readline_initialized = 0;
|
||||
#endif
|
||||
|
||||
shell_reinitialized = 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -7581,6 +7581,11 @@ string_quote_removal (string, quoted)
|
||||
{
|
||||
case '\\':
|
||||
c = string[++sindex];
|
||||
if (c == 0)
|
||||
{
|
||||
*r++ = '\\';
|
||||
break;
|
||||
}
|
||||
if (((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) || dquote) && (sh_syntaxtab[c] & CBSDQUOTE) == 0)
|
||||
*r++ = '\\';
|
||||
/* FALLTHROUGH */
|
||||
|
||||
Executable
+172
@@ -0,0 +1,172 @@
|
||||
#! /usr/bin/perl -w
|
||||
|
||||
# This script is essentially copied from /usr/share/lintian/checks/scripts,
|
||||
# which is:
|
||||
# Copyright (C) 1998 Richard Braakman
|
||||
# Copyright (C) 2002 Josip Rodin
|
||||
# This version is
|
||||
# Copyright (C) 2003 Julian Gilbey
|
||||
#
|
||||
# This program 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 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program 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 this program. If not, you can find it on the World Wide
|
||||
# Web at http://www.gnu.org/copyleft/gpl.html, or write to the Free
|
||||
# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
||||
# MA 02111-1307, USA.
|
||||
|
||||
use strict;
|
||||
|
||||
(my $progname = $0) =~ s|.*/||;
|
||||
|
||||
my $usage = <<"EOF";
|
||||
Usage: $progname [-n] script ...
|
||||
or: $progname --help
|
||||
or: $progname --version
|
||||
This script performs basic checks for the presence of bashisms
|
||||
in /bin/sh scripts.
|
||||
EOF
|
||||
|
||||
my $version = <<"EOF";
|
||||
This is $progname, from the Debian devscripts package, version 2.10.7ubuntu5
|
||||
This code is copyright 2003 by Julian Gilbey <jdg\@debian.org>,
|
||||
based on original code which is copyright 1998 by Richard Braakman
|
||||
and copyright 2002 by Josip Rodin.
|
||||
This program comes with ABSOLUTELY NO WARRANTY.
|
||||
You are free to redistribute this code under the terms of the
|
||||
GNU General Public License, version 2, or (at your option) any later version.
|
||||
EOF
|
||||
|
||||
my $opt_echo = 0;
|
||||
|
||||
##
|
||||
## handle command-line options
|
||||
##
|
||||
if (int(@ARGV) == 0 or $ARGV[0] =~ /^(--help|-h)$/) { print $usage; exit 0; }
|
||||
if (@ARGV and $ARGV[0] =~ /^(--version|-v)$/) { print $version; exit 0; }
|
||||
if (@ARGV and $ARGV[0] =~ /^(--newline|-n)$/) { $opt_echo = 1; }
|
||||
|
||||
|
||||
my $status = 0;
|
||||
|
||||
foreach my $filename (@ARGV) {
|
||||
if ($filename eq '-n' or $filename eq '--newline') {
|
||||
next;
|
||||
}
|
||||
unless (open C, "$filename") {
|
||||
warn "cannot open script $filename for reading: $!\n";
|
||||
$status |= 2;
|
||||
next;
|
||||
}
|
||||
|
||||
my $cat_string = "";
|
||||
|
||||
while (<C>) {
|
||||
if ($. == 1) { # This should be an interpreter line
|
||||
if (m,^\#!\s*(\S+),) {
|
||||
my $interpreter = $1;
|
||||
if ($interpreter =~ m,/bash$,) {
|
||||
warn "script $filename is already a bash script; skipping\n";
|
||||
$status |= 2;
|
||||
last; # end this file
|
||||
}
|
||||
elsif ($interpreter !~ m,/(sh|ash|dash)$,) {
|
||||
warn "script $filename does not appear to be a /bin/sh script; skipping\n";
|
||||
$status |= 2;
|
||||
last;
|
||||
}
|
||||
} else {
|
||||
warn "script $filename does not appear to have a \#! interpreter line;\nyou may get strange results\n";
|
||||
}
|
||||
}
|
||||
|
||||
next if m,^\s*\#,; # skip comment lines
|
||||
chomp;
|
||||
my $orig_line = $_;
|
||||
|
||||
s/(?<!\\)\#.*$//; # eat comments
|
||||
|
||||
if (m/(?:^|\s+)cat\s*\<\<\s*(\w+)/) {
|
||||
$cat_string = $1;
|
||||
}
|
||||
elsif ($cat_string ne "" and m/^$cat_string/) {
|
||||
$cat_string = "";
|
||||
}
|
||||
my $within_another_shell = 0;
|
||||
if (m,(^|\s+)((/usr)?/bin/)?((b|d)?a|k|z|t?c)sh\s+-c\s*.+,) {
|
||||
$within_another_shell = 1;
|
||||
}
|
||||
# if cat_string is set, we are in a HERE document and need not
|
||||
# check for things
|
||||
if ($cat_string eq "" and !$within_another_shell) {
|
||||
my $found = 0;
|
||||
my $match = '';
|
||||
my $explanation = '';
|
||||
my %bashisms = (
|
||||
'(?:^|\s+)function\s+\w+' => q<'function' is useless>,
|
||||
'(?:^|\s+)select\s+\w+' => q<'select' is not POSIX>,
|
||||
'(?:^|\s+)source\s+(?:\.\/|\/|\$)[^\s]+' =>
|
||||
q<should be '.', not 'source'>,
|
||||
'(\[|test|-o|-a)\s*[^\s]+\s+==\s' =>
|
||||
q<should be 'b = a'>,
|
||||
'\s\|\&' => q<pipelining is not POSIX>,
|
||||
'\$\[\w+\]' => q<arithmetic not allowed>,
|
||||
'\$\{\w+\:\d+(?::\d+)?\}' => q<${foo:3[:1]}>,
|
||||
'\$\{!\w+[@*]\}' => q<${!prefix[*|@]>,
|
||||
'\$\{!\w+\}' => q<${!name}>,
|
||||
'\$\{\w+(/.+?){1,2}\}' => q<${parm/?/pat[/str]}>,
|
||||
'[^\\\]\{([^\s]+?,)+[^\\\}\s]+\}' =>
|
||||
q<brace expansion>,
|
||||
'(?:^|\s+)\w+\[\d+\]=' => q<bash arrays, H[0]>,
|
||||
'\$\{\#?\w+\[[0-9\*\@]+\]\}' => q<bash arrays, ${name[0|*|@]}>,
|
||||
'(?:^|\s+)(read\s*(?:;|$))' => q<read without variable>,
|
||||
'\$\(\([A-Za-z]' => q<cnt=$((cnt + 1)) does not work in dash>,
|
||||
'echo\s+-[e]' => q<echo -e>,
|
||||
'exec\s+-[acl]' => q<exec -c/-l/-a name>,
|
||||
'\blet\s' => q<let ...>,
|
||||
'\$RANDOM\b' => q<$RANDOM>,
|
||||
'(?<!\$)\(\(' => q<'((' should be '$(('>,
|
||||
);
|
||||
|
||||
if ($opt_echo) {
|
||||
$bashisms{'echo\s+-[n]'} = 'q<echo -n>';
|
||||
}
|
||||
|
||||
while (my ($re,$expl) = each %bashisms) {
|
||||
if (m/($re)/) {
|
||||
$found = 1;
|
||||
$match = $1;
|
||||
$explanation = $expl;
|
||||
last;
|
||||
}
|
||||
}
|
||||
# since this test is ugly, I have to do it by itself
|
||||
# detect source (.) trying to pass args to the command it runs
|
||||
if (not $found and m/^\s*(\.\s+[^\s]+\s+([^\s]+))/) {
|
||||
if ($2 eq '&&' || $2 eq '||') {
|
||||
# everything is ok
|
||||
;
|
||||
} else {
|
||||
$found = 1;
|
||||
$match = $1;
|
||||
}
|
||||
}
|
||||
unless ($found == 0) {
|
||||
warn "possible bashism in $filename line $. ($explanation):\n$orig_line\n";
|
||||
$status |= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
close C;
|
||||
}
|
||||
|
||||
exit $status;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
BUILD_DIR=/usr/local/build/bash/bash-current
|
||||
BUILD_DIR=/usr/local/build/chet/bash/bash-current
|
||||
THIS_SH=$BUILD_DIR/bash
|
||||
PATH=$PATH:$BUILD_DIR
|
||||
|
||||
|
||||
+14
@@ -1366,6 +1366,7 @@ get_comp_wordbreaks (var)
|
||||
if (rl_completer_word_break_characters == 0 && bash_readline_initialized == 0)
|
||||
enable_hostname_completion (perform_hostname_completion);
|
||||
|
||||
itrace("get: rl_completer_word_break_characters = `%s'", rl_completer_word_break_characters);
|
||||
var_setvalue (var, rl_completer_word_break_characters);
|
||||
|
||||
return (var);
|
||||
@@ -1384,6 +1385,7 @@ assign_comp_wordbreaks (self, value, unused)
|
||||
free (rl_completer_word_break_characters);
|
||||
|
||||
rl_completer_word_break_characters = savestring (value);
|
||||
itrace("assign: rl_completer_word_break_characters = `%s'", rl_completer_word_break_characters);
|
||||
return self;
|
||||
}
|
||||
#endif /* READLINE */
|
||||
@@ -3924,6 +3926,18 @@ stupidly_hack_special_variables (name)
|
||||
(*(special_vars[i].function)) (name);
|
||||
}
|
||||
|
||||
/* Special variables that need hooks to be run when they are unset as part
|
||||
of shell reinitialization should have their sv_ functions run here. */
|
||||
void
|
||||
reinit_special_variables ()
|
||||
{
|
||||
#if defined (READLINE)
|
||||
sv_comp_wordbreaks ("COMP_WORDBREAKS");
|
||||
#endif
|
||||
sv_globignore ("GLOBIGNORE");
|
||||
sv_opterr ("OPTERR");
|
||||
}
|
||||
|
||||
void
|
||||
sv_ifs (name)
|
||||
char *name;
|
||||
|
||||
+2
-2
@@ -362,8 +362,6 @@ initialize_shell_variables (env, privmode)
|
||||
VSETATTR (temp_var, (att_exported | att_imported));
|
||||
array_needs_making = 1;
|
||||
}
|
||||
else
|
||||
internal_error (_("`%s': not a valid identifier"), name);
|
||||
|
||||
name[char_index] = '=';
|
||||
/* temp_var can be NULL if it was an exported function with a syntax
|
||||
@@ -1368,6 +1366,7 @@ get_comp_wordbreaks (var)
|
||||
if (rl_completer_word_break_characters == 0 && bash_readline_initialized == 0)
|
||||
enable_hostname_completion (perform_hostname_completion);
|
||||
|
||||
itrace("get: rl_completer_word_break_characters = `%s'", rl_completer_word_break_characters);
|
||||
var_setvalue (var, rl_completer_word_break_characters);
|
||||
|
||||
return (var);
|
||||
@@ -1386,6 +1385,7 @@ assign_comp_wordbreaks (self, value, unused)
|
||||
free (rl_completer_word_break_characters);
|
||||
|
||||
rl_completer_word_break_characters = savestring (value);
|
||||
itrace("assign: rl_completer_word_break_characters = `%s'", rl_completer_word_break_characters);
|
||||
return self;
|
||||
}
|
||||
#endif /* READLINE */
|
||||
|
||||
@@ -325,6 +325,10 @@ extern void set_pipestatus_from_exit __P((int));
|
||||
is one of the special ones where something special happens. */
|
||||
extern void stupidly_hack_special_variables __P((char *));
|
||||
|
||||
/* Reinitialize some special variables that have external effects upon unset
|
||||
when the shell reinitializes itself. */
|
||||
extern void reinit_special_variables __P((void));
|
||||
|
||||
extern int get_random_number __P((void));
|
||||
|
||||
/* The `special variable' functions that get called when a particular
|
||||
|
||||
+1
-1
@@ -109,7 +109,7 @@ typedef struct _vlist {
|
||||
#define att_assoc 0x0000040 /* variable is an associative array */
|
||||
#define att_trace 0x0000080 /* function is traced with DEBUG trap */
|
||||
|
||||
#define user_attrs (att_exported|att_readonly|att_array|att_integer|att_local|att_assoc|att_trace)
|
||||
#define user_attrs (att_exported|att_readonly|att_integer|att_local|att_trace)
|
||||
|
||||
#define attmask_user 0x0000fff
|
||||
|
||||
|
||||
Reference in New Issue
Block a user