merge bash-4.0 to trunk. kept most haiku stuff.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34016 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
ce80623dff
commit
0c020994fd
|
@ -0,0 +1,625 @@
|
|||
Notes on the Free Translation Project
|
||||
*************************************
|
||||
|
||||
Free software is going international! The Free Translation Project
|
||||
is a way to get maintainers of free software, translators, and users all
|
||||
together, so that will gradually become able to speak many languages.
|
||||
A few packages already provide translations for their messages.
|
||||
|
||||
If you found this `ABOUT-NLS' file inside a distribution, you may
|
||||
assume that the distributed package does use GNU `gettext' internally,
|
||||
itself available at your nearest GNU archive site. But you do _not_
|
||||
need to install GNU `gettext' prior to configuring, installing or using
|
||||
this package with messages translated.
|
||||
|
||||
Installers will find here some useful hints. These notes also
|
||||
explain how users should proceed for getting the programs to use the
|
||||
available translations. They tell how people wanting to contribute and
|
||||
work at translations should contact the appropriate team.
|
||||
|
||||
When reporting bugs in the `intl/' directory or bugs which may be
|
||||
related to internationalization, you should tell about the version of
|
||||
`gettext' which is used. The information can be found in the
|
||||
`intl/VERSION' file, in internationalized packages.
|
||||
|
||||
Quick configuration advice
|
||||
==========================
|
||||
|
||||
If you want to exploit the full power of internationalization, you
|
||||
should configure it using
|
||||
|
||||
./configure --with-included-gettext
|
||||
|
||||
to force usage of internationalizing routines provided within this
|
||||
package, despite the existence of internationalizing capabilities in the
|
||||
operating system where this package is being installed. So far, only
|
||||
the `gettext' implementation in the GNU C library version 2 provides as
|
||||
many features (such as locale alias, message inheritance, automatic
|
||||
charset conversion or plural form handling) as the implementation here.
|
||||
It is also not possible to offer this additional functionality on top
|
||||
of a `catgets' implementation. Future versions of GNU `gettext' will
|
||||
very likely convey even more functionality. So it might be a good idea
|
||||
to change to GNU `gettext' as soon as possible.
|
||||
|
||||
So you need _not_ provide this option if you are using GNU libc 2 or
|
||||
you have installed a recent copy of the GNU gettext package with the
|
||||
included `libintl'.
|
||||
|
||||
INSTALL Matters
|
||||
===============
|
||||
|
||||
Some packages are "localizable" when properly installed; the
|
||||
programs they contain can be made to speak your own native language.
|
||||
Most such packages use GNU `gettext'. Other packages have their own
|
||||
ways to internationalization, predating GNU `gettext'.
|
||||
|
||||
By default, this package will be installed to allow translation of
|
||||
messages. It will automatically detect whether the system already
|
||||
provides the GNU `gettext' functions. If not, the GNU `gettext' own
|
||||
library will be used. This library is wholly contained within this
|
||||
package, usually in the `intl/' subdirectory, so prior installation of
|
||||
the GNU `gettext' package is _not_ required. Installers may use
|
||||
special options at configuration time for changing the default
|
||||
behaviour. The commands:
|
||||
|
||||
./configure --with-included-gettext
|
||||
./configure --disable-nls
|
||||
|
||||
will respectively bypass any pre-existing `gettext' to use the
|
||||
internationalizing routines provided within this package, or else,
|
||||
_totally_ disable translation of messages.
|
||||
|
||||
When you already have GNU `gettext' installed on your system and run
|
||||
configure without an option for your new package, `configure' will
|
||||
probably detect the previously built and installed `libintl.a' file and
|
||||
will decide to use this. This might be not what is desirable. You
|
||||
should use the more recent version of the GNU `gettext' library. I.e.
|
||||
if the file `intl/VERSION' shows that the library which comes with this
|
||||
package is more recent, you should use
|
||||
|
||||
./configure --with-included-gettext
|
||||
|
||||
to prevent auto-detection.
|
||||
|
||||
The configuration process will not test for the `catgets' function
|
||||
and therefore it will not be used. The reason is that even an
|
||||
emulation of `gettext' on top of `catgets' could not provide all the
|
||||
extensions of the GNU `gettext' library.
|
||||
|
||||
Internationalized packages have usually many `po/LL.po' files, where
|
||||
LL gives an ISO 639 two-letter code identifying the language. Unless
|
||||
translations have been forbidden at `configure' time by using the
|
||||
`--disable-nls' switch, all available translations are installed
|
||||
together with the package. However, the environment variable `LINGUAS'
|
||||
may be set, prior to configuration, to limit the installed set.
|
||||
`LINGUAS' should then contain a space separated list of two-letter
|
||||
codes, stating which languages are allowed.
|
||||
|
||||
Using This Package
|
||||
==================
|
||||
|
||||
As a user, if your language has been installed for this package, you
|
||||
only have to set the `LANG' environment variable to the appropriate
|
||||
`LL_CC' combination. Here `LL' is an ISO 639 two-letter language code,
|
||||
and `CC' is an ISO 3166 two-letter country code. For example, let's
|
||||
suppose that you speak German and live in Germany. At the shell
|
||||
prompt, merely execute `setenv LANG de_DE' (in `csh'),
|
||||
`export LANG; LANG=de_DE' (in `sh') or `export LANG=de_DE' (in `bash').
|
||||
This can be done from your `.login' or `.profile' file, once and for
|
||||
all.
|
||||
|
||||
You might think that the country code specification is redundant.
|
||||
But in fact, some languages have dialects in different countries. For
|
||||
example, `de_AT' is used for Austria, and `pt_BR' for Brazil. The
|
||||
country code serves to distinguish the dialects.
|
||||
|
||||
The locale naming convention of `LL_CC', with `LL' denoting the
|
||||
language and `CC' denoting the country, is the one use on systems based
|
||||
on GNU libc. On other systems, some variations of this scheme are
|
||||
used, such as `LL' or `LL_CC.ENCODING'. You can get the list of
|
||||
locales supported by your system for your country by running the command
|
||||
`locale -a | grep '^LL''.
|
||||
|
||||
Not all programs have translations for all languages. By default, an
|
||||
English message is shown in place of a nonexistent translation. If you
|
||||
understand other languages, you can set up a priority list of languages.
|
||||
This is done through a different environment variable, called
|
||||
`LANGUAGE'. GNU `gettext' gives preference to `LANGUAGE' over `LANG'
|
||||
for the purpose of message handling, but you still need to have `LANG'
|
||||
set to the primary language; this is required by other parts of the
|
||||
system libraries. For example, some Swedish users who would rather
|
||||
read translations in German than English for when Swedish is not
|
||||
available, set `LANGUAGE' to `sv:de' while leaving `LANG' to `sv_SE'.
|
||||
|
||||
In the `LANGUAGE' environment variable, but not in the `LANG'
|
||||
environment variable, `LL_CC' combinations can be abbreviated as `LL'
|
||||
to denote the language's main dialect. For example, `de' is equivalent
|
||||
to `de_DE' (German as spoken in Germany), and `pt' to `pt_PT'
|
||||
(Portuguese as spoken in Portugal) in this context.
|
||||
|
||||
Translating Teams
|
||||
=================
|
||||
|
||||
For the Free Translation Project to be a success, we need interested
|
||||
people who like their own language and write it well, and who are also
|
||||
able to synergize with other translators speaking the same language.
|
||||
Each translation team has its own mailing list. The up-to-date list of
|
||||
teams can be found at the Free Translation Project's homepage,
|
||||
`http://www.iro.umontreal.ca/contrib/po/HTML/', in the "National teams"
|
||||
area.
|
||||
|
||||
If you'd like to volunteer to _work_ at translating messages, you
|
||||
should become a member of the translating team for your own language.
|
||||
The subscribing address is _not_ the same as the list itself, it has
|
||||
`-request' appended. For example, speakers of Swedish can send a
|
||||
message to `sv-request@li.org', having this message body:
|
||||
|
||||
subscribe
|
||||
|
||||
Keep in mind that team members are expected to participate
|
||||
_actively_ in translations, or at solving translational difficulties,
|
||||
rather than merely lurking around. If your team does not exist yet and
|
||||
you want to start one, or if you are unsure about what to do or how to
|
||||
get started, please write to `translation@iro.umontreal.ca' to reach the
|
||||
coordinator for all translator teams.
|
||||
|
||||
The English team is special. It works at improving and uniformizing
|
||||
the terminology in use. Proven linguistic skill are praised more than
|
||||
programming skill, here.
|
||||
|
||||
Available Packages
|
||||
==================
|
||||
|
||||
Languages are not equally supported in all packages. The following
|
||||
matrix shows the current state of internationalization, as of May 2003.
|
||||
The matrix shows, in regard of each package, for which languages PO
|
||||
files have been submitted to translation coordination, with a
|
||||
translation percentage of at least 50%.
|
||||
|
||||
Ready PO files am az be bg ca cs da de el en en_GB eo es
|
||||
+-------------------------------------------+
|
||||
a2ps | [] [] [] [] |
|
||||
aegis | () |
|
||||
anubis | |
|
||||
ap-utils | |
|
||||
bash | [] [] [] |
|
||||
batchelor | |
|
||||
bfd | [] [] |
|
||||
binutils | [] [] |
|
||||
bison | [] [] [] |
|
||||
bluez-pin | [] [] |
|
||||
clisp | |
|
||||
clisp | [] [] [] |
|
||||
coreutils | [] [] [] [] |
|
||||
cpio | [] [] [] |
|
||||
darkstat | () [] |
|
||||
diffutils | [] [] [] [] [] [] [] |
|
||||
e2fsprogs | [] [] |
|
||||
enscript | [] [] [] [] |
|
||||
error | [] [] [] [] [] |
|
||||
fetchmail | [] () [] [] [] [] |
|
||||
fileutils | [] [] [] |
|
||||
findutils | [] [] [] [] [] [] |
|
||||
flex | [] [] [] [] |
|
||||
gas | [] |
|
||||
gawk | [] [] [] [] |
|
||||
gcal | [] |
|
||||
gcc | [] [] |
|
||||
gettext | [] [] [] [] [] |
|
||||
gettext-runtime | [] [] [] [] [] |
|
||||
gettext-tools | [] [] |
|
||||
gimp-print | [] [] [] [] [] |
|
||||
gliv | |
|
||||
glunarclock | [] [] [] |
|
||||
gnucash | () [] |
|
||||
gnucash-glossary | [] () [] |
|
||||
gnupg | [] () [] [] [] [] |
|
||||
gpe-calendar | [] |
|
||||
gpe-conf | [] |
|
||||
gpe-contacts | [] |
|
||||
gpe-edit | |
|
||||
gpe-login | [] |
|
||||
gpe-ownerinfo | [] |
|
||||
gpe-sketchbook | [] |
|
||||
gpe-timesheet | |
|
||||
gpe-today | [] |
|
||||
gpe-todo | [] |
|
||||
gphoto2 | [] [] [] [] |
|
||||
gprof | [] [] |
|
||||
gpsdrive | () () () |
|
||||
grep | [] [] [] [] [] |
|
||||
gretl | [] |
|
||||
hello | [] [] [] [] [] [] |
|
||||
id-utils | [] [] |
|
||||
indent | [] [] [] [] |
|
||||
jpilot | [] [] [] [] |
|
||||
jwhois | [] |
|
||||
kbd | [] [] [] [] [] |
|
||||
ld | [] [] |
|
||||
libc | [] [] [] [] [] [] |
|
||||
libgpewidget | [] |
|
||||
libiconv | [] [] [] [] [] |
|
||||
lifelines | [] () |
|
||||
lilypond | [] |
|
||||
lingoteach | |
|
||||
lingoteach_lessons | () () |
|
||||
lynx | [] [] [] [] |
|
||||
m4 | [] [] [] [] |
|
||||
mailutils | [] [] |
|
||||
make | [] [] [] |
|
||||
man-db | [] () [] [] () |
|
||||
mysecretdiary | [] [] [] |
|
||||
nano | [] () [] [] [] |
|
||||
nano_1_0 | [] () [] [] [] |
|
||||
opcodes | [] [] |
|
||||
parted | [] [] [] [] [] |
|
||||
ptx | [] [] [] [] [] |
|
||||
python | |
|
||||
radius | |
|
||||
recode | [] [] [] [] [] [] |
|
||||
screem | |
|
||||
sed | [] [] [] [] [] |
|
||||
sh-utils | [] [] [] |
|
||||
sharutils | [] [] [] [] [] [] |
|
||||
sketch | [] () [] |
|
||||
soundtracker | [] [] [] |
|
||||
sp | [] |
|
||||
tar | [] [] [] [] |
|
||||
texinfo | [] [] [] [] |
|
||||
textutils | [] [] [] [] |
|
||||
tin | () () |
|
||||
util-linux | [] [] [] [] [] |
|
||||
vorbis-tools | [] [] [] |
|
||||
wastesedge | () |
|
||||
wdiff | [] [] [] [] |
|
||||
wget | [] [] [] [] [] [] [] |
|
||||
xchat | [] [] [] |
|
||||
xpad | |
|
||||
+-------------------------------------------+
|
||||
am az be bg ca cs da de el en en_GB eo es
|
||||
0 1 4 2 31 17 54 60 14 1 4 12 56
|
||||
|
||||
et fa fi fr ga gl he hr hu id it ja ko
|
||||
+----------------------------------------+
|
||||
a2ps | [] [] [] () () |
|
||||
aegis | |
|
||||
anubis | [] |
|
||||
ap-utils | [] |
|
||||
bash | [] [] |
|
||||
batchelor | [] |
|
||||
bfd | [] [] |
|
||||
binutils | [] [] |
|
||||
bison | [] [] [] [] |
|
||||
bluez-pin | [] [] [] [] |
|
||||
clisp | |
|
||||
clisp | [] |
|
||||
coreutils | [] [] [] [] |
|
||||
cpio | [] [] [] [] |
|
||||
darkstat | () [] [] [] |
|
||||
diffutils | [] [] [] [] [] [] [] |
|
||||
e2fsprogs | |
|
||||
enscript | [] [] |
|
||||
error | [] [] [] [] |
|
||||
fetchmail | [] |
|
||||
fileutils | [] [] [] [] [] |
|
||||
findutils | [] [] [] [] [] [] [] [] [] [] [] |
|
||||
flex | [] [] |
|
||||
gas | [] |
|
||||
gawk | [] [] |
|
||||
gcal | [] |
|
||||
gcc | [] |
|
||||
gettext | [] [] [] |
|
||||
gettext-runtime | [] [] [] [] |
|
||||
gettext-tools | [] |
|
||||
gimp-print | [] [] |
|
||||
gliv | () |
|
||||
glunarclock | [] [] [] [] |
|
||||
gnucash | [] |
|
||||
gnucash-glossary | [] |
|
||||
gnupg | [] [] [] [] [] [] [] |
|
||||
gpe-calendar | [] |
|
||||
gpe-conf | |
|
||||
gpe-contacts | [] |
|
||||
gpe-edit | [] [] |
|
||||
gpe-login | [] |
|
||||
gpe-ownerinfo | [] [] [] |
|
||||
gpe-sketchbook | [] |
|
||||
gpe-timesheet | [] [] [] |
|
||||
gpe-today | [] [] |
|
||||
gpe-todo | [] [] |
|
||||
gphoto2 | [] [] [] |
|
||||
gprof | [] [] |
|
||||
gpsdrive | () [] () () |
|
||||
grep | [] [] [] [] [] [] [] [] [] [] [] |
|
||||
gretl | [] |
|
||||
hello | [] [] [] [] [] [] [] [] [] [] [] [] [] |
|
||||
id-utils | [] [] [] |
|
||||
indent | [] [] [] [] [] [] [] [] |
|
||||
jpilot | [] () |
|
||||
jwhois | [] [] [] [] |
|
||||
kbd | [] |
|
||||
ld | [] |
|
||||
libc | [] [] [] [] [] [] |
|
||||
libgpewidget | [] [] [] |
|
||||
libiconv | [] [] [] [] [] [] [] [] |
|
||||
lifelines | () |
|
||||
lilypond | [] |
|
||||
lingoteach | [] [] |
|
||||
lingoteach_lessons | |
|
||||
lynx | [] [] [] [] |
|
||||
m4 | [] [] [] [] |
|
||||
mailutils | |
|
||||
make | [] [] [] [] [] [] |
|
||||
man-db | [] () () |
|
||||
mysecretdiary | [] [] |
|
||||
nano | [] [] [] [] |
|
||||
nano_1_0 | [] [] [] [] |
|
||||
opcodes | [] [] |
|
||||
parted | [] [] [] |
|
||||
ptx | [] [] [] [] [] [] [] |
|
||||
python | |
|
||||
radius | |
|
||||
recode | [] [] [] [] [] [] |
|
||||
screem | |
|
||||
sed | [] [] [] [] [] [] [] [] |
|
||||
sh-utils | [] [] [] [] [] [] |
|
||||
sharutils | [] [] [] [] [] |
|
||||
sketch | [] |
|
||||
soundtracker | [] [] [] |
|
||||
sp | [] () |
|
||||
tar | [] [] [] [] [] [] [] [] [] |
|
||||
texinfo | [] [] [] [] |
|
||||
textutils | [] [] [] [] [] |
|
||||
tin | [] () |
|
||||
util-linux | [] [] [] [] () [] |
|
||||
vorbis-tools | [] |
|
||||
wastesedge | () |
|
||||
wdiff | [] [] [] [] [] |
|
||||
wget | [] [] [] [] [] [] [] [] |
|
||||
xchat | [] [] [] |
|
||||
xpad | |
|
||||
+----------------------------------------+
|
||||
et fa fi fr ga gl he hr hu id it ja ko
|
||||
20 1 15 73 14 24 8 10 30 31 19 31 9
|
||||
|
||||
lg lt lv ms nb nl nn no pl pt pt_BR ro
|
||||
+----------------------------------------+
|
||||
a2ps | [] [] () () () [] [] |
|
||||
aegis | () |
|
||||
anubis | [] [] |
|
||||
ap-utils | () |
|
||||
bash | [] |
|
||||
batchelor | |
|
||||
bfd | |
|
||||
binutils | |
|
||||
bison | [] [] [] [] |
|
||||
bluez-pin | [] |
|
||||
clisp | |
|
||||
clisp | [] |
|
||||
coreutils | [] |
|
||||
cpio | [] [] [] |
|
||||
darkstat | [] [] [] [] |
|
||||
diffutils | [] [] [] |
|
||||
e2fsprogs | |
|
||||
enscript | [] [] |
|
||||
error | [] [] |
|
||||
fetchmail | () () |
|
||||
fileutils | [] |
|
||||
findutils | [] [] [] [] |
|
||||
flex | [] |
|
||||
gas | |
|
||||
gawk | [] |
|
||||
gcal | |
|
||||
gcc | |
|
||||
gettext | [] |
|
||||
gettext-runtime | [] |
|
||||
gettext-tools | |
|
||||
gimp-print | [] |
|
||||
gliv | [] |
|
||||
glunarclock | [] |
|
||||
gnucash | |
|
||||
gnucash-glossary | [] [] |
|
||||
gnupg | |
|
||||
gpe-calendar | [] [] |
|
||||
gpe-conf | [] [] |
|
||||
gpe-contacts | [] |
|
||||
gpe-edit | [] [] |
|
||||
gpe-login | [] [] |
|
||||
gpe-ownerinfo | [] [] |
|
||||
gpe-sketchbook | [] [] |
|
||||
gpe-timesheet | [] [] |
|
||||
gpe-today | [] [] |
|
||||
gpe-todo | [] [] |
|
||||
gphoto2 | |
|
||||
gprof | [] |
|
||||
gpsdrive | () () () |
|
||||
grep | [] [] [] [] |
|
||||
gretl | |
|
||||
hello | [] [] [] [] [] [] [] [] [] |
|
||||
id-utils | [] [] [] |
|
||||
indent | [] [] [] |
|
||||
jpilot | () () |
|
||||
jwhois | [] [] [] |
|
||||
kbd | |
|
||||
ld | |
|
||||
libc | [] [] [] [] |
|
||||
libgpewidget | [] [] |
|
||||
libiconv | [] [] |
|
||||
lifelines | |
|
||||
lilypond | [] |
|
||||
lingoteach | |
|
||||
lingoteach_lessons | |
|
||||
lynx | [] [] |
|
||||
m4 | [] [] [] [] |
|
||||
mailutils | |
|
||||
make | [] [] |
|
||||
man-db | [] |
|
||||
mysecretdiary | [] |
|
||||
nano | [] [] [] [] |
|
||||
nano_1_0 | [] [] [] [] |
|
||||
opcodes | [] [] [] |
|
||||
parted | [] [] [] |
|
||||
ptx | [] [] [] [] [] [] [] |
|
||||
python | |
|
||||
radius | |
|
||||
recode | [] [] [] |
|
||||
screem | |
|
||||
sed | [] [] |
|
||||
sh-utils | [] |
|
||||
sharutils | [] |
|
||||
sketch | [] |
|
||||
soundtracker | |
|
||||
sp | |
|
||||
tar | [] [] [] [] [] [] |
|
||||
texinfo | [] |
|
||||
textutils | [] |
|
||||
tin | |
|
||||
util-linux | [] [] |
|
||||
vorbis-tools | [] [] |
|
||||
wastesedge | |
|
||||
wdiff | [] [] [] [] |
|
||||
wget | [] [] [] |
|
||||
xchat | [] [] |
|
||||
xpad | [] |
|
||||
+----------------------------------------+
|
||||
lg lt lv ms nb nl nn no pl pt pt_BR ro
|
||||
0 0 2 11 7 26 3 4 18 15 34 34
|
||||
|
||||
ru sk sl sr sv ta tr uk vi wa zh_CN zh_TW
|
||||
+-------------------------------------------+
|
||||
a2ps | [] [] [] [] [] | 16
|
||||
aegis | () | 0
|
||||
anubis | [] [] | 5
|
||||
ap-utils | () | 1
|
||||
bash | [] | 7
|
||||
batchelor | | 1
|
||||
bfd | [] [] [] | 7
|
||||
binutils | [] [] [] | 7
|
||||
bison | [] [] | 13
|
||||
bluez-pin | | 7
|
||||
clisp | | 0
|
||||
clisp | | 5
|
||||
coreutils | [] [] [] [] [] | 14
|
||||
cpio | [] [] [] | 13
|
||||
darkstat | [] () () | 9
|
||||
diffutils | [] [] [] [] | 21
|
||||
e2fsprogs | [] | 3
|
||||
enscript | [] [] [] | 11
|
||||
error | [] [] [] | 14
|
||||
fetchmail | [] | 7
|
||||
fileutils | [] [] [] [] [] [] | 15
|
||||
findutils | [] [] [] [] [] [] | 27
|
||||
flex | [] [] [] | 10
|
||||
gas | [] | 3
|
||||
gawk | [] [] | 9
|
||||
gcal | [] [] | 4
|
||||
gcc | [] | 4
|
||||
gettext | [] [] [] [] [] [] | 15
|
||||
gettext-runtime | [] [] [] [] [] [] | 16
|
||||
gettext-tools | [] [] | 5
|
||||
gimp-print | [] [] | 10
|
||||
gliv | | 1
|
||||
glunarclock | [] [] [] | 11
|
||||
gnucash | [] [] | 4
|
||||
gnucash-glossary | [] [] [] | 8
|
||||
gnupg | [] [] [] [] | 16
|
||||
gpe-calendar | [] | 5
|
||||
gpe-conf | | 3
|
||||
gpe-contacts | [] | 4
|
||||
gpe-edit | [] | 5
|
||||
gpe-login | [] | 5
|
||||
gpe-ownerinfo | [] | 7
|
||||
gpe-sketchbook | [] | 5
|
||||
gpe-timesheet | [] | 6
|
||||
gpe-today | [] | 6
|
||||
gpe-todo | [] | 6
|
||||
gphoto2 | [] [] | 9
|
||||
gprof | [] [] | 7
|
||||
gpsdrive | [] [] | 3
|
||||
grep | [] [] [] [] | 24
|
||||
gretl | | 2
|
||||
hello | [] [] [] [] [] | 33
|
||||
id-utils | [] [] [] | 11
|
||||
indent | [] [] [] [] | 19
|
||||
jpilot | [] [] [] [] [] | 10
|
||||
jwhois | () () [] [] | 10
|
||||
kbd | [] [] | 8
|
||||
ld | [] [] | 5
|
||||
libc | [] [] [] [] | 20
|
||||
libgpewidget | | 6
|
||||
libiconv | [] [] [] [] [] [] | 21
|
||||
lifelines | [] | 2
|
||||
lilypond | [] | 4
|
||||
lingoteach | | 2
|
||||
lingoteach_lessons | () | 0
|
||||
lynx | [] [] [] [] | 14
|
||||
m4 | [] [] [] | 15
|
||||
mailutils | | 2
|
||||
make | [] [] [] [] | 15
|
||||
man-db | [] | 6
|
||||
mysecretdiary | [] [] | 8
|
||||
nano | [] [] [] | 15
|
||||
nano_1_0 | [] [] [] | 15
|
||||
opcodes | [] [] | 9
|
||||
parted | [] [] | 13
|
||||
ptx | [] [] [] | 22
|
||||
python | | 0
|
||||
radius | | 0
|
||||
recode | [] [] [] [] | 19
|
||||
screem | [] | 1
|
||||
sed | [] [] [] [] [] | 20
|
||||
sh-utils | [] [] [] | 13
|
||||
sharutils | [] [] [] [] | 16
|
||||
sketch | [] | 5
|
||||
soundtracker | [] | 7
|
||||
sp | [] | 3
|
||||
tar | [] [] [] [] [] | 24
|
||||
texinfo | [] [] [] [] | 13
|
||||
textutils | [] [] [] [] [] | 15
|
||||
tin | | 1
|
||||
util-linux | [] [] | 14
|
||||
vorbis-tools | [] | 7
|
||||
wastesedge | | 0
|
||||
wdiff | [] [] [] [] | 17
|
||||
wget | [] [] [] [] [] [] [] | 25
|
||||
xchat | [] [] [] | 11
|
||||
xpad | | 1
|
||||
+-------------------------------------------+
|
||||
50 teams ru sk sl sr sv ta tr uk vi wa zh_CN zh_TW
|
||||
97 domains 32 19 16 0 56 0 48 10 1 1 12 23 913
|
||||
|
||||
Some counters in the preceding matrix are higher than the number of
|
||||
visible blocks let us expect. This is because a few extra PO files are
|
||||
used for implementing regional variants of languages, or language
|
||||
dialects.
|
||||
|
||||
For a PO file in the matrix above to be effective, the package to
|
||||
which it applies should also have been internationalized and
|
||||
distributed as such by its maintainer. There might be an observable
|
||||
lag between the mere existence a PO file and its wide availability in a
|
||||
distribution.
|
||||
|
||||
If May 2003 seems to be old, you may fetch a more recent copy of
|
||||
this `ABOUT-NLS' file on most GNU archive sites. The most up-to-date
|
||||
matrix with full percentage details can be found at
|
||||
`http://www.iro.umontreal.ca/contrib/po/HTML/matrix.html'.
|
||||
|
||||
Using `gettext' in new packages
|
||||
===============================
|
||||
|
||||
If you are writing a freely available program and want to
|
||||
internationalize it you are welcome to use GNU `gettext' in your
|
||||
package. Of course you have to respect the GNU Library General Public
|
||||
License which covers the use of the GNU `gettext' library. This means
|
||||
in particular that even non-free programs can use `libintl' as a shared
|
||||
library, whereas only free software can use `libintl' as a static
|
||||
library or use modified versions of `libintl'.
|
||||
|
||||
Once the sources are changed appropriately and the setup can handle
|
||||
the use of `gettext' the only thing missing are the translations. The
|
||||
Free Translation Project is also available for packages which are not
|
||||
developed inside the GNU project. Therefore the information given above
|
||||
applies also for every other Free Software Project. Contact
|
||||
`translation@iro.umontreal.ca' to make the `.pot' files available to
|
||||
the translation teams.
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
#
|
||||
# Master author manifest for bash
|
||||
#
|
||||
# The files in lib/intl were taken from the GNU gettext distribution.
|
||||
#
|
||||
# Any files appearing in the bash distribution not listed in this file
|
||||
# were created by Chet Ramey.
|
||||
#
|
||||
|
@ -100,6 +102,7 @@ builtins/alias.def Brian Fox, Chet Ramey
|
|||
builtins/bind.def Brian Fox, Chet Ramey
|
||||
builtins/break.def Brian Fox, Chet Ramey
|
||||
builtins/builtin.def Brian Fox, Chet Ramey
|
||||
builtins/caller.def Rocky Bernstein, Chet Ramey
|
||||
builtins/cd.def Brian Fox, Chet Ramey
|
||||
builtins/colon.def Brian Fox, Chet Ramey
|
||||
builtins/command.def Brian Fox, Chet Ramey
|
||||
|
@ -122,6 +125,7 @@ builtins/let.def Chet Ramey, Brian Fox
|
|||
builtins/history.def Brian Fox, Chet Ramey
|
||||
builtins/jobs.def Brian Fox, Chet Ramey
|
||||
builtins/kill.def Brian Fox, Chet Ramey
|
||||
builtins/mapfile.def Rocky Bernstein
|
||||
builtins/mkbuiltins.c Brian Fox, Chet Ramey
|
||||
builtins/pushd.def Brian Fox, Chet Ramey
|
||||
builtins/read.def Brian Fox, Chet Ramey
|
||||
|
@ -451,3 +455,7 @@ lib/sh/vprint.c Chet Ramey, Brian Fox
|
|||
lib/sh/xstrchr.c Chet Ramey, Mitsuru Chinen
|
||||
lib/sh/zread.c Chet Ramey
|
||||
lib/sh/zwrite.c Chet Ramey
|
||||
|
||||
tests/posix-ifs.sh Glenn Fowler
|
||||
|
||||
support/checkbashisms Julian Gilbey, Debian Linux team
|
||||
|
|
2245
src/bin/bash/CHANGES
2245
src/bin/bash/CHANGES
File diff suppressed because it is too large
Load Diff
|
@ -1,11 +1,12 @@
|
|||
This document details the incompatibilites between this version of bash,
|
||||
bash-2.05b, and the previous widely-available version, bash-1.14 (which
|
||||
is still the `standard' version for many Linux distributions). These
|
||||
were discovered by users of bash-2.x, so this list is not comprehensive.
|
||||
Some of these incompatibilities occur between the current version and
|
||||
versions 2.0 and above.
|
||||
This document details the incompatibilities between this version of bash,
|
||||
bash-4.0, and the previous widely-available versions, bash-1.14 (which is
|
||||
still the `standard' version for a few Linux distributions) and bash-2.x.
|
||||
These were discovered by users of bash-2.x and 3.x, so this list is not
|
||||
comprehensive. Some of these incompatibilities occur between the current
|
||||
version and versions 2.0 and above. (The differences between bash-1.14 and
|
||||
bash-2.0 were significant.)
|
||||
|
||||
1. Bash now uses a new quoting syntax, $"...", to do locale-specific
|
||||
1. Bash uses a new quoting syntax, $"...", to do locale-specific
|
||||
string translation. Users who have relied on the (undocumented)
|
||||
behavior of bash-1.14 will have to change their scripts. For
|
||||
instance, if you are doing something like this to get the value of
|
||||
|
@ -183,28 +184,137 @@ versions 2.0 and above.
|
|||
with `z' and still allow individual users to change the collation order.
|
||||
Users may put the above command into their own profiles as well, of course.
|
||||
|
||||
14. Bash versions up to 1.14.7 included an undocumented `-l' operator to
|
||||
the `test/[' builtin. It was a unary operator that expanded to the
|
||||
length of its string argument. This let you do things like
|
||||
14. Bash versions up to 1.14.7 included an undocumented `-l' operator to
|
||||
the `test/[' builtin. It was a unary operator that expanded to the
|
||||
length of its string argument. This let you do things like
|
||||
|
||||
test -l $variable -lt 20
|
||||
|
||||
for example.
|
||||
for example.
|
||||
|
||||
This was included for backwards compatibility with old versions of the
|
||||
Bourne shell, which did not provide an easy way to obtain the length of
|
||||
the value of a shell variable.
|
||||
This was included for backwards compatibility with old versions of the
|
||||
Bourne shell, which did not provide an easy way to obtain the length of
|
||||
the value of a shell variable.
|
||||
|
||||
This operator is not part of the POSIX standard, because one can (and
|
||||
should) use ${#variable} to get the length of a variable's value.
|
||||
Bash-2.x does not support it.
|
||||
This operator is not part of the POSIX standard, because one can (and
|
||||
should) use ${#variable} to get the length of a variable's value.
|
||||
Bash-2.x does not support it.
|
||||
|
||||
15. Bash no longer auto-exports the HOME, PATH, SHELL, TERM, HOSTNAME,
|
||||
HOSTTYPE, MACHTYPE, or OSTYPE variables.
|
||||
15. Bash no longer auto-exports the HOME, PATH, SHELL, TERM, HOSTNAME,
|
||||
HOSTTYPE, MACHTYPE, or OSTYPE variables. If they appear in the initial
|
||||
environment, the export attribute will be set, but if bash provides a
|
||||
default value, they will remain local to the current shell.
|
||||
|
||||
16. Bash no longer initializes the FUNCNAME, GROUPS, or DIRSTACK variables
|
||||
to have special behavior if they appear in the initial environment.
|
||||
16. Bash no longer initializes the FUNCNAME, GROUPS, or DIRSTACK variables
|
||||
to have special behavior if they appear in the initial environment.
|
||||
|
||||
17. Bash no longer removes the export attribute from the SSH_CLIENT or
|
||||
SSH2_CLIENT variables, and no longer attempts to discover whether or
|
||||
not it has been invoked by sshd in order to run the startup files.
|
||||
17. Bash no longer removes the export attribute from the SSH_CLIENT or
|
||||
SSH2_CLIENT variables, and no longer attempts to discover whether or
|
||||
not it has been invoked by sshd in order to run the startup files.
|
||||
|
||||
18. Bash no longer requires that the body of a function be a group command;
|
||||
any compound command is accepted.
|
||||
|
||||
19. As of bash-3.0, the pattern substitution operators no longer perform
|
||||
quote removal on the pattern before attempting the match. This is the
|
||||
way the pattern removal functions behave, and is more consistent.
|
||||
|
||||
20. After bash-3.0 was released, I reimplemented tilde expansion, incorporating
|
||||
it into the mainline word expansion code. This fixes the bug that caused
|
||||
the results of tilde expansion to be re-expanded. There is one
|
||||
incompatibility: a ${paramOPword} expansion within double quotes will not
|
||||
perform tilde expansion on WORD. This is consistent with the other
|
||||
expansions, and what POSIX specifies.
|
||||
|
||||
21. A number of variables have the integer attribute by default, so the +=
|
||||
assignment operator returns expected results: RANDOM, LINENO, MAILCHECK,
|
||||
HISTCMD, OPTIND.
|
||||
|
||||
22. Bash-3.x is much stricter about $LINENO correctly reflecting the line
|
||||
number in a script; assignments to LINENO have little effect.
|
||||
|
||||
23. By default, readline binds the terminal special characters to their
|
||||
readline equivalents. As of bash-3.1/readline-5.1, this is optional and
|
||||
controlled by the bind-tty-special-chars readline variable.
|
||||
|
||||
24. The \W prompt string expansion abbreviates $HOME as `~'. The previous
|
||||
behavior is available with ${PWD##/*/}.
|
||||
|
||||
25. The arithmetic exponentiation operator is right-associative as of bash-3.1.
|
||||
|
||||
26. The rules concerning valid alias names are stricter, as per POSIX.2.
|
||||
|
||||
27. The Readline key binding functions now obey the convert-meta setting active
|
||||
when the binding takes place, as the dispatch code does when characters
|
||||
are read and processed.
|
||||
|
||||
28. The historical behavior of `trap' reverting signal disposition to the
|
||||
original handling in the absence of a valid first argument is implemented
|
||||
only if the first argument is a valid signal number.
|
||||
|
||||
29. In versions of bash after 3.1, the ${parameter//pattern/replacement}
|
||||
expansion does not interpret `%' or `#' specially. Those anchors don't
|
||||
have any real meaning when replacing every match.
|
||||
|
||||
30. Beginning with bash-3.1, the combination of posix mode and enabling the
|
||||
`xpg_echo' option causes echo to ignore all options, not looking for `-n'
|
||||
|
||||
31. Beginning with bash-3.2, bash follows the Bourne-shell-style (and POSIX-
|
||||
style) rules for parsing the contents of old-style backquoted command
|
||||
substitutions. Previous versions of bash attempted to recursively parse
|
||||
embedded quoted strings and shell constructs; bash-3.2 uses strict POSIX
|
||||
rules to find the closing backquote and simply passes the contents of the
|
||||
command substitution to a subshell for parsing and execution.
|
||||
|
||||
32. Beginning with bash-3.2, bash uses access(2) when executing primaries for
|
||||
the test builtin and the [[ compound command, rather than looking at the
|
||||
file permission bits obtained with stat(2). This obeys restrictions of
|
||||
the file system (e.g., read-only or noexec mounts) not available via stat.
|
||||
|
||||
33. Bash-3.2 adopts the convention used by other string and pattern matching
|
||||
operators for the `[[' compound command, and matches any quoted portion
|
||||
of the right-hand-side argument to the =~ operator as a string rather
|
||||
than a regular expression.
|
||||
|
||||
34. Bash-4.0 allows the behavior in the previous item to be modified using
|
||||
the notion of a shell `compatibility level'.
|
||||
|
||||
35. Bash-3.2 (patched) and Bash-4.0 fix a bug that leaves the shell in an
|
||||
inconsistent internal state following an assignment error. One of the
|
||||
changes means that compound commands or { ... } grouping commands are
|
||||
aborted under some circumstances in which they previously were not.
|
||||
This is what Posix specifies.
|
||||
|
||||
36. Bash-4.0 now allows process substitution constructs to pass unchanged
|
||||
through brace expansion, so any expansion of the contents will have to be
|
||||
separately specified, and each process subsitution will have to be
|
||||
separately entered.
|
||||
|
||||
37. Bash-4.0 now allows SIGCHLD to interrupt the wait builtin, as Posix
|
||||
specifies, so the SIGCHLD trap is no longer always invoked once per
|
||||
exiting child if you are using `wait' to wait for all children.
|
||||
|
||||
38. Since bash-4.0 now follows Posix rules for finding the closing delimiter
|
||||
of a $() command substitution, it will not behave as previous versions
|
||||
did, but will catch more syntax and parsing errors before spawning a
|
||||
subshell to evaluate the command substitution.
|
||||
|
||||
39. The programmable completion code uses the same set of delimiting characters
|
||||
as readline when breaking the command line into words, rather than the
|
||||
set of shell metacharacters, so programmable completion and readline
|
||||
should be more consistent.
|
||||
|
||||
40. When the read builtin times out, it attempts to assign any input read to
|
||||
specified variables, which also causes variables to be set to the empty
|
||||
string if there is not enough input. Previous versions discarded the
|
||||
characters read.
|
||||
|
||||
41. Beginning with bash-4.0, when one of the commands in a pipeline is killed
|
||||
by a SIGINT while executing a command list, the shell acts as if it
|
||||
received the interrupt.
|
||||
|
||||
42. Bash-4.0 changes the handling of the set -e option so that the shell exits
|
||||
if a pipeline fails (and not just if the last command in the failing
|
||||
pipeline is a simple command). This is not as Posix specifies. There is
|
||||
work underway to update this portion of the standard; the bash-4.0
|
||||
behavior attempts to capture the consensus at the time of release.
|
||||
|
|
|
@ -1,293 +1,626 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
The Free Software Foundation has exempted Bash from the requirement of
|
||||
Paragraph 2c of the General Public License. This is to say, there is
|
||||
no requirement for Bash to print a notice when it is started
|
||||
interactively in the usual way. We made this exception because users
|
||||
and standards expect shells not to print such messages. This
|
||||
exception applies to any program that serves as a shell and that is
|
||||
based primarily on Bash as opposed to other GNU software.
|
||||
Preamble
|
||||
|
||||
Preamble
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
0. Definitions.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
1. Source Code.
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
14. Revised Versions of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
NO WARRANTY
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Appendix: How to Apply These Terms to Your New Programs
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
|
@ -295,15 +628,15 @@ free software which everyone can redistribute and change under these terms.
|
|||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) 19yy <name of author>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
|
@ -312,36 +645,30 @@ the "copyright" line and a pointer to where the full notice is found.
|
|||
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, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) 19yy name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
|
|
|
@ -191,13 +191,14 @@ the Bash `configure' recognizes.
|
|||
Define if you are using the Andrew File System from Transarc.
|
||||
|
||||
`--with-bash-malloc'
|
||||
Use the Bash version of `malloc' in `lib/malloc/malloc.c'. This
|
||||
is not the same `malloc' that appears in GNU libc, but an older
|
||||
version derived from the 4.2 BSD `malloc'. This `malloc' is very
|
||||
fast, but wastes some space on each allocation. This option is
|
||||
enabled by default. The `NOTES' file contains a list of systems
|
||||
for which this should be turned off, and `configure' disables this
|
||||
option automatically for a number of systems.
|
||||
Use the Bash version of `malloc' in the directory `lib/malloc'.
|
||||
This is not the same `malloc' that appears in GNU libc, but an
|
||||
older version originally derived from the 4.2 BSD `malloc'. This
|
||||
`malloc' is very fast, but wastes some space on each allocation.
|
||||
This option is enabled by default. The `NOTES' file contains a
|
||||
list of systems for which this should be turned off, and
|
||||
`configure' disables this option automatically for a number of
|
||||
systems.
|
||||
|
||||
`--with-curses'
|
||||
Use the curses library instead of the termcap library. This should
|
||||
|
@ -210,7 +211,7 @@ the Bash `configure' recognizes.
|
|||
`--with-installed-readline[=PREFIX]'
|
||||
Define this to make Bash link with a locally-installed version of
|
||||
Readline rather than the version in `lib/readline'. This works
|
||||
only with Readline 4.3 and later versions. If PREFIX is `yes' or
|
||||
only with Readline 5.0 and later versions. If PREFIX is `yes' or
|
||||
not supplied, `configure' uses the values of the make variables
|
||||
`includedir' and `libdir', which are subdirectories of `prefix' by
|
||||
default, to find the installed version of Readline if it is not in
|
||||
|
@ -274,7 +275,16 @@ does not provide the necessary support.
|
|||
|
||||
`--enable-brace-expansion'
|
||||
Include `csh'-like brace expansion ( `b{a,b}c' ==> `bac bbc' ).
|
||||
See *Note Brace Expansion::, for a complete description.
|
||||
See *note Brace Expansion::, for a complete description.
|
||||
|
||||
`--enable-casemod-attributes'
|
||||
Include support for case-modifying attributes in the `declare'
|
||||
builtin and assignment statements. Variables with the UPPERCASE
|
||||
attribute, for example, will have their values converted to
|
||||
uppercase upon assignment.
|
||||
|
||||
`--enable-casemod-expansion'
|
||||
Include support for case-modifying word expansions.
|
||||
|
||||
`--enable-command-timing'
|
||||
Include support for recognizing `time' as a reserved word and for
|
||||
|
@ -283,16 +293,28 @@ does not provide the necessary support.
|
|||
builtins and functions to be timed.
|
||||
|
||||
`--enable-cond-command'
|
||||
Include support for the `[[' conditional command (*note
|
||||
Include support for the `[[' conditional command. (*note
|
||||
Conditional Constructs::).
|
||||
|
||||
`--enable-cond-regexp'
|
||||
Include support for matching POSIX regular expressions using the
|
||||
`=~' binary operator in the `[[' conditional command. (*note
|
||||
Conditional Constructs::).
|
||||
|
||||
`--enable-coprocesses'
|
||||
Include support for coprocesses and the `coproc' reserved word
|
||||
(*note Pipelines::).
|
||||
|
||||
`--enable-debugger'
|
||||
Include support for the bash debugger (distributed separately).
|
||||
|
||||
`--enable-directory-stack'
|
||||
Include support for a `csh'-like directory stack and the `pushd',
|
||||
`popd', and `dirs' builtins (*note The Directory Stack::).
|
||||
|
||||
`--enable-disabled-builtins'
|
||||
Allow builtin commands to be invoked via `builtin xxx' even after
|
||||
`xxx' has been disabled using `enable -n xxx'. See *Note Bash
|
||||
`xxx' has been disabled using `enable -n xxx'. See *note Bash
|
||||
Builtins::, for details of the `builtin' and `enable' builtin
|
||||
commands.
|
||||
|
||||
|
@ -302,7 +324,7 @@ does not provide the necessary support.
|
|||
|
||||
`--enable-extended-glob'
|
||||
Include support for the extended pattern matching features
|
||||
described above under *Note Pattern Matching::.
|
||||
described above under *note Pattern Matching::.
|
||||
|
||||
`--enable-help-builtin'
|
||||
Include the `help' builtin, which displays help on shell builtins
|
||||
|
@ -316,6 +338,10 @@ does not provide the necessary support.
|
|||
This enables the job control features (*note Job Control::), if
|
||||
the operating system supports them.
|
||||
|
||||
`--enable-multibyte'
|
||||
This enables support for multibyte characters if the operating
|
||||
system provides the necessary support.
|
||||
|
||||
`--enable-net-redirections'
|
||||
This enables the special handling of filenames of the form
|
||||
`/dev/tcp/HOST/PORT' and `/dev/udp/HOST/PORT' when used in
|
||||
|
@ -325,30 +351,43 @@ does not provide the necessary support.
|
|||
This enables process substitution (*note Process Substitution::) if
|
||||
the operating system provides the necessary support.
|
||||
|
||||
`--enable-prompt-string-decoding'
|
||||
Turn on the interpretation of a number of backslash-escaped
|
||||
characters in the `$PS1', `$PS2', `$PS3', and `$PS4' prompt
|
||||
strings. See *Note Printing a Prompt::, for a complete list of
|
||||
prompt string escape sequences.
|
||||
|
||||
`--enable-progcomp'
|
||||
Enable the programmable completion facilities (*note Programmable
|
||||
Completion::). If Readline is not enabled, this option has no
|
||||
effect.
|
||||
|
||||
`--enable-prompt-string-decoding'
|
||||
Turn on the interpretation of a number of backslash-escaped
|
||||
characters in the `$PS1', `$PS2', `$PS3', and `$PS4' prompt
|
||||
strings. See *note Printing a Prompt::, for a complete list of
|
||||
prompt string escape sequences.
|
||||
|
||||
`--enable-readline'
|
||||
Include support for command-line editing and history with the Bash
|
||||
version of the Readline library (*note Command Line Editing::).
|
||||
|
||||
`--enable-restricted'
|
||||
Include support for a "restricted shell". If this is enabled,
|
||||
Bash, when called as `rbash', enters a restricted mode. See *Note
|
||||
Bash, when called as `rbash', enters a restricted mode. See *note
|
||||
The Restricted Shell::, for a description of restricted mode.
|
||||
|
||||
`--enable-select'
|
||||
Include the `select' builtin, which allows the generation of simple
|
||||
menus (*note Conditional Constructs::).
|
||||
|
||||
`--enable-separate-helpfiles'
|
||||
Use external files for the documentation displayed by the `help'
|
||||
builtin instead of storing the text internally.
|
||||
|
||||
`--enable-single-help-strings'
|
||||
Store the text displayed by the `help' builtin as a single string
|
||||
for each help topic. This aids in translating the text to
|
||||
different languages. You may need to disable this if your
|
||||
compiler cannot handle very long string literals.
|
||||
|
||||
`--enable-strict-posix-default'
|
||||
Make Bash POSIX-conformant by default (*note Bash POSIX Mode::).
|
||||
|
||||
`--enable-usg-echo-default'
|
||||
A synonym for `--enable-xpg-echo-default'.
|
||||
|
||||
|
@ -357,7 +396,7 @@ does not provide the necessary support.
|
|||
default, without requiring the `-e' option. This sets the default
|
||||
value of the `xpg_echo' shell option to `on', which makes the Bash
|
||||
`echo' behave more like the version specified in the Single Unix
|
||||
Specification, version 2. *Note Bash Builtins::, for a
|
||||
Specification, version 3. *Note Bash Builtins::, for a
|
||||
description of the escape sequences that `echo' recognizes.
|
||||
|
||||
The file `config-top.h' contains C Preprocessor `#define' statements
|
||||
|
|
|
@ -7,7 +7,7 @@ local cpuName = [ Match "([^-]*)-.*" : $(HAIKU_GCC_MACHINE) ] ;
|
|||
local vendorName = [ Match "[^-]*-([^-]*)" : $(HAIKU_GCC_MACHINE) ] ;
|
||||
local osName = [ Match "[^-]*-[^-]*-([^-]*)" : $(HAIKU_GCC_MACHINE) ] ;
|
||||
|
||||
SubDirCcFlags -DHAVE_CONFIG_H -DPROGRAM='\"bash\"' -DSHELL ;
|
||||
SubDirCcFlags -DHAVE_CONFIG_H -DPROGRAM='\"bash\"' -DSHELL -DLOCALEDIR='\"/boot/common/share/locale\"' -DPACKAGE='\"bash\"' ;
|
||||
SubDirCcFlags -DCONF_MACHTYPE='\"$(HAIKU_GCC_MACHINE)\"' ;
|
||||
SubDirCcFlags -DCONF_HOSTTYPE='\"$(cpuName)\"' ;
|
||||
SubDirCcFlags -DCONF_VENDOR='\"$(vendorName)\"' ;
|
||||
|
@ -26,9 +26,9 @@ BuildPlatformMain mksyntax :
|
|||
mksyntax.c ;
|
||||
|
||||
BuildPlatformMain mksignames :
|
||||
mksignames.c ;
|
||||
mksignames.c signames.c ;
|
||||
|
||||
SEARCH on [ FGristFiles mksignames.c ] = [ FDirName $(SUBDIR) support ] ;
|
||||
SEARCH on [ FGristFiles mksignames.c signames.c ] = [ FDirName $(SUBDIR) support ] ;
|
||||
|
||||
rule MkSyntaxExt
|
||||
{
|
||||
|
@ -75,6 +75,7 @@ if $(TARGET_PLATFORM_HAIKU_COMPATIBLE) {
|
|||
}
|
||||
|
||||
BinCommand bash :
|
||||
assoc.c
|
||||
parse.y shell.c eval.c general.c make_cmd.c print_cmd.c
|
||||
dispose_cmd.c execute_cmd.c variables.c version.c
|
||||
expr.c copy_cmd.c flags.c subst.c hashcmd.c hashlib.c mailcheck.c
|
||||
|
|
|
@ -10,7 +10,6 @@ builtins d
|
|||
cross-build d
|
||||
doc d
|
||||
examples d
|
||||
examples/bashdb d
|
||||
examples/obashdb d
|
||||
examples/complete d
|
||||
examples/functions d
|
||||
|
@ -26,18 +25,19 @@ include d
|
|||
lib d
|
||||
lib/glob d
|
||||
lib/glob/doc d
|
||||
lib/intl d
|
||||
lib/malloc d
|
||||
lib/readline d
|
||||
lib/readline/doc d
|
||||
lib/readline/examples d
|
||||
lib/sh d
|
||||
lib/termcap d
|
||||
lib/termcap/grot d
|
||||
lib/tilde d
|
||||
lib/tilde/doc d
|
||||
po d
|
||||
support d
|
||||
tests d
|
||||
tests/misc d
|
||||
ABOUT-NLS f
|
||||
CHANGES f
|
||||
COMPAT f
|
||||
COPYING f
|
||||
|
@ -51,7 +51,7 @@ RBASH f
|
|||
AUTHORS f
|
||||
Y2K f
|
||||
configure.in f
|
||||
configure f
|
||||
configure f 755
|
||||
Makefile.in f
|
||||
config-top.h f
|
||||
config-bot.h f
|
||||
|
@ -59,6 +59,7 @@ config.h.in f
|
|||
aclocal.m4 f
|
||||
array.c f
|
||||
arrayfunc.c f
|
||||
assoc.c f
|
||||
eval.c f
|
||||
print_cmd.c f
|
||||
general.c f
|
||||
|
@ -109,6 +110,7 @@ patchlevel.h f
|
|||
variables.h f
|
||||
array.h f
|
||||
arrayfunc.h f
|
||||
assoc.h f
|
||||
jobs.h f
|
||||
findcmd.h f
|
||||
hashlib.h f
|
||||
|
@ -140,16 +142,17 @@ execute_cmd.h f
|
|||
redir.h f
|
||||
bashtypes.h f
|
||||
mailcheck.h f
|
||||
pathnames.h f
|
||||
xmalloc.h f
|
||||
y.tab.c f
|
||||
y.tab.h f
|
||||
parser-built f
|
||||
pathnames.h.in f
|
||||
builtins/Makefile.in f
|
||||
builtins/alias.def f
|
||||
builtins/bind.def f
|
||||
builtins/break.def f
|
||||
builtins/builtin.def f
|
||||
builtins/caller.def f
|
||||
builtins/cd.def f
|
||||
builtins/colon.def f
|
||||
builtins/command.def f
|
||||
|
@ -174,6 +177,7 @@ builtins/let.def f
|
|||
builtins/history.def f
|
||||
builtins/jobs.def f
|
||||
builtins/kill.def f
|
||||
builtins/mapfile.def f
|
||||
builtins/mkbuiltins.c f
|
||||
builtins/printf.def f
|
||||
builtins/pushd.def f
|
||||
|
@ -200,13 +204,12 @@ builtins/bashgetopt.c f
|
|||
builtins/common.h f
|
||||
builtins/bashgetopt.h f
|
||||
cross-build/cygwin32.cache f
|
||||
cross-build/win32sig.h f
|
||||
cross-build/x86-beos.cache f
|
||||
cross-build/beos-sig.h f
|
||||
cross-build/opennt.cache f
|
||||
include/ansi_stdlib.h f
|
||||
include/chartypes.h f
|
||||
include/filecntl.h f
|
||||
include/gettext.h f
|
||||
include/maxpath.h f
|
||||
include/memalloc.h f
|
||||
include/ocache.h f
|
||||
|
@ -234,6 +237,47 @@ lib/glob/collsyms.h f
|
|||
lib/glob/doc/Makefile f
|
||||
lib/glob/doc/glob.texi f
|
||||
lib/glob/ndir.h f
|
||||
lib/intl/ChangeLog f
|
||||
lib/intl/Makefile.in f
|
||||
lib/intl/VERSION f
|
||||
lib/intl/bindtextdom.c f
|
||||
lib/intl/config.charset f
|
||||
lib/intl/dcgettext.c f
|
||||
lib/intl/dcigettext.c f
|
||||
lib/intl/dcngettext.c f
|
||||
lib/intl/dgettext.c f
|
||||
lib/intl/dngettext.c f
|
||||
lib/intl/eval-plural.h f
|
||||
lib/intl/explodename.c f
|
||||
lib/intl/finddomain.c f
|
||||
lib/intl/gettext.c f
|
||||
lib/intl/gettextP.h f
|
||||
lib/intl/gmo.h f
|
||||
lib/intl/hash-string.h f
|
||||
lib/intl/intl-compat.c f
|
||||
lib/intl/l10nflist.c f
|
||||
lib/intl/libgnuintl.h.in f
|
||||
lib/intl/loadinfo.h f
|
||||
lib/intl/loadmsgcat.c f
|
||||
lib/intl/localcharset.c f
|
||||
lib/intl/localcharset.h f
|
||||
lib/intl/locale.alias f
|
||||
lib/intl/localealias.c f
|
||||
lib/intl/localename.c f
|
||||
lib/intl/log.c f
|
||||
lib/intl/ngettext.c f
|
||||
lib/intl/os2compat.c f
|
||||
lib/intl/os2compat.h f
|
||||
lib/intl/osdep.c f
|
||||
lib/intl/plural-exp.c f
|
||||
lib/intl/plural-exp.h f
|
||||
lib/intl/plural.c f
|
||||
lib/intl/plural.y f
|
||||
lib/intl/ref-add.sin f
|
||||
lib/intl/ref-del.sin f
|
||||
lib/intl/relocatable.c f
|
||||
lib/intl/relocatable.h f
|
||||
lib/intl/textdomain.c f
|
||||
lib/malloc/Makefile.in f
|
||||
lib/malloc/getpagesize.h f
|
||||
lib/malloc/imalloc.h f
|
||||
|
@ -313,14 +357,15 @@ lib/readline/rlstdc.h f
|
|||
lib/readline/rlprivate.h f
|
||||
lib/readline/xmalloc.h f
|
||||
lib/readline/doc/Makefile f
|
||||
lib/readline/doc/manvers.texinfo f
|
||||
lib/readline/doc/rlman.texinfo f
|
||||
lib/readline/doc/rltech.texinfo f
|
||||
lib/readline/doc/rluser.texinfo f
|
||||
lib/readline/doc/rluserman.texinfo f
|
||||
lib/readline/doc/hist.texinfo f
|
||||
lib/readline/doc/hstech.texinfo f
|
||||
lib/readline/doc/hsuser.texinfo f
|
||||
lib/readline/doc/version.texi f
|
||||
lib/readline/doc/rlman.texi f
|
||||
lib/readline/doc/rltech.texi f
|
||||
lib/readline/doc/rluser.texi f
|
||||
lib/readline/doc/rluserman.texi f
|
||||
lib/readline/doc/history.texi f
|
||||
lib/readline/doc/hstech.texi f
|
||||
lib/readline/doc/hsuser.texi f
|
||||
lib/readline/doc/fdl.texi f
|
||||
lib/readline/examples/Makefile f
|
||||
lib/readline/examples/excallback.c f
|
||||
lib/readline/examples/fileman.c f
|
||||
|
@ -331,17 +376,23 @@ lib/readline/examples/rl.c f
|
|||
lib/readline/examples/rlcat.c f
|
||||
lib/readline/examples/Inputrc f
|
||||
lib/sh/Makefile.in f
|
||||
lib/sh/casemod.c f
|
||||
lib/sh/clktck.c f
|
||||
lib/sh/clock.c f
|
||||
lib/sh/eaccess.c f
|
||||
lib/sh/fdprintf.c f
|
||||
lib/sh/fmtullong.c f
|
||||
lib/sh/fmtulong.c f
|
||||
lib/sh/fmtumax.c f
|
||||
lib/sh/fpurge.c f
|
||||
lib/sh/getcwd.c f
|
||||
lib/sh/getenv.c f
|
||||
lib/sh/inet_aton.c f
|
||||
lib/sh/input_avail.c f
|
||||
lib/sh/itos.c f
|
||||
lib/sh/mailstat.c f
|
||||
lib/sh/makepath.c f
|
||||
lib/sh/mbscmp.c f
|
||||
lib/sh/memset.c f
|
||||
lib/sh/mktime.c f
|
||||
lib/sh/netconn.c f
|
||||
|
@ -351,6 +402,7 @@ lib/sh/pathcanon.c f
|
|||
lib/sh/pathphys.c f
|
||||
lib/sh/rename.c f
|
||||
lib/sh/setlinebuf.c f
|
||||
lib/sh/shmatch.c f
|
||||
lib/sh/shquote.c f
|
||||
lib/sh/shtty.c f
|
||||
lib/sh/snprintf.c f
|
||||
|
@ -361,7 +413,9 @@ lib/sh/strftime.c f
|
|||
lib/sh/strindex.c f
|
||||
lib/sh/stringlist.c f
|
||||
lib/sh/stringvec.c f
|
||||
lib/sh/strnlen.c f
|
||||
lib/sh/strpbrk.c f
|
||||
lib/sh/strstr.c f
|
||||
lib/sh/strtod.c f
|
||||
lib/sh/strtoimax.c f
|
||||
lib/sh/strtol.c f
|
||||
|
@ -373,9 +427,15 @@ lib/sh/strtrans.c f
|
|||
lib/sh/times.c f
|
||||
lib/sh/timeval.c f
|
||||
lib/sh/tmpfile.c f
|
||||
lib/sh/uconvert.c f
|
||||
lib/sh/ufuncs.c f
|
||||
lib/sh/vprint.c f
|
||||
lib/sh/wcsdup.c f
|
||||
lib/sh/winsize.c f
|
||||
lib/sh/xstrchr.c f
|
||||
lib/sh/zcatfd.c f
|
||||
lib/sh/zgetline.c f
|
||||
lib/sh/zmapfd.c f
|
||||
lib/sh/zread.c f
|
||||
lib/sh/zwrite.c f
|
||||
lib/termcap/Makefile.in f
|
||||
|
@ -384,28 +444,75 @@ lib/termcap/termcap.c f
|
|||
lib/termcap/termcap.h f
|
||||
lib/termcap/tparam.c f
|
||||
lib/termcap/version.c f
|
||||
lib/termcap/grot/termcap.info f
|
||||
lib/termcap/grot/termcap.info-1 f
|
||||
lib/termcap/grot/termcap.info-2 f
|
||||
lib/termcap/grot/termcap.info-3 f
|
||||
lib/termcap/grot/termcap.info-4 f
|
||||
lib/termcap/grot/NEWS f
|
||||
lib/termcap/grot/INSTALL f
|
||||
lib/termcap/grot/ChangeLog f
|
||||
lib/termcap/grot/texinfo.tex f
|
||||
lib/termcap/grot/termcap.texi f
|
||||
lib/termcap/grot/Makefile.in f
|
||||
lib/termcap/grot/configure f
|
||||
lib/termcap/grot/configure.in f
|
||||
lib/termcap/grot/COPYING f
|
||||
lib/termcap/grot/README f
|
||||
lib/tilde/README f
|
||||
lib/tilde/Makefile.in f
|
||||
lib/tilde/doc/tilde.texi f
|
||||
lib/tilde/doc/Makefile f
|
||||
lib/tilde/tilde.c f
|
||||
lib/tilde/tilde.h f
|
||||
lib/tilde/shell.c f
|
||||
po/LINGUAS f
|
||||
po/Makefile.in.in f
|
||||
po/Makevars f
|
||||
po/POTFILES.in f
|
||||
po/README f
|
||||
po/Rules-builtins f
|
||||
po/Rules-quot f
|
||||
po/bash.pot f
|
||||
po/boldquot.sed f
|
||||
po/en@boldquot.gmo f
|
||||
po/en@boldquot.header f
|
||||
po/en@boldquot.po f
|
||||
po/en@quot.gmo f
|
||||
po/en@quot.header f
|
||||
po/en@quot.po f
|
||||
po/af.gmo f
|
||||
po/af.po f
|
||||
po/bg.gmo f
|
||||
po/bg.po f
|
||||
po/ca.gmo f
|
||||
po/ca.po f
|
||||
po/cs.gmo f
|
||||
po/cs.po f
|
||||
po/de.gmo f
|
||||
po/de.po f
|
||||
po/eo.gmo f
|
||||
po/eo.po f
|
||||
po/es.gmo f
|
||||
po/es.po f
|
||||
po/et.gmo f
|
||||
po/et.po f
|
||||
po/fr.gmo f
|
||||
po/fr.po f
|
||||
po/hu.gmo f
|
||||
po/hu.po f
|
||||
po/id.gmo f
|
||||
po/id.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
|
||||
po/pl.po f
|
||||
po/pt_BR.gmo f
|
||||
po/pt_BR.po f
|
||||
po/ro.gmo f
|
||||
po/ro.po f
|
||||
po/ru.gmo f
|
||||
po/ru.po f
|
||||
po/sk.gmo f
|
||||
po/sk.po f
|
||||
po/sv.gmo f
|
||||
po/sv.po f
|
||||
po/tr.gmo f
|
||||
po/tr.po f
|
||||
po/vi.gmo f
|
||||
po/vi.po f
|
||||
po/zh_TW.gmo f
|
||||
po/zh_TW.po f
|
||||
po/insert-header.sin f
|
||||
po/quot.sed f
|
||||
po/remove-potcdate.sin f
|
||||
CWRU/misc/open-files.c f
|
||||
CWRU/misc/sigs.c f
|
||||
CWRU/misc/sigstat.c f
|
||||
|
@ -414,6 +521,7 @@ CWRU/misc/errlist.c f
|
|||
CWRU/misc/hpux10-dlfcn.h f
|
||||
CWRU/PLATFORMS f
|
||||
CWRU/README f
|
||||
CWRU/audit-patch f
|
||||
CWRU/changelog f
|
||||
CWRU/sh-redir-hack f
|
||||
CWRU/mh-folder-comp f
|
||||
|
@ -427,12 +535,18 @@ doc/README f
|
|||
doc/INTRO f
|
||||
doc/texinfo.tex f
|
||||
doc/bashref.texi f
|
||||
doc/version.texi f
|
||||
doc/bashref.info f
|
||||
doc/article.ms f
|
||||
doc/htmlpost.sh f 755
|
||||
doc/infopost.sh f 755
|
||||
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
|
||||
support/printenv.sh f 755
|
||||
support/printenv.c f
|
||||
|
@ -441,33 +555,36 @@ support/missing f 755
|
|||
support/mkclone f 755
|
||||
support/mkconffiles f 755
|
||||
support/mkdirs f 755
|
||||
support/mkinstalldirs f 755
|
||||
support/mkversion.sh f 755
|
||||
support/mksignames.c f
|
||||
support/signames.c f
|
||||
support/bashbug.sh f
|
||||
support/man2html.c f
|
||||
support/recho.c f
|
||||
support/zecho.c f
|
||||
support/xcase.c f
|
||||
support/SYMLINKS f
|
||||
support/fixlinks f 755
|
||||
support/install.sh f 755
|
||||
support/texi2dvi f
|
||||
support/texi2dvi f 755
|
||||
support/texi2html f 755
|
||||
support/xenix-link.sh f 755
|
||||
support/shobj-conf f 755
|
||||
support/rlvers.sh f 755
|
||||
examples/bashdb/PERMISSION f
|
||||
examples/bashdb/bashdb f
|
||||
examples/bashdb/bashdb.el f
|
||||
examples/INDEX.txt f
|
||||
examples/INDEX.html f
|
||||
examples/obashdb/PERMISSION f
|
||||
examples/obashdb/README f
|
||||
examples/obashdb/bashdb f
|
||||
examples/obashdb/bashdb.fns f
|
||||
examples/obashdb/bashdb.pre f
|
||||
examples/obashdb/bashdb f
|
||||
examples/obashdb/bashdb.el f
|
||||
examples/complete/bash_completion f
|
||||
examples/complete/complete-examples f
|
||||
examples/complete/complete.ianmac f
|
||||
examples/complete/complete2.ianmac f
|
||||
examples/complete/complete.freebsd f
|
||||
examples/complete/complete.gnu-longopt f
|
||||
examples/complete/bashcc-1.0.1.tar.gz f
|
||||
examples/loadables/README f
|
||||
examples/loadables/template.c f
|
||||
examples/loadables/Makefile.in f
|
||||
|
@ -476,6 +593,7 @@ examples/loadables/hello.c f
|
|||
examples/loadables/print.c f
|
||||
examples/loadables/realpath.c f
|
||||
examples/loadables/sleep.c f
|
||||
examples/loadables/strftime.c f
|
||||
examples/loadables/truefalse.c f
|
||||
examples/loadables/getconf.h f
|
||||
examples/loadables/getconf.c f
|
||||
|
@ -498,6 +616,7 @@ examples/loadables/uname.c f
|
|||
examples/loadables/sync.c f
|
||||
examples/loadables/mkdir.c f
|
||||
examples/loadables/ln.c f
|
||||
examples/loadables/mypid.c f
|
||||
examples/loadables/unlink.c f
|
||||
examples/loadables/perl/Makefile.in f
|
||||
examples/loadables/perl/README f
|
||||
|
@ -577,6 +696,8 @@ examples/scripts/showperm.bash f
|
|||
examples/scripts/shprompt f
|
||||
examples/scripts/spin.bash f
|
||||
examples/scripts/timeout f
|
||||
examples/scripts/timeout2 f
|
||||
examples/scripts/timeout3 f
|
||||
examples/scripts/vtree2 f
|
||||
examples/scripts/vtree3 f
|
||||
examples/scripts/vtree3a f
|
||||
|
@ -601,15 +722,37 @@ examples/misc/aliasconv.sh f
|
|||
examples/misc/aliasconv.bash f
|
||||
examples/misc/cshtobash f
|
||||
tests/README f
|
||||
tests/COPYRIGHT f
|
||||
tests/alias.tests f
|
||||
tests/alias.right f
|
||||
tests/appendop.tests f
|
||||
tests/appendop.right f
|
||||
tests/arith-for.tests f
|
||||
tests/arith-for.right f
|
||||
tests/arith.tests f
|
||||
tests/arith.right f
|
||||
tests/arith1.sub f
|
||||
tests/arith2.sub f
|
||||
tests/array.tests f
|
||||
tests/array.right f
|
||||
tests/array1.sub f
|
||||
tests/array2.sub f
|
||||
tests/array3.sub f
|
||||
tests/array4.sub f
|
||||
tests/array5.sub f
|
||||
tests/array6.sub f
|
||||
tests/array7.sub f
|
||||
tests/array8.sub f
|
||||
tests/array9.sub f
|
||||
tests/array-at-star f
|
||||
tests/array2.right f
|
||||
tests/braces-tests f
|
||||
tests/assoc.tests f
|
||||
tests/assoc.right f
|
||||
tests/assoc1.sub f
|
||||
tests/assoc2.sub f
|
||||
tests/assoc3.sub f
|
||||
tests/assoc4.sub f
|
||||
tests/braces.tests f
|
||||
tests/braces.right f
|
||||
tests/builtins.tests f
|
||||
tests/builtins.right f
|
||||
|
@ -620,11 +763,40 @@ tests/source2.sub f
|
|||
tests/source3.sub f
|
||||
tests/source4.sub f
|
||||
tests/source5.sub f
|
||||
tests/source6.sub f
|
||||
tests/case.tests f
|
||||
tests/case.right f
|
||||
tests/casemod.tests f
|
||||
tests/casemod.right f
|
||||
tests/comsub.tests f
|
||||
tests/comsub.right f
|
||||
tests/comsub-eof.tests f
|
||||
tests/comsub-eof0.sub f
|
||||
tests/comsub-eof1.sub f
|
||||
tests/comsub-eof2.sub f
|
||||
tests/comsub-eof3.sub f
|
||||
tests/comsub-eof.right f
|
||||
tests/comsub-posix.tests f
|
||||
tests/comsub-posix.right f
|
||||
tests/comsub-posix1.sub f
|
||||
tests/cond.tests f
|
||||
tests/cond.right f
|
||||
tests/cond-regexp.sub f
|
||||
tests/coproc.tests f
|
||||
tests/coproc.right f
|
||||
tests/cprint.tests f
|
||||
tests/cprint.right f
|
||||
tests/dbg-support.right f
|
||||
tests/dbg-support.sub f
|
||||
tests/dbg-support.tests f
|
||||
tests/dbg-support2.right f
|
||||
tests/dbg-support2.tests f
|
||||
tests/dollar-at-star f
|
||||
tests/dollar-at1.sub f
|
||||
tests/dollar-at2.sub f
|
||||
tests/dollar-star1.sub f
|
||||
tests/dollar-star2.sub f
|
||||
tests/dollar-star3.sub f
|
||||
tests/dollar.right f
|
||||
tests/dstack.tests f
|
||||
tests/dstack.right f
|
||||
|
@ -640,12 +812,19 @@ tests/exec3.sub f
|
|||
tests/exec4.sub f
|
||||
tests/exec5.sub f
|
||||
tests/exec6.sub f
|
||||
tests/exp-tests f
|
||||
tests/exec7.sub f
|
||||
tests/exec8.sub f
|
||||
tests/exp.tests f
|
||||
tests/exp.right f
|
||||
tests/exp1.sub f
|
||||
tests/exp2.sub f
|
||||
tests/extglob.tests f
|
||||
tests/extglob.right f
|
||||
tests/extglob1.sub f
|
||||
tests/extglob2.tests f
|
||||
tests/extglob2.right f
|
||||
tests/extglob3.tests f
|
||||
tests/extglob3.right f
|
||||
tests/func.tests f
|
||||
tests/func.right f
|
||||
tests/func1.sub f
|
||||
|
@ -665,31 +844,49 @@ tests/glob1.sub f
|
|||
tests/glob.right f
|
||||
tests/heredoc.tests f
|
||||
tests/heredoc.right f
|
||||
tests/heredoc1.sub f
|
||||
tests/herestr.tests f
|
||||
tests/herestr.right f
|
||||
tests/histexp.tests f
|
||||
tests/histexp.right f
|
||||
tests/history.tests f
|
||||
tests/history.right f
|
||||
tests/history.list f
|
||||
tests/history.list f 444
|
||||
tests/history1.sub f
|
||||
tests/ifs.tests f
|
||||
tests/ifs.right f
|
||||
tests/ifs-posix.tests f
|
||||
tests/ifs-posix.right f
|
||||
tests/input-line.sh f
|
||||
tests/input-line.sub f
|
||||
tests/input.right f
|
||||
tests/intl.tests f
|
||||
tests/intl1.sub f
|
||||
tests/intl.right f
|
||||
tests/iquote.tests f
|
||||
tests/iquote.right f
|
||||
tests/invert.tests f
|
||||
tests/invert.right f
|
||||
tests/jobs.tests f
|
||||
tests/jobs1.sub f
|
||||
tests/jobs2.sub f
|
||||
tests/jobs3.sub f
|
||||
tests/jobs4.sub f
|
||||
tests/jobs.right f
|
||||
tests/mapfile.data f
|
||||
tests/mapfile.right f
|
||||
tests/mapfile.tests f
|
||||
tests/mapfile1.sub f
|
||||
tests/more-exp.tests f
|
||||
tests/more-exp.right f
|
||||
tests/new-exp.tests f
|
||||
tests/new-exp1.sub f
|
||||
tests/new-exp2.sub f
|
||||
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
|
||||
|
@ -699,6 +896,10 @@ tests/nquote2.tests f
|
|||
tests/nquote2.right f
|
||||
tests/nquote3.tests f
|
||||
tests/nquote3.right f
|
||||
tests/nquote4.tests f
|
||||
tests/nquote4.right f
|
||||
tests/nquote5.tests f
|
||||
tests/nquote5.right f
|
||||
tests/posix2.tests f
|
||||
tests/posix2.right f
|
||||
tests/posixpat.tests f
|
||||
|
@ -715,6 +916,8 @@ tests/read1.sub f
|
|||
tests/read2.sub f
|
||||
tests/read3.sub f
|
||||
tests/read4.sub f
|
||||
tests/read5.sub f
|
||||
tests/read6.sub f
|
||||
tests/redir.tests f
|
||||
tests/redir.right f
|
||||
tests/redir1.sub f
|
||||
|
@ -725,20 +928,35 @@ tests/redir3.in2 f
|
|||
tests/redir4.sub f
|
||||
tests/redir4.in1 f
|
||||
tests/redir5.sub f
|
||||
tests/redir6.sub f
|
||||
tests/redir7.sub f
|
||||
tests/redir8.sub f
|
||||
tests/redir9.sub f
|
||||
tests/rhs-exp.tests f
|
||||
tests/rhs-exp.right f
|
||||
tests/rsh.tests f
|
||||
tests/rsh.right f
|
||||
tests/run-all f
|
||||
tests/run-minimal f
|
||||
tests/run-alias f
|
||||
tests/run-appendop f
|
||||
tests/run-arith-for f
|
||||
tests/run-arith f
|
||||
tests/run-array f
|
||||
tests/run-array2 f
|
||||
tests/run-assoc f
|
||||
tests/run-braces f
|
||||
tests/run-builtins f
|
||||
tests/run-case f
|
||||
tests/run-casemod f
|
||||
tests/run-comsub f
|
||||
tests/run-comsub-eof f
|
||||
tests/run-comsub-posix f
|
||||
tests/run-cond f
|
||||
tests/run-coproc f
|
||||
tests/run-cprint f
|
||||
tests/run-dbg-support f
|
||||
tests/run-dbg-support2 f
|
||||
tests/run-dirstack f
|
||||
tests/run-dollars f
|
||||
tests/run-errors f
|
||||
|
@ -746,6 +964,7 @@ tests/run-execscript f
|
|||
tests/run-exp-tests f
|
||||
tests/run-extglob f
|
||||
tests/run-extglob2 f
|
||||
tests/run-extglob3 f
|
||||
tests/run-func f
|
||||
tests/run-getopts f
|
||||
tests/run-glob-test f
|
||||
|
@ -754,15 +973,21 @@ tests/run-herestr f
|
|||
tests/run-histexpand f
|
||||
tests/run-history f
|
||||
tests/run-ifs f
|
||||
tests/run-ifs-posix f
|
||||
tests/run-input-test f
|
||||
tests/run-intl f
|
||||
tests/run-iquote f
|
||||
tests/run-invert f
|
||||
tests/run-jobs f
|
||||
tests/run-mapfile f
|
||||
tests/run-more-exp f
|
||||
tests/run-new-exp f
|
||||
tests/run-nquote f
|
||||
tests/run-nquote1 f
|
||||
tests/run-nquote2 f
|
||||
tests/run-nquote3 f
|
||||
tests/run-nquote4 f
|
||||
tests/run-nquote5 f
|
||||
tests/run-posix2 f
|
||||
tests/run-posixpat f
|
||||
tests/run-precedence f
|
||||
|
@ -773,23 +998,31 @@ tests/run-redir f
|
|||
tests/run-rhs-exp f
|
||||
tests/run-rsh f
|
||||
tests/run-set-e f
|
||||
tests/run-set-x f
|
||||
tests/run-shopt f
|
||||
tests/run-strip f
|
||||
tests/run-test f
|
||||
tests/run-tilde f
|
||||
tests/run-tilde2 f
|
||||
tests/run-trap f
|
||||
tests/run-type f
|
||||
tests/run-varenv f
|
||||
tests/set-e-test f
|
||||
tests/set-e.tests f
|
||||
tests/set-e1.sub f
|
||||
tests/set-e2.sub f
|
||||
tests/set-e.right f
|
||||
tests/set-x.tests f
|
||||
tests/set-x.right f
|
||||
tests/shopt.tests f
|
||||
tests/shopt.right f
|
||||
tests/strip.tests f
|
||||
tests/strip.right f
|
||||
tests/test.tests f
|
||||
tests/test.right f
|
||||
tests/tilde-tests f
|
||||
tests/tilde.tests f
|
||||
tests/tilde.right f
|
||||
tests/tilde2.tests f
|
||||
tests/tilde2.right f
|
||||
tests/trap.tests f
|
||||
tests/trap.right f
|
||||
tests/trap1.sub f 755
|
||||
|
@ -797,6 +1030,7 @@ tests/trap2.sub f 755
|
|||
tests/trap2a.sub f 755
|
||||
tests/type.tests f
|
||||
tests/type.right f
|
||||
tests/type1.sub f
|
||||
tests/varenv.right f
|
||||
tests/varenv.sh f
|
||||
tests/varenv1.sub f
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
#
|
||||
# Master Manifest file for documentation-only distribution
|
||||
#
|
||||
doc d
|
||||
MANIFEST.doc f
|
||||
doc/article.ps f
|
||||
doc/rose94.ps f
|
||||
doc/bash.ps f
|
||||
doc/bashbug.ps f
|
||||
doc/builtins.ps f
|
||||
doc/rbash.ps f
|
||||
doc/bashref.ps f
|
||||
doc/bashref.dvi f
|
||||
doc/bash.0 f
|
||||
doc/bashbug.0 f
|
||||
doc/builtins.0 f
|
||||
doc/rbash.0 f
|
||||
doc/article.txt f
|
||||
doc/bash.html f
|
||||
doc/bashref.html f
|
||||
doc/article.pdf f
|
||||
doc/bash.pdf f
|
||||
doc/bashref.pdf f
|
||||
doc/rose94.pdf f
|
File diff suppressed because it is too large
Load Diff
|
@ -1,3 +1,518 @@
|
|||
This is a terse description of the new features added to bash-4.0 since
|
||||
the release of bash-3.2. As always, the manual page (doc/bash.1) is
|
||||
the place to look for complete descriptions.
|
||||
|
||||
1. New Features in Bash
|
||||
|
||||
a. When using substring expansion on the positional parameters, a starting
|
||||
index of 0 now causes $0 to be prefixed to the list.
|
||||
|
||||
b. The `help' builtin now prints its columns with entries sorted vertically
|
||||
rather than horizontally.
|
||||
|
||||
c. There is a new variable, $BASHPID, which always returns the process id of
|
||||
the current shell.
|
||||
|
||||
d. There is a new `autocd' option that, when enabled, causes bash to attempt
|
||||
to `cd' to a directory name that is supplied as the first word of a
|
||||
simple command.
|
||||
|
||||
e. There is a new `checkjobs' option that causes the shell to check for and
|
||||
report any running or stopped jobs at exit.
|
||||
|
||||
f. The programmable completion code exports a new COMP_TYPE variable, set to
|
||||
a character describing the type of completion being attempted.
|
||||
|
||||
g. The programmable completion code exports a new COMP_KEY variable, set to
|
||||
the character that caused the completion to be invoked (e.g., TAB).
|
||||
|
||||
h. If creation of a child process fails due to insufficient resources, bash
|
||||
will try again several times before reporting failure.
|
||||
|
||||
i. The programmable completion code now uses the same set of characters as
|
||||
readline when breaking the command line into a list of words.
|
||||
|
||||
j. The block multiplier for the ulimit -c and -f options is now 512 when in
|
||||
Posix mode, as Posix specifies.
|
||||
|
||||
k. Changed the behavior of the read builtin to save any partial input received
|
||||
in the specified variable when the read builtin times out. This also
|
||||
results in variables specified as arguments to read to be set to the empty
|
||||
string when there is no input available. When the read builtin times out,
|
||||
it returns an exit status greater than 128.
|
||||
|
||||
l. The shell now has the notion of a `compatibility level', controlled by
|
||||
new variables settable by `shopt'. Setting this variable currently
|
||||
restores the bash-3.1 behavior when processing quoted strings on the rhs
|
||||
of the `=~' operator to the `[[' command.
|
||||
|
||||
m. The `ulimit' builtin now has new -b (socket buffer size) and -T (number
|
||||
of threads) options.
|
||||
|
||||
n. The -p option to `declare' now displays all variable values and attributes
|
||||
(or function values and attributes if used with -f).
|
||||
|
||||
o. There is a new `compopt' builtin that allows completion functions to modify
|
||||
completion options for existing completions or the completion currently
|
||||
being executed.
|
||||
|
||||
p. The `read' builtin has a new -i option which inserts text into the reply
|
||||
buffer when using readline.
|
||||
|
||||
q. A new `-E' option to the complete builtin allows control of the default
|
||||
behavior for completion on an empty line.
|
||||
|
||||
r. There is now limited support for completing command name words containing
|
||||
globbing characters.
|
||||
|
||||
s. Changed format of internal help documentation for all builtins to roughly
|
||||
follow man page format.
|
||||
|
||||
t. The `help' builtin now has a new -d option, to display a short description,
|
||||
and a -m option, to print help information in a man page-like format.
|
||||
|
||||
u. There is a new `mapfile' builtin to populate an array with lines from a
|
||||
given file. The name `readarray' is a synonym.
|
||||
|
||||
v. If a command is not found, the shell attempts to execute a shell function
|
||||
named `command_not_found_handle', supplying the command words as the
|
||||
function arguments.
|
||||
|
||||
w. There is a new shell option: `globstar'. When enabled, the globbing code
|
||||
treats `**' specially -- it matches all directories (and files within
|
||||
them, when appropriate) recursively.
|
||||
|
||||
x. There is a new shell option: `dirspell'. When enabled, the filename
|
||||
completion code performs spelling correction on directory names during
|
||||
completion.
|
||||
|
||||
y. The `-t' option to the `read' builtin now supports fractional timeout
|
||||
values.
|
||||
|
||||
z. Brace expansion now allows zero-padding of expanded numeric values and
|
||||
will add the proper number of zeroes to make sure all values contain the
|
||||
same number of digits.
|
||||
|
||||
aa. There is a new bash-specific bindable readline function: `dabbrev-expand'.
|
||||
It uses menu completion on a set of words taken from the history list.
|
||||
|
||||
bb. The command assigned to a key sequence with `bind -x' now sets two new
|
||||
variables in the environment of the executed command: READLINE_LINE_BUFFER
|
||||
and READLINE_POINT. The command can change the current readline line
|
||||
and cursor position by modifying READLINE_LINE_BUFFER and READLINE_POINT,
|
||||
respectively.
|
||||
|
||||
cc. There is a new &>> redirection operator, which appends the standard output
|
||||
and standard error to the named file.
|
||||
|
||||
dd. The parser now understands `|&' as a synonym for `2>&1 |', which redirects
|
||||
the standard error for a command through a pipe.
|
||||
|
||||
ee. The new `;&' case statement action list terminator causes execution to
|
||||
continue with the action associated with the next pattern in the
|
||||
statement rather than terminating the command.
|
||||
|
||||
ff. The new `;;&' case statement action list terminator causes the shell to
|
||||
test the next set of patterns after completing execution of the current
|
||||
action, rather than terminating the command.
|
||||
|
||||
gg. The shell understands a new variable: PROMPT_DIRTRIM. When set to an
|
||||
integer value greater than zero, prompt expansion of \w and \W will
|
||||
retain only that number of trailing pathname components and replace
|
||||
the intervening characters with `...'.
|
||||
|
||||
hh. There are new case-modifying word expansions: uppercase (^[^]) and
|
||||
lowercase (,[,]). They can work on either the first character or
|
||||
array element, or globally. They accept an optional shell pattern
|
||||
that determines which characters to modify. There is an optionally-
|
||||
configured feature to include capitalization operators.
|
||||
|
||||
ii. The shell provides associative array variables, with the appropriate
|
||||
support to create, delete, assign values to, and expand them.
|
||||
|
||||
jj. The `declare' builtin now has new -l (convert value to lowercase upon
|
||||
assignment) and -u (convert value to uppercase upon assignment) options.
|
||||
There is an optionally-configurable -c option to capitalize a value at
|
||||
assignment.
|
||||
|
||||
kk. There is a new `coproc' reserved word that specifies a coprocess: an
|
||||
asynchronous command run with two pipes connected to the creating shell.
|
||||
Coprocs can be named. The input and output file descriptors and the
|
||||
PID of the coprocess are available to the calling shell in variables
|
||||
with coproc-specific names.
|
||||
|
||||
ll. A value of 0 for the -t option to `read' now returns success if there is
|
||||
input available to be read from the specified file descriptor.
|
||||
|
||||
mm. CDPATH and GLOBIGNORE are ignored when the shell is running in privileged
|
||||
mode.
|
||||
|
||||
nn. New bindable readline functions shell-forward-word and shell-backward-word,
|
||||
which move forward and backward words delimited by shell metacharacters
|
||||
and honor shell quoting.
|
||||
|
||||
oo. New bindable readline functions shell-backward-kill-word and shell-kill-word
|
||||
which kill words backward and forward, but use the same word boundaries
|
||||
as shell-forward-word and shell-backward-word.
|
||||
|
||||
2. New Features in Readline
|
||||
|
||||
a. A new variable, rl_sort_completion_matches; allows applications to inhibit
|
||||
match list sorting (but beware: some things don't work right if
|
||||
applications do this).
|
||||
|
||||
b. A new variable, rl_completion_invoking_key; allows applications to discover
|
||||
the key that invoked rl_complete or rl_menu_complete.
|
||||
|
||||
c. The functions rl_block_sigint and rl_release_sigint are now public and
|
||||
available to calling applications who want to protect critical sections
|
||||
(like redisplay).
|
||||
|
||||
d. The functions rl_save_state and rl_restore_state are now public and
|
||||
available to calling applications; documented rest of readline's state
|
||||
flag values.
|
||||
|
||||
e. A new user-settable variable, `history-size', allows setting the maximum
|
||||
number of entries in the history list.
|
||||
|
||||
f. There is a new implementation of menu completion, with several improvements
|
||||
over the old; the most notable improvement is a better `completions
|
||||
browsing' mode.
|
||||
|
||||
g. The menu completion code now uses the rl_menu_completion_entry_function
|
||||
variable, allowing applications to provide their own menu completion
|
||||
generators.
|
||||
|
||||
h. There is support for replacing a prefix of a pathname with a `...' when
|
||||
displaying possible completions. This is controllable by setting the
|
||||
`completion-prefix-display-length' variable. Matches with a common prefix
|
||||
longer than this value have the common prefix replaced with `...'.
|
||||
|
||||
i. There is a new `revert-all-at-newline' variable. If enabled, readline will
|
||||
undo all outstanding changes to all history lines when `accept-line' is
|
||||
executed.
|
||||
|
||||
j. If the kernel supports it, readline displays special characters
|
||||
corresponding to a keyboard-generated signal when the signal is received.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
This is a terse description of the new features added to bash-3.2 since
|
||||
the release of bash-3.1. As always, the manual page (doc/bash.1) is
|
||||
the place to look for complete descriptions.
|
||||
|
||||
1. New Features in Bash
|
||||
|
||||
a. Changed the parameter pattern replacement functions to not anchor the
|
||||
pattern at the beginning of the string if doing global replacement - that
|
||||
combination doesn't make any sense.
|
||||
|
||||
b. When running in `word expansion only' mode (--wordexp option), inhibit
|
||||
process substitution.
|
||||
|
||||
c. Loadable builtins now work on MacOS X 10.[34].
|
||||
|
||||
d. Shells running in posix mode no longer set $HOME, as POSIX requires.
|
||||
|
||||
e. The code that checks for binary files being executed as shell scripts now
|
||||
checks only for NUL rather than any non-printing character.
|
||||
|
||||
f. Quoting the string argument to the [[ command's =~ operator now forces
|
||||
string matching, as with the other pattern-matching operators.
|
||||
|
||||
2. New Features in Readline
|
||||
|
||||
a. Calling applications can now set the keyboard timeout to 0, allowing
|
||||
poll-like behavior.
|
||||
|
||||
b. The value of SYS_INPUTRC (configurable at compilation time) is now used as
|
||||
the default last-ditch startup file.
|
||||
|
||||
c. The history file reading functions now allow windows-like \r\n line
|
||||
terminators.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
This is a terse description of the new features added to bash-3.1 since
|
||||
the release of bash-3.0. As always, the manual page (doc/bash.1) is
|
||||
the place to look for complete descriptions.
|
||||
|
||||
1. New Features in Bash
|
||||
|
||||
a. Bash now understands LC_TIME as a special variable so that time display
|
||||
tracks the current locale.
|
||||
|
||||
b. BASH_ARGC, BASH_ARGV, BASH_SOURCE, and BASH_LINENO are no longer created
|
||||
as `invisible' variables and may not be unset.
|
||||
|
||||
c. In POSIX mode, if `xpg_echo' option is enabled, the `echo' builtin doesn't
|
||||
try to interpret any options at all, as POSIX requires.
|
||||
|
||||
d. The `bg' builtin now accepts multiple arguments, as POSIX seems to specify.
|
||||
|
||||
e. Fixed vi-mode word completion and glob expansion to perform tilde
|
||||
expansion.
|
||||
|
||||
f. The `**' mathematic exponentiation operator is now right-associative.
|
||||
|
||||
g. The `ulimit' builtin has new options: -i (max number of pending signals),
|
||||
-q (max size of POSIX message queues), and -x (max number of file locks).
|
||||
|
||||
h. A bare `%' once again expands to the current job when used as a job
|
||||
specifier.
|
||||
|
||||
i. The `+=' assignment operator (append to the value of a string or array) is
|
||||
now supported for assignment statements and arguments to builtin commands
|
||||
that accept assignment statements.
|
||||
|
||||
j. BASH_COMMAND now preserves its value when a DEBUG trap is executed.
|
||||
|
||||
k. The `gnu_errfmt' option is enabled automatically if the shell is running
|
||||
in an emacs terminal window.
|
||||
|
||||
l. New configuration option: --single-help-strings. Causes long help text
|
||||
to be written as a single string; intended to ease translation.
|
||||
|
||||
m. The COMP_WORDBREAKS variable now causes the list of word break characters
|
||||
to be emptied when the variable is unset.
|
||||
|
||||
n. An unquoted expansion of $* when $IFS is empty now causes the positional
|
||||
parameters to be concatenated if the expansion doesn't undergo word
|
||||
splitting.
|
||||
|
||||
o. Bash now inherits $_ from the environment if it appears there at startup.
|
||||
|
||||
p. New shell option: nocasematch. If non-zero, shell pattern matching ignores
|
||||
case when used by `case' and `[[' commands.
|
||||
|
||||
q. The `printf' builtin takes a new option: -v var. That causes the output
|
||||
to be placed into var instead of on stdout.
|
||||
|
||||
r. By default, the shell no longer reports processes dying from SIGPIPE.
|
||||
|
||||
s. Bash now sets the extern variable `environ' to the export environment it
|
||||
creates, so C library functions that call getenv() (and can't use the
|
||||
shell-provided replacement) get current values of environment variables.
|
||||
|
||||
t. A new configuration option, `--enable-strict-posix-default', which will
|
||||
build bash to be POSIX conforming by default.
|
||||
|
||||
u. If compiled for strict POSIX conformance, LINES and COLUMNS may now
|
||||
override the true terminal size.
|
||||
|
||||
2. New Features in Readline
|
||||
|
||||
a. The key sequence sent by the keypad `delete' key is now automatically
|
||||
bound to delete-char.
|
||||
|
||||
b. A negative argument to menu-complete now cycles backward through the
|
||||
completion list.
|
||||
|
||||
c. A new bindable readline variable: bind-tty-special-chars. If non-zero,
|
||||
readline will bind the terminal special characters to their readline
|
||||
equivalents when it's called (on by default).
|
||||
|
||||
d. New bindable command: vi-rubout. Saves deleted text for possible
|
||||
reinsertion, as with any vi-mode `text modification' command; `X' is bound
|
||||
to this in vi command mode.
|
||||
|
||||
e. A new external application-controllable variable that allows the LINES
|
||||
and COLUMNS environment variables to set the window size regardless of
|
||||
what the kernel returns: rl_prefer_env_winsize
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
This is a terse description of the new features added to bash-3.0 since
|
||||
the release of bash-2.05b. As always, the manual page (doc/bash.1) is
|
||||
the place to look for complete descriptions.
|
||||
|
||||
1. New Features in Bash
|
||||
|
||||
a. ANSI string expansion now implements the \x{hexdigits} escape.
|
||||
|
||||
b. There is a new loadable `strftime' builtin.
|
||||
|
||||
c. New variable, COMP_WORDBREAKS, which controls the readline completer's
|
||||
idea of word break characters.
|
||||
|
||||
d. The `type' builtin no longer reports on aliases unless alias expansion
|
||||
will actually be performed.
|
||||
|
||||
e. HISTCONTROL is now a colon-separated list of values, which permits
|
||||
more extensibility and backwards compatibility.
|
||||
|
||||
f. HISTCONTROL may now include the `erasedups' option, which causes all lines
|
||||
matching a line being added to be removed from the history list.
|
||||
|
||||
g. `configure' has a new `--enable-multibyte' argument that permits multibyte
|
||||
character support to be disabled even on systems that support it.
|
||||
|
||||
h. New variables to support the bash debugger: BASH_ARGC, BASH_ARGV,
|
||||
BASH_SOURCE, BASH_LINENO, BASH_SUBSHELL, BASH_EXECUTION_STRING,
|
||||
BASH_COMMAND
|
||||
|
||||
i. FUNCNAME has been changed to support the debugger: it's now an array
|
||||
variable.
|
||||
|
||||
j. for, case, select, arithmetic commands now keep line number information
|
||||
for the debugger.
|
||||
|
||||
k. There is a new `RETURN' trap executed when a function or sourced script
|
||||
returns (not inherited child processes; inherited by command substitution
|
||||
if function tracing is enabled and the debugger is active).
|
||||
|
||||
l. New invocation option: --debugger. Enables debugging and turns on new
|
||||
`extdebug' shell option.
|
||||
|
||||
m. New `functrace' and `errtrace' options to `set -o' cause DEBUG and ERR
|
||||
traps, respectively, to be inherited by shell functions. Equivalent to
|
||||
`set -T' and `set -E' respectively. The `functrace' option also controls
|
||||
whether or not the DEBUG trap is inherited by sourced scripts.
|
||||
|
||||
n. The DEBUG trap is run before binding the variable and running the action
|
||||
list in a `for' command, binding the selection variable and running the
|
||||
query in a `select' command, and before attempting a match in a `case'
|
||||
command.
|
||||
|
||||
o. New `--enable-debugger' option to `configure' to compile in the debugger
|
||||
support code.
|
||||
|
||||
p. `declare -F' now prints out extra line number and source file information
|
||||
if the `extdebug' option is set.
|
||||
|
||||
q. If `extdebug' is enabled, a non-zero return value from a DEBUG trap causes
|
||||
the next command to be skipped, and a return value of 2 while in a
|
||||
function or sourced script forces a `return'.
|
||||
|
||||
r. New `caller' builtin to provide a call stack for the bash debugger.
|
||||
|
||||
s. The DEBUG trap is run just before the first command in a function body is
|
||||
executed, for the debugger.
|
||||
|
||||
t. `for', `select', and `case' command heads are printed when `set -x' is
|
||||
enabled.
|
||||
|
||||
u. There is a new {x..y} brace expansion, which is shorthand for {x.x+1,
|
||||
x+2,...,y}. x and y can be integers or single characters; the sequence
|
||||
may ascend or descend; the increment is always 1.
|
||||
|
||||
v. New ksh93-like ${!array[@]} expansion, expands to all the keys (indices)
|
||||
of array.
|
||||
|
||||
w. New `force_fignore' shopt option; if enabled, suffixes specified by
|
||||
FIGNORE cause words to be ignored when performing word completion even
|
||||
if they're the only possibilities.
|
||||
|
||||
x. New `gnu_errfmt' shopt option; if enabled, error messages follow the `gnu
|
||||
style' (filename:lineno:message) format.
|
||||
|
||||
y. New `-o bashdefault' option to complete and compgen; if set, causes the
|
||||
whole set of bash completions to be performed if the compspec doesn't
|
||||
result in a match.
|
||||
|
||||
z. New `-o plusdirs' option to complete and compgen; if set, causes directory
|
||||
name completion to be performed and the results added to the rest of the
|
||||
possible completions.
|
||||
|
||||
aa. `kill' is available as a builtin even when the shell is built without
|
||||
job control.
|
||||
|
||||
bb. New HISTTIMEFORMAT variable; value is a format string to pass to
|
||||
strftime(3). If set and not null, the `history' builtin prints out
|
||||
timestamp information according to the specified format when displaying
|
||||
history entries. If set, bash tells the history library to write out
|
||||
timestamp information when the history file is written.
|
||||
|
||||
cc. The [[ ... ]] command has a new binary `=~' operator that performs
|
||||
extended regular expression (egrep-like) matching.
|
||||
|
||||
dd. `configure' has a new `--enable-cond-regexp' option (enabled by default)
|
||||
to enable the =~ operator and regexp matching in [[ ... ]].
|
||||
|
||||
ee. Subexpressions matched by the =~ operator are placed in the new
|
||||
BASH_REMATCH array variable.
|
||||
|
||||
ff. New `failglob' option that causes an expansion error when pathname
|
||||
expansion fails to produce a match.
|
||||
|
||||
gg. New `set -o pipefail' option that causes a pipeline to return a failure
|
||||
status if any of the processes in the pipeline fail, not just the last
|
||||
one.
|
||||
|
||||
hh. printf builtin understands two new escape sequences: \" and \?.
|
||||
|
||||
ii. `echo -e' understands two new escape sequences: \" and \?.
|
||||
|
||||
jj. The GNU `gettext' package and libintl have been integrated; the shell's
|
||||
messages can be translated into different languages.
|
||||
|
||||
kk. The `\W' prompt expansion now abbreviates $HOME as `~', like `\w'.
|
||||
|
||||
ll. The error message printed when bash cannot open a shell script supplied
|
||||
as argument 1 now includes the name of the shell, to better identify
|
||||
the error as coming from bash.
|
||||
|
||||
mm. The parameter pattern removal and substitution expansions are now much
|
||||
faster and more efficient when using multibyte characters.
|
||||
|
||||
nn. The `jobs', `kill', and `wait' builtins now accept job control notation
|
||||
even if job control is not enabled.
|
||||
|
||||
oo. The historical behavior of `trap' that allows a missing `action' argument
|
||||
to cause each specified signal's handling to be reset to its default is
|
||||
now only supported when `trap' is given a single non-option argument.
|
||||
|
||||
2. New Features in Readline
|
||||
|
||||
a. History expansion has a new `a' modifier equivalent to the `g' modifier
|
||||
for compatibility with the BSD csh.
|
||||
|
||||
b. History expansion has a new `G' modifier equivalent to the BSD csh `g'
|
||||
modifier, which performs a substitution once per word.
|
||||
|
||||
c. All non-incremental search operations may now undo the operation of
|
||||
replacing the current line with the history line.
|
||||
|
||||
d. The text inserted by an `a' command in vi mode can be reinserted with
|
||||
`.'.
|
||||
|
||||
e. New bindable variable, `show-all-if-unmodified'. If set, the readline
|
||||
completer will list possible completions immediately if there is more
|
||||
than one completion and partial completion cannot be performed.
|
||||
|
||||
f. There is a new application-callable `free_history_entry()' function.
|
||||
|
||||
g. History list entries now contain timestamp information; the history file
|
||||
functions know how to read and write timestamp information associated
|
||||
with each entry.
|
||||
|
||||
h. Four new key binding functions have been added:
|
||||
|
||||
rl_bind_key_if_unbound()
|
||||
rl_bind_key_if_unbound_in_map()
|
||||
rl_bind_keyseq_if_unbound()
|
||||
rl_bind_keyseq_if_unbound_in_map()
|
||||
|
||||
i. New application variable, rl_completion_quote_character, set to any
|
||||
quote character readline finds before it calls the application completion
|
||||
function.
|
||||
|
||||
j. New application variable, rl_completion_suppress_quote, settable by an
|
||||
application completion function. If set to non-zero, readline does not
|
||||
attempt to append a closing quote to a completed word.
|
||||
|
||||
k. New application variable, rl_completion_found_quote, set to a non-zero
|
||||
value if readline determines that the word to be completed is quoted.
|
||||
Set before readline calls any application completion function.
|
||||
|
||||
l. New function hook, rl_completion_word_break_hook, called when readline
|
||||
needs to break a line into words when completion is attempted. Allows
|
||||
the word break characters to vary based on position in the line.
|
||||
|
||||
m. New bindable command: unix-filename-rubout. Does the same thing as
|
||||
unix-word-rubout, but adds `/' to the set of word delimiters.
|
||||
|
||||
n. When listing completions, directories have a `/' appended if the
|
||||
`mark-directories' option has been enabled.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
This is a terse description of the new features added to bash-2.05b since
|
||||
the release of bash-2.05a. As always, the manual page (doc/bash.1) is
|
||||
the place to look for complete descriptions.
|
||||
|
|
|
@ -261,6 +261,10 @@ Platform-Specific Configuration and Operation Notes
|
|||
I have received word that adding -L/etc/lib (or the equivalent
|
||||
-Wl,-L/etc/lib) might also be necessary, in addition to the -R/etc/lib.
|
||||
|
||||
On later versions of Solaris, it may be necessary to add -lnsl before
|
||||
-ldl; statically-linked versions of bash using libnsl are not guaranteed
|
||||
to work correctly on future versions of Solaris.
|
||||
|
||||
12. Configuring bash to build it in a cross environment. Currently only
|
||||
two native versions can be compiled this way, cygwin32 and x86 BeOS.
|
||||
For BeOS, you would configure it like this:
|
||||
|
@ -324,3 +328,20 @@ Platform-Specific Configuration and Operation Notes
|
|||
|
||||
15. Configure with `CC=xlc' if you don't have gcc on AIX 4.2 and later
|
||||
versions. `xlc' running in `cc' mode has trouble compiling error.c.
|
||||
|
||||
16. Configure --disable-multibyte on NetBSD versions (1.4 through at least
|
||||
1.6.1) that include wctype.h but do not define wctype_t.
|
||||
|
||||
17. Do NOT use bison-1.75. It builds a non-working parser. The most
|
||||
obvious effect is that constructs like "for i; do echo $i; done" don't
|
||||
loop over the positional parameters.
|
||||
|
||||
18. I have received reports that using -O2 with the MIPSpro results in a
|
||||
binary that fails in strange ways. Using -O1 seems to work.
|
||||
|
||||
19. There is special handling to ensure the shell links against static
|
||||
versions of the included readline and history libraries on Mac OS X;
|
||||
Apple ships inadequate dynamic libreadline and libhistory "replacements"
|
||||
as standard libraries.
|
||||
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
Bash POSIX Mode
|
||||
===============
|
||||
6.11 Bash POSIX Mode
|
||||
====================
|
||||
|
||||
Starting Bash with the `--posix' command-line option or executing `set
|
||||
-o posix' while Bash is running will cause Bash to conform more closely
|
||||
to the POSIX 1003.2 standard by changing the behavior to match that
|
||||
specified by POSIX in areas where the Bash default differs.
|
||||
to the POSIX standard by changing the behavior to match that specified
|
||||
by POSIX in areas where the Bash default differs.
|
||||
|
||||
When invoked as `sh', Bash enters POSIX mode after reading the startup
|
||||
files.
|
||||
|
@ -22,18 +22,20 @@ The following list is what's changed when `POSIX mode' is in effect:
|
|||
is stopped is `Stopped(SIGNAME)', where SIGNAME is, for example,
|
||||
`SIGTSTP'.
|
||||
|
||||
4. Reserved words may not be aliased.
|
||||
4. The `bg' builtin uses the required format to describe each job
|
||||
placed in the background, which does not include an indication of
|
||||
whether the job is the current or previous job.
|
||||
|
||||
5. The POSIX 1003.2 `PS1' and `PS2' expansions of `!' to the history
|
||||
number and `!!' to `!' are enabled, and parameter expansion is
|
||||
performed on the values of `PS1' and `PS2' regardless of the
|
||||
setting of the `promptvars' option.
|
||||
5. Reserved words appearing in a context where reserved words are
|
||||
recognized do not undergo alias expansion.
|
||||
|
||||
6. Interactive comments are enabled by default. (Bash has them on by
|
||||
default anyway.)
|
||||
6. The POSIX `PS1' and `PS2' expansions of `!' to the history number
|
||||
and `!!' to `!' are enabled, and parameter expansion is performed
|
||||
on the values of `PS1' and `PS2' regardless of the setting of the
|
||||
`promptvars' option.
|
||||
|
||||
7. The POSIX 1003.2 startup files are executed (`$ENV') rather than
|
||||
the normal Bash files.
|
||||
7. The POSIX startup files are executed (`$ENV') rather than the
|
||||
normal Bash files.
|
||||
|
||||
8. Tilde expansion is only performed on assignments preceding a
|
||||
command name, rather than on all assignment statements on the line.
|
||||
|
@ -42,38 +44,37 @@ The following list is what's changed when `POSIX mode' is in effect:
|
|||
value of `$HISTFILE').
|
||||
|
||||
10. The output of `kill -l' prints all the signal names on a single
|
||||
line, separated by spaces.
|
||||
line, separated by spaces, without the `SIG' prefix.
|
||||
|
||||
11. Non-interactive shells exit if FILENAME in `.' FILENAME is not
|
||||
11. The `kill' builtin does not accept signal names with a `SIG'
|
||||
prefix.
|
||||
|
||||
12. Non-interactive shells exit if FILENAME in `.' FILENAME is not
|
||||
found.
|
||||
|
||||
12. Non-interactive shells exit if a syntax error in an arithmetic
|
||||
13. Non-interactive shells exit if a syntax error in an arithmetic
|
||||
expansion results in an invalid expression.
|
||||
|
||||
13. Redirection operators do not perform filename expansion on the word
|
||||
14. Redirection operators do not perform filename expansion on the word
|
||||
in the redirection unless the shell is interactive.
|
||||
|
||||
14. Redirection operators do not perform word splitting on the word in
|
||||
15. Redirection operators do not perform word splitting on the word in
|
||||
the redirection.
|
||||
|
||||
15. Function names must be valid shell `name's. That is, they may not
|
||||
16. Function names must be valid shell `name's. That is, they may not
|
||||
contain characters other than letters, digits, and underscores, and
|
||||
may not start with a digit. Declaring a function with an invalid
|
||||
name causes a fatal syntax error in non-interactive shells.
|
||||
|
||||
16. POSIX 1003.2 `special' builtins are found before shell functions
|
||||
during command lookup.
|
||||
17. POSIX special builtins are found before shell functions during
|
||||
command lookup.
|
||||
|
||||
17. If a POSIX 1003.2 special builtin returns an error status, a
|
||||
18. If a POSIX special builtin returns an error status, a
|
||||
non-interactive shell exits. The fatal errors are those listed in
|
||||
the POSIX.2 standard, and include things like passing incorrect
|
||||
the POSIX standard, and include things like passing incorrect
|
||||
options, redirection errors, variable assignment errors for
|
||||
assignments preceding the command name, and so on.
|
||||
|
||||
18. If the `cd' builtin finds a directory to change to using
|
||||
`$CDPATH', the value it assigns to the `PWD' variable does not
|
||||
contain any symbolic links, as if `cd -P' had been executed.
|
||||
|
||||
19. If `CDPATH' is set, the `cd' builtin will not implicitly append
|
||||
the current directory to it. This means that `cd' will fail if no
|
||||
valid directory name can be constructed from any of the entries in
|
||||
|
@ -91,52 +92,91 @@ The following list is what's changed when `POSIX mode' is in effect:
|
|||
|
||||
22. Process substitution is not available.
|
||||
|
||||
23. Assignment statements preceding POSIX 1003.2 special builtins
|
||||
persist in the shell environment after the builtin completes.
|
||||
23. Assignment statements preceding POSIX special builtins persist in
|
||||
the shell environment after the builtin completes.
|
||||
|
||||
24. Assignment statements preceding shell function calls persist in the
|
||||
shell environment after the function returns, as if a POSIX
|
||||
special builtin command had been executed.
|
||||
|
||||
25. The `export' and `readonly' builtin commands display their output
|
||||
in the format required by POSIX 1003.2.
|
||||
in the format required by POSIX.
|
||||
|
||||
26. The `trap' builtin displays signal names without the leading `SIG'.
|
||||
|
||||
27. The `.' and `source' builtins do not search the current directory
|
||||
27. The `trap' builtin doesn't check the first argument for a possible
|
||||
signal specification and revert the signal handling to the original
|
||||
disposition if it is, unless that argument consists solely of
|
||||
digits and is a valid signal number. If users want to reset the
|
||||
handler for a given signal to the original disposition, they
|
||||
should use `-' as the first argument.
|
||||
|
||||
28. The `.' and `source' builtins do not search the current directory
|
||||
for the filename argument if it is not found by searching `PATH'.
|
||||
|
||||
28. Subshells spawned to execute command substitutions inherit the
|
||||
29. Subshells spawned to execute command substitutions inherit the
|
||||
value of the `-e' option from the parent shell. When not in POSIX
|
||||
mode, Bash clears the `-e' option in such subshells.
|
||||
|
||||
29. Alias expansion is always enabled, even in non-interactive shells.
|
||||
30. Alias expansion is always enabled, even in non-interactive shells.
|
||||
|
||||
30. When the `set' builtin is invoked without options, it does not
|
||||
31. When the `alias' builtin displays alias definitions, it does not
|
||||
display them with a leading `alias ' unless the `-p' option is
|
||||
supplied.
|
||||
|
||||
32. When the `set' builtin is invoked without options, it does not
|
||||
display shell function names and definitions.
|
||||
|
||||
31. When the `set' builtin is invoked without options, it displays
|
||||
33. When the `set' builtin is invoked without options, it displays
|
||||
variable values without quotes, unless they contain shell
|
||||
metacharacters, even if the result contains nonprinting characters.
|
||||
|
||||
32. When the `cd' builtin is invoked in LOGICAL mode, and the pathname
|
||||
34. When the `cd' builtin is invoked in LOGICAL mode, and the pathname
|
||||
constructed from `$PWD' and the directory name supplied as an
|
||||
argument does not refer to an existing directory, `cd' will fail
|
||||
instead of falling back to PHYSICAL mode.
|
||||
|
||||
There is other POSIX 1003.2 behavior that Bash does not implement.
|
||||
Specifically:
|
||||
35. When the `pwd' builtin is supplied the `-P' option, it resets
|
||||
`$PWD' to a pathname containing no symlinks.
|
||||
|
||||
1. Assignment statements affect the execution environment of all
|
||||
builtins, not just special ones.
|
||||
36. The `pwd' builtin verifies that the value it prints is the same as
|
||||
the current directory, even if it is not asked to check the file
|
||||
system with the `-P' option.
|
||||
|
||||
2. When a subshell is created to execute a shell script with execute
|
||||
permission, but without a leading `#!', Bash sets `$0' to the full
|
||||
pathname of the script as found by searching `$PATH', rather than
|
||||
the command as typed by the user.
|
||||
37. When listing the history, the `fc' builtin does not include an
|
||||
indication of whether or not a history entry has been modified.
|
||||
|
||||
3. When using `.' to source a shell script found in `$PATH', bash
|
||||
checks execute permission bits rather than read permission bits,
|
||||
just as if it were searching for a command.
|
||||
38. The default editor used by `fc' is `ed'.
|
||||
|
||||
39. The `type' and `command' builtins will not report a non-executable
|
||||
file as having been found, though the shell will attempt to
|
||||
execute such a file if it is the only so-named file found in
|
||||
`$PATH'.
|
||||
|
||||
40. The `vi' editing mode will invoke the `vi' editor directly when
|
||||
the `v' command is run, instead of checking `$VISUAL' and
|
||||
`$EDITOR'.
|
||||
|
||||
41. When the `xpg_echo' option is enabled, Bash does not attempt to
|
||||
interpret any arguments to `echo' as options. Each argument is
|
||||
displayed, after escape characters are converted.
|
||||
|
||||
42. The `ulimit' builtin uses a block size of 512 bytes for the `-c'
|
||||
and `-f' options.
|
||||
|
||||
|
||||
There is other POSIX behavior that Bash does not implement by default
|
||||
even when in POSIX mode. Specifically:
|
||||
|
||||
1. The `fc' builtin checks `$EDITOR' as a program to edit history
|
||||
entries if `FCEDIT' is unset, rather than defaulting directly to
|
||||
`ed'. `fc' uses `ed' if `EDITOR' is unset.
|
||||
|
||||
2. As noted above, Bash requires the `xpg_echo' option to be enabled
|
||||
for the `echo' builtin to be fully conformant.
|
||||
|
||||
|
||||
Bash can be configured to be POSIX-conformant by default, by specifying
|
||||
the `--enable-strict-posix-default' to `configure' when building (*note
|
||||
Optional Features::).
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
The Restricted Shell
|
||||
====================
|
||||
6.10 The Restricted Shell
|
||||
=========================
|
||||
|
||||
If Bash is started with the name `rbash', or the `--restricted' or `-r'
|
||||
option is supplied at invocation, the shell becomes restricted. A
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
Introduction
|
||||
============
|
||||
|
||||
This is GNU Bash, version 2.05b. Bash is the GNU Project's Bourne
|
||||
This is GNU Bash, version 4.0. Bash is the GNU Project's Bourne
|
||||
Again SHell, a complete implementation of the POSIX.2 shell spec,
|
||||
but also with interactive command line editing, job control on
|
||||
architectures that support it, csh-like features such as history
|
||||
|
@ -11,17 +11,18 @@ type of shell, see the file `doc/bashref.texi'. There is also a
|
|||
large Unix-style man page. The man page is the definitive description
|
||||
of the shell's features.
|
||||
|
||||
See the file CWRU/POSIX.NOTES for a discussion of how Bash differs
|
||||
See the file POSIX for a discussion of how the Bash defaults differ
|
||||
from the POSIX.2 spec and a description of the Bash `posix mode'.
|
||||
|
||||
There are some user-visible incompatibilities between this version
|
||||
of Bash and the previous widely-distributed version, bash-1.14.
|
||||
For details, see the file COMPAT. The NEWS file tersely lists
|
||||
features that are new in this release.
|
||||
of Bash and previous widely-distributed versions, bash-2.05b and
|
||||
bash-3.2. For details, see the file COMPAT. The NEWS file tersely
|
||||
lists features that are new in this release.
|
||||
|
||||
Bash is free software, distributed under the terms of the [GNU]
|
||||
General Public License, version 2. For more information, see the
|
||||
file COPYING.
|
||||
Bash is free software, distributed under the terms of the [GNU] General
|
||||
Public License as published by the Free Software Foundation,
|
||||
version 3 of the License (or any later version). For more information,
|
||||
see the file COPYING.
|
||||
|
||||
A number of frequently-asked questions are answered in the file
|
||||
`doc/FAQ'.
|
||||
|
@ -87,4 +88,4 @@ like this shell to be the best that we can make it.
|
|||
Enjoy!
|
||||
|
||||
Chet Ramey
|
||||
chet@po.cwru.edu
|
||||
chet.ramey@case.edu
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
Since Bash does not manipulate date strings, it is Y2K-safe.
|
||||
|
||||
The only thing that Bash does with date strings is manipulate the string
|
||||
returned by ctime(3) in the prompt customization code. In all cases,
|
||||
it discards the year.
|
||||
returned by ctime(3) or strftime(3) in the prompt customization code.
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,23 +1,23 @@
|
|||
/* alias.c -- Not a full alias, but just the kind that we use in the
|
||||
shell. Csh style alias is somewhere else (`over there, in a box'). */
|
||||
|
||||
/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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. */
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
@ -67,7 +67,7 @@ HASH_TABLE *aliases = (HASH_TABLE *)NULL;
|
|||
void
|
||||
initialize_aliases ()
|
||||
{
|
||||
if (!aliases)
|
||||
if (aliases == 0)
|
||||
aliases = hash_create (ALIAS_HASH_BUCKETS);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
/* alias.h -- structure definitions. */
|
||||
|
||||
/* Copyright (C) 1987,1991 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2009 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 1, or (at your option)
|
||||
any later version.
|
||||
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 3 of the License, 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.
|
||||
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. */
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if !defined (_ALIAS_H_)
|
||||
#define _ALIAS_H_
|
||||
|
|
|
@ -9,23 +9,23 @@
|
|||
* chet@ins.cwru.edu
|
||||
*/
|
||||
|
||||
/* Copyright (C) 1997-2002 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1997-2009 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 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 3 of the License, 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.
|
||||
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. */
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
@ -107,7 +107,7 @@ ARRAY *a;
|
|||
ARRAY *a1;
|
||||
ARRAY_ELEMENT *ae, *new;
|
||||
|
||||
if (!a)
|
||||
if (a == 0)
|
||||
return((ARRAY *) NULL);
|
||||
a1 = array_create();
|
||||
a1->type = a->type;
|
||||
|
@ -120,7 +120,6 @@ ARRAY *a;
|
|||
return(a1);
|
||||
}
|
||||
|
||||
#ifdef INCLUDE_UNUSED
|
||||
/*
|
||||
* Make and return a new array composed of the elements in array A from
|
||||
* S to E, inclusive.
|
||||
|
@ -138,32 +137,32 @@ ARRAY_ELEMENT *s, *e;
|
|||
a = array_create ();
|
||||
a->type = array->type;
|
||||
|
||||
for (p = s, i = 0; p != e; p = element_forw(p), i++) {
|
||||
for (mi = 0, p = s, i = 0; p != e; p = element_forw(p), i++) {
|
||||
n = array_create_element (element_index(p), element_value(p));
|
||||
ADD_BEFORE(a->head, n);
|
||||
mi = element_index(ae);
|
||||
mi = element_index(n);
|
||||
}
|
||||
a->num_elements = i;
|
||||
a->max_index = mi;
|
||||
return a;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Walk the array, calling FUNC once for each element, with the array
|
||||
* element as the argument.
|
||||
*/
|
||||
void
|
||||
array_walk(a, func)
|
||||
array_walk(a, func, udata)
|
||||
ARRAY *a;
|
||||
sh_ae_map_func_t *func;
|
||||
void *udata;
|
||||
{
|
||||
register ARRAY_ELEMENT *ae;
|
||||
|
||||
if (a == 0 || array_empty(a))
|
||||
return;
|
||||
for (ae = element_forw(a->head); ae != a->head; ae = element_forw(ae))
|
||||
if ((*func)(ae) < 0)
|
||||
if ((*func)(ae, udata) < 0)
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -242,9 +241,9 @@ char *s;
|
|||
{
|
||||
register ARRAY_ELEMENT *ae, *new;
|
||||
|
||||
if (a == 0)
|
||||
if (a == 0 || (array_empty(a) && s == 0))
|
||||
return 0;
|
||||
if (n <= 0)
|
||||
else if (n <= 0)
|
||||
return (a->num_elements);
|
||||
|
||||
ae = element_forw(a->head);
|
||||
|
@ -252,27 +251,44 @@ char *s;
|
|||
new = array_create_element(0, s);
|
||||
ADD_BEFORE(ae, new);
|
||||
a->num_elements++;
|
||||
if (array_num_elements(a) == 1) /* array was empty */
|
||||
return 1;
|
||||
}
|
||||
|
||||
a->max_index += n;
|
||||
|
||||
/*
|
||||
* Renumber all elements in the array except the one we just added.
|
||||
*/
|
||||
for ( ; ae != a->head; ae = element_forw(ae))
|
||||
element_index(ae) += n;
|
||||
|
||||
a->max_index = element_index(a->head->prev);
|
||||
|
||||
return (a->num_elements);
|
||||
}
|
||||
|
||||
ARRAY *
|
||||
ARRAY_ELEMENT *
|
||||
array_unshift_element(a)
|
||||
ARRAY *a;
|
||||
{
|
||||
return (array_shift (a, 1, 0));
|
||||
}
|
||||
|
||||
int
|
||||
array_shift_element(a, v)
|
||||
ARRAY *a;
|
||||
char *v;
|
||||
{
|
||||
return (array_rshift (a, 1, v));
|
||||
}
|
||||
|
||||
ARRAY *
|
||||
array_quote(array)
|
||||
ARRAY *array;
|
||||
{
|
||||
ARRAY_ELEMENT *a;
|
||||
char *t;
|
||||
|
||||
if (array == 0 || array->head == 0 || array_empty (array))
|
||||
if (array == 0 || array_head(array) == 0 || array_empty(array))
|
||||
return (ARRAY *)NULL;
|
||||
for (a = element_forw(array->head); a != array->head; a = element_forw(a)) {
|
||||
t = quote_string (a->value);
|
||||
|
@ -282,27 +298,139 @@ ARRAY *array;
|
|||
return array;
|
||||
}
|
||||
|
||||
char *
|
||||
array_subrange (a, start, end, quoted)
|
||||
ARRAY *a;
|
||||
arrayind_t start, end;
|
||||
int quoted;
|
||||
ARRAY *
|
||||
array_quote_escapes(array)
|
||||
ARRAY *array;
|
||||
{
|
||||
ARRAY_ELEMENT *a;
|
||||
char *t;
|
||||
|
||||
if (array == 0 || array_head(array) == 0 || array_empty(array))
|
||||
return (ARRAY *)NULL;
|
||||
for (a = element_forw(array->head); a != array->head; a = element_forw(a)) {
|
||||
t = quote_escapes (a->value);
|
||||
FREE(a->value);
|
||||
a->value = t;
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
ARRAY *
|
||||
array_dequote(array)
|
||||
ARRAY *array;
|
||||
{
|
||||
ARRAY_ELEMENT *a;
|
||||
char *t;
|
||||
|
||||
if (array == 0 || array_head(array) == 0 || array_empty(array))
|
||||
return (ARRAY *)NULL;
|
||||
for (a = element_forw(array->head); a != array->head; a = element_forw(a)) {
|
||||
t = dequote_string (a->value);
|
||||
FREE(a->value);
|
||||
a->value = t;
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
ARRAY *
|
||||
array_dequote_escapes(array)
|
||||
ARRAY *array;
|
||||
{
|
||||
ARRAY_ELEMENT *a;
|
||||
char *t;
|
||||
|
||||
if (array == 0 || array_head(array) == 0 || array_empty(array))
|
||||
return (ARRAY *)NULL;
|
||||
for (a = element_forw(array->head); a != array->head; a = element_forw(a)) {
|
||||
t = dequote_escapes (a->value);
|
||||
FREE(a->value);
|
||||
a->value = t;
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
ARRAY *
|
||||
array_remove_quoted_nulls(array)
|
||||
ARRAY *array;
|
||||
{
|
||||
ARRAY_ELEMENT *a;
|
||||
char *t;
|
||||
|
||||
if (array == 0 || array_head(array) == 0 || array_empty(array))
|
||||
return (ARRAY *)NULL;
|
||||
for (a = element_forw(array->head); a != array->head; a = element_forw(a))
|
||||
a->value = remove_quoted_nulls (a->value);
|
||||
return array;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return a string whose elements are the members of array A beginning at
|
||||
* index START and spanning NELEM members. Null elements are counted.
|
||||
* Since arrays are sparse, unset array elements are not counted.
|
||||
*/
|
||||
char *
|
||||
array_subrange (a, start, nelem, starsub, quoted)
|
||||
ARRAY *a;
|
||||
arrayind_t start, nelem;
|
||||
int starsub, quoted;
|
||||
{
|
||||
ARRAY *a2;
|
||||
ARRAY_ELEMENT *h, *p;
|
||||
arrayind_t i;
|
||||
char *ifs, *sifs, *t;
|
||||
int slen;
|
||||
|
||||
p = array_head (a);
|
||||
if (p == 0 || array_empty (a) || start > array_num_elements (a))
|
||||
p = a ? array_head (a) : 0;
|
||||
if (p == 0 || array_empty (a) || start > array_max_index(a))
|
||||
return ((char *)NULL);
|
||||
|
||||
for (i = 0, p = element_forw(p); p != a->head && i < start; i++, p = element_forw(p))
|
||||
/*
|
||||
* Find element with index START. If START corresponds to an unset
|
||||
* element (arrays can be sparse), use the first element whose index
|
||||
* is >= START. If START is < 0, we count START indices back from
|
||||
* the end of A (not elements, even with sparse arrays -- START is an
|
||||
* index).
|
||||
*/
|
||||
for (p = element_forw(p); p != array_head(a) && start > element_index(p); p = element_forw(p))
|
||||
;
|
||||
|
||||
if (p == a->head)
|
||||
return ((char *)NULL);
|
||||
for (h = p; p != a->head && i < end; i++, p = element_forw(p))
|
||||
|
||||
/* Starting at P, take NELEM elements, inclusive. */
|
||||
for (i = 0, h = p; p != a->head && i < nelem; i++, p = element_forw(p))
|
||||
;
|
||||
|
||||
return (array_to_string_internal (h, p, " ", quoted));
|
||||
a2 = array_slice(a, h, p);
|
||||
|
||||
if (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT))
|
||||
array_quote(a2);
|
||||
else
|
||||
array_quote_escapes(a2);
|
||||
|
||||
if (starsub && (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT))) {
|
||||
/* ${array[*]} */
|
||||
array_remove_quoted_nulls (a2);
|
||||
sifs = ifs_firstchar ((int *)NULL);
|
||||
t = array_to_string (a2, sifs, 0);
|
||||
free (sifs);
|
||||
} else if (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) {
|
||||
/* ${array[@]} */
|
||||
sifs = ifs_firstchar (&slen);
|
||||
ifs = getifs ();
|
||||
if (ifs == 0 || *ifs == 0) {
|
||||
if (slen < 2)
|
||||
sifs = xrealloc(sifs, 2);
|
||||
sifs[0] = ' ';
|
||||
sifs[1] = '\0';
|
||||
}
|
||||
t = array_to_string (a2, sifs, 0);
|
||||
free (sifs);
|
||||
} else
|
||||
t = array_to_string (a2, " ", 0);
|
||||
array_dispose(a2);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
char *
|
||||
|
@ -313,12 +441,13 @@ int mflags;
|
|||
{
|
||||
ARRAY *a2;
|
||||
ARRAY_ELEMENT *e;
|
||||
char *t;
|
||||
char *t, *sifs, *ifs;
|
||||
int slen;
|
||||
|
||||
if (array_head (a) == 0 || array_empty (a))
|
||||
if (a == 0 || array_head(a) == 0 || array_empty(a))
|
||||
return ((char *)NULL);
|
||||
|
||||
a2 = array_copy (a);
|
||||
a2 = array_copy(a);
|
||||
for (e = element_forw(a2->head); e != a2->head; e = element_forw(e)) {
|
||||
t = pat_subst(element_value(e), pat, rep, mflags);
|
||||
FREE(element_value(e));
|
||||
|
@ -326,13 +455,84 @@ int mflags;
|
|||
}
|
||||
|
||||
if (mflags & MATCH_QUOTED)
|
||||
array_quote (a2);
|
||||
t = array_to_string (a2, " ", 0);
|
||||
array_quote(a2);
|
||||
else
|
||||
array_quote_escapes(a2);
|
||||
|
||||
if (mflags & MATCH_STARSUB) {
|
||||
array_remove_quoted_nulls (a2);
|
||||
sifs = ifs_firstchar((int *)NULL);
|
||||
t = array_to_string (a2, sifs, 0);
|
||||
free(sifs);
|
||||
} else if (mflags & MATCH_QUOTED) {
|
||||
/* ${array[@]} */
|
||||
sifs = ifs_firstchar (&slen);
|
||||
ifs = getifs ();
|
||||
if (ifs == 0 || *ifs == 0) {
|
||||
if (slen < 2)
|
||||
sifs = xrealloc (sifs, 2);
|
||||
sifs[0] = ' ';
|
||||
sifs[1] = '\0';
|
||||
}
|
||||
t = array_to_string (a2, sifs, 0);
|
||||
free(sifs);
|
||||
} else
|
||||
t = array_to_string (a2, " ", 0);
|
||||
array_dispose (a2);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
char *
|
||||
array_modcase (a, pat, modop, mflags)
|
||||
ARRAY *a;
|
||||
char *pat;
|
||||
int modop;
|
||||
int mflags;
|
||||
{
|
||||
ARRAY *a2;
|
||||
ARRAY_ELEMENT *e;
|
||||
char *t, *sifs, *ifs;
|
||||
int slen;
|
||||
|
||||
if (a == 0 || array_head(a) == 0 || array_empty(a))
|
||||
return ((char *)NULL);
|
||||
|
||||
a2 = array_copy(a);
|
||||
for (e = element_forw(a2->head); e != a2->head; e = element_forw(e)) {
|
||||
t = sh_modcase(element_value(e), pat, modop);
|
||||
FREE(element_value(e));
|
||||
e->value = t;
|
||||
}
|
||||
|
||||
if (mflags & MATCH_QUOTED)
|
||||
array_quote(a2);
|
||||
else
|
||||
array_quote_escapes(a2);
|
||||
|
||||
if (mflags & MATCH_STARSUB) {
|
||||
array_remove_quoted_nulls (a2);
|
||||
sifs = ifs_firstchar((int *)NULL);
|
||||
t = array_to_string (a2, sifs, 0);
|
||||
free(sifs);
|
||||
} else if (mflags & MATCH_QUOTED) {
|
||||
/* ${array[@]} */
|
||||
sifs = ifs_firstchar (&slen);
|
||||
ifs = getifs ();
|
||||
if (ifs == 0 || *ifs == 0) {
|
||||
if (slen < 2)
|
||||
sifs = xrealloc (sifs, 2);
|
||||
sifs[0] = ' ';
|
||||
sifs[1] = '\0';
|
||||
}
|
||||
t = array_to_string (a2, sifs, 0);
|
||||
free(sifs);
|
||||
} else
|
||||
t = array_to_string (a2, " ", 0);
|
||||
array_dispose (a2);
|
||||
|
||||
return t;
|
||||
}
|
||||
/*
|
||||
* Allocate and return a new array element with index INDEX and value
|
||||
* VALUE.
|
||||
|
@ -365,8 +565,10 @@ void
|
|||
array_dispose_element(ae)
|
||||
ARRAY_ELEMENT *ae;
|
||||
{
|
||||
FREE(ae->value);
|
||||
free(ae);
|
||||
if (ae) {
|
||||
FREE(ae->value);
|
||||
free(ae);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -380,7 +582,7 @@ char *v;
|
|||
{
|
||||
register ARRAY_ELEMENT *new, *ae;
|
||||
|
||||
if (!a)
|
||||
if (a == 0)
|
||||
return(-1);
|
||||
new = array_create_element(i, v);
|
||||
if (i > array_max_index(a)) {
|
||||
|
@ -404,7 +606,7 @@ char *v;
|
|||
*/
|
||||
array_dispose_element(new);
|
||||
free(element_value(ae));
|
||||
ae->value = savestring(v);
|
||||
ae->value = v ? savestring(v) : (char *)NULL;
|
||||
return(0);
|
||||
} else if (element_index(ae) > i) {
|
||||
ADD_BEFORE(ae, new);
|
||||
|
@ -426,7 +628,7 @@ arrayind_t i;
|
|||
{
|
||||
register ARRAY_ELEMENT *ae;
|
||||
|
||||
if (!a || array_empty(a))
|
||||
if (a == 0 || array_empty(a))
|
||||
return((ARRAY_ELEMENT *) NULL);
|
||||
for (ae = element_forw(a->head); ae != a->head; ae = element_forw(ae))
|
||||
if (element_index(ae) == i) {
|
||||
|
@ -460,6 +662,7 @@ arrayind_t i;
|
|||
|
||||
/* Convenience routines for the shell to translate to and from the form used
|
||||
by the rest of the code. */
|
||||
|
||||
WORD_LIST *
|
||||
array_to_word_list(a)
|
||||
ARRAY *a;
|
||||
|
@ -487,6 +690,25 @@ WORD_LIST *list;
|
|||
return (array_assign_list (a, list));
|
||||
}
|
||||
|
||||
WORD_LIST *
|
||||
array_keys_to_word_list(a)
|
||||
ARRAY *a;
|
||||
{
|
||||
WORD_LIST *list;
|
||||
ARRAY_ELEMENT *ae;
|
||||
char *t;
|
||||
|
||||
if (a == 0 || array_empty(a))
|
||||
return((WORD_LIST *)NULL);
|
||||
list = (WORD_LIST *)NULL;
|
||||
for (ae = element_forw(a->head); ae != a->head; ae = element_forw(ae)) {
|
||||
t = itos(element_index(ae));
|
||||
list = make_word_list (make_bare_word(t), list);
|
||||
free(t);
|
||||
}
|
||||
return (REVERSE_LIST(list, WORD_LIST *));
|
||||
}
|
||||
|
||||
ARRAY *
|
||||
array_assign_list (array, list)
|
||||
ARRAY *array;
|
||||
|
@ -521,8 +743,8 @@ ARRAY *a;
|
|||
}
|
||||
|
||||
/*
|
||||
* Return a string that is the concatenation of all the elements in A,
|
||||
* separated by SEP.
|
||||
* Return a string that is the concatenation of the elements in A from START
|
||||
* to END, separated by SEP.
|
||||
*/
|
||||
static char *
|
||||
array_to_string_internal (start, end, sep, quoted)
|
||||
|
@ -586,7 +808,7 @@ int quoted;
|
|||
is = inttostr (element_index(ae), indstr, sizeof(indstr));
|
||||
valstr = element_value (ae) ? sh_double_quote (element_value(ae))
|
||||
: (char *)NULL;
|
||||
elen = STRLEN (indstr) + 8 + STRLEN (valstr);
|
||||
elen = STRLEN (is) + 8 + STRLEN (valstr);
|
||||
RESIZE_MALLOCED_BUFFER (result, rlen, (elen + 1), rsize, rsize);
|
||||
|
||||
result[rlen++] = '[';
|
||||
|
@ -767,7 +989,7 @@ print_array(a)
|
|||
ARRAY *a;
|
||||
{
|
||||
printf("\n");
|
||||
array_walk(a, print_element);
|
||||
array_walk(a, print_element, (void *)NULL);
|
||||
}
|
||||
|
||||
main()
|
||||
|
|
|
@ -1,23 +1,24 @@
|
|||
/* array.h -- definitions for the interface exported by array.c that allows
|
||||
the rest of the shell to manipulate array variables. */
|
||||
|
||||
/* Copyright (C) 1997 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1997-2009 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 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 3 of the License, 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.
|
||||
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. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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. */
|
||||
|
||||
#ifndef _ARRAY_H_
|
||||
#define _ARRAY_H_
|
||||
|
@ -40,7 +41,7 @@ typedef struct array_element {
|
|||
struct array_element *next, *prev;
|
||||
} ARRAY_ELEMENT;
|
||||
|
||||
typedef int sh_ae_map_func_t __P((ARRAY_ELEMENT *));
|
||||
typedef int sh_ae_map_func_t __P((ARRAY_ELEMENT *, void *));
|
||||
|
||||
/* Basic operations on entire arrays */
|
||||
extern ARRAY *array_create __P((void));
|
||||
|
@ -48,14 +49,22 @@ extern void array_flush __P((ARRAY *));
|
|||
extern void array_dispose __P((ARRAY *));
|
||||
extern ARRAY *array_copy __P((ARRAY *));
|
||||
extern ARRAY *array_slice __P((ARRAY *, ARRAY_ELEMENT *, ARRAY_ELEMENT *));
|
||||
extern void array_walk __P((ARRAY *, sh_ae_map_func_t *));
|
||||
extern void array_walk __P((ARRAY *, sh_ae_map_func_t *, void *));
|
||||
|
||||
extern ARRAY_ELEMENT *array_shift __P((ARRAY *, int, int));
|
||||
extern int array_rshift __P((ARRAY *, int, char *));
|
||||
extern ARRAY *array_quote __P((ARRAY *));
|
||||
extern ARRAY_ELEMENT *array_unshift_element __P((ARRAY *));
|
||||
extern int array_shift_element __P((ARRAY *, char *));
|
||||
|
||||
extern char *array_subrange __P((ARRAY *, arrayind_t, arrayind_t, int));
|
||||
extern ARRAY *array_quote __P((ARRAY *));
|
||||
extern ARRAY *array_quote_escapes __P((ARRAY *));
|
||||
extern ARRAY *array_dequote __P((ARRAY *));
|
||||
extern ARRAY *array_dequote_escapes __P((ARRAY *));
|
||||
extern ARRAY *array_remove_quoted_nulls __P((ARRAY *));
|
||||
|
||||
extern char *array_subrange __P((ARRAY *, arrayind_t, arrayind_t, int, int));
|
||||
extern char *array_patsub __P((ARRAY *, char *, char *, int));
|
||||
extern char *array_modcase __P((ARRAY *, char *, int, int));
|
||||
|
||||
/* Basic operations on array elements. */
|
||||
extern ARRAY_ELEMENT *array_create_element __P((arrayind_t, char *));
|
||||
|
@ -69,6 +78,8 @@ extern char *array_reference __P((ARRAY *, arrayind_t));
|
|||
/* Converting to and from arrays */
|
||||
extern WORD_LIST *array_to_word_list __P((ARRAY *));
|
||||
extern ARRAY *array_from_word_list __P((WORD_LIST *));
|
||||
extern WORD_LIST *array_keys_to_word_list __P((ARRAY *));
|
||||
|
||||
extern ARRAY *array_assign_list __P((ARRAY *, WORD_LIST *));
|
||||
|
||||
extern char **array_to_argv __P((ARRAY *));
|
||||
|
@ -90,6 +101,18 @@ extern ARRAY *array_from_string __P((char *, char *));
|
|||
#define element_forw(ae) ((ae)->next)
|
||||
#define element_back(ae) ((ae)->prev)
|
||||
|
||||
/* Convenience */
|
||||
#define array_push(a,v) \
|
||||
do { array_rshift ((a), 1, (v)); } while (0)
|
||||
#define array_pop(a) \
|
||||
do { array_dispose_element (array_shift ((a), 1, 0)); } while (0)
|
||||
|
||||
#define GET_ARRAY_FROM_VAR(n, v, a) \
|
||||
do { \
|
||||
(v) = find_variable (n); \
|
||||
(a) = ((v) && array_p ((v))) ? array_cell (v) : (ARRAY *)0; \
|
||||
} while (0)
|
||||
|
||||
#define ALL_ELEMENT_SUB(c) ((c) == '@' || (c) == '*')
|
||||
|
||||
#endif /* _ARRAY_H_ */
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
/* arrayfunc.c -- High-level array functions used by other parts of the shell. */
|
||||
|
||||
/* Copyright (C) 2001-2002 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 2001-2009 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 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 3 of the License, 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.
|
||||
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. */
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
@ -27,7 +27,10 @@
|
|||
#endif
|
||||
#include <stdio.h>
|
||||
|
||||
#include "bashintl.h"
|
||||
|
||||
#include "shell.h"
|
||||
#include "pathexp.h"
|
||||
|
||||
#include "shmbutil.h"
|
||||
|
||||
|
@ -35,10 +38,17 @@
|
|||
|
||||
extern char *this_command_name;
|
||||
extern int last_command_exit_value;
|
||||
extern int array_needs_making;
|
||||
|
||||
static SHELL_VAR *bind_array_var_internal __P((SHELL_VAR *, arrayind_t, char *, char *, int));
|
||||
|
||||
static char *quote_assign __P((const char *));
|
||||
static void quote_array_assignment_chars __P((WORD_LIST *));
|
||||
static char *array_value_internal __P((char *, int, int, int *));
|
||||
|
||||
/* Standard error message to use when encountering an invalid array subscript */
|
||||
const char * const bash_badsub_errmsg = N_("bad array subscript");
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Functions to manipulate array variables and perform assignments */
|
||||
|
@ -56,7 +66,8 @@ convert_var_to_array (var)
|
|||
|
||||
oldval = value_cell (var);
|
||||
array = array_create ();
|
||||
array_insert (array, 0, oldval);
|
||||
if (oldval)
|
||||
array_insert (array, 0, oldval);
|
||||
|
||||
FREE (value_cell (var));
|
||||
var_setarray (var, array);
|
||||
|
@ -66,6 +77,8 @@ convert_var_to_array (var)
|
|||
var->assign_func = (sh_var_assign_func_t *)NULL;
|
||||
|
||||
INVALIDATE_EXPORTSTR (var);
|
||||
if (exported_p (var))
|
||||
array_needs_making++;
|
||||
|
||||
VSETATTR (var, att_array);
|
||||
VUNSETATTR (var, att_invisible);
|
||||
|
@ -73,6 +86,86 @@ convert_var_to_array (var)
|
|||
return var;
|
||||
}
|
||||
|
||||
/* Convert a shell variable to an array variable. The original value is
|
||||
saved as array[0]. */
|
||||
SHELL_VAR *
|
||||
convert_var_to_assoc (var)
|
||||
SHELL_VAR *var;
|
||||
{
|
||||
char *oldval;
|
||||
HASH_TABLE *hash;
|
||||
|
||||
oldval = value_cell (var);
|
||||
hash = assoc_create (0);
|
||||
if (oldval)
|
||||
assoc_insert (hash, "0", oldval);
|
||||
|
||||
FREE (value_cell (var));
|
||||
var_setassoc (var, hash);
|
||||
|
||||
/* these aren't valid anymore */
|
||||
var->dynamic_value = (sh_var_value_func_t *)NULL;
|
||||
var->assign_func = (sh_var_assign_func_t *)NULL;
|
||||
|
||||
INVALIDATE_EXPORTSTR (var);
|
||||
if (exported_p (var))
|
||||
array_needs_making++;
|
||||
|
||||
VSETATTR (var, att_assoc);
|
||||
VUNSETATTR (var, att_invisible);
|
||||
|
||||
return var;
|
||||
}
|
||||
|
||||
static SHELL_VAR *
|
||||
bind_array_var_internal (entry, ind, key, value, flags)
|
||||
SHELL_VAR *entry;
|
||||
arrayind_t ind;
|
||||
char *key;
|
||||
char *value;
|
||||
int flags;
|
||||
{
|
||||
SHELL_VAR *dentry;
|
||||
char *newval;
|
||||
|
||||
/* If we're appending, we need the old value of the array reference, so
|
||||
fake out make_variable_value with a dummy SHELL_VAR */
|
||||
if (flags & ASS_APPEND)
|
||||
{
|
||||
dentry = (SHELL_VAR *)xmalloc (sizeof (SHELL_VAR));
|
||||
dentry->name = savestring (entry->name);
|
||||
if (assoc_p (entry))
|
||||
newval = assoc_reference (assoc_cell (entry), key);
|
||||
else
|
||||
newval = array_reference (array_cell (entry), ind);
|
||||
if (newval)
|
||||
dentry->value = savestring (newval);
|
||||
else
|
||||
{
|
||||
dentry->value = (char *)xmalloc (1);
|
||||
dentry->value[0] = '\0';
|
||||
}
|
||||
dentry->exportstr = 0;
|
||||
dentry->attributes = entry->attributes & ~(att_array|att_assoc|att_exported);
|
||||
/* Leave the rest of the members uninitialized; the code doesn't look
|
||||
at them. */
|
||||
newval = make_variable_value (dentry, value, flags);
|
||||
dispose_variable (dentry);
|
||||
}
|
||||
else
|
||||
newval = make_variable_value (entry, value, flags);
|
||||
|
||||
if (entry->assign_func)
|
||||
(*entry->assign_func) (entry, newval, ind, key);
|
||||
else if (assoc_p (entry))
|
||||
assoc_insert (assoc_cell (entry), key, newval);
|
||||
else
|
||||
array_insert (array_cell (entry), ind, newval);
|
||||
FREE (newval);
|
||||
|
||||
return (entry);
|
||||
}
|
||||
|
||||
/* Perform an array assignment name[ind]=value. If NAME already exists and
|
||||
is not an array, and IND is 0, perform name=value instead. If NAME exists
|
||||
and is not an array, and IND is not 0, convert it into an array with the
|
||||
|
@ -81,13 +174,13 @@ convert_var_to_array (var)
|
|||
If NAME does not exist, just create an array variable, no matter what
|
||||
IND's value may be. */
|
||||
SHELL_VAR *
|
||||
bind_array_variable (name, ind, value)
|
||||
bind_array_variable (name, ind, value, flags)
|
||||
char *name;
|
||||
arrayind_t ind;
|
||||
char *value;
|
||||
int flags;
|
||||
{
|
||||
SHELL_VAR *entry;
|
||||
char *newval;
|
||||
|
||||
entry = var_lookup (name, shell_variables);
|
||||
|
||||
|
@ -103,23 +196,48 @@ bind_array_variable (name, ind, value)
|
|||
entry = convert_var_to_array (entry);
|
||||
|
||||
/* ENTRY is an array variable, and ARRAY points to the value. */
|
||||
newval = make_variable_value (entry, value);
|
||||
if (entry->assign_func)
|
||||
(*entry->assign_func) (entry, newval, ind);
|
||||
else
|
||||
array_insert (array_cell (entry), ind, newval);
|
||||
FREE (newval);
|
||||
return (bind_array_var_internal (entry, ind, 0, value, flags));
|
||||
}
|
||||
|
||||
return (entry);
|
||||
SHELL_VAR *
|
||||
bind_array_element (entry, ind, value, flags)
|
||||
SHELL_VAR *entry;
|
||||
arrayind_t ind;
|
||||
char *value;
|
||||
int flags;
|
||||
{
|
||||
return (bind_array_var_internal (entry, ind, 0, value, flags));
|
||||
}
|
||||
|
||||
SHELL_VAR *
|
||||
bind_assoc_variable (entry, name, key, value, flags)
|
||||
SHELL_VAR *entry;
|
||||
char *name;
|
||||
char *key;
|
||||
char *value;
|
||||
int flags;
|
||||
{
|
||||
SHELL_VAR *dentry;
|
||||
char *newval;
|
||||
|
||||
if (readonly_p (entry) || noassign_p (entry))
|
||||
{
|
||||
if (readonly_p (entry))
|
||||
err_readonly (name);
|
||||
return (entry);
|
||||
}
|
||||
|
||||
return (bind_array_var_internal (entry, 0, key, value, flags));
|
||||
}
|
||||
|
||||
/* Parse NAME, a lhs of an assignment statement of the form v[s], and
|
||||
assign VALUE to that array element by calling bind_array_variable(). */
|
||||
SHELL_VAR *
|
||||
assign_array_element (name, value)
|
||||
assign_array_element (name, value, flags)
|
||||
char *name, *value;
|
||||
int flags;
|
||||
{
|
||||
char *sub, *vname;
|
||||
char *sub, *vname, *akey;
|
||||
arrayind_t ind;
|
||||
int sublen;
|
||||
SHELL_VAR *entry;
|
||||
|
@ -136,15 +254,32 @@ assign_array_element (name, value)
|
|||
return ((SHELL_VAR *)NULL);
|
||||
}
|
||||
|
||||
ind = array_expand_index (sub, sublen);
|
||||
if (ind < 0)
|
||||
{
|
||||
free (vname);
|
||||
err_badarraysub (name);
|
||||
return ((SHELL_VAR *)NULL);
|
||||
}
|
||||
entry = find_variable (vname);
|
||||
|
||||
entry = bind_array_variable (vname, ind, value);
|
||||
if (entry && assoc_p (entry))
|
||||
{
|
||||
sub[sublen-1] = '\0';
|
||||
akey = expand_assignment_string_to_string (sub, 0); /* [ */
|
||||
sub[sublen-1] = ']';
|
||||
if (akey == 0 || *akey == 0)
|
||||
{
|
||||
free (vname);
|
||||
err_badarraysub (name);
|
||||
return ((SHELL_VAR *)NULL);
|
||||
}
|
||||
entry = bind_assoc_variable (entry, vname, akey, value, flags);
|
||||
}
|
||||
else
|
||||
{
|
||||
ind = array_expand_index (sub, sublen);
|
||||
if (ind < 0)
|
||||
{
|
||||
free (vname);
|
||||
err_badarraysub (name);
|
||||
return ((SHELL_VAR *)NULL);
|
||||
}
|
||||
entry = bind_array_variable (vname, ind, value, flags);
|
||||
}
|
||||
|
||||
free (vname);
|
||||
return (entry);
|
||||
|
@ -152,27 +287,33 @@ assign_array_element (name, value)
|
|||
|
||||
/* Find the array variable corresponding to NAME. If there is no variable,
|
||||
create a new array variable. If the variable exists but is not an array,
|
||||
convert it to an indexed array. If CHECK_FLAGS is non-zero, an existing
|
||||
convert it to an indexed array. If FLAGS&1 is non-zero, an existing
|
||||
variable is checked for the readonly or noassign attribute in preparation
|
||||
for assignment (e.g., by the `read' builtin). */
|
||||
for assignment (e.g., by the `read' builtin). If FLAGS&2 is non-zero, we
|
||||
create an associative array. */
|
||||
SHELL_VAR *
|
||||
find_or_make_array_variable (name, check_flags)
|
||||
find_or_make_array_variable (name, flags)
|
||||
char *name;
|
||||
int check_flags;
|
||||
int flags;
|
||||
{
|
||||
SHELL_VAR *var;
|
||||
|
||||
var = find_variable (name);
|
||||
|
||||
if (var == 0)
|
||||
var = make_new_array_variable (name);
|
||||
else if (check_flags && (readonly_p (var) || noassign_p (var)))
|
||||
var = (flags & 2) ? make_new_assoc_variable (name) : make_new_array_variable (name);
|
||||
else if ((flags & 1) && (readonly_p (var) || noassign_p (var)))
|
||||
{
|
||||
if (readonly_p (var))
|
||||
err_readonly (name);
|
||||
return ((SHELL_VAR *)NULL);
|
||||
}
|
||||
else if (array_p (var) == 0)
|
||||
else if ((flags & 2) && array_p (var))
|
||||
{
|
||||
report_error (_("%s: cannot convert indexed to associative array"), name);
|
||||
return ((SHELL_VAR *)NULL);
|
||||
}
|
||||
else if (array_p (var) == 0 && assoc_p (var) == 0)
|
||||
var = convert_var_to_array (var);
|
||||
|
||||
return (var);
|
||||
|
@ -181,62 +322,64 @@ find_or_make_array_variable (name, check_flags)
|
|||
/* Perform a compound assignment statement for array NAME, where VALUE is
|
||||
the text between the parens: NAME=( VALUE ) */
|
||||
SHELL_VAR *
|
||||
assign_array_from_string (name, value)
|
||||
assign_array_from_string (name, value, flags)
|
||||
char *name, *value;
|
||||
int flags;
|
||||
{
|
||||
SHELL_VAR *var;
|
||||
int vflags;
|
||||
|
||||
var = find_or_make_array_variable (name, 1);
|
||||
vflags = 1;
|
||||
if (flags & ASS_MKASSOC)
|
||||
vflags |= 2;
|
||||
|
||||
var = find_or_make_array_variable (name, vflags);
|
||||
if (var == 0)
|
||||
return ((SHELL_VAR *)NULL);
|
||||
|
||||
return (assign_array_var_from_string (var, value));
|
||||
return (assign_array_var_from_string (var, value, flags));
|
||||
}
|
||||
|
||||
/* Sequentially assign the indices of indexed array variable VAR from the
|
||||
words in LIST. */
|
||||
SHELL_VAR *
|
||||
assign_array_var_from_word_list (var, list)
|
||||
assign_array_var_from_word_list (var, list, flags)
|
||||
SHELL_VAR *var;
|
||||
WORD_LIST *list;
|
||||
int flags;
|
||||
{
|
||||
register arrayind_t i;
|
||||
register WORD_LIST *l;
|
||||
ARRAY *a;
|
||||
|
||||
for (a = array_cell (var), l = list, i = 0; l; l = l->next, i++)
|
||||
a = array_cell (var);
|
||||
i = (flags & ASS_APPEND) ? array_max_index (a) + 1 : 0;
|
||||
|
||||
for (l = list; l; l = l->next, i++)
|
||||
if (var->assign_func)
|
||||
(*var->assign_func) (var, l->word->word, i);
|
||||
(*var->assign_func) (var, l->word->word, i, 0);
|
||||
else
|
||||
array_insert (a, i, l->word->word);
|
||||
return var;
|
||||
}
|
||||
|
||||
/* Perform a compound array assignment: VAR->name=( VALUE ). The
|
||||
VALUE has already had the parentheses stripped. */
|
||||
SHELL_VAR *
|
||||
assign_array_var_from_string (var, value)
|
||||
WORD_LIST *
|
||||
expand_compound_array_assignment (var, value, flags)
|
||||
SHELL_VAR *var;
|
||||
char *value;
|
||||
int flags;
|
||||
{
|
||||
ARRAY *a;
|
||||
WORD_LIST *list, *nlist;
|
||||
char *w, *val, *nval;
|
||||
int ni, len;
|
||||
arrayind_t ind, last_ind;
|
||||
char *val;
|
||||
int ni;
|
||||
|
||||
if (value == 0)
|
||||
return var;
|
||||
|
||||
/* If this is called from declare_builtin, value[0] == '(' and
|
||||
xstrchr(value, ')') != 0. In this case, we need to extract
|
||||
the value from between the parens before going on. */
|
||||
/* I don't believe this condition is ever true any more. */
|
||||
if (*value == '(') /*)*/
|
||||
{
|
||||
ni = 1;
|
||||
val = extract_array_assignment_list (value, &ni);
|
||||
if (val == 0)
|
||||
return var;
|
||||
return (WORD_LIST *)NULL;
|
||||
}
|
||||
else
|
||||
val = value;
|
||||
|
@ -245,7 +388,7 @@ assign_array_var_from_string (var, value)
|
|||
shell expansions including pathname generation and word splitting. */
|
||||
/* First we split the string on whitespace, using the shell parser
|
||||
(ksh93 seems to do this). */
|
||||
list = parse_string_to_word_list (val, "array assign");
|
||||
list = parse_string_to_word_list (val, 1, "array assign");
|
||||
|
||||
/* If we're using [subscript]=value, we need to quote each [ and ] to
|
||||
prevent unwanted filename expansion. */
|
||||
|
@ -261,27 +404,62 @@ assign_array_var_from_string (var, value)
|
|||
if (val != value)
|
||||
free (val);
|
||||
|
||||
a = array_cell (var);
|
||||
return nlist;
|
||||
}
|
||||
|
||||
void
|
||||
assign_compound_array_list (var, nlist, flags)
|
||||
SHELL_VAR *var;
|
||||
WORD_LIST *nlist;
|
||||
int flags;
|
||||
{
|
||||
ARRAY *a;
|
||||
HASH_TABLE *h;
|
||||
WORD_LIST *list;
|
||||
char *w, *val, *nval;
|
||||
int len, iflags;
|
||||
arrayind_t ind, last_ind;
|
||||
char *akey;
|
||||
|
||||
a = (var && array_p (var)) ? array_cell (var) : (ARRAY *)0;
|
||||
h = (var && assoc_p (var)) ? assoc_cell (var) : (HASH_TABLE *)0;
|
||||
|
||||
akey = (char *)0;
|
||||
ind = 0;
|
||||
|
||||
/* Now that we are ready to assign values to the array, kill the existing
|
||||
value. */
|
||||
if (a)
|
||||
array_flush (a);
|
||||
|
||||
for (last_ind = 0, list = nlist; list; list = list->next)
|
||||
if ((flags & ASS_APPEND) == 0)
|
||||
{
|
||||
if (array_p (var) && a)
|
||||
array_flush (a);
|
||||
else if (assoc_p (var) && h)
|
||||
assoc_flush (h);
|
||||
}
|
||||
|
||||
last_ind = (a && (flags & ASS_APPEND)) ? array_max_index (a) + 1 : 0;
|
||||
|
||||
for (list = nlist; list; list = list->next)
|
||||
{
|
||||
iflags = flags;
|
||||
w = list->word->word;
|
||||
|
||||
/* We have a word of the form [ind]=value */
|
||||
if (w[0] == '[')
|
||||
if ((list->word->flags & W_ASSIGNMENT) && w[0] == '[')
|
||||
{
|
||||
len = skipsubscript (w, 0);
|
||||
|
||||
if (w[len] != ']' || w[len+1] != '=')
|
||||
/* XXX - changes for `+=' */
|
||||
if (w[len] != ']' || (w[len+1] != '=' && (w[len+1] != '+' || w[len+2] != '=')))
|
||||
{
|
||||
nval = make_variable_value (var, w);
|
||||
if (assoc_p (var))
|
||||
{
|
||||
err_badarraysub (w);
|
||||
continue;
|
||||
}
|
||||
nval = make_variable_value (var, w, flags);
|
||||
if (var->assign_func)
|
||||
(*var->assign_func) (var, nval, last_ind);
|
||||
(*var->assign_func) (var, nval, last_ind, 0);
|
||||
else
|
||||
array_insert (a, last_ind, nval);
|
||||
FREE (nval);
|
||||
|
@ -297,18 +475,47 @@ assign_array_var_from_string (var, value)
|
|||
|
||||
if (ALL_ELEMENT_SUB (w[1]) && len == 2)
|
||||
{
|
||||
report_error ("%s: cannot assign to non-numeric index", w);
|
||||
if (assoc_p (var))
|
||||
report_error (_("%s: invalid associative array key"), w);
|
||||
else
|
||||
report_error (_("%s: cannot assign to non-numeric index"), w);
|
||||
continue;
|
||||
}
|
||||
|
||||
ind = array_expand_index (w + 1, len);
|
||||
if (ind < 0)
|
||||
if (array_p (var))
|
||||
{
|
||||
err_badarraysub (w);
|
||||
continue;
|
||||
ind = array_expand_index (w + 1, len);
|
||||
if (ind < 0)
|
||||
{
|
||||
err_badarraysub (w);
|
||||
continue;
|
||||
}
|
||||
|
||||
last_ind = ind;
|
||||
}
|
||||
last_ind = ind;
|
||||
val = w + len + 2;
|
||||
else if (assoc_p (var))
|
||||
{
|
||||
akey = substring (w, 1, len);
|
||||
if (akey == 0 || *akey == 0)
|
||||
{
|
||||
err_badarraysub (w);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/* XXX - changes for `+=' -- just accept the syntax. ksh93 doesn't do this */
|
||||
if (w[len + 1] == '+' && w[len + 2] == '=')
|
||||
{
|
||||
iflags |= ASS_APPEND;
|
||||
val = w + len + 3;
|
||||
}
|
||||
else
|
||||
val = w + len + 2;
|
||||
}
|
||||
else if (assoc_p (var))
|
||||
{
|
||||
report_error (_("%s: %s: must use subscript when assigning associative array"), var->name, w);
|
||||
continue;
|
||||
}
|
||||
else /* No [ind]=value, just a stray `=' */
|
||||
{
|
||||
|
@ -318,28 +525,70 @@ assign_array_var_from_string (var, value)
|
|||
|
||||
if (integer_p (var))
|
||||
this_command_name = (char *)NULL; /* no command name for errors */
|
||||
nval = make_variable_value (var, val);
|
||||
if (var->assign_func)
|
||||
(*var->assign_func) (var, nval, ind);
|
||||
else
|
||||
array_insert (a, ind, nval);
|
||||
FREE (nval);
|
||||
bind_array_var_internal (var, ind, akey, val, iflags);
|
||||
last_ind++;
|
||||
}
|
||||
}
|
||||
|
||||
dispose_words (nlist);
|
||||
/* Perform a compound array assignment: VAR->name=( VALUE ). The
|
||||
VALUE has already had the parentheses stripped. */
|
||||
SHELL_VAR *
|
||||
assign_array_var_from_string (var, value, flags)
|
||||
SHELL_VAR *var;
|
||||
char *value;
|
||||
int flags;
|
||||
{
|
||||
WORD_LIST *nlist;
|
||||
|
||||
if (value == 0)
|
||||
return var;
|
||||
|
||||
nlist = expand_compound_array_assignment (var, value, flags);
|
||||
assign_compound_array_list (var, nlist, flags);
|
||||
|
||||
if (nlist)
|
||||
dispose_words (nlist);
|
||||
return (var);
|
||||
}
|
||||
|
||||
/* Quote globbing chars and characters in $IFS before the `=' in an assignment
|
||||
statement (usually a compound array assignment) to protect them from
|
||||
unwanted filename expansion or word splitting. */
|
||||
static char *
|
||||
quote_assign (string)
|
||||
const char *string;
|
||||
{
|
||||
size_t slen;
|
||||
int saw_eq;
|
||||
char *temp, *t;
|
||||
const char *s, *send;
|
||||
DECLARE_MBSTATE;
|
||||
|
||||
slen = strlen (string);
|
||||
send = string + slen;
|
||||
|
||||
t = temp = (char *)xmalloc (slen * 2 + 1);
|
||||
saw_eq = 0;
|
||||
for (s = string; *s; )
|
||||
{
|
||||
if (*s == '=')
|
||||
saw_eq = 1;
|
||||
if (saw_eq == 0 && (glob_char_p (s) || isifs (*s)))
|
||||
*t++ = '\\';
|
||||
|
||||
COPY_CHAR_P (t, s, send);
|
||||
}
|
||||
*t = '\0';
|
||||
return temp;
|
||||
}
|
||||
|
||||
/* For each word in a compound array assignment, if the word looks like
|
||||
[ind]=value, quote the `[' and `]' before the `=' to protect them from
|
||||
unwanted filename expansion. */
|
||||
[ind]=value, quote globbing chars and characters in $IFS before the `='. */
|
||||
static void
|
||||
quote_array_assignment_chars (list)
|
||||
WORD_LIST *list;
|
||||
{
|
||||
char *s, *t, *nword;
|
||||
int saw_eq;
|
||||
char *nword;
|
||||
WORD_LIST *l;
|
||||
|
||||
for (l = list; l; l = l->next)
|
||||
|
@ -349,17 +598,7 @@ quote_array_assignment_chars (list)
|
|||
/* Don't bother if it doesn't look like [ind]=value */
|
||||
if (l->word->word[0] != '[' || xstrchr (l->word->word, '=') == 0) /* ] */
|
||||
continue;
|
||||
s = nword = (char *)xmalloc (strlen (l->word->word) * 2 + 1);
|
||||
saw_eq = 0;
|
||||
for (t = l->word->word; *t; )
|
||||
{
|
||||
if (*t == '=')
|
||||
saw_eq = 1;
|
||||
if (saw_eq == 0 && (*t == '[' || *t == ']'))
|
||||
*s++ = '\\';
|
||||
*s++ = *t++;
|
||||
}
|
||||
*s = '\0';
|
||||
nword = quote_assign (l->word->word);
|
||||
free (l->word->word);
|
||||
l->word->word = nword;
|
||||
}
|
||||
|
@ -376,13 +615,11 @@ skipsubscript (s, i)
|
|||
#if defined (HANDLE_MULTIBYTE)
|
||||
mbstate_t state, state_bak;
|
||||
size_t slength, mblength;
|
||||
size_t mb_cur_max;
|
||||
#endif
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
memset (&state, '\0', sizeof (mbstate_t));
|
||||
slength = strlen (s + i);
|
||||
mb_cur_max = MB_CUR_MAX;
|
||||
#endif
|
||||
|
||||
count = 1;
|
||||
|
@ -390,18 +627,18 @@ skipsubscript (s, i)
|
|||
{
|
||||
/* Advance one (possibly multibyte) character in S starting at I. */
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
if (mb_cur_max > 1)
|
||||
if (MB_CUR_MAX > 1)
|
||||
{
|
||||
state_bak = state;
|
||||
mblength = mbrlen (s + i, slength, &state);
|
||||
|
||||
if (mblength == (size_t)-2 || mblength == (size_t)-1)
|
||||
if (MB_INVALIDCH (mblength))
|
||||
{
|
||||
state = state_bak;
|
||||
i++;
|
||||
slength--;
|
||||
}
|
||||
else if (mblength == 0)
|
||||
else if (MB_NULLWCH (mblength))
|
||||
return i;
|
||||
else
|
||||
{
|
||||
|
@ -416,7 +653,7 @@ skipsubscript (s, i)
|
|||
c = s[i];
|
||||
|
||||
if (c == 0)
|
||||
break;
|
||||
break;
|
||||
else if (c == '[')
|
||||
count++;
|
||||
else if (c == ']')
|
||||
|
@ -436,12 +673,13 @@ unbind_array_element (var, sub)
|
|||
{
|
||||
int len;
|
||||
arrayind_t ind;
|
||||
char *akey;
|
||||
ARRAY_ELEMENT *ae;
|
||||
|
||||
len = skipsubscript (sub, 0);
|
||||
if (sub[len] != ']' || len == 0)
|
||||
{
|
||||
builtin_error ("%s[%s: bad array subscript", var->name, sub);
|
||||
builtin_error ("%s[%s: %s", var->name, sub, _(bash_badsub_errmsg));
|
||||
return -1;
|
||||
}
|
||||
sub[len] = '\0';
|
||||
|
@ -451,15 +689,30 @@ unbind_array_element (var, sub)
|
|||
unbind_variable (var->name);
|
||||
return (0);
|
||||
}
|
||||
ind = array_expand_index (sub, len+1);
|
||||
if (ind < 0)
|
||||
|
||||
if (assoc_p (var))
|
||||
{
|
||||
builtin_error ("[%s]: bad array subscript", sub);
|
||||
return -1;
|
||||
akey = expand_assignment_string_to_string (sub, 0); /* [ */
|
||||
if (akey == 0 || *akey == 0)
|
||||
{
|
||||
builtin_error ("[%s]: %s", sub, _(bash_badsub_errmsg));
|
||||
return -1;
|
||||
}
|
||||
assoc_remove (assoc_cell (var), akey);
|
||||
}
|
||||
ae = array_remove (array_cell (var), ind);
|
||||
if (ae)
|
||||
array_dispose_element (ae);
|
||||
else
|
||||
{
|
||||
ind = array_expand_index (sub, len+1);
|
||||
if (ind < 0)
|
||||
{
|
||||
builtin_error ("[%s]: %s", sub, _(bash_badsub_errmsg));
|
||||
return -1;
|
||||
}
|
||||
ae = array_remove (array_cell (var), ind);
|
||||
if (ae)
|
||||
array_dispose_element (ae);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -483,6 +736,26 @@ print_array_assignment (var, quoted)
|
|||
}
|
||||
}
|
||||
|
||||
/* Format and output an associative array assignment in compound form
|
||||
VAR=(VALUES), suitable for re-use as input. */
|
||||
void
|
||||
print_assoc_assignment (var, quoted)
|
||||
SHELL_VAR *var;
|
||||
int quoted;
|
||||
{
|
||||
char *vstr;
|
||||
|
||||
vstr = assoc_to_assign (assoc_cell (var), quoted);
|
||||
|
||||
if (vstr == 0)
|
||||
printf ("%s=%s\n", var->name, quoted ? "'()'" : "()");
|
||||
else
|
||||
{
|
||||
printf ("%s=%s\n", var->name, vstr);
|
||||
free (vstr);
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
/* */
|
||||
/* Utility functions to manage arrays and their contents for expansion */
|
||||
|
@ -530,7 +803,7 @@ array_expand_index (s, len)
|
|||
exp = (char *)xmalloc (len);
|
||||
strncpy (exp, s, len - 1);
|
||||
exp[len - 1] = '\0';
|
||||
t = expand_string_to_string (exp, 0);
|
||||
t = expand_arith_string (exp, 0);
|
||||
this_command_name = (char *)NULL;
|
||||
val = evalexp (t, &expok);
|
||||
free (t);
|
||||
|
@ -538,6 +811,8 @@ array_expand_index (s, len)
|
|||
if (expok == 0)
|
||||
{
|
||||
last_command_exit_value = EXECUTION_FAILURE;
|
||||
|
||||
top_level_cleanup ();
|
||||
jump_to_top_level (DISCARD);
|
||||
}
|
||||
return val;
|
||||
|
@ -557,12 +832,22 @@ array_variable_name (s, subp, lenp)
|
|||
|
||||
t = xstrchr (s, '[');
|
||||
if (t == 0)
|
||||
return ((char *)NULL);
|
||||
{
|
||||
if (subp)
|
||||
*subp = t;
|
||||
if (lenp)
|
||||
*lenp = 0;
|
||||
return ((char *)NULL);
|
||||
}
|
||||
ind = t - s;
|
||||
ni = skipsubscript (s, ind);
|
||||
if (ni <= ind + 1 || s[ni] != ']')
|
||||
{
|
||||
err_badarraysub (s);
|
||||
if (subp)
|
||||
*subp = t;
|
||||
if (lenp)
|
||||
*lenp = 0;
|
||||
return ((char *)NULL);
|
||||
}
|
||||
|
||||
|
@ -595,14 +880,14 @@ array_variable_part (s, subp, lenp)
|
|||
var = find_variable (t);
|
||||
|
||||
free (t);
|
||||
return var;
|
||||
return (var == 0 || invisible_p (var)) ? (SHELL_VAR *)0 : var;
|
||||
}
|
||||
|
||||
/* Return a string containing the elements in the array and subscript
|
||||
described by S. If the subscript is * or @, obeys quoting rules akin
|
||||
to the expansion of $* and $@ including double quoting. If RTYPE
|
||||
is non-null it gets 1 if the array reference is name[@] or name[*]
|
||||
and 0 otherwise. */
|
||||
is non-null it gets 1 if the array reference is name[*], 2 if the
|
||||
reference is name[@], and 0 otherwise. */
|
||||
static char *
|
||||
array_value_internal (s, quoted, allow_all, rtype)
|
||||
char *s;
|
||||
|
@ -610,6 +895,7 @@ array_value_internal (s, quoted, allow_all, rtype)
|
|||
{
|
||||
int len;
|
||||
arrayind_t ind;
|
||||
char *akey;
|
||||
char *retval, *t, *temp;
|
||||
WORD_LIST *l;
|
||||
SHELL_VAR *var;
|
||||
|
@ -623,20 +909,29 @@ array_value_internal (s, quoted, allow_all, rtype)
|
|||
return (char *)NULL;
|
||||
#endif
|
||||
|
||||
if (len == 0)
|
||||
return ((char *)NULL); /* error message already printed */
|
||||
|
||||
/* [ */
|
||||
if (ALL_ELEMENT_SUB (t[0]) && t[1] == ']')
|
||||
{
|
||||
if (rtype)
|
||||
*rtype = 1;
|
||||
*rtype = (t[0] == '*') ? 1 : 2;
|
||||
if (allow_all == 0)
|
||||
{
|
||||
err_badarraysub (s);
|
||||
return ((char *)NULL);
|
||||
}
|
||||
else if (var == 0)
|
||||
else if (var == 0 || value_cell (var) == 0)
|
||||
return ((char *)NULL);
|
||||
else if (array_p (var) == 0)
|
||||
else if (array_p (var) == 0 && assoc_p (var) == 0)
|
||||
l = add_string_to_list (value_cell (var), (WORD_LIST *)NULL);
|
||||
else if (assoc_p (var))
|
||||
{
|
||||
l = assoc_to_word_list (assoc_cell (var));
|
||||
if (l == (WORD_LIST *)NULL)
|
||||
return ((char *)NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
l = array_to_word_list (array_cell (var));
|
||||
|
@ -659,24 +954,40 @@ array_value_internal (s, quoted, allow_all, rtype)
|
|||
{
|
||||
if (rtype)
|
||||
*rtype = 0;
|
||||
ind = array_expand_index (t, len);
|
||||
if (ind < 0)
|
||||
if (var == 0 || array_p (var) || assoc_p (var) == 0)
|
||||
{
|
||||
if (var)
|
||||
err_badarraysub (var->name);
|
||||
else
|
||||
ind = array_expand_index (t, len);
|
||||
if (ind < 0)
|
||||
{
|
||||
t[-1] = '\0';
|
||||
err_badarraysub (s);
|
||||
t[-1] = '['; /* ] */
|
||||
index_error:
|
||||
if (var)
|
||||
err_badarraysub (var->name);
|
||||
else
|
||||
{
|
||||
t[-1] = '\0';
|
||||
err_badarraysub (s);
|
||||
t[-1] = '['; /* ] */
|
||||
}
|
||||
return ((char *)NULL);
|
||||
}
|
||||
return ((char *)NULL);
|
||||
}
|
||||
else if (assoc_p (var))
|
||||
{
|
||||
t[len - 1] = '\0';
|
||||
akey = expand_assignment_string_to_string (t, 0); /* [ */
|
||||
t[len - 1] = ']';
|
||||
if (akey == 0 || *akey == 0)
|
||||
goto index_error;
|
||||
}
|
||||
|
||||
if (var == 0)
|
||||
return ((char *)NULL);
|
||||
if (array_p (var) == 0)
|
||||
if (array_p (var) == 0 && assoc_p (var) == 0)
|
||||
return (ind == 0 ? value_cell (var) : (char *)NULL);
|
||||
retval = array_reference (array_cell (var), ind);
|
||||
else if (assoc_p (var))
|
||||
retval = assoc_reference (assoc_cell (var), akey);
|
||||
else
|
||||
retval = array_reference (array_cell (var), ind);
|
||||
}
|
||||
|
||||
return retval;
|
||||
|
@ -704,4 +1015,41 @@ get_array_value (s, allow_all, rtype)
|
|||
return (array_value_internal (s, 0, allow_all, rtype));
|
||||
}
|
||||
|
||||
char *
|
||||
array_keys (s, quoted)
|
||||
char *s;
|
||||
int quoted;
|
||||
{
|
||||
int len;
|
||||
char *retval, *t, *temp;
|
||||
WORD_LIST *l;
|
||||
SHELL_VAR *var;
|
||||
|
||||
var = array_variable_part (s, &t, &len);
|
||||
|
||||
/* [ */
|
||||
if (var == 0 || ALL_ELEMENT_SUB (t[0]) == 0 || t[1] != ']')
|
||||
return (char *)NULL;
|
||||
|
||||
if (array_p (var) == 0 && assoc_p (var) == 0)
|
||||
l = add_string_to_list ("0", (WORD_LIST *)NULL);
|
||||
else if (assoc_p (var))
|
||||
l = assoc_keys_to_word_list (assoc_cell (var));
|
||||
else
|
||||
l = array_keys_to_word_list (array_cell (var));
|
||||
if (l == (WORD_LIST *)NULL)
|
||||
return ((char *) NULL);
|
||||
|
||||
if (t[0] == '*' && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)))
|
||||
{
|
||||
temp = string_list_dollar_star (l);
|
||||
retval = quote_string (temp);
|
||||
free (temp);
|
||||
}
|
||||
else /* ${!name[@]} or unquoted ${!name[*]} */
|
||||
retval = string_list_dollar_at (l, quoted);
|
||||
|
||||
dispose_words (l);
|
||||
return retval;
|
||||
}
|
||||
#endif /* ARRAY_VARS */
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
/* arrayfunc.h -- declarations for miscellaneous array functions in arrayfunc.c */
|
||||
|
||||
/* Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 2001-2009 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 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 3 of the License, 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.
|
||||
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. */
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if !defined (_ARRAYFUNC_H_)
|
||||
#define _ARRAYFUNC_H_
|
||||
|
@ -26,25 +26,34 @@
|
|||
#if defined (ARRAY_VARS)
|
||||
|
||||
extern SHELL_VAR *convert_var_to_array __P((SHELL_VAR *));
|
||||
extern SHELL_VAR *convert_var_to_assoc __P((SHELL_VAR *));
|
||||
|
||||
extern SHELL_VAR *bind_array_variable __P((char *, arrayind_t, char *));
|
||||
extern SHELL_VAR *assign_array_element __P((char *, char *));
|
||||
extern SHELL_VAR *bind_array_variable __P((char *, arrayind_t, char *, int));
|
||||
extern SHELL_VAR *bind_array_element __P((SHELL_VAR *, arrayind_t, char *, int));
|
||||
extern SHELL_VAR *assign_array_element __P((char *, char *, int));
|
||||
|
||||
extern SHELL_VAR *find_or_make_array_variable __P((char *, int));
|
||||
|
||||
extern SHELL_VAR *assign_array_from_string __P((char *, char *));
|
||||
extern SHELL_VAR *assign_array_var_from_word_list __P((SHELL_VAR *, WORD_LIST *));
|
||||
extern SHELL_VAR *assign_array_var_from_string __P((SHELL_VAR *, char *));
|
||||
extern SHELL_VAR *assign_array_from_string __P((char *, char *, int));
|
||||
extern SHELL_VAR *assign_array_var_from_word_list __P((SHELL_VAR *, WORD_LIST *, int));
|
||||
|
||||
extern WORD_LIST *expand_compound_array_assignment __P((SHELL_VAR *, char *, int));
|
||||
extern void assign_compound_array_list __P((SHELL_VAR *, WORD_LIST *, int));
|
||||
extern SHELL_VAR *assign_array_var_from_string __P((SHELL_VAR *, char *, int));
|
||||
|
||||
extern int unbind_array_element __P((SHELL_VAR *, char *));
|
||||
extern int skipsubscript __P((const char *, int));
|
||||
|
||||
extern void print_array_assignment __P((SHELL_VAR *, int));
|
||||
extern void print_assoc_assignment __P((SHELL_VAR *, int));
|
||||
|
||||
extern arrayind_t array_expand_index __P((char *, int));
|
||||
extern int valid_array_reference __P((char *));
|
||||
extern char *array_value __P((char *, int, int *));
|
||||
extern char *get_array_value __P((char *, int, int *));
|
||||
|
||||
extern char *array_keys __P((char *, int));
|
||||
|
||||
extern char *array_variable_name __P((char *, char **, int *));
|
||||
extern SHELL_VAR *array_variable_part __P((char *, char **, int *));
|
||||
|
||||
|
|
|
@ -0,0 +1,518 @@
|
|||
/*
|
||||
* assoc.c - functions to manipulate associative arrays
|
||||
*
|
||||
* Associative arrays are standard shell hash tables.
|
||||
*
|
||||
* Chet Ramey
|
||||
* chet@ins.cwru.edu
|
||||
*/
|
||||
|
||||
/* Copyright (C) 2008,2009 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 3 of the License, 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. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if defined (ARRAY_VARS)
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# ifdef _MINIX
|
||||
# include <sys/types.h>
|
||||
# endif
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include "bashansi.h"
|
||||
|
||||
#include "shell.h"
|
||||
#include "array.h"
|
||||
#include "assoc.h"
|
||||
#include "builtins/common.h"
|
||||
|
||||
static WORD_LIST *assoc_to_word_list_internal __P((HASH_TABLE *, int));
|
||||
|
||||
/* assoc_create == hash_create */
|
||||
|
||||
void
|
||||
assoc_dispose (hash)
|
||||
HASH_TABLE *hash;
|
||||
{
|
||||
if (hash)
|
||||
{
|
||||
hash_flush (hash, 0);
|
||||
hash_dispose (hash);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
assoc_flush (hash)
|
||||
HASH_TABLE *hash;
|
||||
{
|
||||
hash_flush (hash, 0);
|
||||
}
|
||||
|
||||
int
|
||||
assoc_insert (hash, key, value)
|
||||
HASH_TABLE *hash;
|
||||
char *key;
|
||||
char *value;
|
||||
{
|
||||
BUCKET_CONTENTS *b;
|
||||
|
||||
b = hash_search (key, hash, HASH_CREATE);
|
||||
if (b == 0)
|
||||
return -1;
|
||||
FREE (b->data);
|
||||
b->data = value ? savestring (value) : (char *)0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
assoc_remove (hash, string)
|
||||
HASH_TABLE *hash;
|
||||
char *string;
|
||||
{
|
||||
BUCKET_CONTENTS *b;
|
||||
|
||||
b = hash_remove (string, hash, 0);
|
||||
if (b)
|
||||
{
|
||||
free ((char *)b->data);
|
||||
free (b->key);
|
||||
free (b);
|
||||
}
|
||||
}
|
||||
|
||||
char *
|
||||
assoc_reference (hash, string)
|
||||
HASH_TABLE *hash;
|
||||
char *string;
|
||||
{
|
||||
BUCKET_CONTENTS *b;
|
||||
|
||||
if (hash == 0)
|
||||
return (char *)0;
|
||||
|
||||
b = hash_search (string, hash, 0);
|
||||
return (b ? (char *)b->data : 0);
|
||||
}
|
||||
|
||||
/* Quote the data associated with each element of the hash table ASSOC,
|
||||
using quote_string */
|
||||
HASH_TABLE *
|
||||
assoc_quote (h)
|
||||
HASH_TABLE *h;
|
||||
{
|
||||
int i;
|
||||
BUCKET_CONTENTS *tlist;
|
||||
char *t;
|
||||
|
||||
if (h == 0 || assoc_empty (h))
|
||||
return ((HASH_TABLE *)NULL);
|
||||
|
||||
for (i = 0; i < h->nbuckets; i++)
|
||||
for (tlist = hash_items (i, h); tlist; tlist = tlist->next)
|
||||
{
|
||||
t = quote_string ((char *)tlist->data);
|
||||
FREE (tlist->data);
|
||||
tlist->data = t;
|
||||
}
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
/* Quote escape characters in the data associated with each element
|
||||
of the hash table ASSOC, using quote_escapes */
|
||||
HASH_TABLE *
|
||||
assoc_quote_escapes (h)
|
||||
HASH_TABLE *h;
|
||||
{
|
||||
int i;
|
||||
BUCKET_CONTENTS *tlist;
|
||||
char *t;
|
||||
|
||||
if (h == 0 || assoc_empty (h))
|
||||
return ((HASH_TABLE *)NULL);
|
||||
|
||||
for (i = 0; i < h->nbuckets; i++)
|
||||
for (tlist = hash_items (i, h); tlist; tlist = tlist->next)
|
||||
{
|
||||
t = quote_escapes ((char *)tlist->data);
|
||||
FREE (tlist->data);
|
||||
tlist->data = t;
|
||||
}
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
HASH_TABLE *
|
||||
assoc_dequote (h)
|
||||
HASH_TABLE *h;
|
||||
{
|
||||
int i;
|
||||
BUCKET_CONTENTS *tlist;
|
||||
char *t;
|
||||
|
||||
if (h == 0 || assoc_empty (h))
|
||||
return ((HASH_TABLE *)NULL);
|
||||
|
||||
for (i = 0; i < h->nbuckets; i++)
|
||||
for (tlist = hash_items (i, h); tlist; tlist = tlist->next)
|
||||
{
|
||||
t = dequote_string ((char *)tlist->data);
|
||||
FREE (tlist->data);
|
||||
tlist->data = t;
|
||||
}
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
HASH_TABLE *
|
||||
assoc_dequote_escapes (h)
|
||||
HASH_TABLE *h;
|
||||
{
|
||||
int i;
|
||||
BUCKET_CONTENTS *tlist;
|
||||
char *t;
|
||||
|
||||
if (h == 0 || assoc_empty (h))
|
||||
return ((HASH_TABLE *)NULL);
|
||||
|
||||
for (i = 0; i < h->nbuckets; i++)
|
||||
for (tlist = hash_items (i, h); tlist; tlist = tlist->next)
|
||||
{
|
||||
t = dequote_escapes ((char *)tlist->data);
|
||||
FREE (tlist->data);
|
||||
tlist->data = t;
|
||||
}
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
HASH_TABLE *
|
||||
assoc_remove_quoted_nulls (h)
|
||||
HASH_TABLE *h;
|
||||
{
|
||||
int i;
|
||||
BUCKET_CONTENTS *tlist;
|
||||
char *t;
|
||||
|
||||
if (h == 0 || assoc_empty (h))
|
||||
return ((HASH_TABLE *)NULL);
|
||||
|
||||
for (i = 0; i < h->nbuckets; i++)
|
||||
for (tlist = hash_items (i, h); tlist; tlist = tlist->next)
|
||||
{
|
||||
t = remove_quoted_nulls ((char *)tlist->data);
|
||||
tlist->data = t;
|
||||
}
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return a string whose elements are the members of array H beginning at
|
||||
* the STARTth element and spanning NELEM members. Null elements are counted.
|
||||
*/
|
||||
char *
|
||||
assoc_subrange (hash, start, nelem, starsub, quoted)
|
||||
HASH_TABLE *hash;
|
||||
arrayind_t start, nelem;
|
||||
int starsub, quoted;
|
||||
{
|
||||
WORD_LIST *l, *save, *h, *t;
|
||||
int i, j;
|
||||
char *ret;
|
||||
|
||||
if (assoc_empty (hash))
|
||||
return ((char *)NULL);
|
||||
|
||||
save = l = assoc_to_word_list (hash);
|
||||
if (save == 0)
|
||||
return ((char *)NULL);
|
||||
|
||||
for (i = 1; l && i < start; i++)
|
||||
l = l->next;
|
||||
if (l == 0)
|
||||
return ((char *)NULL);
|
||||
for (j = 0,h = t = l; l && j < nelem; j++)
|
||||
{
|
||||
t = l;
|
||||
l = l->next;
|
||||
}
|
||||
|
||||
t->next = (WORD_LIST *)NULL;
|
||||
|
||||
ret = string_list_pos_params (starsub ? '*' : '@', h, quoted);
|
||||
|
||||
if (t != l)
|
||||
t->next = l;
|
||||
|
||||
dispose_words (save);
|
||||
return (ret);
|
||||
|
||||
}
|
||||
|
||||
char *
|
||||
assoc_patsub (h, pat, rep, mflags)
|
||||
HASH_TABLE *h;
|
||||
char *pat, *rep;
|
||||
int mflags;
|
||||
{
|
||||
BUCKET_CONTENTS *tlist;
|
||||
int i, slen;
|
||||
HASH_TABLE *h2;
|
||||
char *t, *sifs, *ifs;
|
||||
|
||||
if (h == 0 || assoc_empty (h))
|
||||
return ((char *)NULL);
|
||||
|
||||
h2 = assoc_copy (h);
|
||||
for (i = 0; i < h2->nbuckets; i++)
|
||||
for (tlist = hash_items (i, h2); tlist; tlist = tlist->next)
|
||||
{
|
||||
t = pat_subst ((char *)tlist->data, pat, rep, mflags);
|
||||
FREE (tlist->data);
|
||||
tlist->data = t;
|
||||
}
|
||||
|
||||
if (mflags & MATCH_QUOTED)
|
||||
assoc_quote (h2);
|
||||
else
|
||||
assoc_quote_escapes (h2);
|
||||
|
||||
if (mflags & MATCH_STARSUB)
|
||||
{
|
||||
assoc_remove_quoted_nulls (h2);
|
||||
sifs = ifs_firstchar ((int *)NULL);
|
||||
t = assoc_to_string (h2, sifs, 0);
|
||||
free (sifs);
|
||||
}
|
||||
else if (mflags & MATCH_QUOTED)
|
||||
{
|
||||
/* ${array[@]} */
|
||||
sifs = ifs_firstchar (&slen);
|
||||
ifs = getifs ();
|
||||
if (ifs == 0 || *ifs == 0)
|
||||
{
|
||||
if (slen < 2)
|
||||
sifs = xrealloc (sifs, 2);
|
||||
sifs[0] = ' ';
|
||||
sifs[1] = '\0';
|
||||
}
|
||||
t = assoc_to_string (h2, sifs, 0);
|
||||
free(sifs);
|
||||
}
|
||||
else
|
||||
t = assoc_to_string (h2, " ", 0);
|
||||
|
||||
assoc_dispose (h2);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
char *
|
||||
assoc_modcase (h, pat, modop, mflags)
|
||||
HASH_TABLE *h;
|
||||
char *pat;
|
||||
int modop;
|
||||
int mflags;
|
||||
{
|
||||
BUCKET_CONTENTS *tlist;
|
||||
int i, slen;
|
||||
HASH_TABLE *h2;
|
||||
char *t, *sifs, *ifs;
|
||||
|
||||
if (h == 0 || assoc_empty (h))
|
||||
return ((char *)NULL);
|
||||
|
||||
h2 = assoc_copy (h);
|
||||
for (i = 0; i < h2->nbuckets; i++)
|
||||
for (tlist = hash_items (i, h2); tlist; tlist = tlist->next)
|
||||
{
|
||||
t = sh_modcase ((char *)tlist->data, pat, modop);
|
||||
FREE (tlist->data);
|
||||
tlist->data = t;
|
||||
}
|
||||
|
||||
if (mflags & MATCH_QUOTED)
|
||||
assoc_quote (h2);
|
||||
else
|
||||
assoc_quote_escapes (h2);
|
||||
|
||||
if (mflags & MATCH_STARSUB)
|
||||
{
|
||||
assoc_remove_quoted_nulls (h2);
|
||||
sifs = ifs_firstchar ((int *)NULL);
|
||||
t = assoc_to_string (h2, sifs, 0);
|
||||
free (sifs);
|
||||
}
|
||||
else if (mflags & MATCH_QUOTED)
|
||||
{
|
||||
/* ${array[@]} */
|
||||
sifs = ifs_firstchar (&slen);
|
||||
ifs = getifs ();
|
||||
if (ifs == 0 || *ifs == 0)
|
||||
{
|
||||
if (slen < 2)
|
||||
sifs = xrealloc (sifs, 2);
|
||||
sifs[0] = ' ';
|
||||
sifs[1] = '\0';
|
||||
}
|
||||
t = assoc_to_string (h2, sifs, 0);
|
||||
free(sifs);
|
||||
}
|
||||
else
|
||||
t = assoc_to_string (h2, " ", 0);
|
||||
|
||||
assoc_dispose (h2);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
char *
|
||||
assoc_to_assign (hash, quoted)
|
||||
HASH_TABLE *hash;
|
||||
int quoted;
|
||||
{
|
||||
char *ret;
|
||||
char *istr, *vstr;
|
||||
int i, rsize, rlen, elen;
|
||||
BUCKET_CONTENTS *tlist;
|
||||
|
||||
if (hash == 0 || assoc_empty (hash))
|
||||
return (char *)0;
|
||||
|
||||
ret = xmalloc (rsize = 128);
|
||||
ret[0] = '(';
|
||||
rlen = 1;
|
||||
|
||||
for (i = 0; i < hash->nbuckets; i++)
|
||||
for (tlist = hash_items (i, hash); tlist; tlist = tlist->next)
|
||||
{
|
||||
istr = tlist->key;
|
||||
vstr = tlist->data ? sh_double_quote ((char *)tlist->data) : (char *)0;
|
||||
|
||||
elen = STRLEN (istr) + 8 + STRLEN (vstr);
|
||||
RESIZE_MALLOCED_BUFFER (ret, rlen, (elen+1), rsize, rsize);
|
||||
|
||||
ret[rlen++] = '[';
|
||||
strcpy (ret+rlen, istr);
|
||||
rlen += STRLEN (istr);
|
||||
ret[rlen++] = ']';
|
||||
ret[rlen++] = '=';
|
||||
if (vstr)
|
||||
{
|
||||
strcpy (ret + rlen, vstr);
|
||||
rlen += STRLEN (vstr);
|
||||
}
|
||||
ret[rlen++] = ' ';
|
||||
|
||||
FREE (vstr);
|
||||
}
|
||||
|
||||
RESIZE_MALLOCED_BUFFER (ret, rlen, 1, rsize, 8);
|
||||
ret[rlen++] = ')';
|
||||
ret[rlen] = '\0';
|
||||
|
||||
if (quoted)
|
||||
{
|
||||
vstr = sh_single_quote (ret);
|
||||
free (ret);
|
||||
ret = vstr;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static WORD_LIST *
|
||||
assoc_to_word_list_internal (h, t)
|
||||
HASH_TABLE *h;
|
||||
int t;
|
||||
{
|
||||
WORD_LIST *list;
|
||||
int i;
|
||||
BUCKET_CONTENTS *tlist;
|
||||
char *w;
|
||||
|
||||
if (h == 0 || assoc_empty (h))
|
||||
return((WORD_LIST *)NULL);
|
||||
list = (WORD_LIST *)NULL;
|
||||
|
||||
for (i = 0; i < h->nbuckets; i++)
|
||||
for (tlist = hash_items (i, h); tlist; tlist = tlist->next)
|
||||
{
|
||||
w = (t == 0) ? (char *)tlist->data : (char *)tlist->key;
|
||||
list = make_word_list (make_bare_word(w), list);
|
||||
}
|
||||
return (REVERSE_LIST(list, WORD_LIST *));
|
||||
}
|
||||
|
||||
WORD_LIST *
|
||||
assoc_to_word_list (h)
|
||||
HASH_TABLE *h;
|
||||
{
|
||||
return (assoc_to_word_list_internal (h, 0));
|
||||
}
|
||||
|
||||
WORD_LIST *
|
||||
assoc_keys_to_word_list (h)
|
||||
HASH_TABLE *h;
|
||||
{
|
||||
return (assoc_to_word_list_internal (h, 1));
|
||||
}
|
||||
|
||||
char *
|
||||
assoc_to_string (h, sep, quoted)
|
||||
HASH_TABLE *h;
|
||||
char *sep;
|
||||
int quoted;
|
||||
{
|
||||
BUCKET_CONTENTS *tlist;
|
||||
int i;
|
||||
char *result, *t, *w;
|
||||
WORD_LIST *list, *l;
|
||||
|
||||
if (h == 0)
|
||||
return ((char *)NULL);
|
||||
if (assoc_empty (h))
|
||||
return (savestring (""));
|
||||
|
||||
result = NULL;
|
||||
list = NULL;
|
||||
/* This might be better implemented directly, but it's simple to implement
|
||||
by converting to a word list first, possibly quoting the data, then
|
||||
using list_string */
|
||||
for (i = 0; i < h->nbuckets; i++)
|
||||
for (tlist = hash_items (i, h); tlist; tlist = tlist->next)
|
||||
{
|
||||
w = (char *)tlist->data;
|
||||
if (w == 0)
|
||||
continue;
|
||||
t = quoted ? quote_string (w) : savestring (w);
|
||||
list = make_word_list (make_bare_word(t), list);
|
||||
FREE (t);
|
||||
}
|
||||
|
||||
l = REVERSE_LIST(list, WORD_LIST *);
|
||||
|
||||
result = l ? string_list_internal (l, sep) : savestring ("");
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif /* ARRAY_VARS */
|
|
@ -0,0 +1,61 @@
|
|||
/* assoc.h -- definitions for the interface exported by assoc.c that allows
|
||||
the rest of the shell to manipulate associative array variables. */
|
||||
|
||||
/* Copyright (C) 2008,2009 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 3 of the License, 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. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _ASSOC_H_
|
||||
#define _ASSOC_H_
|
||||
|
||||
#include "stdc.h"
|
||||
#include "hashlib.h"
|
||||
|
||||
#define assoc_empty(h) ((h)->nentries == 0)
|
||||
#define assoc_num_elements(h) ((h)->nentries)
|
||||
|
||||
#define assoc_create(n) (hash_create((n)))
|
||||
|
||||
#define assoc_copy(h) (hash_copy((h), 0))
|
||||
|
||||
#define assoc_walk(h, f) (hash_walk((h), (f))
|
||||
|
||||
extern void assoc_dispose __P((HASH_TABLE *));
|
||||
extern void assoc_flush __P((HASH_TABLE *));
|
||||
|
||||
extern int assoc_insert __P((HASH_TABLE *, char *, char *));
|
||||
extern void assoc_remove __P((HASH_TABLE *, char *));
|
||||
|
||||
extern char *assoc_reference __P((HASH_TABLE *, char *));
|
||||
|
||||
extern char *assoc_subrange __P((HASH_TABLE *, arrayind_t, arrayind_t, int, int));
|
||||
extern char *assoc_patsub __P((HASH_TABLE *, char *, char *, int));
|
||||
extern char *assoc_modcase __P((HASH_TABLE *, char *, int, int));
|
||||
|
||||
extern HASH_TABLE *assoc_quote __P((HASH_TABLE *));
|
||||
extern HASH_TABLE *assoc_quote_escapes __P((HASH_TABLE *));
|
||||
extern HASH_TABLE *assoc_dequote __P((HASH_TABLE *));
|
||||
extern HASH_TABLE *assoc_dequote_escapes __P((HASH_TABLE *));
|
||||
extern HASH_TABLE *assoc_remove_quoted_nulls __P((HASH_TABLE *));
|
||||
|
||||
extern char *assoc_to_assign __P((HASH_TABLE *, int));
|
||||
|
||||
extern WORD_LIST *assoc_to_word_list __P((HASH_TABLE *));
|
||||
extern WORD_LIST *assoc_keys_to_word_list __P((HASH_TABLE *));
|
||||
|
||||
extern char *assoc_to_string __P((HASH_TABLE *, char *, int));
|
||||
#endif /* _ASSOC_H_ */
|
|
@ -1,11 +1,11 @@
|
|||
resource app_version
|
||||
{
|
||||
major = 2,
|
||||
major = 4,
|
||||
middle = 0,
|
||||
minor = 5,
|
||||
minor = 0,
|
||||
variety = 5,
|
||||
internal = 0,
|
||||
short_info = "2.05b",
|
||||
long_info = "2.05b ©2004 The Free Software Foundation"
|
||||
short_info = "4.0.0",
|
||||
long_info = "4.0.0 Copyright 2009 The Free Software Foundation"
|
||||
};
|
||||
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
/* bashansi.h -- Typically included information required by picky compilers. */
|
||||
|
||||
/* Copyright (C) 1993 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1993-2009 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 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 3 of the License, 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.
|
||||
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. */
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if !defined (_BASHANSI_H_)
|
||||
#define _BASHANSI_H_
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
/* bashhist.c -- bash interface to the GNU history library. */
|
||||
|
||||
/* Copyright (C) 1993 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1993-2009 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 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 3 of the License, 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.
|
||||
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. */
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
@ -36,6 +36,8 @@
|
|||
#include "posixstat.h"
|
||||
#include "filecntl.h"
|
||||
|
||||
#include "bashintl.h"
|
||||
|
||||
#include "shell.h"
|
||||
#include "flags.h"
|
||||
#include "input.h"
|
||||
|
@ -50,6 +52,7 @@
|
|||
|
||||
#if defined (READLINE)
|
||||
# include "bashline.h"
|
||||
extern int rl_done, rl_dispatching; /* should really include readline.h */
|
||||
#endif
|
||||
|
||||
#if !defined (errno)
|
||||
|
@ -58,6 +61,7 @@ extern int errno;
|
|||
|
||||
static int histignore_item_func __P((struct ign *));
|
||||
static int check_history_control __P((char *));
|
||||
static void hc_erasedups __P((char *));
|
||||
static void really_add_history __P((char *));
|
||||
|
||||
static struct ignorevar histignore =
|
||||
|
@ -76,8 +80,12 @@ static struct ignorevar histignore =
|
|||
list. This is different than the user-controlled behaviour; this
|
||||
becomes zero when we read lines from a file, for example. */
|
||||
int remember_on_history = 1;
|
||||
int enable_history_list = 1; /* value for `set -o history' */
|
||||
|
||||
/* The number of lines that Bash has added to this history session. */
|
||||
/* The number of lines that Bash has added to this history session. The
|
||||
difference between the number of the top element in the history list
|
||||
(offset from history_base) and the number of lines in the history file.
|
||||
Appending this session's history to the history file resets this to 0. */
|
||||
int history_lines_this_session;
|
||||
|
||||
/* The number of lines that Bash has read from the history file. */
|
||||
|
@ -134,10 +142,14 @@ int literal_history;
|
|||
exit, even if the history has been stifled. */
|
||||
int force_append_history;
|
||||
|
||||
/* A nit for picking at history saving.
|
||||
Value of 0 means save all lines parsed by the shell on the history.
|
||||
Value of 1 means save all lines that do not start with a space.
|
||||
Value of 2 means save all lines that do not match the last line saved. */
|
||||
/* A nit for picking at history saving. Flags have the following values:
|
||||
|
||||
Value == 0 means save all lines parsed by the shell on the history.
|
||||
Value & HC_IGNSPACE means save all lines that do not start with a space.
|
||||
Value & HC_IGNDUPS means save all lines that do not match the last
|
||||
line saved.
|
||||
Value & HC_ERASEDUPS means to remove all other matching lines from the
|
||||
history list before saving the latest line. */
|
||||
int history_control;
|
||||
|
||||
/* Set to 1 if the last command was added to the history list successfully
|
||||
|
@ -145,6 +157,10 @@ int history_control;
|
|||
to a previous entry as part of command-oriented-history processing. */
|
||||
int hist_last_line_added;
|
||||
|
||||
/* Set to 1 if builtins/history.def:push_history added the last history
|
||||
entry. */
|
||||
int hist_last_line_pushed;
|
||||
|
||||
#if defined (READLINE)
|
||||
/* If non-zero, and readline is being used, the user is offered the
|
||||
chance to re-edit a failed history expansion. */
|
||||
|
@ -206,6 +222,9 @@ bash_initialize_history ()
|
|||
history_quotes_inhibit_expansion = 1;
|
||||
history_search_delimiter_chars = ";&()|<>";
|
||||
history_inhibit_expansion_function = bash_history_inhibit_expansion;
|
||||
#if defined (BANG_HISTORY)
|
||||
sv_histchars ("histchars");
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -216,7 +235,7 @@ bash_history_reinit (interact)
|
|||
history_expansion = interact != 0;
|
||||
history_expansion_inhibited = 1;
|
||||
#endif
|
||||
remember_on_history = interact != 0;
|
||||
remember_on_history = enable_history_list = interact != 0;
|
||||
history_inhibit_expansion_function = bash_history_inhibit_expansion;
|
||||
}
|
||||
|
||||
|
@ -246,19 +265,21 @@ void
|
|||
load_history ()
|
||||
{
|
||||
char *hf;
|
||||
struct stat buf;
|
||||
|
||||
/* Truncate history file for interactive shells which desire it.
|
||||
Note that the history file is automatically truncated to the
|
||||
size of HISTSIZE if the user does not explicitly set the size
|
||||
differently. */
|
||||
set_if_not ("HISTSIZE", "500");
|
||||
sv_histsize ("HISTSIZE");
|
||||
|
||||
set_if_not ("HISTFILESIZE", get_string_value ("HISTSIZE"));
|
||||
sv_histsize ("HISTFILESIZE");
|
||||
|
||||
/* Read the history in HISTFILE into the history list. */
|
||||
hf = get_string_value ("HISTFILE");
|
||||
|
||||
if (hf && *hf && stat (hf, &buf) == 0)
|
||||
if (hf && *hf && file_exists (hf))
|
||||
{
|
||||
read_history (hf);
|
||||
using_history ();
|
||||
|
@ -266,16 +287,65 @@ load_history ()
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
bash_clear_history ()
|
||||
{
|
||||
clear_history ();
|
||||
history_lines_this_session = 0;
|
||||
}
|
||||
|
||||
/* Delete and free the history list entry at offset I. */
|
||||
int
|
||||
bash_delete_histent (i)
|
||||
int i;
|
||||
{
|
||||
HIST_ENTRY *discard;
|
||||
|
||||
discard = remove_history (i);
|
||||
if (discard)
|
||||
free_history_entry (discard);
|
||||
history_lines_this_session--;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
bash_delete_last_history ()
|
||||
{
|
||||
register int i;
|
||||
HIST_ENTRY **hlist, *histent;
|
||||
int r;
|
||||
|
||||
hlist = history_list ();
|
||||
if (hlist == NULL)
|
||||
return 0;
|
||||
|
||||
for (i = 0; hlist[i]; i++)
|
||||
;
|
||||
i--;
|
||||
|
||||
/* History_get () takes a parameter that must be offset by history_base. */
|
||||
histent = history_get (history_base + i); /* Don't free this */
|
||||
if (histent == NULL)
|
||||
return 0;
|
||||
|
||||
r = bash_delete_histent (i);
|
||||
|
||||
if (where_history () > history_length)
|
||||
history_set_pos (history_length);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
#ifdef INCLUDE_UNUSED
|
||||
/* Write the existing history out to the history file. */
|
||||
void
|
||||
save_history ()
|
||||
{
|
||||
char *hf;
|
||||
struct stat buf;
|
||||
|
||||
hf = get_string_value ("HISTFILE");
|
||||
if (hf && *hf && stat (hf, &buf) == 0)
|
||||
if (hf && *hf && file_exists (hf))
|
||||
{
|
||||
/* Append only the lines that occurred this session to
|
||||
the history file. */
|
||||
|
@ -285,7 +355,6 @@ save_history ()
|
|||
append_history (history_lines_this_session, hf);
|
||||
else
|
||||
write_history (hf);
|
||||
|
||||
sv_histsize ("HISTFILESIZE");
|
||||
}
|
||||
}
|
||||
|
@ -307,7 +376,7 @@ maybe_append_history (filename)
|
|||
fd = open (filename, O_WRONLY|O_CREAT, 0600);
|
||||
if (fd < 0)
|
||||
{
|
||||
builtin_error ("%s: cannot create: %s", filename, strerror (errno));
|
||||
builtin_error (_("%s: cannot create: %s"), filename, strerror (errno));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
close (fd);
|
||||
|
@ -326,7 +395,6 @@ maybe_save_shell_history ()
|
|||
{
|
||||
int result;
|
||||
char *hf;
|
||||
struct stat buf;
|
||||
|
||||
result = 0;
|
||||
if (history_lines_this_session)
|
||||
|
@ -336,7 +404,7 @@ maybe_save_shell_history ()
|
|||
if (hf && *hf)
|
||||
{
|
||||
/* If the file doesn't exist, then create it. */
|
||||
if (stat (hf, &buf) == -1)
|
||||
if (file_exists (hf) == 0)
|
||||
{
|
||||
int file;
|
||||
file = open (hf, O_CREAT | O_TRUNC | O_WRONLY, 0600);
|
||||
|
@ -433,12 +501,19 @@ pre_process_line (line, print_changes, addit)
|
|||
/* If there was an error, return NULL. */
|
||||
if (expanded < 0 || expanded == 2) /* 2 == print only */
|
||||
{
|
||||
# if defined (READLINE)
|
||||
if (expanded == 2 && rl_dispatching == 0 && *history_value)
|
||||
# else
|
||||
if (expanded == 2 && *history_value)
|
||||
# endif /* !READLINE */
|
||||
maybe_add_history (history_value);
|
||||
|
||||
free (history_value);
|
||||
|
||||
# if defined (READLINE)
|
||||
/* New hack. We can allow the user to edit the
|
||||
failed history expansion. */
|
||||
if (history_reediting && expanded < 0)
|
||||
if (history_reediting && expanded < 0 && rl_done)
|
||||
re_edit (line);
|
||||
# endif /* READLINE */
|
||||
return ((char *)NULL);
|
||||
|
@ -511,27 +586,49 @@ check_history_control (line)
|
|||
HIST_ENTRY *temp;
|
||||
int r;
|
||||
|
||||
switch (history_control)
|
||||
if (history_control == 0)
|
||||
return 1;
|
||||
|
||||
/* ignorespace or ignoreboth */
|
||||
if ((history_control & HC_IGNSPACE) && *line == ' ')
|
||||
return 0;
|
||||
|
||||
/* ignoredups or ignoreboth */
|
||||
if (history_control & HC_IGNDUPS)
|
||||
{
|
||||
case 0: /* nothing */
|
||||
return 1;
|
||||
case 1: /* ignorespace */
|
||||
return (*line != ' ');
|
||||
case 3: /* ignoreboth */
|
||||
if (*line == ' ')
|
||||
return 0;
|
||||
/* FALLTHROUGH if case == 3 (`ignoreboth') */
|
||||
case 2: /* ignoredups */
|
||||
using_history ();
|
||||
temp = previous_history ();
|
||||
|
||||
r = (temp == 0 || STREQ (temp->line, line) == 0);
|
||||
|
||||
using_history ();
|
||||
return r;
|
||||
|
||||
if (r == 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Remove all entries matching LINE from the history list. Triggered when
|
||||
HISTCONTROL includes `erasedups'. */
|
||||
static void
|
||||
hc_erasedups (line)
|
||||
char *line;
|
||||
{
|
||||
HIST_ENTRY *temp;
|
||||
int r;
|
||||
|
||||
using_history ();
|
||||
while (temp = previous_history ())
|
||||
{
|
||||
if (STREQ (temp->line, line))
|
||||
{
|
||||
r = where_history ();
|
||||
remove_history (r);
|
||||
}
|
||||
}
|
||||
using_history ();
|
||||
}
|
||||
|
||||
/* Add LINE to the history list, handling possibly multi-line compound
|
||||
|
@ -577,6 +674,11 @@ check_add_history (line, force)
|
|||
{
|
||||
if (check_history_control (line) && history_should_ignore (line) == 0)
|
||||
{
|
||||
/* We're committed to saving the line. If the user has requested it,
|
||||
remove other matching lines from the history. */
|
||||
if (history_control & HC_ERASEDUPS)
|
||||
hc_erasedups (line);
|
||||
|
||||
if (force)
|
||||
{
|
||||
really_add_history (line);
|
||||
|
@ -635,10 +737,8 @@ bash_add_history (line)
|
|||
free (new_line);
|
||||
|
||||
if (old)
|
||||
{
|
||||
FREE (old->line);
|
||||
free (old);
|
||||
}
|
||||
free_history_entry (old);
|
||||
|
||||
add_it = 0;
|
||||
}
|
||||
}
|
||||
|
@ -654,6 +754,7 @@ really_add_history (line)
|
|||
char *line;
|
||||
{
|
||||
hist_last_line_added = 1;
|
||||
hist_last_line_pushed = 0;
|
||||
add_history (line);
|
||||
history_lines_this_session++;
|
||||
}
|
||||
|
@ -662,7 +763,7 @@ int
|
|||
history_number ()
|
||||
{
|
||||
using_history ();
|
||||
return (get_string_value ("HISTSIZE") ? history_base + where_history () : 1);
|
||||
return (remember_on_history ? history_base + where_history () : 1);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
@ -1,29 +1,39 @@
|
|||
/* bashhist.h -- interface to the bash history functions in bashhist.c. */
|
||||
|
||||
/* Copyright (C) 1993 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1993-2009 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 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 3 of the License, 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.
|
||||
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. */
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if !defined (_BASHHIST_H_)
|
||||
#define _BASHHIST_H_
|
||||
|
||||
#include "stdc.h"
|
||||
|
||||
/* Flag values for history_control */
|
||||
#define HC_IGNSPACE 0x01
|
||||
#define HC_IGNDUPS 0x02
|
||||
#define HC_ERASEDUPS 0x04
|
||||
|
||||
#define HC_IGNBOTH (HC_IGNSPACE|HC_IGNDUPS)
|
||||
|
||||
extern int remember_on_history;
|
||||
extern int enable_history_list; /* value for `set -o history' */
|
||||
extern int literal_history; /* controlled by `shopt lithist' */
|
||||
extern int force_append_history;
|
||||
extern int history_lines_this_session;
|
||||
extern int history_lines_in_file;
|
||||
extern int history_expansion;
|
||||
|
@ -31,6 +41,7 @@ extern int history_control;
|
|||
extern int command_oriented_history;
|
||||
extern int current_command_first_line_saved;
|
||||
extern int hist_last_line_added;
|
||||
extern int hist_last_line_pushed;
|
||||
|
||||
# if defined (BANG_HISTORY)
|
||||
extern int history_expansion_inhibited;
|
||||
|
@ -40,6 +51,9 @@ extern void bash_initialize_history __P((void));
|
|||
extern void bash_history_reinit __P((int));
|
||||
extern void bash_history_disable __P((void));
|
||||
extern void bash_history_enable __P((void));
|
||||
extern void bash_clear_history __P((void));
|
||||
extern int bash_delete_histent __P((int));
|
||||
extern int bash_delete_last_history __P((void));
|
||||
extern void load_history __P((void));
|
||||
extern void save_history __P((void));
|
||||
extern int maybe_append_history __P((char *));
|
||||
|
|
|
@ -1,35 +1,44 @@
|
|||
/* bashintl.h -- Internationalization stuff
|
||||
/* bashintl.h -- Internationalization functions and defines. */
|
||||
|
||||
Copyright (C) 1996 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1996-2009 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 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 3 of the License, 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.
|
||||
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. */
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if !defined (_BASHINTL_H_)
|
||||
#define _BASHINTL_H_
|
||||
|
||||
/* Include this *after* config.h */
|
||||
#if defined (HAVE_LIBINTL_H)
|
||||
# include <libintl.h>
|
||||
#if defined (BUILDTOOL)
|
||||
# undef ENABLE_NLS
|
||||
# define ENABLE_NLS 0
|
||||
#endif
|
||||
|
||||
/* Include this *after* config.h */
|
||||
#include "gettext.h"
|
||||
|
||||
#if defined (HAVE_LOCALE_H)
|
||||
# include <locale.h>
|
||||
#endif
|
||||
|
||||
#define _(msgid) gettext(msgid)
|
||||
#define N_(msgid) msgid
|
||||
#define D_(d, msgid) dgettext(d, msgid)
|
||||
|
||||
#define P_(m1, m2, n) ngettext(m1, m2, n)
|
||||
|
||||
#if defined (HAVE_SETLOCALE) && !defined (LC_ALL)
|
||||
# undef HAVE_SETLOCALE
|
||||
#endif
|
||||
|
@ -38,12 +47,4 @@
|
|||
# define setlocale(cat, loc)
|
||||
#endif
|
||||
|
||||
#if !defined (HAVE_TEXTDOMAIN)
|
||||
# define textdomain(dom)
|
||||
#endif
|
||||
|
||||
#if !defined (HAVE_BINDTEXTDOMAIN)
|
||||
# define bindtextdomain(dom, dir)
|
||||
#endif
|
||||
|
||||
#endif /* !_BASHINTL_H_ */
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
/* bashjmp.h -- wrapper for setjmp.h with necessary bash definitions. */
|
||||
|
||||
/* Copyright (C) 1987,1991 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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. */
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _BASHJMP_H_
|
||||
#define _BASHJMP_H_
|
||||
|
@ -33,9 +33,11 @@ extern procenv_t return_catch; /* used by `return' builtin */
|
|||
xbcopy ((char *)old, (char *)save, sizeof (procenv_t));
|
||||
|
||||
/* Values for the second argument to longjmp/siglongjmp. */
|
||||
#define NOT_JUMPED 0 /* Not returning from a longjmp. */
|
||||
#define FORCE_EOF 1 /* We want to stop parsing. */
|
||||
#define DISCARD 2 /* Discard current command. */
|
||||
#define EXITPROG 3 /* Unconditionally exit the program now. */
|
||||
#define NOT_JUMPED 0 /* Not returning from a longjmp. */
|
||||
#define FORCE_EOF 1 /* We want to stop parsing. */
|
||||
#define DISCARD 2 /* Discard current command. */
|
||||
#define EXITPROG 3 /* Unconditionally exit the program now. */
|
||||
#define ERREXIT 4 /* Exit due to error condition */
|
||||
#define SIGEXIT 5 /* Exit due to fatal terminating signal */
|
||||
|
||||
#endif /* _BASHJMP_H_ */
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,22 +1,22 @@
|
|||
/* bashline.h -- interface to the bash readline functions in bashline.c. */
|
||||
|
||||
/* Copyright (C) 1993 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1993-2009 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 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 3 of the License, 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.
|
||||
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. */
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if !defined (_BASHLINE_H_)
|
||||
#define _BASHLINE_H_
|
||||
|
@ -26,13 +26,17 @@
|
|||
extern int bash_readline_initialized;
|
||||
|
||||
extern void posix_readline_initialize __P((int));
|
||||
extern void reset_completer_word_break_chars __P((void));
|
||||
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 *));
|
||||
|
||||
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));
|
||||
|
@ -42,5 +46,6 @@ 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_ */
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
/* bashtypes.h -- Bash system types. */
|
||||
|
||||
/* Copyright (C) 1993 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1993-2009 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 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 3 of the License, 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.
|
||||
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. */
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if !defined (_BASHTYPES_H_)
|
||||
# define _BASHTYPES_H_
|
||||
|
|
|
@ -4,25 +4,26 @@
|
|||
|
||||
/* Original version by tromey@cns.caltech.edu, Fri Feb 7 1992. */
|
||||
|
||||
/* Copyright (C) 1993 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1993-2009 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 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 3 of the License, 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.
|
||||
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. */
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if defined (BRACE_EXPANSION) && defined (READLINE)
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -35,10 +36,13 @@
|
|||
#endif
|
||||
|
||||
#include "bashansi.h"
|
||||
#include "shmbutil.h"
|
||||
|
||||
#include "shell.h"
|
||||
#include <readline/readline.h>
|
||||
|
||||
static int _strcompare __P((char **, char **));
|
||||
|
||||
/* Find greatest common prefix of two strings. */
|
||||
static int
|
||||
string_gcd (s1, s2)
|
||||
|
@ -145,6 +149,19 @@ really_munge_braces (array, real_start, real_end, gcd_zero)
|
|||
return (result);
|
||||
}
|
||||
|
||||
static int
|
||||
_strcompare (s1, s2)
|
||||
char **s1, **s2;
|
||||
{
|
||||
int result;
|
||||
|
||||
result = **s1 - **s2;
|
||||
if (result == 0)
|
||||
result = strcmp (*s1, *s2);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static int
|
||||
hack_braces_completion (names)
|
||||
char **names;
|
||||
|
@ -152,7 +169,11 @@ hack_braces_completion (names)
|
|||
register int i;
|
||||
char *temp;
|
||||
|
||||
temp = really_munge_braces (names, 1, strvec_len (names), 0);
|
||||
i = strvec_len (names);
|
||||
if (MB_CUR_MAX > 1 && i > 2)
|
||||
qsort (names+1, i-1, sizeof (char *), (QSFUNC *)_strcompare);
|
||||
|
||||
temp = really_munge_braces (names, 1, i, 0);
|
||||
|
||||
for (i = 0; names[i]; ++i)
|
||||
{
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
/* braces.c -- code for doing word expansion in curly braces. */
|
||||
|
||||
/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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. */
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* Stuff in curly braces gets expanded before all other shell expansions. */
|
||||
|
||||
|
@ -39,9 +39,14 @@
|
|||
|
||||
#include "general.h"
|
||||
#include "shmbutil.h"
|
||||
#include "chartypes.h"
|
||||
|
||||
#define brace_whitespace(c) (!(c) || (c) == ' ' || (c) == '\t' || (c) == '\n')
|
||||
|
||||
#define BRACE_SEQ_SPECIFIER ".."
|
||||
|
||||
extern int asprintf __P((char **, const char *, ...)) __attribute__((__format__ (printf, 2, 3)));
|
||||
|
||||
/* Basic idea:
|
||||
|
||||
Segregate the text into 3 sections: preamble (stuff before an open brace),
|
||||
|
@ -52,18 +57,34 @@
|
|||
*/
|
||||
|
||||
/* The character which is used to separate arguments. */
|
||||
int brace_arg_separator = ',';
|
||||
static const int brace_arg_separator = ',';
|
||||
|
||||
#if defined (__P)
|
||||
static int brace_gobbler __P((char *, size_t, int *, int));
|
||||
static char **expand_amble __P((char *, size_t));
|
||||
static char **expand_amble __P((char *, size_t, int));
|
||||
static char **expand_seqterm __P((char *, size_t));
|
||||
static char **mkseq __P((int, int, int, int, int));
|
||||
static char **array_concat __P((char **, char **));
|
||||
#else
|
||||
static int brace_gobbler ();
|
||||
static char **expand_amble ();
|
||||
static char **expand_seqterm ();
|
||||
static char **mkseq();
|
||||
static char **array_concat ();
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
static void
|
||||
dump_result (a)
|
||||
char **a;
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; a[i]; i++)
|
||||
printf ("dump_result: a[%d] = -%s-\n", i, a[i]);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Return an array of strings; the brace expansion of TEXT. */
|
||||
char **
|
||||
brace_expand (text)
|
||||
|
@ -74,14 +95,45 @@ brace_expand (text)
|
|||
char *preamble, *postamble, *amble;
|
||||
size_t alen;
|
||||
char **tack, **result;
|
||||
int i, j, c;
|
||||
int i, j, c, c1;
|
||||
|
||||
DECLARE_MBSTATE;
|
||||
|
||||
/* Find the text of the preamble. */
|
||||
tlen = strlen (text);
|
||||
i = 0;
|
||||
c = brace_gobbler (text, tlen, &i, '{');
|
||||
#if defined (CSH_BRACE_COMPAT)
|
||||
c = brace_gobbler (text, tlen, &i, '{'); /* } */
|
||||
#else
|
||||
/* Make sure that when we exit this loop, c == 0 or text[i] begins a
|
||||
valid brace expansion sequence. */
|
||||
do
|
||||
{
|
||||
c = brace_gobbler (text, tlen, &i, '{'); /* } */
|
||||
c1 = c;
|
||||
/* Verify that c begins a valid brace expansion word. If it doesn't, we
|
||||
go on. Loop stops when there are no more open braces in the word. */
|
||||
if (c)
|
||||
{
|
||||
start = j = i + 1; /* { */
|
||||
c = brace_gobbler (text, tlen, &j, '}');
|
||||
if (c == 0) /* it's not */
|
||||
{
|
||||
i++;
|
||||
c = c1;
|
||||
continue;
|
||||
}
|
||||
else /* it is */
|
||||
{
|
||||
c = c1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
while (c);
|
||||
#endif /* !CSH_BRACE_COMPAT */
|
||||
|
||||
preamble = (char *)xmalloc (i + 1);
|
||||
strncpy (preamble, text, i);
|
||||
|
@ -117,9 +169,9 @@ brace_expand (text)
|
|||
}
|
||||
|
||||
if (text[j] == brace_arg_separator)
|
||||
{
|
||||
{ /* { */
|
||||
strvec_dispose (result);
|
||||
report_error ("missing `}'");
|
||||
report_error ("no closing `%c' in %s", '}', text);
|
||||
throw_to_top_level ();
|
||||
}
|
||||
ADVANCE_CHAR (text, tlen, j);
|
||||
|
@ -161,22 +213,29 @@ brace_expand (text)
|
|||
ADVANCE_CHAR (amble, alen, j);
|
||||
}
|
||||
|
||||
if (!amble[j])
|
||||
if (amble[j] == 0)
|
||||
{
|
||||
free (amble);
|
||||
free (preamble);
|
||||
result[0] = savestring (text);
|
||||
return (result);
|
||||
tack = expand_seqterm (amble, alen);
|
||||
if (tack)
|
||||
goto add_tack;
|
||||
else
|
||||
{
|
||||
free (amble);
|
||||
free (preamble);
|
||||
result[0] = savestring (text);
|
||||
return (result);
|
||||
}
|
||||
}
|
||||
#endif /* SHELL */
|
||||
|
||||
postamble = &text[i + 1];
|
||||
|
||||
tack = expand_amble (amble, alen);
|
||||
tack = expand_amble (amble, alen, 0);
|
||||
add_tack:
|
||||
result = array_concat (result, tack);
|
||||
free (amble);
|
||||
strvec_dispose (tack);
|
||||
|
||||
postamble = text + i + 1;
|
||||
|
||||
tack = brace_expand (postamble);
|
||||
result = array_concat (result, tack);
|
||||
strvec_dispose (tack);
|
||||
|
@ -189,9 +248,10 @@ brace_expand (text)
|
|||
expand each slot which needs it, until there are no more slots which
|
||||
need it. */
|
||||
static char **
|
||||
expand_amble (text, tlen)
|
||||
expand_amble (text, tlen, flags)
|
||||
char *text;
|
||||
size_t tlen;
|
||||
int flags;
|
||||
{
|
||||
char **result, **partial;
|
||||
char *tem;
|
||||
|
@ -220,9 +280,10 @@ expand_amble (text, tlen)
|
|||
result = partial;
|
||||
else
|
||||
{
|
||||
register int lr = strvec_len (result);
|
||||
register int lp = strvec_len (partial);
|
||||
register int j;
|
||||
register int lr, lp, j;
|
||||
|
||||
lr = strvec_len (result);
|
||||
lp = strvec_len (partial);
|
||||
|
||||
result = strvec_resize (result, lp + lr + 1);
|
||||
|
||||
|
@ -239,10 +300,174 @@ expand_amble (text, tlen)
|
|||
return (result);
|
||||
}
|
||||
|
||||
#define ST_BAD 0
|
||||
#define ST_INT 1
|
||||
#define ST_CHAR 2
|
||||
#define ST_ZINT 3
|
||||
|
||||
static char **
|
||||
mkseq (start, end, incr, type, width)
|
||||
int start, end, incr, type, width;
|
||||
{
|
||||
int n, i;
|
||||
char **result, *t;
|
||||
|
||||
n = abs (end - start) + 1;
|
||||
result = strvec_create (n + 1);
|
||||
|
||||
if (incr == 0)
|
||||
incr = 1;
|
||||
|
||||
if (start > end && incr > 0)
|
||||
incr = -incr;
|
||||
else if (start < end && incr < 0)
|
||||
incr = -incr;
|
||||
|
||||
/* Make sure we go through the loop at least once, so {3..3} prints `3' */
|
||||
i = 0;
|
||||
n = start;
|
||||
do
|
||||
{
|
||||
#if defined (SHELL)
|
||||
QUIT; /* XXX - memory leak here */
|
||||
#endif
|
||||
if (type == ST_INT)
|
||||
result[i++] = itos (n);
|
||||
else if (type == ST_ZINT)
|
||||
{
|
||||
int len;
|
||||
len = asprintf (&t, "%0*d", width, n);
|
||||
result[i++] = t;
|
||||
}
|
||||
else
|
||||
{
|
||||
t = (char *)xmalloc (2);
|
||||
t[0] = n;
|
||||
t[1] = '\0';
|
||||
result[i++] = t;
|
||||
}
|
||||
n += incr;
|
||||
if ((incr < 0 && n < end) || (incr > 0 && n > end))
|
||||
break;
|
||||
}
|
||||
while (1);
|
||||
|
||||
result[i] = (char *)0;
|
||||
return (result);
|
||||
}
|
||||
|
||||
static char **
|
||||
expand_seqterm (text, tlen)
|
||||
char *text;
|
||||
size_t tlen;
|
||||
{
|
||||
char *t, *lhs, *rhs;
|
||||
int i, lhs_t, rhs_t, lhs_v, rhs_v, incr, lhs_l, rhs_l, width;
|
||||
intmax_t tl, tr;
|
||||
char **result, *ep;
|
||||
|
||||
t = strstr (text, BRACE_SEQ_SPECIFIER);
|
||||
if (t == 0)
|
||||
return ((char **)NULL);
|
||||
|
||||
lhs_l = t - text; /* index of start of BRACE_SEQ_SPECIFIER */
|
||||
lhs = substring (text, 0, lhs_l);
|
||||
rhs = substring (text, lhs_l + sizeof(BRACE_SEQ_SPECIFIER) - 1, tlen);
|
||||
|
||||
if (lhs[0] == 0 || rhs[0] == 0)
|
||||
{
|
||||
free (lhs);
|
||||
free (rhs);
|
||||
return ((char **)NULL);
|
||||
}
|
||||
|
||||
/* Now figure out whether LHS and RHS are integers or letters. Both
|
||||
sides have to match. */
|
||||
lhs_t = (legal_number (lhs, &tl)) ? ST_INT :
|
||||
((ISALPHA (lhs[0]) && lhs[1] == 0) ? ST_CHAR : ST_BAD);
|
||||
|
||||
/* Decide on rhs and whether or not it looks like the user specified
|
||||
an increment */
|
||||
ep = 0;
|
||||
if (ISDIGIT (rhs[0]) || ((rhs[0] == '+' || rhs[0] == '-') && ISDIGIT (rhs[1])))
|
||||
{
|
||||
rhs_t = ST_INT;
|
||||
tr = strtoimax (rhs, &ep, 10);
|
||||
if (ep && *ep != 0 && *ep != '.')
|
||||
rhs_t = ST_BAD; /* invalid */
|
||||
}
|
||||
else if (ISALPHA (rhs[0]) && (rhs[1] == 0 || rhs[1] == '.'))
|
||||
{
|
||||
rhs_t = ST_CHAR;
|
||||
ep = rhs + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
rhs_t = ST_BAD;
|
||||
ep = 0;
|
||||
}
|
||||
|
||||
incr = 1;
|
||||
if (rhs_t != ST_BAD)
|
||||
{
|
||||
if (ep && *ep == '.' && ep[1] == '.' && ep[2])
|
||||
incr = strtoimax (ep + 2, &ep, 10);
|
||||
if (*ep != 0)
|
||||
rhs_t = ST_BAD; /* invalid incr */
|
||||
}
|
||||
|
||||
if (lhs_t != rhs_t || lhs_t == ST_BAD || rhs_t == ST_BAD)
|
||||
{
|
||||
free (lhs);
|
||||
free (rhs);
|
||||
return ((char **)NULL);
|
||||
}
|
||||
|
||||
/* OK, we have something. It's either a sequence of integers, ascending
|
||||
or descending, or a sequence or letters, ditto. Generate the sequence,
|
||||
put it into a string vector, and return it. */
|
||||
|
||||
if (lhs_t == ST_CHAR)
|
||||
{
|
||||
lhs_v = (unsigned char)lhs[0];
|
||||
rhs_v = (unsigned char)rhs[0];
|
||||
width = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
lhs_v = tl; /* integer truncation */
|
||||
rhs_v = tr;
|
||||
|
||||
/* Decide whether or not the terms need zero-padding */
|
||||
rhs_l = tlen - lhs_l - sizeof (BRACE_SEQ_SPECIFIER) + 1;
|
||||
width = 0;
|
||||
if (lhs_l > 1 && lhs[0] == '0')
|
||||
width = lhs_l, lhs_t = ST_ZINT;
|
||||
if (lhs_l > 2 && lhs[0] == '-' && lhs[1] == '0')
|
||||
width = lhs_l, lhs_t = ST_ZINT;
|
||||
if (rhs_l > 1 && rhs[0] == '0' && width < rhs_l)
|
||||
width = rhs_l, lhs_t = ST_ZINT;
|
||||
if (rhs_l > 2 && rhs[0] == '-' && rhs[1] == '0' && width < rhs_l)
|
||||
width = rhs_l, lhs_t = ST_ZINT;
|
||||
}
|
||||
|
||||
result = mkseq (lhs_v, rhs_v, incr, lhs_t, width);
|
||||
|
||||
free (lhs);
|
||||
free (rhs);
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
/* Start at INDEX, and skip characters in TEXT. Set INDEX to the
|
||||
index of the character matching SATISFY. This understands about
|
||||
quoting. Return the character that caused us to stop searching;
|
||||
this is either the same as SATISFY, or 0. */
|
||||
/* If SATISFY is `}', we are looking for a brace expression, so we
|
||||
should enforce the rules that govern valid brace expansions:
|
||||
1) to count as an arg separator, a comma or `..' has to be outside
|
||||
an inner set of braces.
|
||||
*/
|
||||
static int
|
||||
brace_gobbler (text, tlen, indx, satisfy)
|
||||
char *text;
|
||||
|
@ -250,7 +475,7 @@ brace_gobbler (text, tlen, indx, satisfy)
|
|||
int *indx;
|
||||
int satisfy;
|
||||
{
|
||||
register int i, c, quoted, level, pass_next;
|
||||
register int i, c, quoted, level, commas, pass_next;
|
||||
#if defined (SHELL)
|
||||
int si;
|
||||
char *t;
|
||||
|
@ -258,6 +483,11 @@ brace_gobbler (text, tlen, indx, satisfy)
|
|||
DECLARE_MBSTATE;
|
||||
|
||||
level = quoted = pass_next = 0;
|
||||
#if defined (CSH_BRACE_COMPAT)
|
||||
commas = 1;
|
||||
#else
|
||||
commas = (satisfy == '}') ? 0 : 1;
|
||||
#endif
|
||||
|
||||
i = *indx;
|
||||
while (c = text[i])
|
||||
|
@ -278,6 +508,18 @@ brace_gobbler (text, tlen, indx, satisfy)
|
|||
continue;
|
||||
}
|
||||
|
||||
#if defined (SHELL)
|
||||
/* If compiling for the shell, treat ${...} like \{...} */
|
||||
if (c == '$' && text[i+1] == '{' && quoted != '\'') /* } */
|
||||
{
|
||||
pass_next = 1;
|
||||
i++;
|
||||
if (quoted == 0)
|
||||
level++;
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (quoted)
|
||||
{
|
||||
if (c == quoted)
|
||||
|
@ -294,11 +536,11 @@ brace_gobbler (text, tlen, indx, satisfy)
|
|||
}
|
||||
|
||||
#if defined (SHELL)
|
||||
/* Pass new-style command substitutions through unchanged. */
|
||||
if (c == '$' && text[i+1] == '(') /* ) */
|
||||
/* Pass new-style command and process substitutions through unchanged. */
|
||||
if ((c == '$' || c == '<' || c == '>') && text[i+1] == '(') /* ) */
|
||||
{
|
||||
si = i + 2;
|
||||
t = extract_command_subst (text, &si);
|
||||
t = extract_command_subst (text, &si, 0);
|
||||
i = si;
|
||||
free (t);
|
||||
i++;
|
||||
|
@ -306,7 +548,7 @@ brace_gobbler (text, tlen, indx, satisfy)
|
|||
}
|
||||
#endif
|
||||
|
||||
if (c == satisfy && level == 0 && quoted == 0)
|
||||
if (c == satisfy && level == 0 && quoted == 0 && commas > 0)
|
||||
{
|
||||
/* We ignore an open brace surrounded by whitespace, and also
|
||||
an open brace followed immediately by a close brace preceded
|
||||
|
@ -318,11 +560,7 @@ brace_gobbler (text, tlen, indx, satisfy)
|
|||
i++;
|
||||
continue;
|
||||
}
|
||||
#if defined (SHELL)
|
||||
/* If this is being compiled as part of bash, ignore the `{'
|
||||
in a `${}' construct */
|
||||
if ((c != '{') || i == 0 || (text[i - 1] != '$'))
|
||||
#endif /* SHELL */
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -330,6 +568,13 @@ brace_gobbler (text, tlen, indx, satisfy)
|
|||
level++;
|
||||
else if (c == '}' && level)
|
||||
level--;
|
||||
#if !defined (CSH_BRACE_COMPAT)
|
||||
else if (satisfy == '}' && c == brace_arg_separator && level == 0)
|
||||
commas++;
|
||||
else if (satisfy == '}' && STREQN (text+i, BRACE_SEQ_SPECIFIER, 2) &&
|
||||
text[i+2] != satisfy && level == 0)
|
||||
commas++;
|
||||
#endif
|
||||
|
||||
ADVANCE_CHAR (text, tlen, i);
|
||||
}
|
||||
|
@ -368,8 +613,7 @@ array_concat (arr1, arr2)
|
|||
|
||||
for (j = 0; j < len2; j++)
|
||||
{
|
||||
result[len] =
|
||||
(char *)xmalloc (1 + strlen_1 + strlen (arr2[j]));
|
||||
result[len] = (char *)xmalloc (1 + strlen_1 + strlen (arr2[j]));
|
||||
strcpy (result[len], arr1[i]);
|
||||
strcpy (result[len] + strlen_1, arr2[j]);
|
||||
len++;
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
/* builtins.h -- What a builtin looks like, and where to find them. */
|
||||
|
||||
/* Copyright (C) 1987,1991 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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. */
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
@ -35,11 +35,14 @@
|
|||
#endif
|
||||
|
||||
/* Flags describing various things about a builtin. */
|
||||
#define BUILTIN_ENABLED 0x1 /* This builtin is enabled. */
|
||||
#define BUILTIN_DELETED 0x2 /* This has been deleted with enable -d. */
|
||||
#define STATIC_BUILTIN 0x4 /* This builtin is not dynamically loaded. */
|
||||
#define SPECIAL_BUILTIN 0x8 /* This is a Posix `special' builtin. */
|
||||
#define BUILTIN_ENABLED 0x01 /* This builtin is enabled. */
|
||||
#define BUILTIN_DELETED 0x02 /* This has been deleted with enable -d. */
|
||||
#define STATIC_BUILTIN 0x04 /* This builtin is not dynamically loaded. */
|
||||
#define SPECIAL_BUILTIN 0x08 /* This is a Posix `special' builtin. */
|
||||
#define ASSIGNMENT_BUILTIN 0x10 /* This builtin takes assignment statements. */
|
||||
#define POSIX_BUILTIN 0x20 /* This builtins is special in the Posix command search order. */
|
||||
|
||||
#define BASE_INDENT 4
|
||||
|
||||
/* The thing that we build the array of builtins out of. */
|
||||
struct builtin {
|
||||
|
|
|
@ -1,20 +1,25 @@
|
|||
# This Makefile for building libbuiltins.a is in -*- text -*- for Emacs.
|
||||
#
|
||||
# Copyright (C) 1996 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1996-2009 Free Software Foundation, Inc.
|
||||
|
||||
# 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, or (at your option)
|
||||
# any later version.
|
||||
# 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 3 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.
|
||||
# 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, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
PACKAGE = @PACKAGE_NAME@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
PACKAGE_STRING = @PACKAGE_STRING@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
|
||||
#
|
||||
SHELL = @MAKE_SHELL@
|
||||
|
@ -33,8 +38,12 @@ prefix = @prefix@
|
|||
srcdir = @srcdir@
|
||||
VPATH = .:@srcdir@
|
||||
topdir = @top_srcdir@
|
||||
|
||||
datarootdir = @datarootdir@
|
||||
|
||||
includedir = @includedir@
|
||||
datadir = @datadir@
|
||||
localedir = @localedir@
|
||||
|
||||
# Support an alternate destination root directory for package building
|
||||
DESTDIR =
|
||||
|
@ -43,9 +52,11 @@ INSTALL = @INSTALL@
|
|||
INSTALL_DATA = @INSTALL_DATA@
|
||||
BUILD_DIR = @BUILD_DIR@
|
||||
|
||||
LIBBUILD = ${BUILD_DIR}/lib
|
||||
|
||||
PROFILE_FLAGS = @PROFILE_FLAGS@
|
||||
CFLAGS = @CFLAGS@
|
||||
CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@
|
||||
CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@ @CROSS_COMPILE@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CPPFLAGS_FOR_BUILD = @CPPFLAGS_FOR_BUILD@
|
||||
LOCAL_CFLAGS = @LOCAL_CFLAGS@ ${DEBUG}
|
||||
|
@ -54,7 +65,7 @@ LOCAL_DEFS = @LOCAL_DEFS@
|
|||
|
||||
LIBS = @LIBS@
|
||||
LDFLAGS = @LDFLAGS@ $(LOCAL_LDFLAGS) $(CFLAGS)
|
||||
LDFLAGS_FOR_BUILD = $(LDFLAGS)
|
||||
LDFLAGS_FOR_BUILD = @LDFLAGS_FOR_BUILD@ $(LOCAL_LDFLAGS) $(CFLAGS_FOR_BUILD)
|
||||
LOCAL_LDFLAGS = @LOCAL_LDFLAGS@
|
||||
#LIBS_FOR_BUILD = @LIBS_FOR_BUILD@
|
||||
LIBS_FOR_BUILD = $(LIBS)
|
||||
|
@ -63,10 +74,18 @@ BASHINCDIR = ${topdir}/include
|
|||
|
||||
RL_INCLUDEDIR = @RL_INCLUDEDIR@
|
||||
|
||||
INTL_LIBSRC = ${topdir}/lib/intl
|
||||
INTL_BUILDDIR = ${LIBBUILD}/intl
|
||||
INTL_LIBDIR = ${INTL_BUILDDIR}
|
||||
INTL_LIBRARY = ${INTL_BUILDDIR}/libintl.a
|
||||
INTL_INC = @INTL_INC@
|
||||
INTL_DEP = @INTL_DEP@
|
||||
LIBINTL_H = @LIBINTL_H@
|
||||
|
||||
HELPDIR = @HELPDIR@
|
||||
MKDIRS = ${topdir}/support/mkdirs
|
||||
|
||||
INCLUDES = -I. -I.. @RL_INCLUDE@ -I$(topdir) -I$(BASHINCDIR) -I$(topdir)/lib -I$(srcdir)
|
||||
INCLUDES = -I. -I.. @RL_INCLUDE@ -I$(topdir) -I$(BASHINCDIR) -I$(topdir)/lib -I$(srcdir) ${INTL_INC}
|
||||
|
||||
BASE_CCFLAGS = ${PROFILE_FLAGS} $(DEFS) $(LOCAL_DEFS) $(SYSTEM_FLAGS) \
|
||||
${INCLUDES} $(LOCAL_CFLAGS)
|
||||
|
@ -82,6 +101,7 @@ GCC_LINT_FLAGS = -Wall -Wshadow -Wpointer-arith -Wcast-qual \
|
|||
MKBUILTINS = mkbuiltins$(EXEEXT)
|
||||
DIRECTDEFINE = -D $(srcdir)
|
||||
HELPDIRDEFINE = @HELPDIRDEFINE@
|
||||
HELPSTRINGS = @HELPSTRINGS@
|
||||
|
||||
# xxx this is bad style
|
||||
RL_LIBSRC = $(topdir)/lib/readline
|
||||
|
@ -106,7 +126,8 @@ RL_LIBSRC = $(topdir)/lib/readline
|
|||
$(CC) -c $(CCFLAGS) $<
|
||||
|
||||
DEFSRC = $(srcdir)/alias.def $(srcdir)/bind.def $(srcdir)/break.def \
|
||||
$(srcdir)/builtin.def $(srcdir)/cd.def $(srcdir)/colon.def \
|
||||
$(srcdir)/builtin.def $(srcdir)/caller.def \
|
||||
$(srcdir)/cd.def $(srcdir)/colon.def \
|
||||
$(srcdir)/command.def $(srcdir)/declare.def $(srcdir)/echo.def \
|
||||
$(srcdir)/enable.def $(srcdir)/eval.def $(srcdir)/getopts.def \
|
||||
$(srcdir)/exec.def $(srcdir)/exit.def $(srcdir)/fc.def \
|
||||
|
@ -118,16 +139,16 @@ DEFSRC = $(srcdir)/alias.def $(srcdir)/bind.def $(srcdir)/break.def \
|
|||
$(srcdir)/times.def $(srcdir)/trap.def $(srcdir)/type.def \
|
||||
$(srcdir)/ulimit.def $(srcdir)/umask.def $(srcdir)/wait.def \
|
||||
$(srcdir)/reserved.def $(srcdir)/pushd.def $(srcdir)/shopt.def \
|
||||
$(srcdir)/printf.def $(srcdir)/complete.def
|
||||
$(srcdir)/printf.def $(srcdir)/complete.def $(srcdir)/mapfile.def
|
||||
|
||||
STATIC_SOURCE = common.c evalstring.c evalfile.c getopt.c bashgetopt.c \
|
||||
getopt.h
|
||||
|
||||
OFILES = builtins.o \
|
||||
alias.o bind.o break.o builtin.o cd.o colon.o command.o \
|
||||
alias.o bind.o break.o builtin.o caller.o cd.o colon.o command.o \
|
||||
common.o declare.o echo.o enable.o eval.o evalfile.o \
|
||||
evalstring.o exec.o \
|
||||
exit.o fc.o fg_bg.o hash.o help.o history.o jobs.o kill.o let.o \
|
||||
evalstring.o exec.o exit.o fc.o fg_bg.o hash.o help.o history.o \
|
||||
jobs.o kill.o let.o mapfile.o \
|
||||
pushd.o read.o return.o set.o setattr.o shift.o source.o \
|
||||
suspend.o test.o times.o trap.o type.o ulimit.o umask.o \
|
||||
wait.o getopts.o shopt.o printf.o getopt.o bashgetopt.o complete.o
|
||||
|
@ -145,7 +166,7 @@ builtext.h builtins.c: $(MKBUILTINS) $(DEFSRC)
|
|||
@-if test -f builtins.c; then mv -f builtins.c old-builtins.c; fi
|
||||
@-if test -f builtext.h; then mv -f builtext.h old-builtext.h; fi
|
||||
./$(MKBUILTINS) -externfile builtext.h -structfile builtins.c \
|
||||
-noproduction $(DIRECTDEFINE) $(HELPDIRDEFINE) $(DEFSRC)
|
||||
-noproduction $(DIRECTDEFINE) $(HELPDIRDEFINE) $(HELPSTRINGS) $(DEFSRC)
|
||||
@-if cmp -s old-builtext.h builtext.h 2>/dev/null; then \
|
||||
mv old-builtext.h builtext.h; \
|
||||
else \
|
||||
|
@ -162,9 +183,8 @@ helpdoc: $(MKBUILTINS) $(DEFSRC)
|
|||
|
||||
install-help:
|
||||
@-if test -n "${HELPDIR}" && test -d helpfiles ; then \
|
||||
test -d ${HELPDIR} || ${SHELL} ${MKDIRS} $(DESTDIR)$(HELPDIR) ;\
|
||||
( cd helpfiles ; \
|
||||
for f in *; do \
|
||||
test -d $(DESTDIR)${HELPDIR} || ${SHELL} ${MKDIRS} $(DESTDIR)$(HELPDIR) ;\
|
||||
( for f in helpfiles/*; do \
|
||||
echo installing $$f; \
|
||||
${INSTALL_DATA} $$f $(DESTDIR)$(HELPDIR); \
|
||||
done; ) ; \
|
||||
|
@ -214,10 +234,25 @@ distclean maintainer-clean: clean
|
|||
|
||||
$(OFILES): $(MKBUILTINS) ../config.h
|
||||
|
||||
../version.h: ../config.h ../Makefile Makefile
|
||||
-( cd ${BUILD_DIR} && ${MAKE} ${MFLAGS} version.h )
|
||||
|
||||
# maintainer special - for now
|
||||
po: builtins.c
|
||||
xgettext -L C -o $(topdir)/po/builtins.pot --keyword='N_' builtins.c 2>/dev/null
|
||||
|
||||
${LIBINTL_H}:
|
||||
@echo making $@ in ${INTL_BUILDDIR}
|
||||
@(cd ${INTL_BUILDDIR} && \
|
||||
$(MAKE) $(MFLAGS) libintl.h) || exit 1
|
||||
|
||||
# dependencies
|
||||
|
||||
alias.o: alias.def
|
||||
bind.o: bind.def
|
||||
break.o: break.def
|
||||
builtin.o: builtin.def
|
||||
caller.o: caller.def
|
||||
cd.o: cd.def
|
||||
colon.o: colon.def
|
||||
command.o: command.def
|
||||
|
@ -235,6 +270,7 @@ history.o: history.def
|
|||
jobs.o: jobs.def
|
||||
kill.o: kill.def
|
||||
let.o: let.def
|
||||
mapfile.o: mapfile.def
|
||||
printf.o: printf.def
|
||||
pushd.o: pushd.def
|
||||
read.o: read.def
|
||||
|
@ -263,7 +299,7 @@ bashgetopt.o: $(topdir)/command.h $(topdir)/general.h $(topdir)/xmalloc.h $(topd
|
|||
bashgetopt.o: $(topdir)/variables.h $(topdir)/conftypes.h $(topdir)/quit.h $(BASHINCDIR)/maxpath.h
|
||||
bashgetopt.o: $(topdir)/unwind_prot.h $(topdir)/dispose_cmd.h
|
||||
bashgetopt.o: $(topdir)/make_cmd.h $(topdir)/subst.h $(topdir)/sig.h
|
||||
bashgetopt.o: $(topdir)/pathnames.h $(topdir)/externs.h $(srcdir)/common.h
|
||||
bashgetopt.o: ../pathnames.h $(topdir)/externs.h $(srcdir)/common.h
|
||||
bashgetopt.o: $(BASHINCDIR)/chartypes.h
|
||||
common.o: $(topdir)/bashtypes.h $(BASHINCDIR)/posixstat.h $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h
|
||||
common.o: $(topdir)/shell.h $(topdir)/syntax.h ../config.h $(topdir)/bashjmp.h $(BASHINCDIR)/posixjmp.h
|
||||
|
@ -274,7 +310,7 @@ common.o: $(topdir)/siglist.h $(topdir)/bashhist.h $(topdir)/quit.h
|
|||
common.o: $(topdir)/unwind_prot.h $(BASHINCDIR)/maxpath.h $(topdir)/jobs.h
|
||||
common.o: $(topdir)/builtins.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
|
||||
common.o: $(topdir)/subst.h $(topdir)/execute_cmd.h $(topdir)/error.h
|
||||
common.o: $(topdir)/externs.h $(topdir)/pathnames.h ./builtext.h
|
||||
common.o: $(topdir)/externs.h ../pathnames.h ./builtext.h
|
||||
common.o: $(BASHINCDIR)/chartypes.h
|
||||
evalfile.o: $(topdir)/bashtypes.h $(BASHINCDIR)/posixstat.h ${BASHINCDIR}/filecntl.h
|
||||
evalfile.o: $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h
|
||||
|
@ -283,7 +319,7 @@ evalfile.o: $(topdir)/command.h $(topdir)/general.h $(topdir)/xmalloc.h $(topdir
|
|||
evalfile.o: $(topdir)/variables.h $(topdir)/conftypes.h $(topdir)/quit.h $(BASHINCDIR)/maxpath.h
|
||||
evalfile.o: $(topdir)/unwind_prot.h $(topdir)/dispose_cmd.h
|
||||
evalfile.o: $(topdir)/make_cmd.h $(topdir)/subst.h $(topdir)/sig.h
|
||||
evalfile.o: $(topdir)/pathnames.h $(topdir)/externs.h
|
||||
evalfile.o: ../pathnames.h $(topdir)/externs.h
|
||||
evalfile.o: $(topdir)/jobs.h $(topdir)/builtins.h $(topdir)/flags.h
|
||||
evalfile.o: $(topdir)/input.h $(topdir)/execute_cmd.h
|
||||
evalfile.o: $(topdir)/bashhist.h $(srcdir)/common.h
|
||||
|
@ -303,8 +339,8 @@ getopt.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/bashjmp.h $(topdir)/com
|
|||
getopt.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/error.h $(topdir)/variables.h $(topdir)/conftypes.h
|
||||
getopt.o: $(topdir)/quit.h $(BASHINCDIR)/maxpath.h $(topdir)/unwind_prot.h
|
||||
getopt.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
|
||||
getopt.o: $(topdir)/sig.h $(topdir)/pathnames.h $(topdir)/externs.h
|
||||
getopt.o: $(srcdir)/getopt.h
|
||||
getopt.o: $(topdir)/sig.h ../pathnames.h $(topdir)/externs.h
|
||||
getopt.o: $(srcdir)/getopt.h
|
||||
mkbuiltins.o: ../config.h $(topdir)/bashtypes.h $(BASHINCDIR)/posixstat.h
|
||||
mkbuiltins.o: ${BASHINCDIR}/filecntl.h
|
||||
mkbuiltins.o: $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h
|
||||
|
@ -331,6 +367,12 @@ builtin.o: $(topdir)/quit.h $(srcdir)/common.h $(BASHINCDIR)/maxpath.h
|
|||
builtin.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
|
||||
builtin.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
|
||||
builtin.o: $(srcdir)/bashgetopt.h
|
||||
caller.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
|
||||
caller.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/quit.h $(topdir)/dispose_cmd.h
|
||||
caller.o: $(topdir)/make_cmd.h $(topdir)/subst.h $(topdir)/externs.h
|
||||
caller.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
|
||||
caller.o: $(srcdir)/common.h $(BASHINCDIR)/maxpath.h ./builtext.h
|
||||
caller.o: ${BASHINCDIR}/chartypes.h $(topdir)/bashtypes.h
|
||||
cd.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
|
||||
cd.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/quit.h $(topdir)/dispose_cmd.h
|
||||
cd.o: $(topdir)/make_cmd.h $(topdir)/subst.h $(topdir)/externs.h
|
||||
|
@ -347,6 +389,7 @@ declare.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
|
|||
declare.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
|
||||
declare.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
|
||||
declare.o: $(topdir)/arrayfunc.h $(srcdir)/bashgetopt.h
|
||||
declare.o: ./builtext.h
|
||||
echo.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
|
||||
echo.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/subst.h $(topdir)/externs.h
|
||||
echo.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
|
||||
|
@ -362,7 +405,7 @@ enable.o: $(topdir)/pcomplete.h
|
|||
eval.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
|
||||
eval.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
|
||||
eval.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
|
||||
eval.o: $(topdir)/subst.h $(topdir)/externs.h
|
||||
eval.o: $(topdir)/subst.h $(topdir)/externs.h
|
||||
eval.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
|
||||
eval.o: $(BASHINCDIR)/maxpath.h
|
||||
exec.o: $(topdir)/bashtypes.h
|
||||
|
@ -372,12 +415,12 @@ exec.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
|
|||
exec.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/flags.h
|
||||
exec.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
|
||||
exec.o: $(srcdir)/common.h $(topdir)/execute_cmd.h $(BASHINCDIR)/maxpath.h
|
||||
exec.o: $(topdir)/findcmd.h
|
||||
exec.o: $(topdir)/findcmd.h $(topdir)/jobs.h
|
||||
exit.o: $(topdir)/bashtypes.h
|
||||
exit.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
|
||||
exit.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
|
||||
exit.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
|
||||
exit.o: $(topdir)/subst.h $(topdir)/externs.h
|
||||
exit.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/jobs.h
|
||||
exit.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
|
||||
exit.o: $(BASHINCDIR)/maxpath.h ./builtext.h
|
||||
fc.o: $(topdir)/bashtypes.h $(BASHINCDIR)/posixstat.h
|
||||
|
@ -395,6 +438,7 @@ fg_bg.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
|
|||
fg_bg.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
|
||||
fg_bg.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
|
||||
fg_bg.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
|
||||
fg_bg.o: $(topdir)/jobs.h
|
||||
getopts.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
|
||||
getopts.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
|
||||
getopts.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
|
||||
|
@ -416,7 +460,7 @@ history.o: $(topdir)/bashtypes.h
|
|||
history.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
|
||||
history.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
|
||||
history.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
|
||||
history.o: $(topdir)/subst.h $(topdir)/externs.h
|
||||
history.o: $(topdir)/subst.h $(topdir)/externs.h
|
||||
history.o: ${BASHINCDIR}/filecntl.h $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h
|
||||
history.o: $(topdir)/variables.h $(topdir)/conftypes.h $(topdir)/bashhist.h $(BASHINCDIR)/maxpath.h
|
||||
inlib.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
|
||||
|
@ -426,7 +470,7 @@ inlib.o: $(BASHINCDIR)/maxpath.h $(topdir)/subst.h $(topdir)/externs.h
|
|||
inlib.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
|
||||
jobs.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
|
||||
jobs.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/quit.h $(srcdir)/bashgetopt.h
|
||||
jobs.o: $(BASHINCDIR)/maxpath.h $(topdir)/externs.h
|
||||
jobs.o: $(BASHINCDIR)/maxpath.h $(topdir)/externs.h $(topdir)/jobs.h
|
||||
jobs.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
|
||||
jobs.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
|
||||
kill.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
|
||||
|
@ -434,6 +478,7 @@ kill.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/subst.h $(topdir)/exte
|
|||
kill.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
|
||||
kill.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/trap.h $(topdir)/unwind_prot.h
|
||||
kill.o: $(topdir)/variables.h $(topdir)/conftypes.h $(BASHINCDIR)/maxpath.h
|
||||
kill.o: $(topdir)/jobs.h
|
||||
let.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
|
||||
let.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
|
||||
let.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
|
||||
|
@ -443,13 +488,13 @@ printf.o: ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/bashjmp.h
|
|||
printf.o: $(topdir)/command.h $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
|
||||
printf.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
|
||||
printf.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/sig.h
|
||||
printf.o: $(topdir)/pathnames.h $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h
|
||||
printf.o: ../pathnames.h $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h
|
||||
printf.o: $(topdir)/variables.h $(topdir)/conftypes.h $(BASHINCDIR)/stdc.h $(srcdir)/bashgetopt.h
|
||||
printf.o: $(topdir)/bashtypes.h ${srcdir}/common.h $(BASHINCDIR)/chartypes.h
|
||||
pushd.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
|
||||
pushd.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
|
||||
pushd.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
|
||||
pushd.o: $(topdir)/subst.h $(topdir)/externs.h
|
||||
pushd.o: $(topdir)/subst.h $(topdir)/externs.h
|
||||
pushd.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
|
||||
pushd.o: $(BASHINCDIR)/maxpath.h $(srcdir)/common.h ./builtext.h
|
||||
read.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
|
||||
|
@ -474,7 +519,7 @@ setattr.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
|
|||
setattr.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h $(BASHINCDIR)/maxpath.h
|
||||
setattr.o: $(topdir)/quit.h $(srcdir)/common.h $(srcdir)/bashgetopt.h
|
||||
setattr.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
|
||||
setattr.o: $(topdir)/externs.h
|
||||
setattr.o: $(topdir)/externs.h
|
||||
setattr.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
|
||||
setattr.o: $(topdir)/arrayfunc.h
|
||||
shift.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
|
||||
|
@ -487,12 +532,13 @@ source.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/fi
|
|||
source.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
|
||||
source.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
|
||||
source.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
|
||||
source.o: $(srcdir)/bashgetopt.h
|
||||
source.o: $(srcdir)/bashgetopt.h $(topdir)/flags.h $(topdir)/trap.h
|
||||
suspend.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
|
||||
suspend.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
|
||||
suspend.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
|
||||
suspend.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
|
||||
suspend.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
|
||||
suspend.o: $(topdir)/jobs.h
|
||||
test.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
|
||||
test.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
|
||||
test.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
|
||||
|
@ -533,6 +579,7 @@ wait.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
|
|||
wait.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
|
||||
wait.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
|
||||
wait.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
|
||||
wait.o: $(topdir)/jobs.h
|
||||
wait.o: $(BASHINCDIR)/chartypes.h
|
||||
shopt.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
|
||||
shopt.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
|
||||
|
@ -541,12 +588,56 @@ shopt.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
|
|||
shopt.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
|
||||
shopt.o: $(srcdir)/common.h $(srcdir)/bashgetopt.h
|
||||
|
||||
complete.o: ../config.h
|
||||
complete.o: ../config.h
|
||||
complete.o: ${topdir}/shell.h $(topdir)/syntax.h ${topdir}/bashjmp.h ${BASHINCDIR}/posixjmp.h ${topdir}/sig.h
|
||||
complete.o: ${topdir}/unwind_prot.h ${topdir}/variables.h
|
||||
complete.o: ${topdir}/bashtypes.h ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
|
||||
complete.o: ${topdir}/builtins.h
|
||||
complete.o: ${topdir}/pcomplete.h
|
||||
complete.o: ${srcdir}/common.h ${srcdir}/bashgetopt.h
|
||||
mapfile.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
|
||||
mapfile.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
|
||||
mapfile.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
|
||||
mapfile.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
|
||||
mapfile.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/variables.h $(topdir)/conftypes.h
|
||||
mapfile.o: $(topdir)/arrayfunc.h
|
||||
|
||||
#bind.o: $(RL_LIBSRC)chardefs.h $(RL_LIBSRC)readline.h $(RL_LIBSRC)keymaps.h
|
||||
|
||||
# libintl dependencies
|
||||
bind.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
|
||||
break.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
|
||||
caller.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
|
||||
cd.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
|
||||
common.c: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
|
||||
complete.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
|
||||
declare.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
|
||||
enable.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
|
||||
evalfile.c: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
|
||||
exec.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
|
||||
exit.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
|
||||
fc.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
|
||||
fg_bg.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
|
||||
getopt.c: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
|
||||
hash.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
|
||||
help.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
|
||||
history.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
|
||||
inlib.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
|
||||
jobs.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
|
||||
kill.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
|
||||
let.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
|
||||
mapfile.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
|
||||
mkbuiltins.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
|
||||
printf.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
|
||||
pushd.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
|
||||
read.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
|
||||
return.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
|
||||
set.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
|
||||
setattr.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
|
||||
shift.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
|
||||
shopt.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
|
||||
source.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
|
||||
suspend.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
|
||||
type.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
|
||||
ulimit.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
|
||||
umask.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
|
||||
|
|
|
@ -1,35 +1,43 @@
|
|||
This file is alias.def, from which is created alias.c
|
||||
It implements the builtins "alias" and "unalias" in Bash.
|
||||
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$BUILTIN alias
|
||||
$FUNCTION alias_builtin
|
||||
$DEPENDS_ON ALIAS
|
||||
$PRODUCES alias.c
|
||||
$SHORT_DOC alias [-p] [name[=value] ... ]
|
||||
`alias' with no arguments or with the -p option prints the list
|
||||
of aliases in the form alias NAME=VALUE on standard output.
|
||||
Define or display aliases.
|
||||
|
||||
Without arguments, `alias' prints the list of aliases in the reusable
|
||||
form `alias NAME=VALUE' on standard output.
|
||||
|
||||
Otherwise, an alias is defined for each NAME whose VALUE is given.
|
||||
A trailing space in VALUE causes the next word to be checked for
|
||||
alias substitution when the alias is expanded. Alias returns
|
||||
true unless a NAME is given for which no alias has been defined.
|
||||
alias substitution when the alias is expanded.
|
||||
|
||||
Options:
|
||||
-p Print all defined aliases in a reusable format
|
||||
|
||||
Exit Status:
|
||||
alias returns true unless a NAME is supplied for which no alias has been
|
||||
defined.
|
||||
$END
|
||||
|
||||
#include <config.h>
|
||||
|
@ -44,6 +52,7 @@ $END
|
|||
#endif
|
||||
|
||||
# include "../bashansi.h"
|
||||
# include "../bashintl.h"
|
||||
|
||||
# include <stdio.h>
|
||||
# include "../shell.h"
|
||||
|
@ -51,17 +60,23 @@ $END
|
|||
# include "common.h"
|
||||
# include "bashgetopt.h"
|
||||
|
||||
static void print_alias __P((alias_t *));
|
||||
/* Flags for print_alias */
|
||||
#define AL_REUSABLE 0x01
|
||||
|
||||
static void print_alias __P((alias_t *, int));
|
||||
|
||||
extern int posixly_correct;
|
||||
|
||||
/* Hack the alias command in a Korn shell way. */
|
||||
int
|
||||
alias_builtin (list)
|
||||
WORD_LIST *list;
|
||||
{
|
||||
int any_failed, offset, pflag;
|
||||
int any_failed, offset, pflag, dflags;
|
||||
alias_t **alias_list, *t;
|
||||
char *name, *value;
|
||||
|
||||
dflags = posixly_correct ? 0 : AL_REUSABLE;
|
||||
pflag = 0;
|
||||
reset_internal_getopt ();
|
||||
while ((offset = internal_getopt (list, "p")) != -1)
|
||||
|
@ -70,6 +85,7 @@ alias_builtin (list)
|
|||
{
|
||||
case 'p':
|
||||
pflag = 1;
|
||||
dflags |= AL_REUSABLE;
|
||||
break;
|
||||
default:
|
||||
builtin_usage ();
|
||||
|
@ -90,12 +106,12 @@ alias_builtin (list)
|
|||
return (EXECUTION_SUCCESS);
|
||||
|
||||
for (offset = 0; alias_list[offset]; offset++)
|
||||
print_alias (alias_list[offset]);
|
||||
print_alias (alias_list[offset], dflags);
|
||||
|
||||
free (alias_list); /* XXX - Do not free the strings. */
|
||||
|
||||
if (list == 0)
|
||||
return (EXECUTION_SUCCESS);
|
||||
return (sh_chkwrite (EXECUTION_SUCCESS));
|
||||
}
|
||||
|
||||
any_failed = 0;
|
||||
|
@ -111,13 +127,19 @@ alias_builtin (list)
|
|||
name[offset] = '\0';
|
||||
value = name + offset + 1;
|
||||
|
||||
add_alias (name, value);
|
||||
if (legal_alias_name (name, 0) == 0)
|
||||
{
|
||||
builtin_error (_("`%s': invalid alias name"), name);
|
||||
any_failed++;
|
||||
}
|
||||
else
|
||||
add_alias (name, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
t = find_alias (name);
|
||||
if (t)
|
||||
print_alias (t);
|
||||
print_alias (t, dflags);
|
||||
else
|
||||
{
|
||||
sh_notfound (name);
|
||||
|
@ -134,9 +156,13 @@ alias_builtin (list)
|
|||
$BUILTIN unalias
|
||||
$FUNCTION unalias_builtin
|
||||
$DEPENDS_ON ALIAS
|
||||
$SHORT_DOC unalias [-a] [name ...]
|
||||
Remove NAMEs from the list of defined aliases. If the -a option is given,
|
||||
then remove all alias definitions.
|
||||
$SHORT_DOC unalias [-a] name [name ...]
|
||||
Remove each NAME from the list of defined aliases.
|
||||
|
||||
Options:
|
||||
-a remove all alias definitions.
|
||||
|
||||
Return success unless a NAME is not an existing alias.
|
||||
$END
|
||||
|
||||
#if defined (ALIAS)
|
||||
|
@ -171,6 +197,12 @@ unalias_builtin (list)
|
|||
return (EXECUTION_SUCCESS);
|
||||
}
|
||||
|
||||
if (list == 0)
|
||||
{
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
}
|
||||
|
||||
aflag = 0;
|
||||
while (list)
|
||||
{
|
||||
|
@ -192,13 +224,16 @@ unalias_builtin (list)
|
|||
|
||||
/* Output ALIAS in such a way as to allow it to be read back in. */
|
||||
static void
|
||||
print_alias (alias)
|
||||
print_alias (alias, flags)
|
||||
alias_t *alias;
|
||||
int flags;
|
||||
{
|
||||
char *value;
|
||||
|
||||
value = sh_single_quote (alias->value);
|
||||
printf ("alias %s=%s\n", alias->name, value);
|
||||
if (flags & AL_REUSABLE)
|
||||
printf ("alias ");
|
||||
printf ("%s=%s\n", alias->name, value);
|
||||
free (value);
|
||||
|
||||
fflush (stdout);
|
||||
|
|
|
@ -2,21 +2,21 @@
|
|||
|
||||
/* Copyright (C) 1992-2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
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 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 3 of the License, 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.
|
||||
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. */
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
|
|
@ -4,19 +4,19 @@
|
|||
|
||||
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 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 3 of the License, 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.
|
||||
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. */
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* See getopt.h for the explanation of these variables. */
|
||||
|
||||
|
|
|
@ -1,23 +1,22 @@
|
|||
This file is bind.def, from which is created bind.c.
|
||||
It implements the builtin "bind" in Bash.
|
||||
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES bind.c
|
||||
|
||||
|
@ -27,12 +26,15 @@ $BUILTIN bind
|
|||
$DEPENDS_ON READLINE
|
||||
$FUNCTION bind_builtin
|
||||
$SHORT_DOC bind [-lpvsPVS] [-m keymap] [-f filename] [-q name] [-u name] [-r keyseq] [-x keyseq:shell-command] [keyseq:readline-function or readline-command]
|
||||
Bind a key sequence to a Readline function or a macro, or set
|
||||
a Readline variable. The non-option argument syntax is equivalent
|
||||
to that found in ~/.inputrc, but must be passed as a single argument:
|
||||
bind '"\C-x\C-r": re-read-init-file'.
|
||||
bind accepts the following options:
|
||||
-m keymap Use `keymap' as the keymap for the duration of this
|
||||
Set Readline key bindings and variables.
|
||||
|
||||
Bind a key sequence to a Readline function or a macro, or set a
|
||||
Readline variable. The non-option argument syntax is equivalent to
|
||||
that found in ~/.inputrc, but must be passed as a single argument:
|
||||
e.g., bind '"\C-x\C-r": re-read-init-file'.
|
||||
|
||||
Options:
|
||||
-m keymap Use KEYMAP as the keymap for the duration of this
|
||||
command. Acceptable keymap names are emacs,
|
||||
emacs-standard, emacs-meta, emacs-ctlx, vi, vi-move,
|
||||
vi-command, and vi-insert.
|
||||
|
@ -40,18 +42,21 @@ bind accepts the following options:
|
|||
-P List function names and bindings.
|
||||
-p List functions and bindings in a form that can be
|
||||
reused as input.
|
||||
-r keyseq Remove the binding for KEYSEQ.
|
||||
-x keyseq:shell-command Cause SHELL-COMMAND to be executed when
|
||||
KEYSEQ is entered.
|
||||
-f filename Read key bindings from FILENAME.
|
||||
-q function-name Query about which keys invoke the named function.
|
||||
-u function-name Unbind all keys which are bound to the named function.
|
||||
-V List variable names and values
|
||||
-v List variable names and values in a form that can
|
||||
be reused as input.
|
||||
-S List key sequences that invoke macros and their values
|
||||
-s List key sequences that invoke macros and their values
|
||||
in a form that can be reused as input.
|
||||
-V List variable names and values
|
||||
-v List variable names and values in a form that can
|
||||
be reused as input.
|
||||
-q function-name Query about which keys invoke the named function.
|
||||
-u function-name Unbind all keys which are bound to the named function.
|
||||
-r keyseq Remove the binding for KEYSEQ.
|
||||
-f filename Read key bindings from FILENAME.
|
||||
-x keyseq:shell-command Cause SHELL-COMMAND to be executed when
|
||||
KEYSEQ is entered.
|
||||
|
||||
Exit Status:
|
||||
bind returns 0 unless an unrecognized option is given or an error occurs.
|
||||
$END
|
||||
|
||||
#if defined (READLINE)
|
||||
|
@ -72,6 +77,8 @@ extern int errno;
|
|||
#include <readline/readline.h>
|
||||
#include <readline/history.h>
|
||||
|
||||
#include "../bashintl.h"
|
||||
|
||||
#include "../shell.h"
|
||||
#include "../bashline.h"
|
||||
#include "bashgetopt.h"
|
||||
|
@ -108,14 +115,21 @@ bind_builtin (list)
|
|||
char *initfile, *map_name, *fun_name, *unbind_name, *remove_seq, *cmd_seq;
|
||||
|
||||
if (no_line_editing)
|
||||
return (EXECUTION_FAILURE);
|
||||
{
|
||||
#if 0
|
||||
builtin_error (_("line editing not enabled"));
|
||||
return (EXECUTION_FAILURE);
|
||||
#else
|
||||
builtin_warning (_("line editing not enabled"));
|
||||
#endif
|
||||
}
|
||||
|
||||
kmap = saved_keymap = (Keymap) NULL;
|
||||
flags = 0;
|
||||
initfile = map_name = fun_name = unbind_name = remove_seq = (char *)NULL;
|
||||
return_code = EXECUTION_SUCCESS;
|
||||
|
||||
if (!bash_readline_initialized)
|
||||
if (bash_readline_initialized == 0)
|
||||
initialize_readline ();
|
||||
|
||||
begin_unwind_frame ("bind_builtin");
|
||||
|
@ -189,7 +203,7 @@ bind_builtin (list)
|
|||
kmap = rl_get_keymap_by_name (map_name);
|
||||
if (!kmap)
|
||||
{
|
||||
builtin_error ("`%s': invalid keymap name", map_name);
|
||||
builtin_error (_("`%s': invalid keymap name"), map_name);
|
||||
BIND_RETURN (EXECUTION_FAILURE);
|
||||
}
|
||||
}
|
||||
|
@ -228,7 +242,7 @@ bind_builtin (list)
|
|||
{
|
||||
if (rl_read_init_file (initfile) != 0)
|
||||
{
|
||||
builtin_error ("%s: cannot read: %s", initfile, strerror (errno));
|
||||
builtin_error (_("%s: cannot read: %s"), initfile, strerror (errno));
|
||||
BIND_RETURN (EXECUTION_FAILURE);
|
||||
}
|
||||
}
|
||||
|
@ -243,7 +257,7 @@ bind_builtin (list)
|
|||
{
|
||||
if (rl_set_key (remove_seq, (rl_command_func_t *)NULL, rl_get_keymap ()) != 0)
|
||||
{
|
||||
builtin_error ("`%s': cannot unbind", remove_seq);
|
||||
builtin_error (_("`%s': cannot unbind"), remove_seq);
|
||||
BIND_RETURN (EXECUTION_FAILURE);
|
||||
}
|
||||
}
|
||||
|
@ -264,7 +278,7 @@ bind_builtin (list)
|
|||
|
||||
run_unwind_frame ("bind_builtin");
|
||||
|
||||
return (return_code);
|
||||
return (sh_chkwrite (return_code));
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -278,7 +292,7 @@ query_bindings (name)
|
|||
function = rl_named_function (name);
|
||||
if (function == 0)
|
||||
{
|
||||
builtin_error ("`%s': unknown function name", name);
|
||||
builtin_error (_("`%s': unknown function name"), name);
|
||||
return EXECUTION_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -286,11 +300,11 @@ query_bindings (name)
|
|||
|
||||
if (!keyseqs)
|
||||
{
|
||||
printf ("%s is not bound to any keys.\n", name);
|
||||
printf (_("%s is not bound to any keys.\n"), name);
|
||||
return EXECUTION_FAILURE;
|
||||
}
|
||||
|
||||
printf ("%s can be invoked via ", name);
|
||||
printf (_("%s can be invoked via "), name);
|
||||
for (j = 0; j < 5 && keyseqs[j]; j++)
|
||||
printf ("\"%s\"%s", keyseqs[j], keyseqs[j + 1] ? ", " : ".\n");
|
||||
if (keyseqs[j])
|
||||
|
@ -308,7 +322,7 @@ unbind_command (name)
|
|||
function = rl_named_function (name);
|
||||
if (function == 0)
|
||||
{
|
||||
builtin_error ("`%s': unknown function name", name);
|
||||
builtin_error (_("`%s': unknown function name"), name);
|
||||
return EXECUTION_FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,31 +1,35 @@
|
|||
This file is break.def, from which is created break.c.
|
||||
It implements the builtins "break" and "continue" in Bash.
|
||||
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES break.c
|
||||
|
||||
$BUILTIN break
|
||||
$FUNCTION break_builtin
|
||||
$SHORT_DOC break [n]
|
||||
Exit from within a FOR, WHILE or UNTIL loop. If N is specified,
|
||||
break N levels.
|
||||
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>
|
||||
|
||||
|
@ -36,6 +40,8 @@ $END
|
|||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "../bashintl.h"
|
||||
|
||||
#include "../shell.h"
|
||||
#include "common.h"
|
||||
|
||||
|
@ -64,11 +70,11 @@ break_builtin (list)
|
|||
if (check_loop_level () == 0)
|
||||
return (EXECUTION_SUCCESS);
|
||||
|
||||
newbreak = get_numeric_arg (list, 1);
|
||||
(void)get_numeric_arg (list, 1, &newbreak);
|
||||
|
||||
if (newbreak <= 0)
|
||||
{
|
||||
sh_erange (list->word->word, "loop count");
|
||||
sh_erange (list->word->word, _("loop count"));
|
||||
breaking = loop_level;
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
@ -84,8 +90,13 @@ break_builtin (list)
|
|||
$BUILTIN continue
|
||||
$FUNCTION continue_builtin
|
||||
$SHORT_DOC continue [n]
|
||||
Resume the next iteration of the enclosing FOR, WHILE or UNTIL loop.
|
||||
If N is specified, resume at the N-th enclosing loop.
|
||||
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 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
|
||||
|
@ -99,11 +110,11 @@ continue_builtin (list)
|
|||
if (check_loop_level () == 0)
|
||||
return (EXECUTION_SUCCESS);
|
||||
|
||||
newcont = get_numeric_arg (list, 1);
|
||||
(void)get_numeric_arg (list, 1, &newcont);
|
||||
|
||||
if (newcont <= 0)
|
||||
{
|
||||
sh_erange (list->word->word, "loop count");
|
||||
sh_erange (list->word->word, _("loop count"));
|
||||
breaking = loop_level;
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
@ -123,7 +134,7 @@ check_loop_level ()
|
|||
{
|
||||
#if defined (BREAK_COMPLAINS)
|
||||
if (loop_level == 0 && posixly_correct == 0)
|
||||
builtin_error ("only meaningful in a `for', `while', or `until' loop");
|
||||
builtin_error (_("only meaningful in a `for', `while', or `until' loop"));
|
||||
#endif /* BREAK_COMPLAINS */
|
||||
|
||||
return (loop_level);
|
||||
|
|
|
@ -1,32 +1,37 @@
|
|||
This file is builtin.def, from which is created builtin.c.
|
||||
It implements the builtin "builtin" in Bash.
|
||||
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES builtin.c
|
||||
|
||||
$BUILTIN builtin
|
||||
$FUNCTION builtin_builtin
|
||||
$SHORT_DOC builtin [shell-builtin [arg ...]]
|
||||
Run a shell builtin. This is useful when you wish to rename a
|
||||
shell builtin to be a function, but need the functionality of the
|
||||
builtin within the function itself.
|
||||
Execute shell builtins.
|
||||
|
||||
Execute SHELL-BUILTIN with arguments ARGs without performing command
|
||||
lookup. This is useful when you wish to reimplement a shell builtin
|
||||
as a shell function, but need to execute the builtin within the function.
|
||||
|
||||
Exit Status:
|
||||
Returns the exit status of SHELL-BUILTIN, or false if SHELL-BUILTIN is
|
||||
not a shell builtin..
|
||||
$END
|
||||
#include <config.h>
|
||||
|
||||
|
@ -68,7 +73,7 @@ builtin_builtin (list)
|
|||
|
||||
if (!function)
|
||||
{
|
||||
builtin_error ("%s: not a shell builtin", command);
|
||||
sh_notbuiltin (command);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -0,0 +1,153 @@
|
|||
This file is caller.def, from which is created caller.c. It implements the
|
||||
builtin "caller" in Bash.
|
||||
|
||||
Copyright (C) 2002-2008 Rocky Bernstein for 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 3 of the License, 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. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES caller.c
|
||||
|
||||
$BUILTIN caller
|
||||
$FUNCTION caller_builtin
|
||||
$DEPENDS_ON DEBUGGER
|
||||
$SHORT_DOC caller [expr]
|
||||
Return the context of the current subroutine call.
|
||||
|
||||
Without EXPR, returns "$line $filename". With EXPR, returns
|
||||
"$line $subroutine $filename"; this extra information can be used to
|
||||
provide a stack trace.
|
||||
|
||||
The value of EXPR indicates how many call frames to go back before the
|
||||
current one; the top frame is frame 0.
|
||||
|
||||
Exit Status:
|
||||
Returns 0 unless the shell is not executing a shell function or EXPR
|
||||
is invalid.
|
||||
$END
|
||||
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
#include "chartypes.h"
|
||||
#include "bashtypes.h"
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# ifdef _MINIX
|
||||
# include <sys/types.h>
|
||||
# endif
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include "../bashintl.h"
|
||||
|
||||
#include "../shell.h"
|
||||
#include "common.h"
|
||||
#include "builtext.h"
|
||||
#include "bashgetopt.h"
|
||||
|
||||
#ifdef LOADABLE_BUILTIN
|
||||
# include "builtins.h"
|
||||
#endif
|
||||
|
||||
#if !defined (errno)
|
||||
extern int errno;
|
||||
#endif /* !errno */
|
||||
|
||||
int
|
||||
caller_builtin (list)
|
||||
WORD_LIST *list;
|
||||
{
|
||||
#if !defined (ARRAY_VARS)
|
||||
printf ("1 NULL\n");
|
||||
return (EXECUTION_FAILURE);
|
||||
#else
|
||||
SHELL_VAR *funcname_v, *bash_source_v, *bash_lineno_v;
|
||||
ARRAY *funcname_a, *bash_source_a, *bash_lineno_a;
|
||||
char *funcname_s, *source_s, *lineno_s;
|
||||
intmax_t num;
|
||||
|
||||
GET_ARRAY_FROM_VAR ("FUNCNAME", funcname_v, funcname_a);
|
||||
GET_ARRAY_FROM_VAR ("BASH_SOURCE", bash_source_v, bash_source_a);
|
||||
GET_ARRAY_FROM_VAR ("BASH_LINENO", bash_lineno_v, bash_lineno_a);
|
||||
|
||||
if (bash_lineno_a == 0 || array_empty (bash_lineno_a))
|
||||
return (EXECUTION_FAILURE);
|
||||
|
||||
if (bash_source_a == 0 || array_empty (bash_source_a))
|
||||
return (EXECUTION_FAILURE);
|
||||
|
||||
if (no_options (list))
|
||||
return (EX_USAGE);
|
||||
list = loptend; /* skip over possible `--' */
|
||||
|
||||
/* If there is no argument list, then give short form: line filename. */
|
||||
if (list == 0)
|
||||
{
|
||||
lineno_s = array_reference (bash_lineno_a, 0);
|
||||
source_s = array_reference (bash_source_a, 1);
|
||||
printf("%s %s\n", lineno_s ? lineno_s : "NULL", source_s ? source_s : "NULL");
|
||||
return (EXECUTION_SUCCESS);
|
||||
}
|
||||
|
||||
if (funcname_a == 0 || array_empty (funcname_a))
|
||||
return (EXECUTION_FAILURE);
|
||||
|
||||
if (legal_number (list->word->word, &num))
|
||||
{
|
||||
lineno_s = array_reference (bash_lineno_a, num);
|
||||
source_s = array_reference (bash_source_a, num+1);
|
||||
funcname_s = array_reference (funcname_a, num+1);
|
||||
|
||||
if (lineno_s == NULL|| source_s == NULL || funcname_s == NULL)
|
||||
return (EXECUTION_FAILURE);
|
||||
|
||||
printf("%s %s %s\n", lineno_s, funcname_s, source_s);
|
||||
}
|
||||
else
|
||||
{
|
||||
sh_invalidnum (list->word->word);
|
||||
builtin_usage ();
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
return (EXECUTION_SUCCESS);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef LOADABLE_BUILTIN
|
||||
static char *caller_doc[] = {
|
||||
N_("Returns the context of the current subroutine call.\n\
|
||||
\n\
|
||||
Without EXPR, returns "$line $filename". With EXPR, returns\n\
|
||||
"$line $subroutine $filename"; this extra information can be used to\n\
|
||||
provide a stack trace.\n\
|
||||
\n\
|
||||
The value of EXPR indicates how many call frames to go back before the\n\
|
||||
current one; the top frame is frame 0."),
|
||||
(char *)NULL
|
||||
};
|
||||
|
||||
struct builtin caller_struct = {
|
||||
"caller",
|
||||
caller_builtin,
|
||||
BUILTIN_ENABLED,
|
||||
caller_doc,
|
||||
"caller [EXPR]",
|
||||
0
|
||||
};
|
||||
|
||||
#endif /* LOADABLE_BUILTIN */
|
|
@ -1,23 +1,22 @@
|
|||
This file is cd.def, from which is created cd.c. It implements the
|
||||
builtins "cd" and "pwd" in Bash.
|
||||
|
||||
Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES cd.c
|
||||
#include <config.h>
|
||||
|
@ -39,6 +38,7 @@ $PRODUCES cd.c
|
|||
#include <stdio.h>
|
||||
|
||||
#include "../bashansi.h"
|
||||
#include "../bashintl.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <tilde/tilde.h>
|
||||
|
@ -55,13 +55,13 @@ extern int errno;
|
|||
|
||||
extern int posixly_correct;
|
||||
extern int array_needs_making;
|
||||
extern char *bash_getcwd_errstr;
|
||||
extern const char * const bash_getcwd_errstr;
|
||||
|
||||
static int bindpwd __P((int));
|
||||
static void setpwd __P((char *));
|
||||
static char *resetpwd __P((char *));
|
||||
static int change_to_directory __P((char *, int));
|
||||
|
||||
static char *cdspell __P((char *));
|
||||
|
||||
/* Change this to 1 to get cd spelling correction by default. */
|
||||
int cdspelling = 0;
|
||||
|
||||
|
@ -70,27 +70,58 @@ int cdable_vars;
|
|||
$BUILTIN cd
|
||||
$FUNCTION cd_builtin
|
||||
$SHORT_DOC cd [-L|-P] [dir]
|
||||
Change the current directory to DIR. The variable $HOME is the
|
||||
default DIR. The variable CDPATH defines the search path for
|
||||
the directory containing DIR. Alternative directory names in CDPATH
|
||||
are separated by a colon (:). A null directory name is the same as
|
||||
the current directory, i.e. `.'. If DIR begins with a slash (/),
|
||||
then CDPATH is not used. If the directory is not found, and the
|
||||
shell option `cdable_vars' is set, then try the word as a variable
|
||||
name. If that variable has a value, then cd to the value of that
|
||||
variable. The -P option says to use the physical directory structure
|
||||
instead of following symbolic links; the -L option forces symbolic links
|
||||
to be followed.
|
||||
Change the shell working directory.
|
||||
|
||||
Change the current directory to DIR. The default DIR is the value of the
|
||||
HOME shell variable.
|
||||
|
||||
The variable CDPATH defines the search path for the directory containing
|
||||
DIR. Alternative directory names in CDPATH are separated by a colon (:).
|
||||
A null directory name is the same as the current directory. If DIR begins
|
||||
with a slash (/), then CDPATH is not used.
|
||||
|
||||
If the directory is not found, and the shell option `cdable_vars' is set,
|
||||
the word is assumed to be a variable name. If that variable has a value,
|
||||
its value is used for DIR.
|
||||
|
||||
Options:
|
||||
-L force symbolic links to be followed
|
||||
-P use the physical directory structure without following symbolic
|
||||
links
|
||||
|
||||
The default is to follow symbolic links, as if `-L' were specified.
|
||||
|
||||
Exit Status:
|
||||
Returns 0 if the directory is changed; non-zero otherwise.
|
||||
$END
|
||||
|
||||
/* Just set $PWD, don't change OLDPWD. Used by `pwd -P' in posix mode. */
|
||||
static void
|
||||
setpwd (dirname)
|
||||
char *dirname;
|
||||
{
|
||||
int old_anm;
|
||||
SHELL_VAR *tvar;
|
||||
|
||||
old_anm = array_needs_making;
|
||||
tvar = bind_variable ("PWD", dirname ? dirname : "", 0);
|
||||
if (old_anm == 0 && array_needs_making && exported_p (tvar))
|
||||
{
|
||||
update_export_env_inplace ("PWD=", 4, dirname ? dirname : "");
|
||||
array_needs_making = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
bindpwd (no_symlinks)
|
||||
int no_symlinks;
|
||||
{
|
||||
char *dirname, *pwdvar;
|
||||
int old_anm;
|
||||
int old_anm, r;
|
||||
SHELL_VAR *tvar;
|
||||
|
||||
r = sh_chkwrite (EXECUTION_SUCCESS);
|
||||
|
||||
#define tcwd the_current_working_directory
|
||||
dirname = tcwd ? (no_symlinks ? sh_physpath (tcwd, 0) : tcwd)
|
||||
: get_working_directory ("cd");
|
||||
|
@ -99,35 +130,32 @@ bindpwd (no_symlinks)
|
|||
old_anm = array_needs_making;
|
||||
pwdvar = get_string_value ("PWD");
|
||||
|
||||
tvar = bind_variable ("OLDPWD", pwdvar);
|
||||
tvar = bind_variable ("OLDPWD", pwdvar, 0);
|
||||
if (old_anm == 0 && array_needs_making && exported_p (tvar))
|
||||
{
|
||||
update_export_env_inplace ("OLDPWD=", 7, pwdvar);
|
||||
array_needs_making = 0;
|
||||
}
|
||||
|
||||
tvar = bind_variable ("PWD", dirname);
|
||||
if (old_anm == 0 && array_needs_making && exported_p (tvar))
|
||||
{
|
||||
update_export_env_inplace ("PWD=", 4, dirname);
|
||||
array_needs_making = 0;
|
||||
}
|
||||
setpwd (dirname);
|
||||
|
||||
if (dirname && dirname != the_current_working_directory)
|
||||
free (dirname);
|
||||
return (EXECUTION_SUCCESS);
|
||||
|
||||
return (r);
|
||||
}
|
||||
|
||||
/* Call get_working_directory to reset the value of
|
||||
the_current_working_directory () */
|
||||
static char *
|
||||
resetpwd ()
|
||||
resetpwd (caller)
|
||||
char *caller;
|
||||
{
|
||||
char *tdir;
|
||||
|
||||
FREE (the_current_working_directory);
|
||||
the_current_working_directory = (char *)NULL;
|
||||
tdir = get_working_directory ("cd");
|
||||
tdir = get_working_directory (caller);
|
||||
return (tdir);
|
||||
}
|
||||
|
||||
|
@ -184,7 +212,7 @@ cd_builtin (list)
|
|||
|
||||
if (dirname == 0)
|
||||
{
|
||||
builtin_error ("HOME not set");
|
||||
builtin_error (_("HOME not set"));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
lflag = 0;
|
||||
|
@ -196,14 +224,18 @@ cd_builtin (list)
|
|||
|
||||
if (dirname == 0)
|
||||
{
|
||||
builtin_error ("OLDPWD not set");
|
||||
builtin_error (_("OLDPWD not set"));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
#if 0
|
||||
lflag = interactive ? LCD_PRINTPATH : 0;
|
||||
#else
|
||||
lflag = LCD_PRINTPATH; /* According to SUSv3 */
|
||||
#endif
|
||||
}
|
||||
else if (absolute_pathname (list->word->word))
|
||||
dirname = list->word->word;
|
||||
else if (cdpath = get_string_value ("CDPATH"))
|
||||
else if (privileged_mode == 0 && (cdpath = get_string_value ("CDPATH")))
|
||||
{
|
||||
dirname = list->word->word;
|
||||
|
||||
|
@ -222,13 +254,17 @@ cd_builtin (list)
|
|||
is used to find the directory to change to, the new
|
||||
directory name is echoed to stdout, whether or not
|
||||
the shell is interactive. */
|
||||
if (opt)
|
||||
printf ("%s\n", no_symlinks ? temp : the_current_working_directory);
|
||||
if (opt && (path = no_symlinks ? temp : the_current_working_directory))
|
||||
printf ("%s\n", path);
|
||||
|
||||
free (temp);
|
||||
#if 0
|
||||
/* Posix.2 says that after using CDPATH, the resultant
|
||||
value of $PWD will not contain `.' or `..'. */
|
||||
return (bindpwd (posixly_correct || no_symlinks));
|
||||
#else
|
||||
return (bindpwd (no_symlinks));
|
||||
#endif
|
||||
}
|
||||
else
|
||||
free (temp);
|
||||
|
@ -275,7 +311,7 @@ cd_builtin (list)
|
|||
typo. This is similar to the UNIX 8th and 9th Edition shells. */
|
||||
if (lflag & LCD_DOSPELL)
|
||||
{
|
||||
temp = cdspell (dirname);
|
||||
temp = dirspell (dirname);
|
||||
if (temp && change_to_directory (temp, no_symlinks))
|
||||
{
|
||||
printf ("%s\n", temp);
|
||||
|
@ -291,10 +327,19 @@ cd_builtin (list)
|
|||
|
||||
$BUILTIN pwd
|
||||
$FUNCTION pwd_builtin
|
||||
$SHORT_DOC pwd [-PL]
|
||||
Print the current working directory. With the -P option, pwd prints
|
||||
the physical directory, without any symbolic links; the -L option
|
||||
makes pwd follow symbolic links.
|
||||
$SHORT_DOC pwd [-LP]
|
||||
Print the name of the current working directory.
|
||||
|
||||
Options:
|
||||
-L print the value of $PWD if it names the current working
|
||||
directory
|
||||
-P print the physical directory, without any symbolic links
|
||||
|
||||
By default, `pwd' behaves as if `-L' were specified.
|
||||
|
||||
Exit Status:
|
||||
Returns 0 unless an invalid option is given or the current directory
|
||||
cannot be read.
|
||||
$END
|
||||
|
||||
/* Non-zero means that pwd always prints the physical directory, without
|
||||
|
@ -307,16 +352,17 @@ pwd_builtin (list)
|
|||
WORD_LIST *list;
|
||||
{
|
||||
char *directory;
|
||||
int opt;
|
||||
int opt, pflag;
|
||||
|
||||
verbatim_pwd = no_symbolic_links;
|
||||
pflag = 0;
|
||||
reset_internal_getopt ();
|
||||
while ((opt = internal_getopt (list, "LP")) != -1)
|
||||
{
|
||||
switch (opt)
|
||||
{
|
||||
case 'P':
|
||||
verbatim_pwd = 1;
|
||||
verbatim_pwd = pflag = 1;
|
||||
break;
|
||||
case 'L':
|
||||
verbatim_pwd = 0;
|
||||
|
@ -332,20 +378,24 @@ pwd_builtin (list)
|
|||
|
||||
directory = tcwd ? (verbatim_pwd ? sh_physpath (tcwd, 0) : tcwd)
|
||||
: get_working_directory ("pwd");
|
||||
|
||||
/* Try again using getcwd() if canonicalization fails (for instance, if
|
||||
the file system has changed state underneath bash). */
|
||||
if ((tcwd && directory == 0) ||
|
||||
(posixly_correct && same_file (".", tcwd, (struct stat *)0, (struct stat *)0) == 0))
|
||||
directory = resetpwd ("pwd");
|
||||
|
||||
#undef tcwd
|
||||
|
||||
if (directory)
|
||||
{
|
||||
printf ("%s\n", directory);
|
||||
/* This is dumb but posix-mandated. */
|
||||
if (posixly_correct && pflag)
|
||||
setpwd (directory);
|
||||
if (directory != the_current_working_directory)
|
||||
free (directory);
|
||||
fflush (stdout);
|
||||
if (ferror (stdout))
|
||||
{
|
||||
builtin_error ("write error: %s", strerror (errno));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
return (EXECUTION_SUCCESS);
|
||||
return (sh_chkwrite (EXECUTION_SUCCESS));
|
||||
}
|
||||
else
|
||||
return (EXECUTION_FAILURE);
|
||||
|
@ -363,7 +413,7 @@ change_to_directory (newdir, nolinks)
|
|||
int nolinks;
|
||||
{
|
||||
char *t, *tdir;
|
||||
int err, canon_failed;
|
||||
int err, canon_failed, r, ndlen, dlen;
|
||||
|
||||
tdir = (char *)NULL;
|
||||
|
||||
|
@ -381,6 +431,9 @@ change_to_directory (newdir, nolinks)
|
|||
tdir = nolinks ? sh_physpath (t, 0)
|
||||
: sh_canonpath (t, PATH_CHECKDOTDOT|PATH_CHECKEXISTS);
|
||||
|
||||
ndlen = strlen (newdir);
|
||||
dlen = strlen (t);
|
||||
|
||||
/* Use the canonicalized version of NEWDIR, or, if canonicalization
|
||||
failed, use the non-canonical form. */
|
||||
canon_failed = 0;
|
||||
|
@ -396,10 +449,15 @@ change_to_directory (newdir, nolinks)
|
|||
/* In POSIX mode, if we're resolving symlinks logically and sh_canonpath
|
||||
returns NULL (because it checks the path, it will return NULL if the
|
||||
resolved path doesn't exist), fail immediately. */
|
||||
if (posixly_correct && nolinks == 0 && canon_failed)
|
||||
if (posixly_correct && nolinks == 0 && canon_failed && (errno != ENAMETOOLONG || ndlen > PATH_MAX))
|
||||
{
|
||||
#if defined ENAMETOOLONG
|
||||
if (errno != ENOENT && errno != ENAMETOOLONG)
|
||||
#else
|
||||
if (errno != ENOENT)
|
||||
#endif
|
||||
errno = ENOTDIR;
|
||||
free (tdir);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -409,62 +467,47 @@ change_to_directory (newdir, nolinks)
|
|||
/* If canonicalization failed, but the chdir succeeded, reset the
|
||||
shell's idea of the_current_working_directory. */
|
||||
if (canon_failed)
|
||||
resetpwd ();
|
||||
else
|
||||
{
|
||||
FREE (the_current_working_directory);
|
||||
the_current_working_directory = tdir;
|
||||
t = resetpwd ("cd");
|
||||
if (t == 0)
|
||||
set_working_directory (tdir);
|
||||
}
|
||||
else
|
||||
set_working_directory (tdir);
|
||||
|
||||
free (tdir);
|
||||
return (1);
|
||||
}
|
||||
|
||||
/* We failed to change to the appropriate directory name. If we tried
|
||||
what the user passed (nolinks != 0), punt now. */
|
||||
if (nolinks)
|
||||
return (0);
|
||||
{
|
||||
free (tdir);
|
||||
return (0);
|
||||
}
|
||||
|
||||
err = errno;
|
||||
free (tdir);
|
||||
|
||||
/* We're not in physical mode (nolinks == 0), but we failed to change to
|
||||
the canonicalized directory name (TDIR). Try what the user passed
|
||||
verbatim. If we succeed, reinitialize the_current_working_directory. */
|
||||
if (chdir (newdir) == 0)
|
||||
{
|
||||
tdir = resetpwd ();
|
||||
FREE (tdir);
|
||||
t = resetpwd ("cd");
|
||||
if (t == 0)
|
||||
set_working_directory (tdir);
|
||||
else
|
||||
free (t);
|
||||
|
||||
return (1);
|
||||
r = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
errno = err;
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
/* Code for cd spelling correction. Original patch submitted by
|
||||
Neil Russel (caret@c-side.com). */
|
||||
|
||||
static char *
|
||||
cdspell (dirname)
|
||||
char *dirname;
|
||||
{
|
||||
int n;
|
||||
char *guess;
|
||||
|
||||
n = (strlen (dirname) * 3 + 1) / 2 + 1;
|
||||
guess = (char *)xmalloc (n);
|
||||
|
||||
switch (spname (dirname, guess))
|
||||
{
|
||||
case -1:
|
||||
default:
|
||||
free (guess);
|
||||
return (char *)NULL;
|
||||
case 0:
|
||||
case 1:
|
||||
return guess;
|
||||
r = 0;
|
||||
}
|
||||
|
||||
free (tdir);
|
||||
return r;
|
||||
}
|
||||
|
|
|
@ -1,23 +1,22 @@
|
|||
This file is colon.def, from which is created colon.c.
|
||||
It implements the builtin ":" in Bash.
|
||||
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES colon.c
|
||||
|
||||
|
@ -25,19 +24,30 @@ $BUILTIN :
|
|||
$DOCNAME colon
|
||||
$FUNCTION colon_builtin
|
||||
$SHORT_DOC :
|
||||
No effect; the command does nothing. A zero exit code is returned.
|
||||
Null command.
|
||||
|
||||
No effect; the command does nothing.
|
||||
|
||||
Exit Status:
|
||||
Always succeeds.
|
||||
$END
|
||||
|
||||
$BUILTIN true
|
||||
$FUNCTION colon_builtin
|
||||
$SHORT_DOC true
|
||||
Return a successful result.
|
||||
|
||||
Exit Status:
|
||||
Always succeeds.
|
||||
$END
|
||||
|
||||
$BUILTIN false
|
||||
$FUNCTION false_builtin
|
||||
$SHORT_DOC false
|
||||
Return an unsuccessful result.
|
||||
|
||||
Exit Status:
|
||||
Always fails.
|
||||
$END
|
||||
|
||||
/* Return a successful result. */
|
||||
|
|
|
@ -1,35 +1,42 @@
|
|||
This file is command.def, from which is created command.c.
|
||||
It implements the builtin "command" in Bash.
|
||||
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES command.c
|
||||
|
||||
$BUILTIN command
|
||||
$FUNCTION command_builtin
|
||||
$SHORT_DOC command [-pVv] command [arg ...]
|
||||
Runs COMMAND with ARGS ignoring shell functions. If you have a shell
|
||||
function called `ls', and you wish to call the command `ls', you can
|
||||
say "command ls". If the -p option is given, a default value is used
|
||||
for PATH that is guaranteed to find all of the standard utilities. If
|
||||
the -V or -v option is given, a string is printed describing COMMAND.
|
||||
The -V option produces a more verbose description.
|
||||
Execute a simple command or display information about commands.
|
||||
|
||||
Runs COMMAND with ARGS suppressing shell function lookup, or display
|
||||
information about the specified COMMANDs. Can be used to invoke commands
|
||||
on disk when a function with the same name exists.
|
||||
|
||||
Options:
|
||||
-p use a default value for PATH that is guaranteed to find all of
|
||||
the standard utilities
|
||||
-v print a description of COMMAND similar to the `type' builtin
|
||||
-V print a more verbose description of each COMMAND
|
||||
|
||||
Exit Status:
|
||||
Returns exit status of COMMAND, or failure if COMMAND is not found.
|
||||
$END
|
||||
|
||||
#include <config.h>
|
||||
|
@ -78,7 +85,7 @@ command_builtin (list)
|
|||
use_standard_path = 1;
|
||||
break;
|
||||
case 'V':
|
||||
verbose = CDESC_SHORTDESC; /* look in common.h for constants */
|
||||
verbose = CDESC_SHORTDESC|CDESC_ABSPATH; /* look in common.h for constants */
|
||||
break;
|
||||
case 'v':
|
||||
verbose = CDESC_REUSABLE; /* ditto */
|
||||
|
@ -101,7 +108,7 @@ command_builtin (list)
|
|||
{
|
||||
found = describe_command (list->word->word, verbose);
|
||||
|
||||
if (found == 0)
|
||||
if (found == 0 && verbose != CDESC_REUSABLE)
|
||||
sh_notfound (list->word->word);
|
||||
|
||||
any_found += found;
|
||||
|
@ -131,7 +138,7 @@ command_builtin (list)
|
|||
add_unwind_protect ((Function *)restore_path, old_path);
|
||||
|
||||
standard_path = get_standard_path ();
|
||||
bind_variable ("PATH", standard_path ? standard_path : "");
|
||||
bind_variable ("PATH", standard_path ? standard_path : "", 0);
|
||||
FREE (standard_path);
|
||||
}
|
||||
|
||||
|
@ -170,7 +177,7 @@ restore_path (var)
|
|||
{
|
||||
if (var)
|
||||
{
|
||||
bind_variable ("PATH", var);
|
||||
bind_variable ("PATH", var, 0);
|
||||
free (var);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1,20 +1,22 @@
|
|||
/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
/* common.c - utility functions for all builtins */
|
||||
|
||||
/* Copyright (C) 1987-2009 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 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 3 of the License, 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. */
|
||||
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. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
@ -40,6 +42,9 @@
|
|||
#endif
|
||||
|
||||
#include "../bashansi.h"
|
||||
#include "../bashintl.h"
|
||||
|
||||
#define NEED_FPURGE_DECL
|
||||
|
||||
#include "../shell.h"
|
||||
#include "maxpath.h"
|
||||
|
@ -68,7 +73,7 @@ extern int last_command_exit_value;
|
|||
extern int running_trap;
|
||||
extern int posixly_correct;
|
||||
extern char *this_command_name, *shell_name;
|
||||
extern char *bash_getcwd_errstr;
|
||||
extern const char * const bash_getcwd_errstr;
|
||||
|
||||
/* Used by some builtins and the mainline code. */
|
||||
sh_builtin_func_t *last_shell_builtin = (sh_builtin_func_t *)NULL;
|
||||
|
@ -83,6 +88,22 @@ sh_builtin_func_t *this_shell_builtin = (sh_builtin_func_t *)NULL;
|
|||
/* This is a lot like report_error (), but it is for shell builtins
|
||||
instead of shell control structures, and it won't ever exit the
|
||||
shell. */
|
||||
|
||||
static void
|
||||
builtin_error_prolog ()
|
||||
{
|
||||
char *name;
|
||||
|
||||
name = get_name_for_error ();
|
||||
fprintf (stderr, "%s: ", name);
|
||||
|
||||
if (interactive_shell == 0)
|
||||
fprintf (stderr, _("line %d: "), executing_line_number ());
|
||||
|
||||
if (this_command_name && *this_command_name)
|
||||
fprintf (stderr, "%s: ", this_command_name);
|
||||
}
|
||||
|
||||
void
|
||||
#if defined (PREFER_STDARG)
|
||||
builtin_error (const char *format, ...)
|
||||
|
@ -93,16 +114,29 @@ builtin_error (format, va_alist)
|
|||
#endif
|
||||
{
|
||||
va_list args;
|
||||
char *name;
|
||||
|
||||
name = get_name_for_error ();
|
||||
fprintf (stderr, "%s: ", name);
|
||||
builtin_error_prolog ();
|
||||
|
||||
if (interactive_shell == 0)
|
||||
fprintf (stderr, "line %d: ", executing_line_number ());
|
||||
SH_VA_START (args, format);
|
||||
|
||||
if (this_command_name && *this_command_name)
|
||||
fprintf (stderr, "%s: ", this_command_name);
|
||||
vfprintf (stderr, format, args);
|
||||
va_end (args);
|
||||
fprintf (stderr, "\n");
|
||||
}
|
||||
|
||||
void
|
||||
#if defined (PREFER_STDARG)
|
||||
builtin_warning (const char *format, ...)
|
||||
#else
|
||||
builtin_warning (format, va_alist)
|
||||
const char *format;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list args;
|
||||
|
||||
builtin_error_prolog ();
|
||||
fprintf (stderr, _("warning: "));
|
||||
|
||||
SH_VA_START (args, format);
|
||||
|
||||
|
@ -116,7 +150,7 @@ void
|
|||
builtin_usage ()
|
||||
{
|
||||
if (this_command_name && *this_command_name)
|
||||
fprintf (stderr, "%s: usage: ", this_command_name);
|
||||
fprintf (stderr, _("%s: usage: "), this_command_name);
|
||||
fprintf (stderr, "%s\n", current_builtin->short_doc);
|
||||
fflush (stderr);
|
||||
}
|
||||
|
@ -129,7 +163,8 @@ no_args (list)
|
|||
{
|
||||
if (list)
|
||||
{
|
||||
builtin_error ("too many arguments");
|
||||
builtin_error (_("too many arguments"));
|
||||
top_level_cleanup ();
|
||||
jump_to_top_level (DISCARD);
|
||||
}
|
||||
}
|
||||
|
@ -153,21 +188,21 @@ void
|
|||
sh_needarg (s)
|
||||
char *s;
|
||||
{
|
||||
builtin_error ("%s: option requires an argument", s);
|
||||
builtin_error (_("%s: option requires an argument"), s);
|
||||
}
|
||||
|
||||
void
|
||||
sh_neednumarg (s)
|
||||
char *s;
|
||||
{
|
||||
builtin_error ("%s: numeric argument required", s);
|
||||
builtin_error (_("%s: numeric argument required"), s);
|
||||
}
|
||||
|
||||
void
|
||||
sh_notfound (s)
|
||||
char *s;
|
||||
{
|
||||
builtin_error ("%s: not found", s);
|
||||
builtin_error (_("%s: not found"), s);
|
||||
}
|
||||
|
||||
/* Function called when one of the builtin commands detects an invalid
|
||||
|
@ -176,49 +211,57 @@ void
|
|||
sh_invalidopt (s)
|
||||
char *s;
|
||||
{
|
||||
builtin_error ("%s: invalid option", s);
|
||||
builtin_error (_("%s: invalid option"), s);
|
||||
}
|
||||
|
||||
void
|
||||
sh_invalidoptname (s)
|
||||
char *s;
|
||||
{
|
||||
builtin_error ("%s: invalid option name", s);
|
||||
builtin_error (_("%s: invalid option name"), s);
|
||||
}
|
||||
|
||||
void
|
||||
sh_invalidid (s)
|
||||
char *s;
|
||||
{
|
||||
builtin_error ("`%s': not a valid identifier", s);
|
||||
builtin_error (_("`%s': not a valid identifier"), s);
|
||||
}
|
||||
|
||||
void
|
||||
sh_invalidnum (s)
|
||||
char *s;
|
||||
{
|
||||
builtin_error ("%s: invalid number", s);
|
||||
char *msg;
|
||||
|
||||
if (*s == '0' && isdigit (s[1]))
|
||||
msg = _("invalid octal number");
|
||||
else if (*s == '0' && s[1] == 'x')
|
||||
msg = _("invalid hex number");
|
||||
else
|
||||
msg = _("invalid number");
|
||||
builtin_error ("%s: %s", s, msg);
|
||||
}
|
||||
|
||||
void
|
||||
sh_invalidsig (s)
|
||||
char *s;
|
||||
{
|
||||
builtin_error ("%s: invalid signal specification", s);
|
||||
builtin_error (_("%s: invalid signal specification"), s);
|
||||
}
|
||||
|
||||
void
|
||||
sh_badpid (s)
|
||||
char *s;
|
||||
{
|
||||
builtin_error ("`%s': not a pid or valid job spec", s);
|
||||
builtin_error (_("`%s': not a pid or valid job spec"), s);
|
||||
}
|
||||
|
||||
void
|
||||
sh_readonly (s)
|
||||
const char *s;
|
||||
{
|
||||
builtin_error ("%s: readonly variable", s);
|
||||
builtin_error (_("%s: readonly variable"), s);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -226,9 +269,9 @@ sh_erange (s, desc)
|
|||
char *s, *desc;
|
||||
{
|
||||
if (s)
|
||||
builtin_error ("%s: %s out of range", s, desc ? desc : "argument");
|
||||
builtin_error (_("%s: %s out of range"), s, desc ? desc : _("argument"));
|
||||
else
|
||||
builtin_error ("%s out of range", desc ? desc : "argument");
|
||||
builtin_error (_("%s out of range"), desc ? desc : _("argument"));
|
||||
}
|
||||
|
||||
#if defined (JOB_CONTROL)
|
||||
|
@ -236,7 +279,7 @@ void
|
|||
sh_badjob (s)
|
||||
char *s;
|
||||
{
|
||||
builtin_error ("%s: no such job", s);
|
||||
builtin_error (_("%s: no such job"), s);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -244,9 +287,9 @@ sh_nojobs (s)
|
|||
char *s;
|
||||
{
|
||||
if (s)
|
||||
builtin_error ("%s: no job control");
|
||||
builtin_error (_("%s: no job control"), s);
|
||||
else
|
||||
builtin_error ("no job control");
|
||||
builtin_error (_("no job control"));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -256,12 +299,53 @@ sh_restricted (s)
|
|||
char *s;
|
||||
{
|
||||
if (s)
|
||||
builtin_error ("%s: restricted", s);
|
||||
builtin_error (_("%s: restricted"), s);
|
||||
else
|
||||
builtin_error ("restricted");
|
||||
builtin_error (_("restricted"));
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
sh_notbuiltin (s)
|
||||
char *s;
|
||||
{
|
||||
builtin_error (_("%s: not a shell builtin"), s);
|
||||
}
|
||||
|
||||
void
|
||||
sh_wrerror ()
|
||||
{
|
||||
#if defined (DONT_REPORT_BROKEN_PIPE_WRITE_ERRORS) && defined (EPIPE)
|
||||
if (errno != EPIPE)
|
||||
#endif /* DONT_REPORT_BROKEN_PIPE_WRITE_ERRORS && EPIPE */
|
||||
builtin_error (_("write error: %s"), strerror (errno));
|
||||
}
|
||||
|
||||
void
|
||||
sh_ttyerror (set)
|
||||
int set;
|
||||
{
|
||||
if (set)
|
||||
builtin_error (_("error setting terminal attributes: %s"), strerror (errno));
|
||||
else
|
||||
builtin_error (_("error getting terminal attributes: %s"), strerror (errno));
|
||||
}
|
||||
|
||||
int
|
||||
sh_chkwrite (s)
|
||||
int s;
|
||||
{
|
||||
fflush (stdout);
|
||||
if (ferror (stdout))
|
||||
{
|
||||
sh_wrerror ();
|
||||
fpurge (stdout);
|
||||
clearerr (stdout);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
return (s);
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Shell positional parameter manipulation */
|
||||
|
@ -357,36 +441,44 @@ set_dollar_vars_changed ()
|
|||
/* Read a numeric arg for this_command_name, the name of the shell builtin
|
||||
that wants it. LIST is the word list that the arg is to come from.
|
||||
Accept only the numeric argument; report an error if other arguments
|
||||
follow. If FATAL is true, call throw_to_top_level, which exits the
|
||||
shell; if not, call jump_to_top_level (DISCARD), which aborts the
|
||||
current command. */
|
||||
intmax_t
|
||||
get_numeric_arg (list, fatal)
|
||||
follow. If FATAL is 1, call throw_to_top_level, which exits the
|
||||
shell; if it's 2, call jump_to_top_level (DISCARD), which aborts the
|
||||
current command; if FATAL is 0, return an indication of an invalid
|
||||
number by setting *NUMOK == 0 and return -1. */
|
||||
int
|
||||
get_numeric_arg (list, fatal, count)
|
||||
WORD_LIST *list;
|
||||
int fatal;
|
||||
intmax_t *count;
|
||||
{
|
||||
intmax_t count = 1;
|
||||
char *arg;
|
||||
|
||||
if (count)
|
||||
*count = 1;
|
||||
|
||||
if (list && list->word && ISOPTION (list->word->word, '-'))
|
||||
list = list->next;
|
||||
|
||||
if (list)
|
||||
{
|
||||
register char *arg;
|
||||
|
||||
arg = list->word->word;
|
||||
if (arg == 0 || (legal_number (arg, &count) == 0))
|
||||
if (arg == 0 || (legal_number (arg, count) == 0))
|
||||
{
|
||||
sh_neednumarg (list->word->word);
|
||||
if (fatal)
|
||||
sh_neednumarg (list->word->word ? list->word->word : "`'");
|
||||
if (fatal == 0)
|
||||
return 0;
|
||||
else if (fatal == 1) /* fatal == 1; abort */
|
||||
throw_to_top_level ();
|
||||
else
|
||||
jump_to_top_level (DISCARD);
|
||||
else /* fatal == 2; discard current command */
|
||||
{
|
||||
top_level_cleanup ();
|
||||
jump_to_top_level (DISCARD);
|
||||
}
|
||||
}
|
||||
no_args (list->next);
|
||||
}
|
||||
|
||||
return (count);
|
||||
return (1);
|
||||
}
|
||||
|
||||
/* Get an eight-bit status value from LIST */
|
||||
|
@ -453,29 +545,24 @@ char *
|
|||
get_working_directory (for_whom)
|
||||
char *for_whom;
|
||||
{
|
||||
char *directory;
|
||||
|
||||
if (no_symbolic_links)
|
||||
{
|
||||
if (the_current_working_directory)
|
||||
free (the_current_working_directory);
|
||||
|
||||
FREE (the_current_working_directory);
|
||||
the_current_working_directory = (char *)NULL;
|
||||
}
|
||||
|
||||
if (the_current_working_directory == 0)
|
||||
{
|
||||
the_current_working_directory = (char *)xmalloc (PATH_MAX);
|
||||
the_current_working_directory[0] = '\0';
|
||||
directory = getcwd (the_current_working_directory, PATH_MAX);
|
||||
if (directory == 0)
|
||||
#if defined (GETCWD_BROKEN)
|
||||
the_current_working_directory = getcwd (0, PATH_MAX);
|
||||
#else
|
||||
the_current_working_directory = getcwd (0, 0);
|
||||
#endif
|
||||
if (the_current_working_directory == 0)
|
||||
{
|
||||
fprintf (stderr, "%s: could not get current directory: %s: %s\n",
|
||||
fprintf (stderr, _("%s: error retrieving current directory: %s: %s\n"),
|
||||
(for_whom && *for_whom) ? for_whom : get_name_for_error (),
|
||||
bash_getcwd_errstr, strerror (errno));
|
||||
|
||||
free (the_current_working_directory);
|
||||
the_current_working_directory = (char *)NULL;
|
||||
_(bash_getcwd_errstr), strerror (errno));
|
||||
return (char *)NULL;
|
||||
}
|
||||
}
|
||||
|
@ -506,15 +593,17 @@ get_job_by_name (name, flags)
|
|||
{
|
||||
register int i, wl, cl, match, job;
|
||||
register PROCESS *p;
|
||||
register JOB *j;
|
||||
|
||||
job = NO_JOB;
|
||||
wl = strlen (name);
|
||||
for (i = job_slots - 1; i >= 0; i--)
|
||||
for (i = js.j_jobslots - 1; i >= 0; i--)
|
||||
{
|
||||
if (jobs[i] == 0 || ((flags & JM_STOPPED) && JOBSTATE(i) != JSTOPPED))
|
||||
j = get_job_by_jid (i);
|
||||
if (j == 0 || ((flags & JM_STOPPED) && J_JOBSTATE(j) != JSTOPPED))
|
||||
continue;
|
||||
|
||||
p = jobs[i]->pipe;
|
||||
p = j->pipe;
|
||||
do
|
||||
{
|
||||
if (flags & JM_EXACT)
|
||||
|
@ -537,15 +626,15 @@ get_job_by_name (name, flags)
|
|||
else if (job != NO_JOB)
|
||||
{
|
||||
if (this_shell_builtin)
|
||||
builtin_error ("%s: ambiguous job spec", name);
|
||||
builtin_error (_("%s: ambiguous job spec"), name);
|
||||
else
|
||||
report_error ("%s: ambiguous job spec", name);
|
||||
report_error (_("%s: ambiguous job spec"), name);
|
||||
return (DUP_JOB);
|
||||
}
|
||||
else
|
||||
job = i;
|
||||
}
|
||||
while (p != jobs[i]->pipe);
|
||||
while (p != j->pipe);
|
||||
}
|
||||
|
||||
return (job);
|
||||
|
@ -560,12 +649,12 @@ get_job_spec (list)
|
|||
int job, jflags;
|
||||
|
||||
if (list == 0)
|
||||
return (current_job);
|
||||
return (js.j_current);
|
||||
|
||||
word = list->word->word;
|
||||
|
||||
if (*word == '\0')
|
||||
return (current_job);
|
||||
return (NO_JOB);
|
||||
|
||||
if (*word == '%')
|
||||
word++;
|
||||
|
@ -573,11 +662,7 @@ get_job_spec (list)
|
|||
if (DIGIT (*word) && all_digits (word))
|
||||
{
|
||||
job = atoi (word);
|
||||
#if 0
|
||||
return (job >= job_slots ? NO_JOB : job - 1);
|
||||
#else
|
||||
return (job > job_slots ? NO_JOB : job - 1);
|
||||
#endif
|
||||
return (job > js.j_jobslots ? NO_JOB : job - 1);
|
||||
}
|
||||
|
||||
jflags = 0;
|
||||
|
@ -586,10 +671,10 @@ get_job_spec (list)
|
|||
case 0:
|
||||
case '%':
|
||||
case '+':
|
||||
return (current_job);
|
||||
return (js.j_current);
|
||||
|
||||
case '-':
|
||||
return (previous_job);
|
||||
return (js.j_previous);
|
||||
|
||||
case '?': /* Substring search requested. */
|
||||
jflags |= JM_SUBSTRING;
|
||||
|
@ -602,6 +687,9 @@ get_job_spec (list)
|
|||
}
|
||||
#endif /* JOB_CONTROL */
|
||||
|
||||
/*
|
||||
* NOTE: `kill' calls this function with forcecols == 0
|
||||
*/
|
||||
int
|
||||
display_signal_list (list, forcecols)
|
||||
WORD_LIST *list;
|
||||
|
@ -609,8 +697,7 @@ display_signal_list (list, forcecols)
|
|||
{
|
||||
register int i, column;
|
||||
char *name;
|
||||
int result;
|
||||
int signum;
|
||||
int result, signum, dflags;
|
||||
intmax_t lsignum;
|
||||
|
||||
result = EXECUTION_SUCCESS;
|
||||
|
@ -623,12 +710,18 @@ display_signal_list (list, forcecols)
|
|||
continue;
|
||||
|
||||
if (posixly_correct && !forcecols)
|
||||
printf ("%s%s", name, (i == NSIG - 1) ? "" : " ");
|
||||
{
|
||||
/* This is for the kill builtin. POSIX.2 says the signal names
|
||||
are displayed without the `SIG' prefix. */
|
||||
if (STREQN (name, "SIG", 3))
|
||||
name += 3;
|
||||
printf ("%s%s", name, (i == NSIG - 1) ? "" : " ");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf ("%2d) %s", i, name);
|
||||
|
||||
if (++column < 4)
|
||||
if (++column < 5)
|
||||
printf ("\t");
|
||||
else
|
||||
{
|
||||
|
@ -677,7 +770,10 @@ display_signal_list (list, forcecols)
|
|||
}
|
||||
else
|
||||
{
|
||||
signum = decode_signal (list->word->word);
|
||||
dflags = DSIG_NOCASE;
|
||||
if (posixly_correct == 0 || this_shell_builtin != kill_builtin)
|
||||
dflags |= DSIG_SIGPREFIX;
|
||||
signum = decode_signal (list->word->word, dflags);
|
||||
if (signum == NO_SIG)
|
||||
{
|
||||
sh_invalidsig (list->word->word);
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
/* common.h -- extern declarations for functions defined in common.c. */
|
||||
|
||||
/* Copyright (C) 1993-2002 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1993-2004 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 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 3 of the License, 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.
|
||||
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. */
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if !defined (__COMMON_H)
|
||||
# define __COMMON_H
|
||||
|
@ -30,6 +30,9 @@
|
|||
#define SEVAL_INTERACT 0x002
|
||||
#define SEVAL_NOHIST 0x004
|
||||
#define SEVAL_NOFREE 0x008
|
||||
#define SEVAL_RESETLINE 0x010
|
||||
#define SEVAL_PARSEONLY 0x020
|
||||
#define SEVAL_NOLONGJMP 0x040
|
||||
|
||||
/* Flags for describe_command, shared between type.def and command.def */
|
||||
#define CDESC_ALL 0x001 /* type -a */
|
||||
|
@ -39,6 +42,7 @@
|
|||
#define CDESC_PATH_ONLY 0x010 /* type -p */
|
||||
#define CDESC_FORCE_PATH 0x020 /* type -ap or type -P */
|
||||
#define CDESC_NOFUNCS 0x040 /* type -f */
|
||||
#define CDESC_ABSPATH 0x080 /* convert to absolute path, no ./ */
|
||||
|
||||
/* Flags for get_job_by_name */
|
||||
#define JM_PREFIX 0x01 /* prefix of job name */
|
||||
|
@ -55,6 +59,7 @@
|
|||
|
||||
/* Functions from common.c */
|
||||
extern void builtin_error __P((const char *, ...)) __attribute__((__format__ (printf, 1, 2)));
|
||||
extern void builtin_warning __P((const char *, ...)) __attribute__((__format__ (printf, 1, 2)));
|
||||
extern void builtin_usage __P((void));
|
||||
extern void no_args __P((WORD_LIST *));
|
||||
extern int no_options __P((WORD_LIST *));
|
||||
|
@ -74,6 +79,10 @@ extern void sh_badjob __P((char *));
|
|||
extern void sh_readonly __P((const char *));
|
||||
extern void sh_nojobs __P((char *));
|
||||
extern void sh_restricted __P((char *));
|
||||
extern void sh_notbuiltin __P((char *));
|
||||
extern void sh_wrerror __P((void));
|
||||
extern void sh_ttyerror __P((int));
|
||||
extern int sh_chkwrite __P((int));
|
||||
|
||||
extern char **make_builtin_argv __P((WORD_LIST *, int *));
|
||||
extern void remember_args __P((WORD_LIST *, int));
|
||||
|
@ -82,7 +91,7 @@ extern int dollar_vars_changed __P((void));
|
|||
extern void set_dollar_vars_unchanged __P((void));
|
||||
extern void set_dollar_vars_changed __P((void));
|
||||
|
||||
extern intmax_t get_numeric_arg __P((WORD_LIST *, int));
|
||||
extern int get_numeric_arg __P((WORD_LIST *, int, intmax_t *));
|
||||
extern int get_exitstat __P((WORD_LIST *));
|
||||
extern int read_octal __P((char *));
|
||||
|
||||
|
@ -105,6 +114,9 @@ extern sh_builtin_func_t *builtin_address __P((char *));
|
|||
extern sh_builtin_func_t *find_special_builtin __P((char *));
|
||||
extern void initialize_shell_builtins __P((void));
|
||||
|
||||
/* Functions from exit.def */
|
||||
extern void bash_logout __P((void));
|
||||
|
||||
/* Functions from getopts.def */
|
||||
extern void getopts_reset __P((int));
|
||||
|
||||
|
@ -134,6 +146,7 @@ extern int describe_command __P((char *, int));
|
|||
|
||||
/* Functions from setattr.def */
|
||||
extern int set_or_show_attributes __P((WORD_LIST *, int, int));
|
||||
extern int show_all_var_attributes __P((int, int));
|
||||
extern int show_var_attributes __P((SHELL_VAR *, int, int));
|
||||
extern int show_name_attributes __P((char *, int));
|
||||
extern void set_var_attribute __P((char *, int, int));
|
||||
|
@ -142,15 +155,16 @@ extern void set_var_attribute __P((char *, int, int));
|
|||
extern char *get_dirstack_from_string __P((char *));
|
||||
extern char *get_dirstack_element __P((intmax_t, int));
|
||||
extern void set_dirstack_element __P((intmax_t, int, char *));
|
||||
extern WORD_LIST *get_directory_stack __P((void));
|
||||
extern WORD_LIST *get_directory_stack __P((int));
|
||||
|
||||
/* Functions from evalstring.c */
|
||||
extern int parse_and_execute __P((char *, const char *, int));
|
||||
extern void parse_and_execute_cleanup __P((void));
|
||||
extern int parse_string __P((char *, const char *, int, char **));
|
||||
|
||||
/* Functions from evalfile.c */
|
||||
extern int maybe_execute_file __P((const char *, int));
|
||||
extern int source_file __P((const char *));
|
||||
extern int source_file __P((const char *, int));
|
||||
extern int fc_execute_file __P((const char *));
|
||||
|
||||
#endif /* !__COMMON_H */
|
||||
|
|
|
@ -1,35 +1,45 @@
|
|||
This file is complete.def, from which is created complete.c.
|
||||
It implements the builtins "complete" and "compgen" in Bash.
|
||||
It implements the builtins "complete", "compgen", and "compopt" in Bash.
|
||||
|
||||
Copyright (C) 1999-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999-2009 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES complete.c
|
||||
|
||||
$BUILTIN complete
|
||||
$DEPENDS_ON PROGRAMMABLE_COMPLETION
|
||||
$FUNCTION complete_builtin
|
||||
$SHORT_DOC complete [-abcdefgjksuv] [-pr] [-o option] [-A action] [-G globpat] [-W wordlist] [-P prefix] [-S suffix] [-X filterpat] [-F function] [-C command] [name ...]
|
||||
For each NAME, specify how arguments are to be completed.
|
||||
If the -p option is supplied, or if no options are supplied, existing
|
||||
completion specifications are printed in a way that allows them to be
|
||||
reused as input. The -r option removes a completion specification for
|
||||
each NAME, or, if no NAMEs are supplied, all completion specifications.
|
||||
$SHORT_DOC complete [-abcdefgjksuv] [-pr] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [name ...]
|
||||
Specify how arguments are to be completed by Readline.
|
||||
|
||||
For each NAME, specify how arguments are to be completed. If no options
|
||||
are supplied, existing completion specifications are printed in a way that
|
||||
allows them to be reused as input.
|
||||
|
||||
Options:
|
||||
-p print existing completion specifications in a reusable format
|
||||
-r remove a completion specification for each NAME, or, if no
|
||||
NAMEs are supplied, all completion specifications
|
||||
|
||||
When completion is attempted, the actions are applied in the order the
|
||||
uppercase-letter options are listed above.
|
||||
|
||||
Exit Status:
|
||||
Returns success unless an invalid option is supplied or an error occurs.
|
||||
$END
|
||||
|
||||
#include <config.h>
|
||||
|
@ -43,10 +53,12 @@ $END
|
|||
#endif
|
||||
|
||||
#include "../bashansi.h"
|
||||
#include "../bashintl.h"
|
||||
|
||||
#include "../shell.h"
|
||||
#include "../builtins.h"
|
||||
#include "../pcomplete.h"
|
||||
#include "../bashline.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "bashgetopt.h"
|
||||
|
@ -55,22 +67,31 @@ $END
|
|||
|
||||
#define STRDUP(x) ((x) ? savestring (x) : (char *)NULL)
|
||||
|
||||
/* Structure containing all the non-action (binary) options; filled in by
|
||||
build_actions(). */
|
||||
struct _optflags {
|
||||
int pflag;
|
||||
int rflag;
|
||||
int Eflag;
|
||||
};
|
||||
|
||||
static int find_compact __P((char *));
|
||||
static int find_compopt __P((char *));
|
||||
|
||||
static int build_actions __P((WORD_LIST *, int *, int *, unsigned long *, unsigned long *));
|
||||
static int build_actions __P((WORD_LIST *, struct _optflags *, unsigned long *, unsigned long *));
|
||||
|
||||
static int remove_cmd_completions __P((WORD_LIST *));
|
||||
|
||||
static int print_one_completion __P((char *, COMPSPEC *));
|
||||
static int print_compitem __P((BUCKET_CONTENTS *));
|
||||
static void print_compopts __P((const char *, COMPSPEC *, int));
|
||||
static void print_all_completions __P((void));
|
||||
static int print_cmd_completions __P((WORD_LIST *));
|
||||
|
||||
static char *Garg, *Warg, *Parg, *Sarg, *Xarg, *Farg, *Carg;
|
||||
|
||||
static struct _compacts {
|
||||
char *actname;
|
||||
static const struct _compacts {
|
||||
const char * const actname;
|
||||
int actflag;
|
||||
int actopt;
|
||||
} compacts[] = {
|
||||
|
@ -102,14 +123,16 @@ static struct _compacts {
|
|||
};
|
||||
|
||||
/* This should be a STRING_INT_ALIST */
|
||||
static struct _compopt {
|
||||
char *optname;
|
||||
const static struct _compopt {
|
||||
const char * const optname;
|
||||
int optflag;
|
||||
} compopts[] = {
|
||||
{ "bashdefault", COPT_BASHDEFAULT },
|
||||
{ "default", COPT_DEFAULT },
|
||||
{ "dirnames", COPT_DIRNAMES },
|
||||
{ "filenames",COPT_FILENAMES},
|
||||
{ "nospace", COPT_NOSPACE },
|
||||
{ "plusdirs", COPT_PLUSDIRS },
|
||||
{ (char *)NULL, 0 },
|
||||
};
|
||||
|
||||
|
@ -152,9 +175,9 @@ find_compopt (name)
|
|||
*/
|
||||
|
||||
static int
|
||||
build_actions (list, pp, rp, actp, optp)
|
||||
build_actions (list, flagp, actp, optp)
|
||||
WORD_LIST *list;
|
||||
int *pp, *rp;
|
||||
struct _optflags *flagp;
|
||||
unsigned long *actp, *optp;
|
||||
{
|
||||
int opt, ind, opt_given;
|
||||
|
@ -164,15 +187,15 @@ build_actions (list, pp, rp, actp, optp)
|
|||
opt_given = 0;
|
||||
|
||||
reset_internal_getopt ();
|
||||
while ((opt = internal_getopt (list, "abcdefgjko:prsuvA:G:W:P:S:X:F:C:")) != -1)
|
||||
while ((opt = internal_getopt (list, "abcdefgjko:prsuvA:G:W:P:S:X:F:C:E")) != -1)
|
||||
{
|
||||
opt_given = 1;
|
||||
switch (opt)
|
||||
{
|
||||
case 'r':
|
||||
if (rp)
|
||||
if (flagp)
|
||||
{
|
||||
*rp = 1;
|
||||
flagp->rflag = 1;
|
||||
break;
|
||||
}
|
||||
else
|
||||
|
@ -183,9 +206,9 @@ build_actions (list, pp, rp, actp, optp)
|
|||
}
|
||||
|
||||
case 'p':
|
||||
if (pp)
|
||||
if (flagp)
|
||||
{
|
||||
*pp = 1;
|
||||
flagp->pflag = 1;
|
||||
break;
|
||||
}
|
||||
else
|
||||
|
@ -244,7 +267,7 @@ build_actions (list, pp, rp, actp, optp)
|
|||
ind = find_compact (list_optarg);
|
||||
if (ind < 0)
|
||||
{
|
||||
builtin_error ("%s: invalid action name", list_optarg);
|
||||
builtin_error (_("%s: invalid action name"), list_optarg);
|
||||
return (EX_USAGE);
|
||||
}
|
||||
acts |= compacts[ind].actflag;
|
||||
|
@ -252,6 +275,18 @@ build_actions (list, pp, rp, actp, optp)
|
|||
case 'C':
|
||||
Carg = list_optarg;
|
||||
break;
|
||||
case 'E':
|
||||
if (flagp)
|
||||
{
|
||||
flagp->Eflag = 1;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
sh_invalidopt ("-E");
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
}
|
||||
case 'F':
|
||||
Farg = list_optarg;
|
||||
break;
|
||||
|
@ -287,9 +322,11 @@ int
|
|||
complete_builtin (list)
|
||||
WORD_LIST *list;
|
||||
{
|
||||
int opt_given, pflag, rflag, rval;
|
||||
int opt_given, rval;
|
||||
unsigned long acts, copts;
|
||||
COMPSPEC *cs;
|
||||
struct _optflags oflags;
|
||||
WORD_LIST *l, *wl;
|
||||
|
||||
if (list == 0)
|
||||
{
|
||||
|
@ -297,24 +334,33 @@ complete_builtin (list)
|
|||
return (EXECUTION_SUCCESS);
|
||||
}
|
||||
|
||||
opt_given = pflag = rflag = 0;
|
||||
opt_given = oflags.pflag = oflags.rflag = oflags.Eflag = 0;
|
||||
|
||||
acts = copts = (unsigned long)0L;
|
||||
Garg = Warg = Parg = Sarg = Xarg = Farg = Carg = (char *)NULL;
|
||||
cs = (COMPSPEC *)NULL;
|
||||
|
||||
/* Build the actions from the arguments. Also sets the [A-Z]arg variables
|
||||
as a side effect if they are supplied as options. */
|
||||
rval = build_actions (list, &pflag, &rflag, &acts, &copts);
|
||||
rval = build_actions (list, &oflags, &acts, &copts);
|
||||
if (rval == EX_USAGE)
|
||||
return (rval);
|
||||
opt_given = rval != EXECUTION_FAILURE;
|
||||
|
||||
list = loptend;
|
||||
|
||||
wl = oflags.Eflag ? make_word_list (make_bare_word ("_EmptycmD_"), (WORD_LIST *)NULL) : 0;
|
||||
|
||||
/* -p overrides everything else */
|
||||
if (pflag || (list == 0 && opt_given == 0))
|
||||
if (oflags.pflag || (list == 0 && opt_given == 0))
|
||||
{
|
||||
if (list == 0)
|
||||
if (wl)
|
||||
{
|
||||
rval = print_cmd_completions (wl);
|
||||
dispose_words (wl);
|
||||
return rval;
|
||||
}
|
||||
else if (list == 0)
|
||||
{
|
||||
print_all_completions ();
|
||||
return (EXECUTION_SUCCESS);
|
||||
|
@ -323,9 +369,15 @@ complete_builtin (list)
|
|||
}
|
||||
|
||||
/* next, -r overrides everything else. */
|
||||
if (rflag)
|
||||
if (oflags.rflag)
|
||||
{
|
||||
if (list == 0)
|
||||
if (wl)
|
||||
{
|
||||
rval = remove_cmd_completions (wl);
|
||||
dispose_words (wl);
|
||||
return rval;
|
||||
}
|
||||
else if (list == 0)
|
||||
{
|
||||
progcomp_flush ();
|
||||
return (EXECUTION_SUCCESS);
|
||||
|
@ -333,7 +385,7 @@ complete_builtin (list)
|
|||
return (remove_cmd_completions (list));
|
||||
}
|
||||
|
||||
if (list == 0 && opt_given)
|
||||
if (wl == 0 && list == 0 && opt_given)
|
||||
{
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
|
@ -353,13 +405,14 @@ complete_builtin (list)
|
|||
cs->command = STRDUP (Carg);
|
||||
cs->filterpat = STRDUP (Xarg);
|
||||
|
||||
for (rval = EXECUTION_SUCCESS ; list; list = list->next)
|
||||
for (rval = EXECUTION_SUCCESS, l = wl ? wl : list ; l; l = l->next)
|
||||
{
|
||||
/* Add CS as the compspec for the specified commands. */
|
||||
if (progcomp_insert (list->word->word, cs) == 0)
|
||||
if (progcomp_insert (l->word->word, cs) == 0)
|
||||
rval = EXECUTION_FAILURE;
|
||||
}
|
||||
|
||||
dispose_words (wl);
|
||||
return (rval);
|
||||
}
|
||||
|
||||
|
@ -374,7 +427,7 @@ remove_cmd_completions (list)
|
|||
{
|
||||
if (progcomp_remove (l->word->word) == 0)
|
||||
{
|
||||
builtin_error ("%s: no completion specification", l->word->word);
|
||||
builtin_error (_("%s: no completion specification"), l->word->word);
|
||||
ret = EXECUTION_FAILURE;
|
||||
}
|
||||
}
|
||||
|
@ -415,6 +468,14 @@ remove_cmd_completions (list)
|
|||
printf ("-o %s ", f); \
|
||||
} while (0)
|
||||
|
||||
#define XPRINTCOMPOPT(a, f) \
|
||||
do { \
|
||||
if (copts & a) \
|
||||
printf ("-o %s ", f); \
|
||||
else \
|
||||
printf ("+o %s ", f); \
|
||||
} while (0)
|
||||
|
||||
static int
|
||||
print_one_completion (cmd, cs)
|
||||
char *cmd;
|
||||
|
@ -428,10 +489,12 @@ print_one_completion (cmd, cs)
|
|||
copts = cs->options;
|
||||
|
||||
/* First, print the -o options. */
|
||||
PRINTCOMPOPT (COPT_BASHDEFAULT, "bashdefault");
|
||||
PRINTCOMPOPT (COPT_DEFAULT, "default");
|
||||
PRINTCOMPOPT (COPT_DIRNAMES, "dirnames");
|
||||
PRINTCOMPOPT (COPT_FILENAMES, "filenames");
|
||||
PRINTCOMPOPT (COPT_NOSPACE, "nospace");
|
||||
PRINTCOMPOPT (COPT_PLUSDIRS, "plusdirs");
|
||||
|
||||
acts = cs->actions;
|
||||
|
||||
|
@ -472,15 +535,49 @@ print_one_completion (cmd, cs)
|
|||
SQPRINTARG (cs->suffix, "-S");
|
||||
SQPRINTARG (cs->filterpat, "-X");
|
||||
|
||||
SQPRINTARG (cs->command, "-C");
|
||||
|
||||
/* simple arguments that don't require quoting */
|
||||
PRINTARG (cs->funcname, "-F");
|
||||
PRINTARG (cs->command, "-C");
|
||||
|
||||
printf ("%s\n", cmd);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
print_compopts (cmd, cs, full)
|
||||
const char *cmd;
|
||||
COMPSPEC *cs;
|
||||
int full;
|
||||
{
|
||||
int copts;
|
||||
|
||||
printf ("compopt ");
|
||||
copts = cs->options;
|
||||
|
||||
if (full)
|
||||
{
|
||||
XPRINTCOMPOPT (COPT_BASHDEFAULT, "bashdefault");
|
||||
XPRINTCOMPOPT (COPT_DEFAULT, "default");
|
||||
XPRINTCOMPOPT (COPT_DIRNAMES, "dirnames");
|
||||
XPRINTCOMPOPT (COPT_FILENAMES, "filenames");
|
||||
XPRINTCOMPOPT (COPT_NOSPACE, "nospace");
|
||||
XPRINTCOMPOPT (COPT_PLUSDIRS, "plusdirs");
|
||||
}
|
||||
else
|
||||
{
|
||||
PRINTCOMPOPT (COPT_BASHDEFAULT, "bashdefault");
|
||||
PRINTCOMPOPT (COPT_DEFAULT, "default");
|
||||
PRINTCOMPOPT (COPT_DIRNAMES, "dirnames");
|
||||
PRINTCOMPOPT (COPT_FILENAMES, "filenames");
|
||||
PRINTCOMPOPT (COPT_NOSPACE, "nospace");
|
||||
PRINTCOMPOPT (COPT_PLUSDIRS, "plusdirs");
|
||||
}
|
||||
|
||||
printf ("%s\n", cmd);
|
||||
}
|
||||
|
||||
static int
|
||||
print_compitem (item)
|
||||
BUCKET_CONTENTS *item;
|
||||
|
@ -515,21 +612,26 @@ print_cmd_completions (list)
|
|||
print_one_completion (l->word->word, cs);
|
||||
else
|
||||
{
|
||||
builtin_error ("%s: no completion specification", l->word->word);
|
||||
builtin_error (_("%s: no completion specification"), l->word->word);
|
||||
ret = EXECUTION_FAILURE;
|
||||
}
|
||||
}
|
||||
return (ret);
|
||||
|
||||
return (sh_chkwrite (ret));
|
||||
}
|
||||
|
||||
$BUILTIN compgen
|
||||
$DEPENDS_ON PROGRAMMABLE_COMPLETION
|
||||
$FUNCTION compgen_builtin
|
||||
$SHORT_DOC compgen [-abcdefgjksuv] [-o option] [-A action] [-G globpat] [-W wordlist] [-P prefix] [-S suffix] [-X filterpat] [-F function] [-C command] [word]
|
||||
Display the possible completions depending on the options. Intended
|
||||
to be used from within a shell function generating possible completions.
|
||||
If the optional WORD argument is supplied, matches against WORD are
|
||||
generated.
|
||||
$SHORT_DOC compgen [-abcdefgjksuv] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [word]
|
||||
Display possible completions depending on the options.
|
||||
|
||||
Intended to be used from within a shell function generating possible
|
||||
completions. If the optional WORD argument is supplied, matches against
|
||||
WORD are generated.
|
||||
|
||||
Exit Status:
|
||||
Returns success unless an invalid option is supplied or an error occurs.
|
||||
$END
|
||||
|
||||
int
|
||||
|
@ -540,7 +642,7 @@ compgen_builtin (list)
|
|||
unsigned long acts, copts;
|
||||
COMPSPEC *cs;
|
||||
STRINGLIST *sl;
|
||||
char *word;
|
||||
char *word, **matches;
|
||||
|
||||
if (list == 0)
|
||||
return (EXECUTION_SUCCESS);
|
||||
|
@ -551,7 +653,7 @@ compgen_builtin (list)
|
|||
|
||||
/* Build the actions from the arguments. Also sets the [A-Z]arg variables
|
||||
as a side effect if they are supplied as options. */
|
||||
rval = build_actions (list, (int *)NULL, (int *)NULL, &acts, &copts);
|
||||
rval = build_actions (list, (struct _optflags *)NULL, &acts, &copts);
|
||||
if (rval == EX_USAGE)
|
||||
return (rval);
|
||||
if (rval == EXECUTION_FAILURE)
|
||||
|
@ -562,9 +664,9 @@ compgen_builtin (list)
|
|||
word = (list && list->word) ? list->word->word : "";
|
||||
|
||||
if (Farg)
|
||||
internal_warning ("compgen: -F option may not work as you expect");
|
||||
builtin_error (_("warning: -F option may not work as you expect"));
|
||||
if (Carg)
|
||||
internal_warning ("compgen: -C option may not work as you expect");
|
||||
builtin_error (_("warning: -C option may not work as you expect"));
|
||||
|
||||
/* If we get here, we need to build a compspec and evaluate it. */
|
||||
cs = compspec_create ();
|
||||
|
@ -583,12 +685,19 @@ compgen_builtin (list)
|
|||
rval = EXECUTION_FAILURE;
|
||||
sl = gen_compspec_completions (cs, "compgen", word, 0, 0);
|
||||
|
||||
/* If the compspec wants the bash default completions, temporarily
|
||||
turn off programmable completion and call the bash completion code. */
|
||||
if ((sl == 0 || sl->list_len == 0) && (copts & COPT_BASHDEFAULT))
|
||||
{
|
||||
matches = bash_default_completion (word, 0, 0, 0, 0);
|
||||
sl = completions_to_stringlist (matches);
|
||||
strvec_dispose (matches);
|
||||
}
|
||||
|
||||
/* This isn't perfect, but it's the best we can do, given what readline
|
||||
exports from its set of completion utility functions. */
|
||||
if ((sl == 0 || sl->list_len == 0) && (copts & COPT_DEFAULT))
|
||||
{
|
||||
char **matches;
|
||||
|
||||
matches = rl_completion_matches (word, rl_filename_completion_function);
|
||||
sl = completions_to_stringlist (matches);
|
||||
strvec_dispose (matches);
|
||||
|
@ -607,3 +716,114 @@ compgen_builtin (list)
|
|||
compspec_dispose (cs);
|
||||
return (rval);
|
||||
}
|
||||
|
||||
$BUILTIN compopt
|
||||
$DEPENDS_ON PROGRAMMABLE_COMPLETION
|
||||
$FUNCTION compopt_builtin
|
||||
$SHORT_DOC compopt [-o|+o option] [name ...]
|
||||
Modify or display completion options.
|
||||
|
||||
Modify the completion options for each NAME, or, if no NAMEs are supplied,
|
||||
the completion currently begin executed. If no OPTIONs are givenm, print
|
||||
the completion options for each NAME or the current completion specification.
|
||||
|
||||
Options:
|
||||
-o option Set completion option OPTION for each NAME
|
||||
|
||||
Using `+o' instead of `-o' turns off the specified option.
|
||||
|
||||
Arguments:
|
||||
|
||||
Each NAME refers to a command for which a completion specification must
|
||||
have previously been defined using the `complete' builtin. If no NAMEs
|
||||
are supplied, compopt must be called by a function currently generating
|
||||
completions, and the options for that currently-executing completion
|
||||
generator are modified.
|
||||
|
||||
Exit Status:
|
||||
Returns success unless an invalid option is supplied or NAME does not
|
||||
have a completion specification defined.
|
||||
$END
|
||||
|
||||
int
|
||||
compopt_builtin (list)
|
||||
WORD_LIST *list;
|
||||
{
|
||||
int opts_on, opts_off, *opts, opt, oind, ret, Eflag;
|
||||
WORD_LIST *l;
|
||||
COMPSPEC *cs;
|
||||
|
||||
opts_on = opts_off = 0;
|
||||
ret = EXECUTION_SUCCESS;
|
||||
|
||||
reset_internal_getopt ();
|
||||
while ((opt = internal_getopt (list, "+o:")) != EOF)
|
||||
{
|
||||
opts = (list_opttype == '-') ? &opts_on : &opts_off;
|
||||
|
||||
switch (opt)
|
||||
{
|
||||
case 'o':
|
||||
oind = find_compopt (list_optarg);
|
||||
if (oind < 0)
|
||||
{
|
||||
sh_invalidoptname (list_optarg);
|
||||
return (EX_USAGE);
|
||||
}
|
||||
*opts |= compopts[oind].optflag;
|
||||
break;
|
||||
default:
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
}
|
||||
}
|
||||
list = loptend;
|
||||
|
||||
if (list == 0)
|
||||
{
|
||||
if (RL_ISSTATE (RL_STATE_COMPLETING) == 0 || pcomp_curcs == 0)
|
||||
{
|
||||
builtin_error (_("not currently executing completion function"));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
cs = pcomp_curcs;
|
||||
|
||||
if (opts_on == 0 && opts_off == 0)
|
||||
{
|
||||
print_compopts (pcomp_curcmd, cs, 1);
|
||||
return (sh_chkwrite (ret));
|
||||
}
|
||||
|
||||
/* Set the compspec options */
|
||||
pcomp_set_compspec_options (cs, opts_on, 1);
|
||||
pcomp_set_compspec_options (cs, opts_off, 0);
|
||||
|
||||
/* And change the readline variables the options control */
|
||||
pcomp_set_readline_variables (opts_on, 1);
|
||||
pcomp_set_readline_variables (opts_off, 0);
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
for (l = list; l; l = l->next)
|
||||
{
|
||||
cs = progcomp_search (l->word->word);
|
||||
if (cs == 0)
|
||||
{
|
||||
builtin_error (_("%s: no completion specification"), l->word->word);
|
||||
ret = EXECUTION_FAILURE;
|
||||
continue;
|
||||
}
|
||||
if (opts_on == 0 && opts_off == 0)
|
||||
{
|
||||
print_compopts (l->word->word, cs, 1);
|
||||
continue; /* XXX -- fill in later */
|
||||
}
|
||||
|
||||
/* Set the compspec options */
|
||||
pcomp_set_compspec_options (cs, opts_on, 1);
|
||||
pcomp_set_compspec_options (cs, opts_off, 0);
|
||||
}
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
|
|
@ -1,58 +1,67 @@
|
|||
This file is declare.def, from which is created declare.c.
|
||||
It implements the builtins "declare" and "local" in Bash.
|
||||
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES declare.c
|
||||
|
||||
$BUILTIN declare
|
||||
$FUNCTION declare_builtin
|
||||
$SHORT_DOC declare [-afFirtx] [-p] name[=value] ...
|
||||
Declare variables and/or give them attributes. If no NAMEs are
|
||||
given, then display the values of variables instead. The -p option
|
||||
will display the attributes and values of each NAME.
|
||||
$SHORT_DOC declare [-aAfFilrtux] [-p] [name[=value] ...]
|
||||
Set variable values and attributes.
|
||||
|
||||
The flags are:
|
||||
Declare variables and give them attributes. If no NAMEs are given,
|
||||
display the attributes and values of all variables.
|
||||
|
||||
-a to make NAMEs arrays (if supported)
|
||||
-f to select from among function names only
|
||||
-F to display function names without definitions
|
||||
Options:
|
||||
-f restrict action or display to function names and definitions
|
||||
-F restrict display to function names only (plus line number and
|
||||
source file when debugging)
|
||||
-p display the attributes and value of each NAME
|
||||
|
||||
Options which set attributes:
|
||||
-a to make NAMEs indexed arrays (if supported)
|
||||
-A to make NAMEs associative arrays (if supported)
|
||||
-i to make NAMEs have the `integer' attribute
|
||||
-l to convert NAMEs to lower case on assignment
|
||||
-r to make NAMEs readonly
|
||||
-t to make NAMEs have the `trace' attribute
|
||||
-u to convert NAMEs to upper case on assignment
|
||||
-x to make NAMEs export
|
||||
|
||||
Using `+' instead of `-' turns off the given attribute.
|
||||
|
||||
Variables with the integer attribute have arithmetic evaluation (see
|
||||
`let') done when the variable is assigned to.
|
||||
the `let' command) performed when the variable is assigned a value.
|
||||
|
||||
When displaying values of variables, -f displays a function's name
|
||||
and definition. The -F option restricts the display to function
|
||||
name only.
|
||||
When used in a function, `declare' makes NAMEs local, as with the `local'
|
||||
command.
|
||||
|
||||
Using `+' instead of `-' turns off the given attribute instead. When
|
||||
used in a function, makes NAMEs local, as with the `local' command.
|
||||
Exit Status:
|
||||
Returns success unless an invalid option is supplied or an error occurs.
|
||||
$END
|
||||
|
||||
$BUILTIN typeset
|
||||
$FUNCTION declare_builtin
|
||||
$SHORT_DOC typeset [-afFirtx] [-p] name[=value] ...
|
||||
Obsolete. See `declare'.
|
||||
$SHORT_DOC typeset [-aAfFilrtux] [-p] name[=value] ...
|
||||
Set variable values and attributes.
|
||||
|
||||
Obsolete. See `help declare'.
|
||||
$END
|
||||
|
||||
#include <config.h>
|
||||
|
@ -67,6 +76,7 @@ $END
|
|||
#include <stdio.h>
|
||||
|
||||
#include "../bashansi.h"
|
||||
#include "../bashintl.h"
|
||||
|
||||
#include "../shell.h"
|
||||
#include "common.h"
|
||||
|
@ -74,6 +84,7 @@ $END
|
|||
#include "bashgetopt.h"
|
||||
|
||||
extern int array_needs_making;
|
||||
extern int posixly_correct;
|
||||
|
||||
static int declare_internal __P((register WORD_LIST *, int));
|
||||
|
||||
|
@ -87,10 +98,18 @@ declare_builtin (list)
|
|||
|
||||
$BUILTIN local
|
||||
$FUNCTION local_builtin
|
||||
$SHORT_DOC local name[=value] ...
|
||||
Create a local variable called NAME, and give it VALUE. LOCAL
|
||||
can only be used within a function; it makes the variable NAME
|
||||
have a visible scope restricted to that function and its children.
|
||||
$SHORT_DOC local [option] name[=value] ...
|
||||
Define local variables.
|
||||
|
||||
Create a local variable called NAME, and give it VALUE. OPTION can
|
||||
be any option accepted by `declare'.
|
||||
|
||||
Local variables can only be used within a function; they are visible
|
||||
only to the function where they are defined and its children.
|
||||
|
||||
Exit Status:
|
||||
Returns success unless an invalid option is supplied, an error occurs,
|
||||
or the shell is not executing a function.
|
||||
$END
|
||||
int
|
||||
local_builtin (list)
|
||||
|
@ -100,15 +119,15 @@ local_builtin (list)
|
|||
return (declare_internal (list, 1));
|
||||
else
|
||||
{
|
||||
builtin_error ("can only be used in a function");
|
||||
builtin_error (_("can only be used in a function"));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined (ARRAY_VARS)
|
||||
# define DECLARE_OPTS "+afiprtxF"
|
||||
# define DECLARE_OPTS "+acfilprtuxAF"
|
||||
#else
|
||||
# define DECLARE_OPTS "+fiprtxF"
|
||||
# define DECLARE_OPTS "+cfilprtuxF"
|
||||
#endif
|
||||
|
||||
/* The workhorse function. */
|
||||
|
@ -117,9 +136,11 @@ declare_internal (list, local_var)
|
|||
register WORD_LIST *list;
|
||||
int local_var;
|
||||
{
|
||||
int flags_on, flags_off, *flags, any_failed, assign_error, pflag, nodefs, opt;
|
||||
int flags_on, flags_off, *flags;
|
||||
int any_failed, assign_error, pflag, nodefs, opt;
|
||||
char *t, *subscript_start;
|
||||
SHELL_VAR *var;
|
||||
FUNCTION_DEF *shell_fn;
|
||||
|
||||
flags_on = flags_off = any_failed = assign_error = pflag = nodefs = 0;
|
||||
reset_internal_getopt ();
|
||||
|
@ -132,8 +153,19 @@ declare_internal (list, local_var)
|
|||
case 'a':
|
||||
#if defined (ARRAY_VARS)
|
||||
*flags |= att_array;
|
||||
#endif
|
||||
break;
|
||||
#else
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
#endif
|
||||
case 'A':
|
||||
#if defined (ARRAY_VARS)
|
||||
*flags |= att_assoc;
|
||||
break;
|
||||
#else
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
#endif
|
||||
case 'p':
|
||||
if (local_var == 0)
|
||||
pflag++;
|
||||
|
@ -158,6 +190,25 @@ declare_internal (list, local_var)
|
|||
*flags |= att_exported;
|
||||
array_needs_making = 1;
|
||||
break;
|
||||
#if defined (CASEMOD_ATTRS)
|
||||
# if defined (CASEMOD_CAPCASE)
|
||||
case 'c':
|
||||
*flags |= att_capcase;
|
||||
if (flags == &flags_on)
|
||||
flags_off |= att_uppercase|att_lowercase;
|
||||
break;
|
||||
# endif
|
||||
case 'l':
|
||||
*flags |= att_lowercase;
|
||||
if (flags == &flags_on)
|
||||
flags_off |= att_capcase|att_uppercase;
|
||||
break;
|
||||
case 'u':
|
||||
*flags |= att_uppercase;
|
||||
if (flags == &flags_on)
|
||||
flags_off |= att_capcase|att_lowercase;
|
||||
break;
|
||||
#endif /* CASEMOD_ATTRS */
|
||||
default:
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
|
@ -168,7 +219,7 @@ declare_internal (list, local_var)
|
|||
|
||||
/* If there are no more arguments left, then we just want to show
|
||||
some variables. */
|
||||
if (list == 0) /* declare -[afFirtx] */
|
||||
if (list == 0) /* declare -[aAfFirtx] */
|
||||
{
|
||||
/* Show local variables defined at this context level if this is
|
||||
the `local' builtin. */
|
||||
|
@ -187,19 +238,17 @@ declare_internal (list, local_var)
|
|||
free (vlist);
|
||||
}
|
||||
}
|
||||
else if (pflag && (flags_on == 0 || flags_on == att_function))
|
||||
show_all_var_attributes (flags_on == 0, nodefs);
|
||||
else if (flags_on == 0)
|
||||
return (set_builtin ((WORD_LIST *)NULL));
|
||||
else
|
||||
{
|
||||
if (flags_on == 0)
|
||||
set_builtin ((WORD_LIST *)NULL);
|
||||
else
|
||||
set_or_show_attributes ((WORD_LIST *)NULL, flags_on, nodefs);
|
||||
}
|
||||
set_or_show_attributes ((WORD_LIST *)NULL, flags_on, nodefs);
|
||||
|
||||
fflush (stdout);
|
||||
return (EXECUTION_SUCCESS);
|
||||
return (sh_chkwrite (EXECUTION_SUCCESS));
|
||||
}
|
||||
|
||||
if (pflag) /* declare -p [-afFirtx] name [name...] */
|
||||
if (pflag) /* declare -p [-aAfFirtx] name [name...] */
|
||||
{
|
||||
for (any_failed = 0; list; list = list->next)
|
||||
{
|
||||
|
@ -210,27 +259,33 @@ declare_internal (list, local_var)
|
|||
any_failed++;
|
||||
}
|
||||
}
|
||||
return (any_failed ? EXECUTION_FAILURE : EXECUTION_SUCCESS);
|
||||
return (sh_chkwrite (any_failed ? EXECUTION_FAILURE : EXECUTION_SUCCESS));
|
||||
}
|
||||
|
||||
#define NEXT_VARIABLE() free (name); list = list->next; continue
|
||||
|
||||
/* There are arguments left, so we are making variables. */
|
||||
while (list) /* declare [-afFirx] name [name ...] */
|
||||
while (list) /* declare [-aAfFirx] name [name ...] */
|
||||
{
|
||||
char *value, *name;
|
||||
int offset;
|
||||
int offset, aflags;
|
||||
#if defined (ARRAY_VARS)
|
||||
int making_array_special, compound_array_assign, simple_array_assign;
|
||||
#endif
|
||||
|
||||
name = savestring (list->word->word);
|
||||
offset = assignment (name);
|
||||
offset = assignment (name, 0);
|
||||
aflags = 0;
|
||||
|
||||
if (offset) /* declare [-afFirx] name=value */
|
||||
if (offset) /* declare [-aAfFirx] name=value */
|
||||
{
|
||||
name[offset] = '\0';
|
||||
value = name + offset + 1;
|
||||
if (name[offset - 1] == '+')
|
||||
{
|
||||
aflags |= ASS_APPEND;
|
||||
name[offset - 1] = '\0';
|
||||
}
|
||||
}
|
||||
else
|
||||
value = "";
|
||||
|
@ -247,8 +302,12 @@ declare_internal (list, local_var)
|
|||
else
|
||||
making_array_special = 0;
|
||||
#endif
|
||||
|
||||
if (legal_identifier (name) == 0)
|
||||
|
||||
/* If we're in posix mode or not looking for a shell function (since
|
||||
shell function names don't have to be valid identifiers when the
|
||||
shell's not in posix mode), check whether or not the argument is a
|
||||
valid, well-formed shell identifier. */
|
||||
if ((posixly_correct || (flags_on & att_function) == 0) && legal_identifier (name) == 0)
|
||||
{
|
||||
sh_invalidid (name);
|
||||
assign_error++;
|
||||
|
@ -265,7 +324,9 @@ declare_internal (list, local_var)
|
|||
if (variable_context && ((flags_on & att_function) == 0))
|
||||
{
|
||||
#if defined (ARRAY_VARS)
|
||||
if ((flags_on & att_array) || making_array_special)
|
||||
if (flags_on & att_assoc)
|
||||
var = make_local_assoc_variable (name);
|
||||
else if ((flags_on & att_array) || making_array_special)
|
||||
var = make_local_array_variable (name);
|
||||
else
|
||||
#endif
|
||||
|
@ -289,7 +350,7 @@ declare_internal (list, local_var)
|
|||
{
|
||||
if (offset) /* declare -f [-rix] foo=bar */
|
||||
{
|
||||
builtin_error ("cannot use `-f' to make functions");
|
||||
builtin_error (_("cannot use `-f' to make functions"));
|
||||
free (name);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
@ -301,7 +362,7 @@ declare_internal (list, local_var)
|
|||
{
|
||||
if (readonly_p (var) && (flags_off & att_readonly))
|
||||
{
|
||||
builtin_error ("%s: readonly function", name);
|
||||
builtin_error (_("%s: readonly function"), name);
|
||||
any_failed++;
|
||||
NEXT_VARIABLE ();
|
||||
}
|
||||
|
@ -309,9 +370,23 @@ declare_internal (list, local_var)
|
|||
/* declare -[Ff] name [name...] */
|
||||
if (flags_on == att_function && flags_off == 0)
|
||||
{
|
||||
t = nodefs ? var->name
|
||||
: named_function_string (name, function_cell (var), 1);
|
||||
printf ("%s\n", t);
|
||||
#if defined (DEBUGGER)
|
||||
if (nodefs && debugging_mode)
|
||||
{
|
||||
shell_fn = find_function_def (var->name);
|
||||
if (shell_fn)
|
||||
printf ("%s %d %s\n", var->name, shell_fn->line, shell_fn->source_file);
|
||||
else
|
||||
printf ("%s\n", var->name);
|
||||
}
|
||||
else
|
||||
#endif /* DEBUGGER */
|
||||
{
|
||||
t = nodefs ? var->name
|
||||
: named_function_string (name, function_cell (var), FUNC_MULTILINE|FUNC_EXTERNAL);
|
||||
printf ("%s\n", t);
|
||||
any_failed = sh_chkwrite (any_failed);
|
||||
}
|
||||
}
|
||||
else /* declare -[fF] -[rx] name [name...] */
|
||||
{
|
||||
|
@ -324,7 +399,7 @@ declare_internal (list, local_var)
|
|||
NEXT_VARIABLE ();
|
||||
}
|
||||
}
|
||||
else /* declare -[airx] name [name...] */
|
||||
else /* declare -[aAirx] name [name...] */
|
||||
{
|
||||
/* Non-null if we just created or fetched a local variable. */
|
||||
if (var == 0)
|
||||
|
@ -333,11 +408,20 @@ declare_internal (list, local_var)
|
|||
if (var == 0)
|
||||
{
|
||||
#if defined (ARRAY_VARS)
|
||||
if ((flags_on & att_array) || making_array_special)
|
||||
if (flags_on & att_assoc)
|
||||
var = make_new_assoc_variable (name);
|
||||
else if ((flags_on & att_array) || making_array_special)
|
||||
var = make_new_array_variable (name);
|
||||
else
|
||||
#endif
|
||||
var = bind_variable (name, "");
|
||||
|
||||
if (offset)
|
||||
var = bind_variable (name, "", 0);
|
||||
else
|
||||
{
|
||||
var = bind_variable (name, (char *)NULL, 0);
|
||||
VSETATTR (var, att_invisible);
|
||||
}
|
||||
}
|
||||
|
||||
/* Cannot use declare +r to turn off readonly attribute. */
|
||||
|
@ -359,24 +443,48 @@ declare_internal (list, local_var)
|
|||
}
|
||||
|
||||
#if defined (ARRAY_VARS)
|
||||
if ((making_array_special || (flags_on & att_array) || array_p (var)) && offset)
|
||||
if ((making_array_special || (flags_on & (att_array|att_assoc)) || array_p (var) || assoc_p (var)) && offset)
|
||||
{
|
||||
if (value[0] == '(' && strchr (value, ')'))
|
||||
int vlen;
|
||||
vlen = STRLEN (value);
|
||||
|
||||
if (value[0] == '(' && value[vlen-1] == ')')
|
||||
compound_array_assign = 1;
|
||||
else
|
||||
simple_array_assign = 1;
|
||||
}
|
||||
|
||||
/* Cannot use declare +a name to remove an array variable. */
|
||||
if ((flags_off & att_array) && array_p (var))
|
||||
/* Cannot use declare +a name or declare +A name to remove an
|
||||
array variable. */
|
||||
if (((flags_off & att_array) && array_p (var)) || ((flags_off & att_assoc) && assoc_p (var)))
|
||||
{
|
||||
builtin_error ("%s: cannot destroy array variables in this way", name);
|
||||
builtin_error (_("%s: cannot destroy array variables in this way"), name);
|
||||
any_failed++;
|
||||
NEXT_VARIABLE ();
|
||||
}
|
||||
|
||||
/* declare -a name makes name an array variable. */
|
||||
if ((making_array_special || (flags_on & att_array)) && array_p (var) == 0)
|
||||
if ((flags_on & att_array) && assoc_p (var))
|
||||
{
|
||||
builtin_error (_("%s: cannot convert associative to indexed array"), name);
|
||||
any_failed++;
|
||||
NEXT_VARIABLE ();
|
||||
}
|
||||
if ((flags_on & att_assoc) && array_p (var))
|
||||
{
|
||||
builtin_error (_("%s: cannot convert indexed to associative array"), name);
|
||||
any_failed++;
|
||||
NEXT_VARIABLE ();
|
||||
}
|
||||
|
||||
/* declare -A name[[n]] makes name an associative array variable. */
|
||||
if (flags_on & att_assoc)
|
||||
{
|
||||
if (assoc_p (var) == 0)
|
||||
var = convert_var_to_assoc (var);
|
||||
}
|
||||
/* declare -a name[[n]] or declare name[n] makes name an indexed
|
||||
array variable. */
|
||||
else if ((making_array_special || (flags_on & att_array)) && array_p (var) == 0)
|
||||
var = convert_var_to_array (var);
|
||||
#endif /* ARRAY_VARS */
|
||||
|
||||
|
@ -385,23 +493,23 @@ declare_internal (list, local_var)
|
|||
|
||||
#if defined (ARRAY_VARS)
|
||||
if (offset && compound_array_assign)
|
||||
assign_array_var_from_string (var, value);
|
||||
assign_array_var_from_string (var, value, aflags);
|
||||
else if (simple_array_assign && subscript_start)
|
||||
{
|
||||
/* declare [-a] name[N]=value */
|
||||
*subscript_start = '['; /* ] */
|
||||
var = assign_array_element (name, value);
|
||||
var = assign_array_element (name, value, 0); /* XXX - not aflags */
|
||||
*subscript_start = '\0';
|
||||
}
|
||||
else if (simple_array_assign)
|
||||
/* let bind_array_variable take care of this. */
|
||||
bind_array_variable (name, 0, value);
|
||||
bind_array_variable (name, 0, value, aflags);
|
||||
else
|
||||
#endif
|
||||
/* bind_variable_value duplicates the essential internals of
|
||||
bind_variable() */
|
||||
if (offset)
|
||||
bind_variable_value (var, value);
|
||||
bind_variable_value (var, value, aflags);
|
||||
|
||||
/* If we found this variable in the temporary environment, as with
|
||||
`var=value declare -x var', make sure it is treated identically
|
||||
|
@ -421,7 +529,7 @@ declare_internal (list, local_var)
|
|||
if (tv)
|
||||
{
|
||||
tvalue = var_isset (var) ? savestring (value_cell (var)) : savestring ("");
|
||||
tv = bind_variable (var->name, tvalue);
|
||||
tv = bind_variable (var->name, tvalue, 0);
|
||||
tv->attributes |= var->attributes & ~att_tempvar;
|
||||
if (tv->context > 0)
|
||||
VSETATTR (tv, att_propagate);
|
||||
|
|
|
@ -1,23 +1,22 @@
|
|||
This file is echo.def, from which is created echo.c.
|
||||
It implements the builtin "echo" in Bash.
|
||||
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES echo.c
|
||||
#include <config.h>
|
||||
|
@ -31,34 +30,54 @@ $PRODUCES echo.c
|
|||
#include <stdio.h>
|
||||
#include "../shell.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
$BUILTIN echo
|
||||
$FUNCTION echo_builtin
|
||||
$DEPENDS_ON V9_ECHO
|
||||
$SHORT_DOC echo [-neE] [arg ...]
|
||||
Output the ARGs. If -n is specified, the trailing newline is
|
||||
suppressed. If the -e option is given, interpretation of the
|
||||
following backslash-escaped characters is turned on:
|
||||
\a alert (bell)
|
||||
\b backspace
|
||||
\c suppress trailing newline
|
||||
\E escape character
|
||||
\f form feed
|
||||
\n new line
|
||||
\r carriage return
|
||||
\t horizontal tab
|
||||
\v vertical tab
|
||||
\\ backslash
|
||||
\num the character whose ASCII code is NUM (octal).
|
||||
Write arguments to the standard output.
|
||||
|
||||
You can explicitly turn off the interpretation of the above characters
|
||||
with the -E option.
|
||||
Display the ARGs on the standard output followed by a newline.
|
||||
|
||||
Options:
|
||||
-n do not append a newline
|
||||
-e enable interpretation of the following backslash escapes
|
||||
-E explicitly suppress interpretation of backslash escapes
|
||||
|
||||
`echo' interprets the following backslash-escaped characters:
|
||||
\a alert (bell)
|
||||
\b backspace
|
||||
\c suppress further output
|
||||
\e escape character
|
||||
\f form feed
|
||||
\n new line
|
||||
\r carriage return
|
||||
\t horizontal tab
|
||||
\v vertical tab
|
||||
\\ backslash
|
||||
\0nnn the character whose ASCII code is NNN (octal). NNN can be
|
||||
0 to 3 octal digits
|
||||
\xHH the eight-bit character whose value is HH (hexadecimal). HH
|
||||
can be one or two hex digits
|
||||
|
||||
Exit Status:
|
||||
Returns success unless a write error occurs.
|
||||
$END
|
||||
|
||||
$BUILTIN echo
|
||||
$FUNCTION echo_builtin
|
||||
$DEPENDS_ON !V9_ECHO
|
||||
$SHORT_DOC echo [-n] [arg ...]
|
||||
Output the ARGs. If -n is specified, the trailing newline is suppressed.
|
||||
Write arguments to the standard output.
|
||||
|
||||
Display the ARGs on the standard output followed by a newline.
|
||||
|
||||
Options:
|
||||
-n do not append a newline
|
||||
|
||||
Exit Status:
|
||||
Returns success unless a write error occurs.
|
||||
$END
|
||||
|
||||
#if defined (V9_ECHO)
|
||||
|
@ -72,12 +91,14 @@ $END
|
|||
existing system shells won't barf. Regrettably, the SUS v2 has
|
||||
standardized the Sys V echo behavior. This variable is external
|
||||
so that we can have a `shopt' variable to control it at runtime. */
|
||||
#if defined (DEFAULT_ECHO_TO_XPG)
|
||||
#if defined (DEFAULT_ECHO_TO_XPG) || defined (STRICT_POSIX)
|
||||
int xpg_echo = 1;
|
||||
#else
|
||||
int xpg_echo = 0;
|
||||
#endif /* DEFAULT_ECHO_TO_XPG */
|
||||
|
||||
extern int posixly_correct;
|
||||
|
||||
/* Print the words in LIST to standard output. If the first word is
|
||||
`-n', then don't print a trailing newline. We also support the
|
||||
echo syntax from Version 9 Unix systems. */
|
||||
|
@ -91,6 +112,9 @@ echo_builtin (list)
|
|||
do_v9 = xpg_echo;
|
||||
display_return = 1;
|
||||
|
||||
if (posixly_correct && xpg_echo)
|
||||
goto just_echo;
|
||||
|
||||
for (; list && (temp = list->word->word) && *temp == '-'; list = list->next)
|
||||
{
|
||||
/* If it appears that we are handling options, then make sure that
|
||||
|
@ -133,6 +157,9 @@ echo_builtin (list)
|
|||
|
||||
just_echo:
|
||||
|
||||
clearerr (stdout); /* clear error before writing and testing success */
|
||||
|
||||
terminate_immediately++;
|
||||
while (list)
|
||||
{
|
||||
i = len = 0;
|
||||
|
@ -165,11 +192,7 @@ just_echo:
|
|||
|
||||
if (display_return)
|
||||
putchar ('\n');
|
||||
fflush (stdout);
|
||||
if (ferror (stdout))
|
||||
{
|
||||
clearerr (stdout);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
return (EXECUTION_SUCCESS);
|
||||
|
||||
terminate_immediately--;
|
||||
return (sh_chkwrite (EXECUTION_SUCCESS));
|
||||
}
|
||||
|
|
|
@ -1,42 +1,51 @@
|
|||
This file is enable.def, from which is created enable.c.
|
||||
It implements the builtin "enable" in Bash.
|
||||
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES enable.c
|
||||
|
||||
$BUILTIN enable
|
||||
$FUNCTION enable_builtin
|
||||
$SHORT_DOC enable [-pnds] [-a] [-f filename] [name ...]
|
||||
Enable and disable builtin shell commands. This allows
|
||||
you to use a disk command which has the same name as a shell
|
||||
builtin without specifying a full pathname. If -n is used, the
|
||||
NAMEs become disabled; otherwise NAMEs are enabled. For example,
|
||||
to use the `test' found in $PATH instead of the shell builtin
|
||||
version, type `enable -n test'. On systems supporting dynamic
|
||||
loading, the -f option may be used to load new builtins from the
|
||||
shared object FILENAME. The -d option will delete a builtin
|
||||
previously loaded with -f. If no non-option names are given, or
|
||||
the -p option is supplied, a list of builtins is printed. The
|
||||
-a option means to print every builtin with an indication of whether
|
||||
or not it is enabled. The -s option restricts the output to the POSIX.2
|
||||
`special' builtins. The -n option displays a list of all disabled builtins.
|
||||
$SHORT_DOC enable [-a] [-dnps] [-f filename] [name ...]
|
||||
Enable and disable shell builtins.
|
||||
|
||||
Enables and disables builtin shell commands. Disabling allows you to
|
||||
execute a disk command which has the same name as a shell builtin
|
||||
without using a full pathname.
|
||||
|
||||
Options:
|
||||
-a print a list of builtins showing whether or not each is enabled
|
||||
-n disable each NAME or display a list of disabled builtins
|
||||
-p print the list of builtins in a reusable format
|
||||
-s print only the names of Posix `special' builtins
|
||||
|
||||
Options controlling dynamic loading:
|
||||
-f Load builtin NAME from shared object FILENAME
|
||||
-d Remove a builtin loaded with -f
|
||||
|
||||
Without options, each NAME is enabled.
|
||||
|
||||
To use the `test' found in $PATH instead of the shell builtin
|
||||
version, type `enable -n test'.
|
||||
|
||||
Exit Status:
|
||||
Returns success unless NAME is not a shell builtin or an error occurs.
|
||||
$END
|
||||
|
||||
#include <config.h>
|
||||
|
@ -50,6 +59,8 @@ $END
|
|||
|
||||
#include <stdio.h>
|
||||
#include "../bashansi.h"
|
||||
#include "../bashintl.h"
|
||||
|
||||
#include "../shell.h"
|
||||
#include "../builtins.h"
|
||||
#include "../flags.h"
|
||||
|
@ -123,7 +134,7 @@ enable_builtin (list)
|
|||
filename = list_optarg;
|
||||
break;
|
||||
#else
|
||||
builtin_error ("dynamic loading not available");
|
||||
builtin_error (_("dynamic loading not available"));
|
||||
return (EX_USAGE);
|
||||
#endif
|
||||
#if defined (HAVE_DLCLOSE)
|
||||
|
@ -131,7 +142,7 @@ enable_builtin (list)
|
|||
flags |= DFLAG;
|
||||
break;
|
||||
#else
|
||||
builtin_error ("dynamic loading not available");
|
||||
builtin_error (_("dynamic loading not available"));
|
||||
return (EX_USAGE);
|
||||
#endif /* HAVE_DLCLOSE */
|
||||
default:
|
||||
|
@ -197,7 +208,7 @@ enable_builtin (list)
|
|||
|
||||
if (opt == EXECUTION_FAILURE)
|
||||
{
|
||||
builtin_error ("%s: not a shell builtin", list->word->word);
|
||||
sh_notbuiltin (list->word->word);
|
||||
result = EXECUTION_FAILURE;
|
||||
}
|
||||
list = list->next;
|
||||
|
@ -298,7 +309,7 @@ dyn_load_builtin (list, flags, filename)
|
|||
|
||||
if (handle == 0)
|
||||
{
|
||||
builtin_error ("cannot open shared object %s: %s", filename, dlerror ());
|
||||
builtin_error (_("cannot open shared object %s: %s"), filename, dlerror ());
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
|
@ -321,8 +332,8 @@ dyn_load_builtin (list, flags, filename)
|
|||
b = (struct builtin *)dlsym (handle, struct_name);
|
||||
if (b == 0)
|
||||
{
|
||||
builtin_error ("cannot find %s in shared object %s: %s", struct_name,
|
||||
filename, dlerror ());
|
||||
builtin_error (_("cannot find %s in shared object %s: %s"),
|
||||
struct_name, filename, dlerror ());
|
||||
free (struct_name);
|
||||
continue;
|
||||
}
|
||||
|
@ -440,12 +451,12 @@ dyn_unload_builtin (name)
|
|||
b = builtin_address_internal (name, 1);
|
||||
if (b == 0)
|
||||
{
|
||||
builtin_error ("%s: not a shell builtin", name);
|
||||
sh_notbuiltin (name);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
if (b->flags & STATIC_BUILTIN)
|
||||
{
|
||||
builtin_error ("%s: not dynamically loaded", name);
|
||||
builtin_error (_("%s: not dynamically loaded"), name);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
|
@ -460,7 +471,7 @@ dyn_unload_builtin (name)
|
|||
using it drops to zero. */
|
||||
if (ref == 1 && local_dlclose (handle) != 0)
|
||||
{
|
||||
builtin_error ("%s: cannot delete: %s", name, dlerror ());
|
||||
builtin_error (_("%s: cannot delete: %s"), name, dlerror ());
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,30 +1,35 @@
|
|||
This file is eval.def, from which is created eval.c.
|
||||
It implements the builtin "eval" in Bash.
|
||||
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES eval.c
|
||||
|
||||
$BUILTIN eval
|
||||
$FUNCTION eval_builtin
|
||||
$SHORT_DOC eval [arg ...]
|
||||
Read ARGs as input to the shell and execute the resulting command(s).
|
||||
Execute arguments as a shell command.
|
||||
|
||||
Combine ARGs into a single string, use the result as input to the shell,
|
||||
and execute the resulting commands.
|
||||
|
||||
Exit Status:
|
||||
Returns exit status of command or success if command is null.
|
||||
$END
|
||||
|
||||
#include <config.h>
|
||||
|
|
|
@ -1,20 +1,22 @@
|
|||
/* Copyright (C) 1996 Free Software Foundation, Inc.
|
||||
/* evalfile.c - read and evaluate commands from a file or file descriptor */
|
||||
|
||||
/* Copyright (C) 1996-2009 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 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 3 of the License, 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. */
|
||||
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. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
@ -31,6 +33,7 @@
|
|||
#include <errno.h>
|
||||
|
||||
#include "../bashansi.h"
|
||||
#include "../bashintl.h"
|
||||
|
||||
#include "../shell.h"
|
||||
#include "../jobs.h"
|
||||
|
@ -38,11 +41,14 @@
|
|||
#include "../flags.h"
|
||||
#include "../input.h"
|
||||
#include "../execute_cmd.h"
|
||||
#include "../trap.h"
|
||||
|
||||
#if defined (HISTORY)
|
||||
# include "../bashhist.h"
|
||||
#endif
|
||||
|
||||
#include <typemax.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#if !defined (errno)
|
||||
|
@ -58,9 +64,10 @@ extern int errno;
|
|||
#define FEVAL_HISTORY 0x020
|
||||
#define FEVAL_CHECKBINARY 0x040
|
||||
#define FEVAL_REGFILE 0x080
|
||||
#define FEVAL_NOPUSHARGS 0x100
|
||||
|
||||
extern int posixly_correct;
|
||||
extern int indirection_level, startup_state, subshell_environment;
|
||||
extern int indirection_level, subshell_environment;
|
||||
extern int return_catch_flag, return_catch_value;
|
||||
extern int last_command_exit_value;
|
||||
|
||||
|
@ -75,13 +82,33 @@ _evalfile (filename, flags)
|
|||
volatile int old_interactive;
|
||||
procenv_t old_return_catch;
|
||||
int return_val, fd, result, pflags;
|
||||
ssize_t nr; /* return value from read(2) */
|
||||
char *string;
|
||||
struct stat finfo;
|
||||
size_t file_size;
|
||||
sh_vmsg_func_t *errfunc;
|
||||
#if defined (ARRAY_VARS)
|
||||
SHELL_VAR *funcname_v, *nfv, *bash_source_v, *bash_lineno_v;
|
||||
ARRAY *funcname_a, *bash_source_a, *bash_lineno_a;
|
||||
# if defined (DEBUGGER)
|
||||
SHELL_VAR *bash_argv_v, *bash_argc_v;
|
||||
ARRAY *bash_argv_a, *bash_argc_a;
|
||||
# endif
|
||||
char *t, tt[2];
|
||||
#endif
|
||||
|
||||
USE_VAR(pflags);
|
||||
|
||||
#if defined (ARRAY_VARS)
|
||||
GET_ARRAY_FROM_VAR ("FUNCNAME", funcname_v, funcname_a);
|
||||
GET_ARRAY_FROM_VAR ("BASH_SOURCE", bash_source_v, bash_source_a);
|
||||
GET_ARRAY_FROM_VAR ("BASH_LINENO", bash_lineno_v, bash_lineno_a);
|
||||
# if defined (DEBUGGER)
|
||||
GET_ARRAY_FROM_VAR ("BASH_ARGV", bash_argv_v, bash_argv_a);
|
||||
GET_ARRAY_FROM_VAR ("BASH_ARGC", bash_argc_v, bash_argc_a);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
fd = open (filename, O_RDONLY);
|
||||
|
||||
if (fd < 0 || (fstat (fd, &finfo) == -1))
|
||||
|
@ -104,12 +131,12 @@ file_error_and_exit:
|
|||
|
||||
if (S_ISDIR (finfo.st_mode))
|
||||
{
|
||||
(*errfunc) ("%s: is a directory", filename);
|
||||
(*errfunc) (_("%s: is a directory"), filename);
|
||||
return ((flags & FEVAL_BUILTIN) ? EXECUTION_FAILURE : -1);
|
||||
}
|
||||
else if ((flags & FEVAL_REGFILE) && S_ISREG (finfo.st_mode) == 0)
|
||||
{
|
||||
(*errfunc) ("%s: not a regular file", filename);
|
||||
(*errfunc) (_("%s: not a regular file"), filename);
|
||||
return ((flags & FEVAL_BUILTIN) ? EXECUTION_FAILURE : -1);
|
||||
}
|
||||
|
||||
|
@ -117,7 +144,7 @@ file_error_and_exit:
|
|||
/* Check for overflow with large files. */
|
||||
if (file_size != finfo.st_size || file_size + 1 < file_size)
|
||||
{
|
||||
(*errfunc) ("%s: file is too large", filename);
|
||||
(*errfunc) (_("%s: file is too large"), filename);
|
||||
return ((flags & FEVAL_BUILTIN) ? EXECUTION_FAILURE : -1);
|
||||
}
|
||||
|
||||
|
@ -125,31 +152,37 @@ file_error_and_exit:
|
|||
setmode (fd, O_TEXT);
|
||||
#endif
|
||||
|
||||
string = (char *)xmalloc (1 + file_size);
|
||||
result = read (fd, string, file_size);
|
||||
string[result] = '\0';
|
||||
if (S_ISREG (finfo.st_mode) && file_size <= SSIZE_MAX)
|
||||
{
|
||||
string = (char *)xmalloc (1 + file_size);
|
||||
nr = read (fd, string, file_size);
|
||||
if (nr >= 0)
|
||||
string[nr] = '\0';
|
||||
}
|
||||
else
|
||||
nr = zmapfd (fd, &string, 0);
|
||||
|
||||
return_val = errno;
|
||||
close (fd);
|
||||
errno = return_val;
|
||||
|
||||
if (result < 0) /* XXX was != file_size, not < 0 */
|
||||
if (nr < 0) /* XXX was != file_size, not < 0 */
|
||||
{
|
||||
free (string);
|
||||
goto file_error_and_exit;
|
||||
}
|
||||
|
||||
if (result == 0)
|
||||
if (nr == 0)
|
||||
{
|
||||
free (string);
|
||||
return ((flags & FEVAL_BUILTIN) ? EXECUTION_SUCCESS : 1);
|
||||
}
|
||||
|
||||
if ((flags & FEVAL_CHECKBINARY) &&
|
||||
check_binary_file (string, (result > 80) ? 80 : result))
|
||||
check_binary_file (string, (nr > 80) ? 80 : nr))
|
||||
{
|
||||
free (string);
|
||||
(*errfunc) ("%s: cannot execute binary file", filename);
|
||||
(*errfunc) (_("%s: cannot execute binary file"), filename);
|
||||
return ((flags & FEVAL_BUILTIN) ? EX_BINARY_FILE : -1);
|
||||
}
|
||||
|
||||
|
@ -176,8 +209,27 @@ file_error_and_exit:
|
|||
return_catch_flag++;
|
||||
sourcelevel++;
|
||||
|
||||
#if defined (ARRAY_VARS)
|
||||
array_push (bash_source_a, (char *)filename);
|
||||
t = itos (executing_line_number ());
|
||||
array_push (bash_lineno_a, t);
|
||||
free (t);
|
||||
array_push (funcname_a, "source"); /* not exactly right */
|
||||
# if defined (DEBUGGER)
|
||||
/* Have to figure out a better way to do this when `source' is supplied
|
||||
arguments */
|
||||
if ((flags & FEVAL_NOPUSHARGS) == 0)
|
||||
{
|
||||
array_push (bash_argv_a, (char *)filename);
|
||||
tt[0] = '1'; tt[1] = '\0';
|
||||
array_push (bash_argc_a, tt);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* set the flags to be passed to parse_and_execute */
|
||||
pflags = (flags & FEVAL_HISTORY) ? 0 : SEVAL_NOHIST;
|
||||
pflags = SEVAL_RESETLINE;
|
||||
pflags |= (flags & FEVAL_HISTORY) ? 0 : SEVAL_NOHIST;
|
||||
|
||||
if (flags & FEVAL_BUILTIN)
|
||||
result = EXECUTION_SUCCESS;
|
||||
|
@ -205,6 +257,26 @@ file_error_and_exit:
|
|||
COPY_PROCENV (old_return_catch, return_catch);
|
||||
}
|
||||
|
||||
#if defined (ARRAY_VARS)
|
||||
/* These two variables cannot be unset, and cannot be affected by the
|
||||
sourced file. */
|
||||
array_pop (bash_source_a);
|
||||
array_pop (bash_lineno_a);
|
||||
|
||||
/* FUNCNAME can be unset, and so can potentially be changed by the
|
||||
sourced file. */
|
||||
GET_ARRAY_FROM_VAR ("FUNCNAME", nfv, funcname_a);
|
||||
if (nfv == funcname_v)
|
||||
array_pop (funcname_a);
|
||||
# if defined (DEBUGGER)
|
||||
if ((flags & FEVAL_NOPUSHARGS) == 0)
|
||||
{
|
||||
array_pop (bash_argc_a);
|
||||
array_pop (bash_argv_a);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
return ((flags & FEVAL_BUILTIN) ? result : 1);
|
||||
}
|
||||
|
||||
|
@ -240,14 +312,20 @@ fc_execute_file (filename)
|
|||
#endif /* HISTORY */
|
||||
|
||||
int
|
||||
source_file (filename)
|
||||
source_file (filename, sflags)
|
||||
const char *filename;
|
||||
int sflags;
|
||||
{
|
||||
int flags;
|
||||
int flags, rval;
|
||||
|
||||
flags = FEVAL_BUILTIN|FEVAL_UNWINDPROT|FEVAL_NONINT;
|
||||
if (sflags)
|
||||
flags |= FEVAL_NOPUSHARGS;
|
||||
/* POSIX shells exit if non-interactive and file error. */
|
||||
if (posixly_correct && !interactive_shell)
|
||||
flags |= FEVAL_LONGJMP;
|
||||
return (_evalfile (filename, flags));
|
||||
rval = _evalfile (filename, flags);
|
||||
|
||||
run_return_trap ();
|
||||
return rval;
|
||||
}
|
||||
|
|
|
@ -1,20 +1,22 @@
|
|||
/* Copyright (C) 1996 Free Software Foundation, Inc.
|
||||
/* evalstring.c - evaluate a string as one or more shell commands.
|
||||
|
||||
/* Copyright (C) 1996-2009 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 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 3 of the License, 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. */
|
||||
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. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
@ -42,6 +44,8 @@
|
|||
#include "../redir.h"
|
||||
#include "../trap.h"
|
||||
|
||||
#include <y.tab.h>
|
||||
|
||||
#if defined (HISTORY)
|
||||
# include "../bashhist.h"
|
||||
#endif
|
||||
|
@ -54,16 +58,31 @@ extern int errno;
|
|||
|
||||
#define IS_BUILTIN(s) (builtin_address_internal(s, 0) != (struct builtin *)NULL)
|
||||
|
||||
extern int indirection_level, startup_state, subshell_environment;
|
||||
extern int indirection_level, subshell_environment;
|
||||
extern int line_number;
|
||||
extern int current_token, shell_eof_token;
|
||||
extern int last_command_exit_value;
|
||||
extern int running_trap;
|
||||
extern int loop_level;
|
||||
extern int executing_list;
|
||||
extern int comsub_ignore_return;
|
||||
extern int posixly_correct;
|
||||
|
||||
int parse_and_execute_level = 0;
|
||||
|
||||
static int cat_file __P((REDIRECT *));
|
||||
|
||||
#define PE_TAG "parse_and_execute top"
|
||||
#define PS_TAG "parse_string top"
|
||||
|
||||
#if defined (HISTORY)
|
||||
static void
|
||||
set_history_remembering ()
|
||||
{
|
||||
remember_on_history = enable_history_list;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* How to force parse_and_execute () to clean up after itself. */
|
||||
void
|
||||
parse_and_execute_cleanup ()
|
||||
|
@ -73,47 +92,43 @@ parse_and_execute_cleanup ()
|
|||
run_trap_cleanup (running_trap - 1);
|
||||
unfreeze_jobs_list ();
|
||||
}
|
||||
run_unwind_frame ("parse_and_execute_top");
|
||||
|
||||
if (have_unwind_protects ())
|
||||
run_unwind_frame (PE_TAG);
|
||||
else
|
||||
parse_and_execute_level = 0; /* XXX */
|
||||
}
|
||||
|
||||
/* Parse and execute the commands in STRING. Returns whatever
|
||||
execute_command () returns. This frees STRING. FLAGS is a
|
||||
flags word; look in common.h for the possible values. Actions
|
||||
are:
|
||||
(flags & SEVAL_NONINT) -> interactive = 0;
|
||||
(flags & SEVAL_INTERACT) -> interactive = 1;
|
||||
(flags & SEVAL_NOHIST) -> call bash_history_disable ()
|
||||
(flags & SEVAL_NOFREE) -> don't free STRING when finished
|
||||
*/
|
||||
|
||||
int
|
||||
parse_and_execute (string, from_file, flags)
|
||||
static void
|
||||
parse_prologue (string, flags, tag)
|
||||
char *string;
|
||||
const char *from_file;
|
||||
int flags;
|
||||
char *tag;
|
||||
{
|
||||
int code, x;
|
||||
volatile int should_jump_to_top_level, last_result;
|
||||
char *orig_string;
|
||||
COMMAND *volatile command;
|
||||
int x;
|
||||
|
||||
orig_string = string;
|
||||
/* Unwind protect this invocation of parse_and_execute (). */
|
||||
begin_unwind_frame ("parse_and_execute_top");
|
||||
begin_unwind_frame (tag);
|
||||
unwind_protect_int (parse_and_execute_level);
|
||||
unwind_protect_jmp_buf (top_level);
|
||||
unwind_protect_int (indirection_level);
|
||||
unwind_protect_int (line_number);
|
||||
unwind_protect_int (loop_level);
|
||||
unwind_protect_int (executing_list);
|
||||
unwind_protect_int (comsub_ignore_return);
|
||||
if (flags & (SEVAL_NONINT|SEVAL_INTERACT))
|
||||
unwind_protect_int (interactive);
|
||||
|
||||
#if defined (HISTORY)
|
||||
unwind_protect_int (remember_on_history); /* can be used in scripts */
|
||||
if (parse_and_execute_level == 0)
|
||||
add_unwind_protect (set_history_remembering, (char *)NULL);
|
||||
else
|
||||
unwind_protect_int (remember_on_history); /* can be used in scripts */
|
||||
# if defined (BANG_HISTORY)
|
||||
if (interactive_shell)
|
||||
{
|
||||
unwind_protect_int (history_expansion_inhibited);
|
||||
}
|
||||
unwind_protect_int (history_expansion_inhibited);
|
||||
# endif /* BANG_HISTORY */
|
||||
#endif /* HISTORY */
|
||||
|
||||
|
@ -128,9 +143,6 @@ parse_and_execute (string, from_file, flags)
|
|||
add_unwind_protect (xfree, orig_string);
|
||||
end_unwind_frame ();
|
||||
|
||||
parse_and_execute_level++;
|
||||
push_stream (1); /* reset the line number */
|
||||
indirection_level++;
|
||||
if (flags & (SEVAL_NONINT|SEVAL_INTERACT))
|
||||
interactive = (flags & SEVAL_NONINT) ? 0 : 1;
|
||||
|
||||
|
@ -138,14 +150,53 @@ parse_and_execute (string, from_file, flags)
|
|||
if (flags & SEVAL_NOHIST)
|
||||
bash_history_disable ();
|
||||
#endif /* HISTORY */
|
||||
}
|
||||
|
||||
/* Parse and execute the commands in STRING. Returns whatever
|
||||
execute_command () returns. This frees STRING. FLAGS is a
|
||||
flags word; look in common.h for the possible values. Actions
|
||||
are:
|
||||
(flags & SEVAL_NONINT) -> interactive = 0;
|
||||
(flags & SEVAL_INTERACT) -> interactive = 1;
|
||||
(flags & SEVAL_NOHIST) -> call bash_history_disable ()
|
||||
(flags & SEVAL_NOFREE) -> don't free STRING when finished
|
||||
(flags & SEVAL_RESETLINE) -> reset line_number to 1
|
||||
*/
|
||||
|
||||
int
|
||||
parse_and_execute (string, from_file, flags)
|
||||
char *string;
|
||||
const char *from_file;
|
||||
int flags;
|
||||
{
|
||||
int code, lreset;
|
||||
volatile int should_jump_to_top_level, last_result;
|
||||
COMMAND *volatile command;
|
||||
|
||||
parse_prologue (string, flags, PE_TAG);
|
||||
|
||||
parse_and_execute_level++;
|
||||
|
||||
lreset = flags & SEVAL_RESETLINE;
|
||||
|
||||
/* Reset the line number if the caller wants us to. If we don't reset the
|
||||
line number, we have to subtract one, because we will add one just
|
||||
before executing the next command (resetting the line number sets it to
|
||||
0; the first line number is 1). */
|
||||
push_stream (lreset);
|
||||
if (lreset == 0)
|
||||
line_number--;
|
||||
|
||||
indirection_level++;
|
||||
|
||||
code = should_jump_to_top_level = 0;
|
||||
last_result = EXECUTION_SUCCESS;
|
||||
command = (COMMAND *)NULL;
|
||||
|
||||
with_input_from_string (string, from_file);
|
||||
while (*(bash_input.location.string))
|
||||
{
|
||||
command = (COMMAND *)NULL;
|
||||
|
||||
if (interrupt_state)
|
||||
{
|
||||
last_result = EXECUTION_FAILURE;
|
||||
|
@ -163,15 +214,18 @@ parse_and_execute (string, from_file, flags)
|
|||
switch (code)
|
||||
{
|
||||
case FORCE_EOF:
|
||||
case ERREXIT:
|
||||
case EXITPROG:
|
||||
run_unwind_frame ("pe_dispose");
|
||||
if (command)
|
||||
run_unwind_frame ("pe_dispose");
|
||||
/* Remember to call longjmp (top_level) after the old
|
||||
value for it is restored. */
|
||||
should_jump_to_top_level = 1;
|
||||
goto out;
|
||||
|
||||
case DISCARD:
|
||||
run_unwind_frame ("pe_dispose");
|
||||
if (command)
|
||||
run_unwind_frame ("pe_dispose");
|
||||
last_result = last_command_exit_value = EXECUTION_FAILURE; /* XXX */
|
||||
if (subshell_environment)
|
||||
{
|
||||
|
@ -194,7 +248,7 @@ parse_and_execute (string, from_file, flags)
|
|||
|
||||
if (parse_command () == 0)
|
||||
{
|
||||
if (interactive_shell == 0 && read_but_dont_execute)
|
||||
if ((flags & SEVAL_PARSEONLY) || (interactive_shell == 0 && read_but_dont_execute))
|
||||
{
|
||||
last_result = EXECUTION_SUCCESS;
|
||||
dispose_command (global_command);
|
||||
|
@ -211,22 +265,31 @@ parse_and_execute (string, from_file, flags)
|
|||
|
||||
global_command = (COMMAND *)NULL;
|
||||
|
||||
if ((subshell_environment & SUBSHELL_COMSUB) && comsub_ignore_return)
|
||||
command->flags |= CMD_IGNORE_RETURN;
|
||||
|
||||
#if defined (ONESHOT)
|
||||
/*
|
||||
* IF
|
||||
* we were invoked as `bash -c' (startup_state == 2) AND
|
||||
* parse_and_execute has not been called recursively AND
|
||||
* we're not running a trap AND
|
||||
* we have parsed the full command (string == '\0') AND
|
||||
* we're not going to run the exit trap AND
|
||||
* we have a simple command without redirections AND
|
||||
* the command is not being timed
|
||||
* the command is not being timed AND
|
||||
* the command's return status is not being inverted
|
||||
* THEN
|
||||
* tell the execution code that we don't need to fork
|
||||
*/
|
||||
if (startup_state == 2 && parse_and_execute_level == 1 &&
|
||||
running_trap == 0 &&
|
||||
*bash_input.location.string == '\0' &&
|
||||
command->type == cm_simple &&
|
||||
!command->redirects && !command->value.Simple->redirects &&
|
||||
((command->flags & CMD_TIME_PIPELINE) == 0))
|
||||
signal_is_trapped (EXIT_TRAP) == 0 &&
|
||||
command->redirects == 0 && command->value.Simple->redirects == 0 &&
|
||||
((command->flags & CMD_TIME_PIPELINE) == 0) &&
|
||||
((command->flags & CMD_INVERT_RETURN) == 0))
|
||||
{
|
||||
command->flags |= CMD_NO_FORK;
|
||||
command->value.Simple->flags |= CMD_NO_FORK;
|
||||
|
@ -269,7 +332,7 @@ parse_and_execute (string, from_file, flags)
|
|||
|
||||
out:
|
||||
|
||||
run_unwind_frame ("parse_and_execute_top");
|
||||
run_unwind_frame (PE_TAG);
|
||||
|
||||
if (interrupt_state && parse_and_execute_level == 0)
|
||||
{
|
||||
|
@ -286,6 +349,110 @@ parse_and_execute (string, from_file, flags)
|
|||
return (last_result);
|
||||
}
|
||||
|
||||
/* Parse a command contained in STRING according to FLAGS and return the
|
||||
number of characters consumed from the string. If non-NULL, set *ENDP
|
||||
to the position in the string where the parse ended. Used to validate
|
||||
command substitutions during parsing to obey Posix rules about finding
|
||||
the end of the command and balancing parens. */
|
||||
int
|
||||
parse_string (string, from_file, flags, endp)
|
||||
char *string;
|
||||
const char *from_file;
|
||||
int flags;
|
||||
char **endp;
|
||||
{
|
||||
int code, nc;
|
||||
volatile int should_jump_to_top_level;
|
||||
COMMAND *volatile command, *oglobal;
|
||||
char *ostring;
|
||||
|
||||
parse_prologue (string, flags, PS_TAG);
|
||||
|
||||
/* Reset the line number if the caller wants us to. If we don't reset the
|
||||
line number, we have to subtract one, because we will add one just
|
||||
before executing the next command (resetting the line number sets it to
|
||||
0; the first line number is 1). */
|
||||
push_stream (0);
|
||||
|
||||
code = should_jump_to_top_level = 0;
|
||||
oglobal = global_command;
|
||||
ostring = string;
|
||||
|
||||
with_input_from_string (string, from_file);
|
||||
while (*(bash_input.location.string))
|
||||
{
|
||||
command = (COMMAND *)NULL;
|
||||
|
||||
#if 0
|
||||
if (interrupt_state)
|
||||
break;
|
||||
#endif
|
||||
|
||||
/* Provide a location for functions which `longjmp (top_level)' to
|
||||
jump to. */
|
||||
code = setjmp (top_level);
|
||||
|
||||
if (code)
|
||||
{
|
||||
#if defined (DEBUG)
|
||||
itrace("parse_string: longjmp executed: code = %d", code);
|
||||
#endif
|
||||
should_jump_to_top_level = 0;
|
||||
switch (code)
|
||||
{
|
||||
case FORCE_EOF:
|
||||
case ERREXIT:
|
||||
case EXITPROG:
|
||||
case DISCARD: /* XXX */
|
||||
if (command)
|
||||
dispose_command (command);
|
||||
/* Remember to call longjmp (top_level) after the old
|
||||
value for it is restored. */
|
||||
should_jump_to_top_level = 1;
|
||||
goto out;
|
||||
|
||||
default:
|
||||
command_error ("parse_string", CMDERR_BADJUMP, code, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (parse_command () == 0)
|
||||
{
|
||||
dispose_command (global_command);
|
||||
global_command = (COMMAND *)NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((flags & SEVAL_NOLONGJMP) == 0)
|
||||
{
|
||||
should_jump_to_top_level = 1;
|
||||
code = DISCARD;
|
||||
}
|
||||
else
|
||||
reset_parser (); /* XXX - sets token_to_read */
|
||||
break;
|
||||
}
|
||||
|
||||
if (current_token == yacc_EOF || current_token == shell_eof_token)
|
||||
break;
|
||||
}
|
||||
|
||||
out:
|
||||
|
||||
global_command = oglobal;
|
||||
nc = bash_input.location.string - ostring;
|
||||
if (endp)
|
||||
*endp = bash_input.location.string;
|
||||
|
||||
run_unwind_frame (PS_TAG);
|
||||
|
||||
if (should_jump_to_top_level)
|
||||
jump_to_top_level (code);
|
||||
|
||||
return (nc);
|
||||
}
|
||||
|
||||
/* Handle a $( < file ) command substitution. This expands the filename,
|
||||
returning errors as appropriate, then just cats the file to the standard
|
||||
output. */
|
||||
|
@ -293,9 +460,8 @@ static int
|
|||
cat_file (r)
|
||||
REDIRECT *r;
|
||||
{
|
||||
char lbuf[128], *fn;
|
||||
char *fn;
|
||||
int fd, rval;
|
||||
ssize_t nr;
|
||||
|
||||
if (r->instruction != r_input_direction)
|
||||
return -1;
|
||||
|
|
|
@ -1,37 +1,44 @@
|
|||
This file is exec.def, from which is created exec.c.
|
||||
It implements the builtin "exec" in Bash.
|
||||
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES exec.c
|
||||
|
||||
$BUILTIN exec
|
||||
$FUNCTION exec_builtin
|
||||
$SHORT_DOC exec [-cl] [-a name] file [redirection ...]
|
||||
Exec FILE, replacing this shell with the specified program.
|
||||
If FILE is not specified, the redirections take effect in this
|
||||
shell. If the first argument is `-l', then place a dash in the
|
||||
zeroth arg passed to FILE, as login does. If the `-c' option
|
||||
is supplied, FILE is executed with a null environment. The `-a'
|
||||
option means to make set argv[0] of the executed process to NAME.
|
||||
If the file cannot be executed and the shell is not interactive,
|
||||
then the shell exits, unless the shell option `execfail' is set.
|
||||
$SHORT_DOC exec [-cl] [-a name] [command [arguments ...]] [redirection ...]
|
||||
Replace the shell with the given command.
|
||||
|
||||
Execute COMMAND, replacing this shell with the specified program.
|
||||
ARGUMENTS become the arguments to COMMAND. If COMMAND is not specified,
|
||||
any redirections take effect in the current shell.
|
||||
|
||||
Options:
|
||||
-a name pass NAME as the zeroth argument to COMMAND
|
||||
-c execute COMMAND with an empty environment
|
||||
-l place a dash in the zeroth argument to COMMAND
|
||||
|
||||
If the command cannot be executed, a non-interactive shell exits, unless
|
||||
the shell option `execfail' is set.
|
||||
|
||||
Exit Status:
|
||||
Returns success unless COMMAND is not found or a redirection error occurs.
|
||||
$END
|
||||
|
||||
#include <config.h>
|
||||
|
@ -46,6 +53,7 @@ $END
|
|||
#endif
|
||||
|
||||
#include "../bashansi.h"
|
||||
#include "../bashintl.h"
|
||||
|
||||
#include "../shell.h"
|
||||
#include "../execute_cmd.h"
|
||||
|
@ -201,15 +209,14 @@ exec_builtin (list)
|
|||
|
||||
if (executable_file (command) == 0)
|
||||
{
|
||||
builtin_error ("%s: cannot execute: %s", command, strerror (errno));
|
||||
builtin_error (_("%s: cannot execute: %s"), command, strerror (errno));
|
||||
exit_value = EX_NOEXEC; /* As per Posix.2, 3.14.6 */
|
||||
}
|
||||
else
|
||||
file_error (command);
|
||||
|
||||
failed_exec:
|
||||
if (command)
|
||||
free (command);
|
||||
FREE (command);
|
||||
|
||||
if (subshell_environment || (interactive == 0 && no_exit_on_failed_exec == 0))
|
||||
exit_shell (exit_value);
|
||||
|
@ -221,7 +228,8 @@ failed_exec:
|
|||
initialize_signals (1);
|
||||
|
||||
#if defined (JOB_CONTROL)
|
||||
restart_job_control ();
|
||||
if (interactive_shell || job_control)
|
||||
restart_job_control ();
|
||||
#endif /* JOB_CONTROL */
|
||||
|
||||
return (exit_value);
|
||||
|
|
|
@ -1,30 +1,31 @@
|
|||
This file is exit.def, from which is created exit.c.
|
||||
It implements the builtins "exit", and "logout" in Bash.
|
||||
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES exit.c
|
||||
|
||||
$BUILTIN exit
|
||||
$FUNCTION exit_builtin
|
||||
$SHORT_DOC exit [n]
|
||||
Exit the shell with a status of N. If N is omitted, the exit status
|
||||
Exit the shell.
|
||||
|
||||
Exits the shell with a status of N. If N is omitted, the exit status
|
||||
is that of the last command executed.
|
||||
$END
|
||||
|
||||
|
@ -37,13 +38,17 @@ $END
|
|||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "../bashintl.h"
|
||||
|
||||
#include "../shell.h"
|
||||
#include "../jobs.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "builtext.h" /* for jobs_builtin */
|
||||
|
||||
extern int check_jobs_at_exit;
|
||||
extern int last_command_exit_value;
|
||||
extern int running_trap, trap_saved_exit_value;
|
||||
extern int subshell_environment;
|
||||
extern sh_builtin_func_t *this_shell_builtin;
|
||||
extern sh_builtin_func_t *last_shell_builtin;
|
||||
|
@ -57,7 +62,7 @@ exit_builtin (list)
|
|||
{
|
||||
if (interactive)
|
||||
{
|
||||
fprintf (stderr, login_shell ? "logout\n" : "exit\n");
|
||||
fprintf (stderr, login_shell ? _("logout\n") : "exit\n");
|
||||
fflush (stderr);
|
||||
}
|
||||
|
||||
|
@ -66,8 +71,11 @@ exit_builtin (list)
|
|||
|
||||
$BUILTIN logout
|
||||
$FUNCTION logout_builtin
|
||||
$SHORT_DOC logout
|
||||
Logout of a login shell.
|
||||
$SHORT_DOC logout [n]
|
||||
Exit a login shell.
|
||||
|
||||
Exits a login shell with exit status N. Returns an error if not executed
|
||||
in a login shell.
|
||||
$END
|
||||
|
||||
/* How to logout. */
|
||||
|
@ -77,7 +85,7 @@ logout_builtin (list)
|
|||
{
|
||||
if (login_shell == 0 /* && interactive */)
|
||||
{
|
||||
builtin_error ("not login shell: use `exit'");
|
||||
builtin_error (_("not login shell: use `exit'"));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
else
|
||||
|
@ -91,7 +99,7 @@ exit_or_logout (list)
|
|||
int exit_value;
|
||||
|
||||
#if defined (JOB_CONTROL)
|
||||
int exit_immediate_okay;
|
||||
int exit_immediate_okay, stopmsg;
|
||||
|
||||
exit_immediate_okay = (interactive == 0 ||
|
||||
last_shell_builtin == exit_builtin ||
|
||||
|
@ -99,29 +107,56 @@ exit_or_logout (list)
|
|||
last_shell_builtin == jobs_builtin);
|
||||
|
||||
/* Check for stopped jobs if the user wants to. */
|
||||
if (!exit_immediate_okay)
|
||||
if (exit_immediate_okay == 0)
|
||||
{
|
||||
register int i;
|
||||
for (i = 0; i < job_slots; i++)
|
||||
for (i = stopmsg = 0; i < js.j_jobslots; i++)
|
||||
if (jobs[i] && STOPPED (i))
|
||||
{
|
||||
fprintf (stderr, "There are stopped jobs.\n");
|
||||
stopmsg = JSTOPPED;
|
||||
else if (check_jobs_at_exit && stopmsg == 0 && RUNNING (i))
|
||||
stopmsg = JRUNNING;
|
||||
|
||||
/* This is NOT superfluous because EOF can get here without
|
||||
going through the command parser. Set both last and this
|
||||
so that either `exit', `logout', or ^D will work to exit
|
||||
immediately if nothing intervenes. */
|
||||
this_shell_builtin = last_shell_builtin = exit_builtin;
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
if (stopmsg == JSTOPPED)
|
||||
fprintf (stderr, _("There are stopped jobs.\n"));
|
||||
else if (stopmsg == JRUNNING)
|
||||
fprintf (stderr, _("There are running jobs.\n"));
|
||||
|
||||
if (stopmsg && check_jobs_at_exit)
|
||||
list_all_jobs (JLIST_STANDARD);
|
||||
|
||||
if (stopmsg)
|
||||
{
|
||||
/* This is NOT superfluous because EOF can get here without
|
||||
going through the command parser. Set both last and this
|
||||
so that either `exit', `logout', or ^D will work to exit
|
||||
immediately if nothing intervenes. */
|
||||
this_shell_builtin = last_shell_builtin = exit_builtin;
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
}
|
||||
#endif /* JOB_CONTROL */
|
||||
|
||||
/* Get return value if present. This means that you can type
|
||||
`logout 5' to a shell, and it returns 5. */
|
||||
|
||||
exit_value = get_exitstat (list);
|
||||
/* If we're running the exit trap (running_trap == 1, since running_trap
|
||||
gets set to SIG+1), and we don't have a argument given to `exit'
|
||||
(list == 0), use the exit status we saved before running the trap
|
||||
commands (trap_saved_exit_value). */
|
||||
exit_value = (running_trap == 1 && list == 0) ? trap_saved_exit_value : get_exitstat (list);
|
||||
|
||||
bash_logout ();
|
||||
|
||||
last_command_exit_value = exit_value;
|
||||
|
||||
/* Exit the program. */
|
||||
jump_to_top_level (EXITPROG);
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
void
|
||||
bash_logout ()
|
||||
{
|
||||
/* Run our `~/.bash_logout' file if it exists, and this is a login shell. */
|
||||
if (login_shell && sourced_logout++ == 0 && subshell_environment == 0)
|
||||
{
|
||||
|
@ -130,10 +165,4 @@ exit_or_logout (list)
|
|||
maybe_execute_file (SYS_BASH_LOGOUT, 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
last_command_exit_value = exit_value;
|
||||
|
||||
/* Exit the program. */
|
||||
jump_to_top_level (EXITPROG);
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
|
|
@ -1,60 +1,63 @@
|
|||
This file is fc.def, from which is created fc.c.
|
||||
It implements the builtin "fc" in Bash.
|
||||
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES fc.c
|
||||
|
||||
$BUILTIN fc
|
||||
$FUNCTION fc_builtin
|
||||
$DEPENDS_ON HISTORY
|
||||
$SHORT_DOC fc [-e ename] [-nlr] [first] [last] or fc -s [pat=rep] [cmd]
|
||||
$SHORT_DOC fc [-e ename] [-lnr] [first] [last] or fc -s [pat=rep] [command]
|
||||
Display or execute commands from the history list.
|
||||
|
||||
fc is used to list or edit and re-execute commands from the history list.
|
||||
FIRST and LAST can be numbers specifying the range, or FIRST can be a
|
||||
string, which means the most recent command beginning with that
|
||||
string.
|
||||
|
||||
-e ENAME selects which editor to use. Default is FCEDIT, then EDITOR,
|
||||
then vi.
|
||||
Options:
|
||||
-e ENAME select which editor to use. Default is FCEDIT, then EDITOR,
|
||||
then vi
|
||||
-l list lines instead of editing
|
||||
-n omit line numbers when listing
|
||||
-r reverse the order of the lines (newest listed first)
|
||||
|
||||
-l means list lines instead of editing.
|
||||
-n means no line numbers listed.
|
||||
-r means reverse the order of the lines (making it newest listed first).
|
||||
|
||||
With the `fc -s [pat=rep ...] [command]' format, the command is
|
||||
With the `fc -s [pat=rep ...] [command]' format, COMMAND is
|
||||
re-executed after the substitution OLD=NEW is performed.
|
||||
|
||||
A useful alias to use with this is r='fc -s', so that typing `r cc'
|
||||
runs the last command beginning with `cc' and typing `r' re-executes
|
||||
the last command.
|
||||
|
||||
Exit Status:
|
||||
Returns success or status of executed command; non-zero if an error occurs.
|
||||
$END
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#if defined (HISTORY)
|
||||
#if defined (HAVE_SYS_PARAM_H)
|
||||
#ifndef _MINIX
|
||||
# include <sys/param.h>
|
||||
#endif
|
||||
#include "../bashtypes.h"
|
||||
#include "posixstat.h"
|
||||
#if defined (HAVE_SYS_FILE_H)
|
||||
#if ! defined(_MINIX) && defined (HAVE_SYS_FILE_H)
|
||||
# include <sys/file.h>
|
||||
#endif
|
||||
|
||||
|
@ -66,6 +69,7 @@ $END
|
|||
#include <chartypes.h>
|
||||
|
||||
#include "../bashansi.h"
|
||||
#include "../bashintl.h"
|
||||
#include <errno.h>
|
||||
|
||||
#include "../shell.h"
|
||||
|
@ -81,9 +85,9 @@ $END
|
|||
extern int errno;
|
||||
#endif /* !errno */
|
||||
|
||||
extern int echo_input_at_read;
|
||||
extern int current_command_line_count;
|
||||
extern int literal_history;
|
||||
extern int posixly_correct;
|
||||
|
||||
extern int unlink __P((const char *));
|
||||
|
||||
|
@ -155,6 +159,11 @@ static void fc_addhist __P((char *));
|
|||
|
||||
/* String to execute on a file that we want to edit. */
|
||||
#define FC_EDIT_COMMAND "${FCEDIT:-${EDITOR:-vi}}"
|
||||
#if defined (STRICT_POSIX)
|
||||
# define POSIX_FC_EDIT_COMMAND "${FCEDIT:-ed}"
|
||||
#else
|
||||
# define POSIX_FC_EDIT_COMMAND "${FCEDIT:-${EDITOR:-ed}}"
|
||||
#endif
|
||||
|
||||
int
|
||||
fc_builtin (list)
|
||||
|
@ -166,7 +175,7 @@ fc_builtin (list)
|
|||
int histbeg, histend, last_hist, retval, opt;
|
||||
FILE *stream;
|
||||
REPL *rlist, *rl;
|
||||
char *ename, *command, *newcom;
|
||||
char *ename, *command, *newcom, *fcedit;
|
||||
HIST_ENTRY **hlist;
|
||||
char *fn;
|
||||
|
||||
|
@ -249,7 +258,7 @@ fc_builtin (list)
|
|||
|
||||
if (command == NULL)
|
||||
{
|
||||
builtin_error ("no command found");
|
||||
builtin_error (_("no command found"));
|
||||
if (rlist)
|
||||
FREE_RLIST ();
|
||||
|
||||
|
@ -284,7 +293,7 @@ fc_builtin (list)
|
|||
line was actually added (HISTIGNORE may have caused it to not be),
|
||||
so we check hist_last_line_added. */
|
||||
|
||||
last_hist = i - 1 - hist_last_line_added;
|
||||
last_hist = i - remember_on_history - hist_last_line_added;
|
||||
|
||||
if (list)
|
||||
{
|
||||
|
@ -302,7 +311,7 @@ fc_builtin (list)
|
|||
if (listing)
|
||||
{
|
||||
histend = last_hist;
|
||||
histbeg = histend - 16;
|
||||
histbeg = histend - 16 + 1; /* +1 because loop below uses >= */
|
||||
if (histbeg < 0)
|
||||
histbeg = 0;
|
||||
}
|
||||
|
@ -311,10 +320,25 @@ fc_builtin (list)
|
|||
histbeg = histend = last_hist;
|
||||
}
|
||||
|
||||
/* "When not listing, the fc command that caused the editing shall not be
|
||||
entered into the history list." */
|
||||
if (listing == 0 && hist_last_line_added)
|
||||
{
|
||||
bash_delete_last_history ();
|
||||
/* If we're editing a single command -- the last command in the
|
||||
history -- and we just removed the dummy command added by
|
||||
edit_and_execute_command (), we need to check whether or not we
|
||||
just removed the last command in the history and need to back
|
||||
the pointer up. remember_on_history is off because we're running
|
||||
in parse_and_execute(). */
|
||||
if (histbeg == histend && histend == last_hist && hlist[last_hist] == 0)
|
||||
last_hist = histbeg = --histend;
|
||||
}
|
||||
|
||||
/* We print error messages for line specifications out of range. */
|
||||
if ((histbeg < 0) || (histend < 0))
|
||||
{
|
||||
sh_erange ((char *)NULL, "history specification");
|
||||
sh_erange ((char *)NULL, _("history specification"));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
|
@ -335,7 +359,7 @@ fc_builtin (list)
|
|||
stream = sh_mktmpfp ("bash-fc", MT_USERANDOM|MT_USETMPDIR, &fn);
|
||||
if (stream == 0)
|
||||
{
|
||||
builtin_error ("cannot open temp file %s", fn ? fn : "");
|
||||
builtin_error (_("%s: cannot open temp file: %s"), fn ? fn : "", strerror (errno));
|
||||
FREE (fn);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
@ -347,13 +371,25 @@ fc_builtin (list)
|
|||
if (numbering)
|
||||
fprintf (stream, "%d", i + history_base);
|
||||
if (listing)
|
||||
fprintf (stream, "\t%c", histdata (i) ? '*' : ' ');
|
||||
{
|
||||
if (posixly_correct)
|
||||
fputs ("\t", stream);
|
||||
else
|
||||
fprintf (stream, "\t%c", histdata (i) ? '*' : ' ');
|
||||
}
|
||||
fprintf (stream, "%s\n", histline (i));
|
||||
}
|
||||
|
||||
if (listing)
|
||||
return (EXECUTION_SUCCESS);
|
||||
return (sh_chkwrite (EXECUTION_SUCCESS));
|
||||
|
||||
fflush (stream);
|
||||
if (ferror (stream))
|
||||
{
|
||||
sh_wrerror ();
|
||||
fclose (stream);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
fclose (stream);
|
||||
|
||||
/* Now edit the file of commands. */
|
||||
|
@ -364,8 +400,9 @@ fc_builtin (list)
|
|||
}
|
||||
else
|
||||
{
|
||||
command = (char *)xmalloc (3 + strlen (FC_EDIT_COMMAND) + strlen (fn));
|
||||
sprintf (command, "%s %s", FC_EDIT_COMMAND, fn);
|
||||
fcedit = posixly_correct ? POSIX_FC_EDIT_COMMAND : FC_EDIT_COMMAND;
|
||||
command = (char *)xmalloc (3 + strlen (fcedit) + strlen (fn));
|
||||
sprintf (command, "%s %s", fcedit, fn);
|
||||
}
|
||||
retval = parse_and_execute (command, "fc", SEVAL_NOHIST);
|
||||
if (retval != EXECUTION_SUCCESS)
|
||||
|
@ -419,10 +456,11 @@ fc_gethnum (command, hlist)
|
|||
char *command;
|
||||
HIST_ENTRY **hlist;
|
||||
{
|
||||
int sign = 1, n, clen;
|
||||
int sign, n, clen;
|
||||
register int i, j;
|
||||
register char *s;
|
||||
|
||||
sign = 1;
|
||||
/* Count history elements. */
|
||||
for (i = 0; hlist[i]; i++);
|
||||
|
||||
|
@ -432,8 +470,9 @@ fc_gethnum (command, hlist)
|
|||
and makes the last command that this deals with be the last command
|
||||
the user entered before the fc. We need to check whether the
|
||||
line was actually added (HISTIGNORE may have caused it to not be),
|
||||
so we check hist_last_line_added. */
|
||||
i -= 1 + hist_last_line_added;
|
||||
so we check hist_last_line_added. This needs to agree with the
|
||||
calculation of last_hist in fc_builtin above. */
|
||||
i -= remember_on_history + hist_last_line_added;
|
||||
|
||||
/* No specification defaults to most recent command. */
|
||||
if (command == NULL)
|
||||
|
@ -489,7 +528,7 @@ fc_gethist (command, hlist)
|
|||
{
|
||||
int i;
|
||||
|
||||
if (!hlist)
|
||||
if (hlist == 0)
|
||||
return ((char *)NULL);
|
||||
|
||||
i = fc_gethnum (command, hlist);
|
||||
|
@ -573,41 +612,18 @@ static void
|
|||
fc_replhist (command)
|
||||
char *command;
|
||||
{
|
||||
register int i;
|
||||
HIST_ENTRY **hlist, *histent, *discard;
|
||||
int n;
|
||||
|
||||
if (command == 0 || *command == '\0')
|
||||
return;
|
||||
|
||||
hlist = history_list ();
|
||||
|
||||
if (hlist == NULL)
|
||||
return;
|
||||
|
||||
for (i = 0; hlist[i]; i++);
|
||||
i--;
|
||||
|
||||
/* History_get () takes a parameter that should be
|
||||
offset by history_base. */
|
||||
|
||||
histent = history_get (history_base + i); /* Don't free this */
|
||||
if (histent == NULL)
|
||||
return;
|
||||
|
||||
n = strlen (command);
|
||||
|
||||
if (command[n - 1] == '\n')
|
||||
command[n - 1] = '\0';
|
||||
|
||||
if (command && *command)
|
||||
{
|
||||
discard = remove_history (i);
|
||||
if (discard)
|
||||
{
|
||||
FREE (discard->line);
|
||||
free ((char *) discard);
|
||||
}
|
||||
bash_delete_last_history ();
|
||||
maybe_add_history (command); /* Obeys HISTCONTROL setting. */
|
||||
}
|
||||
}
|
||||
|
@ -620,13 +636,16 @@ fc_addhist (line)
|
|||
{
|
||||
register int n;
|
||||
|
||||
if (line == 0 || *line == 0)
|
||||
return;
|
||||
|
||||
n = strlen (line);
|
||||
|
||||
if (line[n - 1] == '\n')
|
||||
line[n - 1] = '\0';
|
||||
|
||||
if (line && *line)
|
||||
maybe_add_history (line);
|
||||
maybe_add_history (line); /* Obeys HISTCONTROL setting. */
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,23 +1,22 @@
|
|||
This file is fg_bg.def, from which is created fg_bg.c.
|
||||
It implements the builtins "bg" and "fg" in Bash.
|
||||
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES fg_bg.c
|
||||
|
||||
|
@ -25,9 +24,14 @@ $BUILTIN fg
|
|||
$FUNCTION fg_builtin
|
||||
$DEPENDS_ON JOB_CONTROL
|
||||
$SHORT_DOC fg [job_spec]
|
||||
Place JOB_SPEC in the foreground, and make it the current job. If
|
||||
JOB_SPEC is not present, the shell's notion of the current job is
|
||||
used.
|
||||
Move job to the foreground.
|
||||
|
||||
Place the job identified by JOB_SPEC in the foreground, making it the
|
||||
current job. If JOB_SPEC is not present, the shell's notion of the
|
||||
current job is used.
|
||||
|
||||
Exit Status:
|
||||
Status of command placed in foreground, or failure if an error occurs.
|
||||
$END
|
||||
|
||||
#include <config.h>
|
||||
|
@ -39,6 +43,8 @@ $END
|
|||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "../bashintl.h"
|
||||
|
||||
#include "../shell.h"
|
||||
#include "../jobs.h"
|
||||
#include "common.h"
|
||||
|
@ -80,10 +86,15 @@ fg_builtin (list)
|
|||
$BUILTIN bg
|
||||
$FUNCTION bg_builtin
|
||||
$DEPENDS_ON JOB_CONTROL
|
||||
$SHORT_DOC bg [job_spec]
|
||||
Place JOB_SPEC in the background, as if it had been started with
|
||||
`&'. If JOB_SPEC is not present, the shell's notion of the current
|
||||
job is used.
|
||||
$SHORT_DOC bg [job_spec ...]
|
||||
Move jobs to the background.
|
||||
|
||||
Place the jobs identified by each JOB_SPEC in the background, as if they
|
||||
had been started with `&'. If JOB_SPEC is not present, the shell's notion
|
||||
of the current job is used.
|
||||
|
||||
Exit Status:
|
||||
Returns success unless job control is not enabled or an error occurs.
|
||||
$END
|
||||
|
||||
#if defined (JOB_CONTROL)
|
||||
|
@ -92,6 +103,8 @@ int
|
|||
bg_builtin (list)
|
||||
WORD_LIST *list;
|
||||
{
|
||||
int r;
|
||||
|
||||
if (job_control == 0)
|
||||
{
|
||||
sh_nojobs ((char *)NULL);
|
||||
|
@ -102,7 +115,19 @@ bg_builtin (list)
|
|||
return (EX_USAGE);
|
||||
list = loptend;
|
||||
|
||||
return (fg_bg (list, 0));
|
||||
/* This relies on the fact that fg_bg() takes a WORD_LIST *, but only acts
|
||||
on the first member (if any) of that list. */
|
||||
r = EXECUTION_SUCCESS;
|
||||
do
|
||||
{
|
||||
if (fg_bg (list, 0) == EXECUTION_FAILURE)
|
||||
r = EXECUTION_FAILURE;
|
||||
if (list)
|
||||
list = list->next;
|
||||
}
|
||||
while (list);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/* How to put a job into the foreground/background. */
|
||||
|
@ -113,29 +138,31 @@ fg_bg (list, foreground)
|
|||
{
|
||||
sigset_t set, oset;
|
||||
int job, status, old_async_pid;
|
||||
JOB *j;
|
||||
|
||||
BLOCK_CHILD (set, oset);
|
||||
job = get_job_spec (list);
|
||||
|
||||
if (job < 0 || job >= job_slots || jobs[job] == 0)
|
||||
if (INVALID_JOB (job))
|
||||
{
|
||||
if (job != DUP_JOB)
|
||||
sh_badjob (list ? list->word->word : "current");
|
||||
sh_badjob (list ? list->word->word : _("current"));
|
||||
|
||||
goto failure;
|
||||
}
|
||||
|
||||
/* Or if jobs[job]->pgrp == shell_pgrp. */
|
||||
j = get_job_by_jid (job);
|
||||
/* Or if j->pgrp == shell_pgrp. */
|
||||
if (IS_JOBCONTROL (job) == 0)
|
||||
{
|
||||
builtin_error ("job %%%d started without job control", job + 1);
|
||||
builtin_error (_("job %d started without job control"), job + 1);
|
||||
goto failure;
|
||||
}
|
||||
|
||||
if (foreground == 0)
|
||||
{
|
||||
old_async_pid = last_asynchronous_pid;
|
||||
last_asynchronous_pid = jobs[job]->pgrp; /* As per Posix.2 5.4.2 */
|
||||
last_asynchronous_pid = j->pgrp; /* As per Posix.2 5.4.2 */
|
||||
}
|
||||
|
||||
status = start_job (job, foreground);
|
||||
|
@ -144,7 +171,7 @@ fg_bg (list, foreground)
|
|||
{
|
||||
/* win: */
|
||||
UNBLOCK_CHILD (oset);
|
||||
return (status);
|
||||
return (foreground ? status : EXECUTION_SUCCESS);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1,21 +1,22 @@
|
|||
/* getopt for BASH.
|
||||
/* getopt.c - getopt for Bash. Used by the getopt builtin. */
|
||||
|
||||
Copyright (C) 1993, 1994
|
||||
Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1993-2009 Free Software Foundation, Inc.
|
||||
|
||||
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, or (at your option) any
|
||||
later version.
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
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 3 of the License, 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 this program; if not, write to the Free Software
|
||||
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
@ -28,6 +29,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include "memalloc.h"
|
||||
#include "../bashintl.h"
|
||||
#include "../shell.h"
|
||||
#include "getopt.h"
|
||||
|
||||
|
@ -105,8 +107,8 @@ int sh_badopt = 0;
|
|||
ARGV-element, is returned in `sh_optarg'. */
|
||||
|
||||
/* 1003.2 specifies the format of this message. */
|
||||
#define BADOPT(x) fprintf (stderr, "%s: illegal option -- %c\n", argv[0], x)
|
||||
#define NEEDARG(x) fprintf (stderr, "%s: option requires an argument -- %c\n", argv[0], x)
|
||||
#define BADOPT(x) fprintf (stderr, _("%s: illegal option -- %c\n"), argv[0], x)
|
||||
#define NEEDARG(x) fprintf (stderr, _("%s: option requires an argument -- %c\n"), argv[0], x)
|
||||
|
||||
int
|
||||
sh_getopt (argc, argv, optstring)
|
||||
|
|
|
@ -1,19 +1,22 @@
|
|||
/* Declarations for getopt.
|
||||
Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
|
||||
/* getopt.h - declarations for getopt. */
|
||||
|
||||
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, or (at your option) any
|
||||
later version.
|
||||
/* Copyright (C) 1989, 1990, 1991, 1992, 1993, 2008,2009 Free Software Foundation, Inc.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
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 3 of the License, 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 this program; if not, write to the Free Software
|
||||
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* XXX THIS HAS BEEN MODIFIED FOR INCORPORATION INTO BASH XXX */
|
||||
|
||||
|
|
|
@ -1,30 +1,32 @@
|
|||
This file is getopts.def, from which is created getopts.c.
|
||||
It implements the builtin "getopts" in Bash.
|
||||
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2004 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES getopts.c
|
||||
|
||||
$BUILTIN getopts
|
||||
$FUNCTION getopts_builtin
|
||||
$SHORT_DOC getopts optstring name [arg]
|
||||
Getopts is used by shell procedures to parse positional parameters.
|
||||
Parse option arguments.
|
||||
|
||||
Getopts is used by shell procedures to parse positional parameters
|
||||
as options.
|
||||
|
||||
OPTSTRING contains the option letters to be recognized; if a letter
|
||||
is followed by a colon, the option is expected to have an argument,
|
||||
|
@ -44,7 +46,7 @@ seen, getopts places the option character found into OPTARG. If a
|
|||
required argument is not found, getopts places a ':' into NAME and
|
||||
sets OPTARG to the option character found. If getopts is not in
|
||||
silent mode, and an invalid option is seen, getopts places '?' into
|
||||
NAME and unsets OPTARG. If a required option is not found, a '?'
|
||||
NAME and unsets OPTARG. If a required argument is not found, a '?'
|
||||
is placed in NAME, OPTARG is unset, and a diagnostic message is
|
||||
printed.
|
||||
|
||||
|
@ -54,6 +56,10 @@ OPTSTRING is not a colon. OPTERR has the value 1 by default.
|
|||
|
||||
Getopts normally parses the positional parameters ($0 - $9), but if
|
||||
more arguments are given, they are parsed instead.
|
||||
|
||||
Exit Status:
|
||||
Returns success if an option is found; fails if the end of options is
|
||||
encountered or an error occurs.
|
||||
$END
|
||||
|
||||
#include <config.h>
|
||||
|
@ -101,7 +107,7 @@ getopts_bind_variable (name, value)
|
|||
|
||||
if (legal_identifier (name))
|
||||
{
|
||||
v = bind_variable (name, value);
|
||||
v = bind_variable (name, value, 0);
|
||||
return (v && (readonly_p (v) == 0)) ? EXECUTION_SUCCESS : EXECUTION_FAILURE;
|
||||
}
|
||||
else
|
||||
|
@ -228,7 +234,7 @@ dogetopts (argc, argv)
|
|||
}
|
||||
while (n /= 10);
|
||||
}
|
||||
bind_variable ("OPTIND", numval + i);
|
||||
bind_variable ("OPTIND", numval + i, 0);
|
||||
|
||||
/* If an error occurred, decide which one it is and set the return
|
||||
code appropriately. In all cases, the option character in error
|
||||
|
@ -245,6 +251,7 @@ dogetopts (argc, argv)
|
|||
|
||||
if (ret == G_EOF)
|
||||
{
|
||||
unbind_variable ("OPTARG");
|
||||
getopts_bind_variable (name, "?");
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
@ -258,7 +265,7 @@ dogetopts (argc, argv)
|
|||
{
|
||||
strval[0] = (char)sh_optopt;
|
||||
strval[1] = '\0';
|
||||
bind_variable ("OPTARG", strval);
|
||||
bind_variable ("OPTARG", strval, 0);
|
||||
}
|
||||
else
|
||||
unbind_variable ("OPTARG");
|
||||
|
@ -275,7 +282,7 @@ dogetopts (argc, argv)
|
|||
|
||||
strval[0] = (char)sh_optopt;
|
||||
strval[1] = '\0';
|
||||
bind_variable ("OPTARG", strval);
|
||||
bind_variable ("OPTARG", strval, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -285,7 +292,7 @@ dogetopts (argc, argv)
|
|||
return (ret);
|
||||
}
|
||||
|
||||
bind_variable ("OPTARG", sh_optarg);
|
||||
bind_variable ("OPTARG", sh_optarg, 0);
|
||||
|
||||
strval[0] = (char) ret;
|
||||
strval[1] = '\0';
|
||||
|
|
|
@ -1,39 +1,47 @@
|
|||
This file is hash.def, from which is created hash.c.
|
||||
It implements the builtin "hash" in Bash.
|
||||
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES hash.c
|
||||
|
||||
$BUILTIN hash
|
||||
$FUNCTION hash_builtin
|
||||
$SHORT_DOC hash [-lr] [-p pathname] [-dt] [name ...]
|
||||
For each NAME, the full pathname of the command is determined and
|
||||
remembered. If the -p option is supplied, PATHNAME is used as the
|
||||
full pathname of NAME, and no path search is performed. The -r
|
||||
option causes the shell to forget all remembered locations. The -d
|
||||
option causes the shell to forget the remembered location of each NAME.
|
||||
If the -t option is supplied the full pathname to which each NAME
|
||||
corresponds is printed. If multiple NAME arguments are supplied with
|
||||
-t, the NAME is printed before the hashed full pathname. The -l option
|
||||
causes output to be displayed in a format that may be reused as input.
|
||||
If no arguments are given, information about remembered commands is displayed.
|
||||
Remember or display program locations.
|
||||
|
||||
Determine and remember the full pathname of each command NAME. If
|
||||
no arguments are given, information about remembered commands is displayed.
|
||||
|
||||
Options:
|
||||
-d forget the remembered location of each NAME
|
||||
-l display in a format that may be reused as input
|
||||
-p pathname use PATHNAME is the full pathname of NAME
|
||||
-r forget all remembered locations
|
||||
-t print the remembered location of each NAME, preceding
|
||||
each location with the corresponding NAME if multiple
|
||||
NAMEs are given
|
||||
Arguments:
|
||||
NAME Each NAME is searched for in $PATH and added to the list
|
||||
of remembered commands.
|
||||
|
||||
Exit Status:
|
||||
Returns success unless NAME is not found or an invalid option is given.
|
||||
$END
|
||||
|
||||
#include <config.h>
|
||||
|
@ -49,6 +57,7 @@ $END
|
|||
#include <errno.h>
|
||||
|
||||
#include "../bashansi.h"
|
||||
#include "../bashintl.h"
|
||||
|
||||
#include "../shell.h"
|
||||
#include "../builtins.h"
|
||||
|
@ -58,6 +67,7 @@ $END
|
|||
#include "common.h"
|
||||
#include "bashgetopt.h"
|
||||
|
||||
extern int posixly_correct;
|
||||
extern int dot_found_in_search;
|
||||
extern char *this_command_name;
|
||||
|
||||
|
@ -79,7 +89,7 @@ hash_builtin (list)
|
|||
|
||||
if (hashing_enabled == 0)
|
||||
{
|
||||
builtin_error ("hashing disabled");
|
||||
builtin_error (_("hashing disabled"));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
|
@ -123,8 +133,9 @@ hash_builtin (list)
|
|||
we test expunge_hash_table. */
|
||||
if (list == 0 && expunge_hash_table == 0)
|
||||
{
|
||||
if (print_hashed_commands (list_portably) == 0)
|
||||
printf ("%s: hash table empty\n", this_command_name);
|
||||
opt = print_hashed_commands (list_portably);
|
||||
if (opt == 0 && posixly_correct == 0)
|
||||
printf (_("%s: hash table empty\n"), this_command_name);
|
||||
|
||||
return (EXECUTION_SUCCESS);
|
||||
}
|
||||
|
@ -155,7 +166,7 @@ hash_builtin (list)
|
|||
#ifdef EISDIR
|
||||
builtin_error ("%s: %s", pathname, strerror (EISDIR));
|
||||
#else
|
||||
builtin_error ("%s: is a directory", pathname);
|
||||
builtin_error (_("%s: is a directory"), pathname);
|
||||
#endif
|
||||
opt = EXECUTION_FAILURE;
|
||||
}
|
||||
|
@ -164,10 +175,13 @@ hash_builtin (list)
|
|||
}
|
||||
else if (absolute_program (w))
|
||||
continue;
|
||||
else if (delete && phash_remove (w))
|
||||
else if (delete)
|
||||
{
|
||||
sh_notfound (w);
|
||||
opt = EXECUTION_FAILURE;
|
||||
if (phash_remove (w))
|
||||
{
|
||||
sh_notfound (w);
|
||||
opt = EXECUTION_FAILURE;
|
||||
}
|
||||
}
|
||||
else if (add_hashed_command (w, 0))
|
||||
opt = EXECUTION_FAILURE;
|
||||
|
@ -227,7 +241,7 @@ print_hashed_commands (fmt)
|
|||
return (0);
|
||||
|
||||
if (fmt == 0)
|
||||
printf ("hits\tcommand\n");
|
||||
printf (_("hits\tcommand\n"));
|
||||
hash_walk (hashed_filenames, fmt ? print_portable_hash_info : print_hash_info);
|
||||
return (1);
|
||||
}
|
||||
|
|
|
@ -1,35 +1,46 @@
|
|||
This file is help.def, from which is created help.c.
|
||||
It implements the builtin "help" in Bash.
|
||||
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES help.c
|
||||
|
||||
$BUILTIN help
|
||||
$FUNCTION help_builtin
|
||||
$DEPENDS_ON HELP_BUILTIN
|
||||
$SHORT_DOC help [-s] [pattern ...]
|
||||
Display helpful information about builtin commands. If PATTERN is
|
||||
$SHORT_DOC help [-ds] [pattern ...]
|
||||
Display information about builtin commands.
|
||||
|
||||
Displays brief summaries of builtin commands. If PATTERN is
|
||||
specified, gives detailed help on all commands matching PATTERN,
|
||||
otherwise a list of the builtins is printed. The -s option
|
||||
restricts the output for each builtin command matching PATTERN to
|
||||
a short usage synopsis.
|
||||
otherwise the list of help topics is printed.
|
||||
|
||||
Options:
|
||||
-d output short description for each topic
|
||||
-m display usage in pseudo-manpage format
|
||||
-s output only a short usage synopsis for each topic matching
|
||||
PATTERN
|
||||
|
||||
Arguments:
|
||||
PATTERN Pattern specifiying a help topic
|
||||
|
||||
Exit Status:
|
||||
Returns success unless PATTERN is not found or an invalid option is given.
|
||||
$END
|
||||
|
||||
#include <config.h>
|
||||
|
@ -48,6 +59,8 @@ $END
|
|||
|
||||
#include <filecntl.h>
|
||||
|
||||
#include "../bashintl.h"
|
||||
|
||||
#include "../shell.h"
|
||||
#include "../builtins.h"
|
||||
#include "../pathexp.h"
|
||||
|
@ -61,7 +74,13 @@ $END
|
|||
extern int errno;
|
||||
#endif
|
||||
|
||||
extern const char * const bash_copyright;
|
||||
extern const char * const bash_license;
|
||||
|
||||
static void show_builtin_command_help __P((void));
|
||||
static int open_helpfile __P((char *));
|
||||
static void show_desc __P((char *, int));
|
||||
static void show_manpage __P((char *, int));
|
||||
static void show_longdoc __P((int));
|
||||
|
||||
/* Print out a list of the known functions in the shell, and what they do.
|
||||
|
@ -73,14 +92,20 @@ help_builtin (list)
|
|||
{
|
||||
register int i;
|
||||
char *pattern, *name;
|
||||
int plen, match_found, sflag;
|
||||
int plen, match_found, sflag, dflag, mflag;
|
||||
|
||||
sflag = 0;
|
||||
dflag = sflag = mflag = 0;
|
||||
reset_internal_getopt ();
|
||||
while ((i = internal_getopt (list, "s")) != -1)
|
||||
while ((i = internal_getopt (list, "dms")) != -1)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 'd':
|
||||
dflag = 1;
|
||||
break;
|
||||
case 'm':
|
||||
mflag = 1;
|
||||
break;
|
||||
case 's':
|
||||
sflag = 1;
|
||||
break;
|
||||
|
@ -102,7 +127,7 @@ help_builtin (list)
|
|||
|
||||
if (glob_pattern_p (list->word->word))
|
||||
{
|
||||
printf ("Shell commands matching keyword%s `", list->next ? "s" : "");
|
||||
printf (ngettext ("Shell commands matching keyword `", "Shell commands matching keywords `", (list->next ? 2 : 1)));
|
||||
print_word_list (list, ", ");
|
||||
printf ("'\n\n");
|
||||
}
|
||||
|
@ -118,19 +143,29 @@ help_builtin (list)
|
|||
if ((strncmp (pattern, name, plen) == 0) ||
|
||||
(strmatch (pattern, name, FNMATCH_EXTFLAG) != FNM_NOMATCH))
|
||||
{
|
||||
match_found++;
|
||||
if (dflag)
|
||||
{
|
||||
show_desc (name, i);
|
||||
continue;
|
||||
}
|
||||
else if (mflag)
|
||||
{
|
||||
show_manpage (name, i);
|
||||
continue;
|
||||
}
|
||||
|
||||
printf ("%s: %s\n", name, shell_builtins[i].short_doc);
|
||||
|
||||
if (sflag == 0)
|
||||
show_longdoc (i);
|
||||
|
||||
match_found++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (match_found == 0)
|
||||
{
|
||||
builtin_error ("no help topics match `%s'. Try `help help' or `man -k %s' or `info %s'.", pattern, pattern, pattern);
|
||||
builtin_error (_("no help topics match `%s'. Try `help help' or `man -k %s' or `info %s'."), pattern, pattern, pattern);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
|
@ -138,6 +173,21 @@ help_builtin (list)
|
|||
return (EXECUTION_SUCCESS);
|
||||
}
|
||||
|
||||
static int
|
||||
open_helpfile (name)
|
||||
char *name;
|
||||
{
|
||||
int fd;
|
||||
|
||||
fd = open (name, O_RDONLY);
|
||||
if (fd == -1)
|
||||
{
|
||||
builtin_error (_("%s: cannot open: %s"), name, strerror (errno));
|
||||
return -1;
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
/* By convention, enforced by mkbuiltins.c, if separate help files are being
|
||||
used, the long_doc array contains one string -- the full pathname of the
|
||||
help file for this builtin. */
|
||||
|
@ -153,50 +203,181 @@ show_longdoc (i)
|
|||
|
||||
if (doc && doc[0] && *doc[0] == '/' && doc[1] == (char *)NULL)
|
||||
{
|
||||
fd = open (doc[0], O_RDONLY);
|
||||
if (fd == -1)
|
||||
{
|
||||
builtin_error ("%s: cannot open: %s", doc[0], strerror (errno));
|
||||
return;
|
||||
}
|
||||
fd = open_helpfile (doc[0]);
|
||||
if (fd < 0)
|
||||
return;
|
||||
zcatfd (fd, 1, doc[0]);
|
||||
close (fd);
|
||||
}
|
||||
else
|
||||
for (j = 0; doc[j]; j++)
|
||||
printf (" %s\n", doc[j]);
|
||||
printf ("%*s%s\n", BASE_INDENT, " ", _(doc[j]));
|
||||
}
|
||||
|
||||
static void
|
||||
show_desc (name, i)
|
||||
char *name;
|
||||
int i;
|
||||
{
|
||||
register int j;
|
||||
char **doc, *line;
|
||||
int fd, usefile;
|
||||
|
||||
doc = (char **)shell_builtins[i].long_doc;
|
||||
|
||||
usefile = (doc && doc[0] && *doc[0] == '/' && doc[1] == (char *)NULL);
|
||||
if (usefile)
|
||||
{
|
||||
fd = open_helpfile (doc[0]);
|
||||
if (fd < 0)
|
||||
return;
|
||||
zmapfd (fd, &line, doc[0]);
|
||||
close (fd);
|
||||
}
|
||||
else
|
||||
line = doc ? doc[0] : (char *)NULL;
|
||||
|
||||
printf ("%s - ", name);
|
||||
for (j = 0; line && line[j]; j++)
|
||||
{
|
||||
putchar (line[j]);
|
||||
if (line[j] == '\n')
|
||||
break;
|
||||
}
|
||||
|
||||
fflush (stdout);
|
||||
|
||||
if (usefile)
|
||||
free (line);
|
||||
}
|
||||
|
||||
/* Print builtin help in pseudo-manpage format. */
|
||||
static void
|
||||
show_manpage (name, i)
|
||||
char *name;
|
||||
int i;
|
||||
{
|
||||
register int j;
|
||||
char **doc, *line;
|
||||
int fd, usefile;
|
||||
|
||||
doc = (char **)shell_builtins[i].long_doc;
|
||||
|
||||
usefile = (doc && doc[0] && *doc[0] == '/' && doc[1] == (char *)NULL);
|
||||
if (usefile)
|
||||
{
|
||||
fd = open_helpfile (doc[0]);
|
||||
if (fd < 0)
|
||||
return;
|
||||
zmapfd (fd, &line, doc[0]);
|
||||
close (fd);
|
||||
}
|
||||
else
|
||||
line = doc ? _(doc[0]) : (char *)NULL;
|
||||
|
||||
/* NAME */
|
||||
printf ("NAME\n");
|
||||
printf ("%*s%s - ", BASE_INDENT, " ", name);
|
||||
for (j = 0; line && line[j]; j++)
|
||||
{
|
||||
putchar (line[j]);
|
||||
if (line[j] == '\n')
|
||||
break;
|
||||
}
|
||||
printf ("\n");
|
||||
|
||||
/* SYNOPSIS */
|
||||
printf ("SYNOPSIS\n");
|
||||
printf ("%*s%s\n\n", BASE_INDENT, " ", shell_builtins[i].short_doc);
|
||||
|
||||
/* DESCRIPTION */
|
||||
printf ("DESCRIPTION\n");
|
||||
if (usefile == 0)
|
||||
{
|
||||
for (j = 0; doc[j]; j++)
|
||||
printf ("%*s%s\n", BASE_INDENT, " ", _(doc[j]));
|
||||
}
|
||||
else
|
||||
{
|
||||
for (j = 0; line && line[j]; j++)
|
||||
{
|
||||
putchar (line[j]);
|
||||
if (line[j] == '\n')
|
||||
printf ("%*s", BASE_INDENT, " ");
|
||||
}
|
||||
}
|
||||
putchar ('\n');
|
||||
|
||||
/* SEE ALSO */
|
||||
printf ("SEE ALSO\n");
|
||||
printf ("%*sbash(1)\n\n", BASE_INDENT, " ");
|
||||
|
||||
/* IMPLEMENTATION */
|
||||
printf ("IMPLEMENTATION\n");
|
||||
printf ("%*s", BASE_INDENT, " ");
|
||||
show_shell_version (0);
|
||||
printf ("%*s", BASE_INDENT, " ");
|
||||
printf ("%s\n", _(bash_copyright));
|
||||
printf ("%*s", BASE_INDENT, " ");
|
||||
printf ("%s\n", _(bash_license));
|
||||
|
||||
fflush (stdout);
|
||||
if (usefile)
|
||||
free (line);
|
||||
}
|
||||
|
||||
static void
|
||||
show_builtin_command_help ()
|
||||
{
|
||||
int i, j;
|
||||
char blurb[36];
|
||||
int height, width;
|
||||
char *t, blurb[128];
|
||||
|
||||
printf (
|
||||
"These shell commands are defined internally. Type `help' to see this list.\n\
|
||||
_("These shell commands are defined internally. Type `help' to see this list.\n\
|
||||
Type `help name' to find out more about the function `name'.\n\
|
||||
Use `info bash' to find out more about the shell in general.\n\
|
||||
Use `man -k' or `info' to find out more about commands not in this list.\n\
|
||||
\n\
|
||||
A star (*) next to a name means that the command is disabled.\n\
|
||||
\n");
|
||||
\n"));
|
||||
|
||||
for (i = 0; i < num_shell_builtins; i++)
|
||||
t = get_string_value ("COLUMNS");
|
||||
width = (t && *t) ? atoi (t) : 80;
|
||||
if (width <= 0)
|
||||
width = 80;
|
||||
|
||||
width /= 2;
|
||||
if (width > sizeof (blurb))
|
||||
width = sizeof (blurb);
|
||||
height = (num_shell_builtins + 1) / 2; /* number of rows */
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
QUIT;
|
||||
blurb[0] = (shell_builtins[i].flags & BUILTIN_ENABLED) ? ' ' : '*';
|
||||
strncpy (blurb + 1, shell_builtins[i].short_doc, 34);
|
||||
blurb[35] = '\0';
|
||||
printf ("%s", blurb);
|
||||
|
||||
if (i % 2)
|
||||
printf ("\n");
|
||||
else
|
||||
for (j = strlen (blurb); j < 35; j++)
|
||||
putc (' ', stdout);
|
||||
/* first column */
|
||||
blurb[0] = (shell_builtins[i].flags & BUILTIN_ENABLED) ? ' ' : '*';
|
||||
strncpy (blurb + 1, shell_builtins[i].short_doc, width - 2);
|
||||
blurb[width - 2] = '>'; /* indicate truncation */
|
||||
blurb[width - 1] = '\0';
|
||||
printf ("%s", blurb);
|
||||
if (((i << 1) >= num_shell_builtins) || (i+height >= num_shell_builtins))
|
||||
{
|
||||
printf ("\n");
|
||||
break;
|
||||
}
|
||||
|
||||
/* two spaces */
|
||||
for (j = strlen (blurb); j < width; j++)
|
||||
putc (' ', stdout);
|
||||
|
||||
/* second column */
|
||||
blurb[0] = (shell_builtins[i+height].flags & BUILTIN_ENABLED) ? ' ' : '*';
|
||||
strncpy (blurb + 1, shell_builtins[i+height].short_doc, width - 3);
|
||||
blurb[width - 3] = '>'; /* indicate truncation */
|
||||
blurb[width - 2] = '\0';
|
||||
printf ("%s\n", blurb);
|
||||
}
|
||||
if (i % 2)
|
||||
printf ("\n");
|
||||
}
|
||||
#endif /* HELP_BUILTIN */
|
||||
|
|
|
@ -1,53 +1,65 @@
|
|||
This file is history.def, from which is created history.c.
|
||||
It implements the builtin "history" in Bash.
|
||||
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES history.c
|
||||
|
||||
$BUILTIN history
|
||||
$FUNCTION history_builtin
|
||||
$DEPENDS_ON HISTORY
|
||||
$SHORT_DOC history [-c] [-d offset] [n] or history -awrn [filename] or history -ps arg [arg...]
|
||||
Display the history list with line numbers. Lines listed with
|
||||
with a `*' have been modified. Argument of N says to list only
|
||||
the last N lines. The `-c' option causes the history list to be
|
||||
cleared by deleting all of the entries. The `-d' option deletes
|
||||
the history entry at offset OFFSET. The `-w' option writes out the
|
||||
current history to the history file; `-r' means to read the file and
|
||||
append the contents to the history list instead. `-a' means
|
||||
to append history lines from this session to the history file.
|
||||
Argument `-n' means to read all history lines not already read
|
||||
from the history file and append them to the history list. If
|
||||
FILENAME is given, then that is used as the history file else
|
||||
$SHORT_DOC history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg...]
|
||||
Display or manipulate the history list.
|
||||
|
||||
Display the history list with line numbers, prefixing each modified
|
||||
entry with a `*'. An argument of N lists only the last N entries.
|
||||
|
||||
Options:
|
||||
-c clear the history list by deleting all of the entries
|
||||
-d offset delete the history entry at offset OFFSET.
|
||||
|
||||
-a append history lines from this session to the history file
|
||||
-n read all history lines not already read from the history file
|
||||
-r read the history file and append the contents to the history
|
||||
list
|
||||
-w write the current history to the history file
|
||||
and append them to the history list
|
||||
|
||||
-p perform history expansion on each ARG and display the result
|
||||
without storing it in the history list
|
||||
-s append the ARGs to the history list as a single entry
|
||||
|
||||
If FILENAME is given, it is used as the history file. Otherwise,
|
||||
if $HISTFILE has a value, that is used, else ~/.bash_history.
|
||||
If the -s option is supplied, the non-option ARGs are appended to
|
||||
the history list as a single entry. The -p option means to perform
|
||||
history expansion on each ARG and display the result, without storing
|
||||
anything in the history list.
|
||||
|
||||
If the $HISTTIMEFORMAT variable is set and not null, its value is used
|
||||
as a format string for strftime(3) to print the time stamp associated
|
||||
with each displayed history entry. No time stamps are printed otherwise.
|
||||
|
||||
Exit Status:
|
||||
Returns success unless an invalid option is given or an error occurs.
|
||||
$END
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#if defined (HISTORY)
|
||||
#include "../bashtypes.h"
|
||||
#if defined (HAVE_SYS_FILE_H)
|
||||
#if ! defined(_MINIX) && defined (HAVE_SYS_FILE_H)
|
||||
# include <sys/file.h>
|
||||
#endif
|
||||
#include "posixstat.h"
|
||||
|
@ -59,6 +71,7 @@ $END
|
|||
#endif
|
||||
|
||||
#include "../bashansi.h"
|
||||
#include "../bashintl.h"
|
||||
|
||||
#include "../shell.h"
|
||||
#include "../bashhist.h"
|
||||
|
@ -71,10 +84,10 @@ extern int errno;
|
|||
#endif
|
||||
|
||||
extern int current_command_line_count;
|
||||
extern int force_append_history; /* shopt -s histappend */
|
||||
|
||||
static void display_history __P((WORD_LIST *));
|
||||
static int delete_histent __P((int));
|
||||
static int delete_last_history __P((void));
|
||||
static char *histtime __P((HIST_ENTRY *, const char *));
|
||||
static int display_history __P((WORD_LIST *));
|
||||
static void push_history __P((WORD_LIST *));
|
||||
static int expand_and_print_history __P((WORD_LIST *));
|
||||
|
||||
|
@ -91,7 +104,7 @@ int
|
|||
history_builtin (list)
|
||||
WORD_LIST *list;
|
||||
{
|
||||
int flags, opt, result, old_history_lines;
|
||||
int flags, opt, result, old_history_lines, obase;
|
||||
char *filename, *delete_arg;
|
||||
intmax_t delete_offset;
|
||||
|
||||
|
@ -138,14 +151,14 @@ history_builtin (list)
|
|||
opt = flags & (AFLAG|RFLAG|WFLAG|NFLAG);
|
||||
if (opt && opt != AFLAG && opt != RFLAG && opt != WFLAG && opt != NFLAG)
|
||||
{
|
||||
builtin_error ("cannot use more than one of -anrw");
|
||||
builtin_error (_("cannot use more than one of -anrw"));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
/* clear the history, but allow other arguments to add to it again. */
|
||||
if (flags & CFLAG)
|
||||
{
|
||||
clear_history ();
|
||||
bash_clear_history ();
|
||||
if (list == 0)
|
||||
return (EXECUTION_SUCCESS);
|
||||
}
|
||||
|
@ -161,7 +174,7 @@ history_builtin (list)
|
|||
{
|
||||
if (list)
|
||||
return (expand_and_print_history (list));
|
||||
return (EXECUTION_SUCCESS);
|
||||
return (sh_chkwrite (EXECUTION_SUCCESS));
|
||||
}
|
||||
#endif
|
||||
else if (flags & DFLAG)
|
||||
|
@ -170,11 +183,11 @@ history_builtin (list)
|
|||
|| (delete_offset < history_base)
|
||||
|| (delete_offset > (history_base + history_length)))
|
||||
{
|
||||
sh_erange (delete_arg, "history position");
|
||||
sh_erange (delete_arg, _("history position"));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
opt = delete_offset;
|
||||
result = delete_histent (opt - history_base);
|
||||
result = bash_delete_histent (opt - history_base);
|
||||
/* Since remove_history changes history_length, this can happen if
|
||||
we delete the last history entry. */
|
||||
if (where_history () > history_length)
|
||||
|
@ -183,8 +196,8 @@ history_builtin (list)
|
|||
}
|
||||
else if ((flags & (AFLAG|RFLAG|NFLAG|WFLAG|CFLAG)) == 0)
|
||||
{
|
||||
display_history (list);
|
||||
return (EXECUTION_SUCCESS);
|
||||
result = display_history (list);
|
||||
return (sh_chkwrite (result));
|
||||
}
|
||||
|
||||
filename = list ? list->word->word : get_string_value ("HISTFILE");
|
||||
|
@ -200,11 +213,27 @@ history_builtin (list)
|
|||
{
|
||||
/* Read all of the lines in the file that we haven't already read. */
|
||||
old_history_lines = history_lines_in_file;
|
||||
obase = history_base;
|
||||
|
||||
using_history ();
|
||||
result = read_history_range (filename, history_lines_in_file, -1);
|
||||
using_history ();
|
||||
|
||||
history_lines_in_file = where_history ();
|
||||
history_lines_this_session += history_lines_in_file - old_history_lines;
|
||||
|
||||
/* If we're rewriting the history file at shell exit rather than just
|
||||
appending the lines from this session to it, the question is whether
|
||||
we reset history_lines_this_session to 0, losing any history entries
|
||||
we had before we read the new entries from the history file, or
|
||||
whether we count the new entries we just read from the file as
|
||||
history lines added during this session.
|
||||
Right now, we do the latter. This will cause these history entries
|
||||
to be written to the history file along with any intermediate entries
|
||||
we add when we do a `history -a', but the alternative is losing
|
||||
them altogether. */
|
||||
if (force_append_history == 0)
|
||||
history_lines_this_session += history_lines_in_file - old_history_lines +
|
||||
history_base - obase;
|
||||
}
|
||||
|
||||
return (result ? EXECUTION_FAILURE : EXECUTION_SUCCESS);
|
||||
|
@ -214,17 +243,36 @@ history_builtin (list)
|
|||
#define histline(i) (hlist[(i)]->line)
|
||||
#define histdata(i) (hlist[(i)]->data)
|
||||
|
||||
static void
|
||||
static char *
|
||||
histtime (hlist, histtimefmt)
|
||||
HIST_ENTRY *hlist;
|
||||
const char *histtimefmt;
|
||||
{
|
||||
static char timestr[128];
|
||||
time_t t;
|
||||
|
||||
t = history_get_time (hlist);
|
||||
if (t)
|
||||
strftime (timestr, sizeof (timestr), histtimefmt, localtime (&t));
|
||||
else
|
||||
strcpy (timestr, "??");
|
||||
return timestr;
|
||||
}
|
||||
|
||||
static int
|
||||
display_history (list)
|
||||
WORD_LIST *list;
|
||||
{
|
||||
register int i;
|
||||
intmax_t limit;
|
||||
HIST_ENTRY **hlist;
|
||||
char *histtimefmt, *timestr;
|
||||
|
||||
if (list)
|
||||
{
|
||||
limit = get_numeric_arg (list, 0);
|
||||
if (get_numeric_arg (list, 0, &limit) == 0)
|
||||
return (EXECUTION_FAILURE);
|
||||
|
||||
if (limit < 0)
|
||||
limit = -limit;
|
||||
}
|
||||
|
@ -243,54 +291,22 @@ display_history (list)
|
|||
else
|
||||
i = 0;
|
||||
|
||||
histtimefmt = get_string_value ("HISTTIMEFORMAT");
|
||||
|
||||
while (hlist[i])
|
||||
{
|
||||
QUIT;
|
||||
printf ("%5d%c %s\n", i + history_base,
|
||||
|
||||
timestr = (histtimefmt && *histtimefmt) ? histtime (hlist[i], histtimefmt) : (char *)NULL;
|
||||
printf ("%5d%c %s%s\n", i + history_base,
|
||||
histdata(i) ? '*' : ' ',
|
||||
((timestr && *timestr) ? timestr : ""),
|
||||
histline(i));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Delete and free the history list entry at offset I. */
|
||||
static int
|
||||
delete_histent (i)
|
||||
int i;
|
||||
{
|
||||
HIST_ENTRY *discard;
|
||||
|
||||
discard = remove_history (i);
|
||||
if (discard)
|
||||
{
|
||||
if (discard->line)
|
||||
free (discard->line);
|
||||
free ((char *) discard);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
delete_last_history ()
|
||||
{
|
||||
register int i;
|
||||
HIST_ENTRY **hlist, *histent;
|
||||
|
||||
hlist = history_list ();
|
||||
if (hlist == NULL)
|
||||
return 0;
|
||||
|
||||
for (i = 0; hlist[i]; i++)
|
||||
;
|
||||
i--;
|
||||
|
||||
/* History_get () takes a parameter that must be offset by history_base. */
|
||||
histent = history_get (history_base + i); /* Don't free this */
|
||||
if (histent == NULL)
|
||||
return 0;
|
||||
|
||||
return (delete_histent (i));
|
||||
return (EXECUTION_SUCCESS);
|
||||
}
|
||||
|
||||
/* Remove the last entry in the history list and add each argument in
|
||||
|
@ -308,10 +324,12 @@ push_history (list)
|
|||
If you don't want history -s to remove the compound command from the
|
||||
history, change #if 0 to #if 1 below. */
|
||||
#if 0
|
||||
if (hist_last_line_added && delete_last_history () == 0)
|
||||
if (hist_last_line_pushed == 0 && hist_last_line_added && bash_delete_last_history () == 0)
|
||||
#else
|
||||
if ((hist_last_line_added || (current_command_line_count > 0 && current_command_first_line_saved && command_oriented_history))
|
||||
&& delete_last_history () == 0)
|
||||
if (hist_last_line_pushed == 0 &&
|
||||
(hist_last_line_added ||
|
||||
(current_command_line_count > 0 && current_command_first_line_saved && command_oriented_history))
|
||||
&& bash_delete_last_history () == 0)
|
||||
#endif
|
||||
return;
|
||||
|
||||
|
@ -323,6 +341,8 @@ push_history (list)
|
|||
entry. Without FORCE=1, if current_command_line_count were > 1, the
|
||||
line would be appended to the entry before the just-deleted entry. */
|
||||
check_add_history (s, 1); /* obeys HISTCONTROL, HISTIGNORE */
|
||||
|
||||
hist_last_line_pushed = 1; /* XXX */
|
||||
free (s);
|
||||
}
|
||||
|
||||
|
@ -334,7 +354,7 @@ expand_and_print_history (list)
|
|||
char *s;
|
||||
int r, result;
|
||||
|
||||
if (hist_last_line_added && delete_last_history () == 0)
|
||||
if (hist_last_line_pushed == 0 && hist_last_line_added && bash_delete_last_history () == 0)
|
||||
return EXECUTION_FAILURE;
|
||||
result = EXECUTION_SUCCESS;
|
||||
while (list)
|
||||
|
@ -342,7 +362,7 @@ expand_and_print_history (list)
|
|||
r = history_expand (list->word->word, &s);
|
||||
if (r < 0)
|
||||
{
|
||||
builtin_error ("%s: history expansion failed", list->word->word);
|
||||
builtin_error (_("%s: history expansion failed"), list->word->word);
|
||||
result = EXECUTION_FAILURE;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -5,19 +5,18 @@ Copyright (C) 1987-2002 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES inlib.c
|
||||
#include <config.h>
|
||||
|
@ -29,12 +28,17 @@ $BUILTIN inlib
|
|||
$FUNCTION inlib_builtin
|
||||
$DEPENDS_ON apollo
|
||||
$SHORT_DOC inlib pathname [pathname...]
|
||||
Install user-supplied library.
|
||||
|
||||
Install a user-supplied library specified by pathname in the current
|
||||
shell process. The library is used to resolve external references
|
||||
in programs and libraries loaded after its installation. Note
|
||||
that the library is not loaded into the address space unless it is
|
||||
needed to resolve an external reference. The list of inlibed
|
||||
libraries is passed to all children of the current shell.
|
||||
|
||||
Exit Status:
|
||||
Returns success unless PATHNAME is not found or an error occurs.
|
||||
$END
|
||||
|
||||
#if defined (apollo)
|
||||
|
@ -64,7 +68,7 @@ inlib_builtin (list)
|
|||
|
||||
if (status.all != status_$ok)
|
||||
{
|
||||
builtin_error ("%s: inlib failed", list->word->word);
|
||||
builtin_error (_("%s: inlib failed"), list->word->word);
|
||||
return_value = EXECUTION_FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,23 +1,22 @@
|
|||
This file is jobs.def, from which is created jobs.c.
|
||||
It implements the builtins "jobs" and "disown" in Bash.
|
||||
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES jobs.c
|
||||
|
||||
|
@ -25,15 +24,26 @@ $BUILTIN jobs
|
|||
$FUNCTION jobs_builtin
|
||||
$DEPENDS_ON JOB_CONTROL
|
||||
$SHORT_DOC jobs [-lnprs] [jobspec ...] or jobs -x command [args]
|
||||
Lists the active jobs. The -l option lists process id's in addition
|
||||
to the normal information; the -p option lists process id's only.
|
||||
If -n is given, only processes that have changed status since the last
|
||||
notification are printed. JOBSPEC restricts output to that job. The
|
||||
-r and -s options restrict output to running and stopped jobs only,
|
||||
respectively. Without options, the status of all active jobs is
|
||||
printed. If -x is given, COMMAND is run after all job specifications
|
||||
that appear in ARGS have been replaced with the process ID of that job's
|
||||
Display status of jobs.
|
||||
|
||||
Lists the active jobs. JOBSPEC restricts output to that job.
|
||||
Without options, the status of all active jobs is displayed.
|
||||
|
||||
Options:
|
||||
-l lists process IDs in addition to the normal information
|
||||
-n list only processes that have changed status since the last
|
||||
notification
|
||||
-p lists process IDs only
|
||||
-r restrict output to running jobs
|
||||
-s restrict output to stopped jobs
|
||||
|
||||
If -x is supplied, COMMAND is run after all job specifications that
|
||||
appear in ARGS have been replaced with the process ID of that job's
|
||||
process group leader.
|
||||
|
||||
Exit Status:
|
||||
Returns success unless an invalid option is given or an error occurs.
|
||||
If -x is used, returns the exit status of COMMAND.
|
||||
$END
|
||||
|
||||
#include <config.h>
|
||||
|
@ -46,6 +56,7 @@ $END
|
|||
#endif
|
||||
|
||||
#include "../bashansi.h"
|
||||
#include "../bashintl.h"
|
||||
|
||||
#include "../shell.h"
|
||||
#include "../jobs.h"
|
||||
|
@ -74,9 +85,6 @@ jobs_builtin (list)
|
|||
int form, execute, state, opt, any_failed, job;
|
||||
sigset_t set, oset;
|
||||
|
||||
if (job_control == 0 && interactive_shell == 0)
|
||||
return (EXECUTION_SUCCESS);
|
||||
|
||||
execute = any_failed = 0;
|
||||
form = JLIST_STANDARD;
|
||||
state = JSTATE_ANY;
|
||||
|
@ -98,7 +106,7 @@ jobs_builtin (list)
|
|||
case 'x':
|
||||
if (form != JLIST_STANDARD)
|
||||
{
|
||||
builtin_error ("no other options allowed with `-x'");
|
||||
builtin_error (_("no other options allowed with `-x'"));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
execute++;
|
||||
|
@ -143,7 +151,7 @@ jobs_builtin (list)
|
|||
BLOCK_CHILD (set, oset);
|
||||
job = get_job_spec (list);
|
||||
|
||||
if ((job == NO_JOB) || !jobs || !jobs[job])
|
||||
if ((job == NO_JOB) || jobs == 0 || get_job_by_jid (job) == 0)
|
||||
{
|
||||
sh_badjob (list->word->word);
|
||||
any_failed++;
|
||||
|
@ -163,6 +171,8 @@ execute_list_with_replacements (list)
|
|||
{
|
||||
register WORD_LIST *l;
|
||||
int job, result;
|
||||
COMMAND *command;
|
||||
JOB *j;
|
||||
|
||||
/* First do the replacement of job specifications with pids. */
|
||||
for (l = list; l; l = l->next)
|
||||
|
@ -172,31 +182,29 @@ execute_list_with_replacements (list)
|
|||
job = get_job_spec (l);
|
||||
|
||||
/* A bad job spec is not really a job spec! Pass it through. */
|
||||
if (job < 0 || job >= job_slots || !jobs[job])
|
||||
if (INVALID_JOB (job))
|
||||
continue;
|
||||
|
||||
j = get_job_by_jid (job);
|
||||
free (l->word->word);
|
||||
l->word->word = itos (jobs[job]->pgrp);
|
||||
l->word->word = itos (j->pgrp);
|
||||
}
|
||||
}
|
||||
|
||||
/* Next make a new simple command and execute it. */
|
||||
begin_unwind_frame ("jobs_builtin");
|
||||
{
|
||||
COMMAND *command = (COMMAND *)NULL;
|
||||
|
||||
add_unwind_protect (dispose_command, command);
|
||||
command = make_bare_simple_command ();
|
||||
command->value.Simple->words = copy_word_list (list);
|
||||
command->value.Simple->redirects = (REDIRECT *)NULL;
|
||||
command->flags |= CMD_INHIBIT_EXPANSION;
|
||||
command->value.Simple->flags |= CMD_INHIBIT_EXPANSION;
|
||||
|
||||
command = make_bare_simple_command ();
|
||||
command->value.Simple->words = copy_word_list (list);
|
||||
command->value.Simple->redirects = (REDIRECT *)NULL;
|
||||
command->flags |= CMD_INHIBIT_EXPANSION;
|
||||
command->value.Simple->flags |= CMD_INHIBIT_EXPANSION;
|
||||
add_unwind_protect (dispose_command, command);
|
||||
result = execute_command (command);
|
||||
dispose_command (command);
|
||||
|
||||
result = execute_command (command);
|
||||
}
|
||||
|
||||
run_unwind_frame ("jobs_builtin");
|
||||
discard_unwind_frame ("jobs_builtin");
|
||||
return (result);
|
||||
}
|
||||
#endif /* JOB_CONTROL */
|
||||
|
@ -205,11 +213,19 @@ $BUILTIN disown
|
|||
$FUNCTION disown_builtin
|
||||
$DEPENDS_ON JOB_CONTROL
|
||||
$SHORT_DOC disown [-h] [-ar] [jobspec ...]
|
||||
By default, removes each JOBSPEC argument from the table of active jobs.
|
||||
If the -h option is given, the job is not removed from the table, but is
|
||||
marked so that SIGHUP is not sent to the job if the shell receives a
|
||||
SIGHUP. The -a option, when JOBSPEC is not supplied, means to remove all
|
||||
jobs from the job table; the -r option means to remove only running jobs.
|
||||
Remove jobs from current shell.
|
||||
|
||||
Removes each JOBSPEC argument from the table of active jobs. Without
|
||||
any JOBSPECs, the shell uses its notion of the current job.
|
||||
|
||||
Options:
|
||||
-a remove all jobs if JOBSPEC is not supplied
|
||||
-h mark each JOBSPEC so that SIGHUP is not sent to the job if the
|
||||
shell receives a SIGHUP
|
||||
-r remove only running jobs
|
||||
|
||||
Exit Status:
|
||||
Returns success unless an invalid option or JOBSPEC is given.
|
||||
$END
|
||||
|
||||
#if defined (JOB_CONTROL)
|
||||
|
@ -261,9 +277,9 @@ disown_builtin (list)
|
|||
? get_job_by_pid ((pid_t) pid_value, 0)
|
||||
: get_job_spec (list);
|
||||
|
||||
if (job == NO_JOB || jobs == 0 || job < 0 || job >= job_slots || jobs[job] == 0)
|
||||
if (job == NO_JOB || jobs == 0 || INVALID_JOB (job))
|
||||
{
|
||||
sh_badjob (list ? list->word->word : "current");
|
||||
sh_badjob (list ? list->word->word : _("current"));
|
||||
retval = EXECUTION_FAILURE;
|
||||
}
|
||||
else if (nohup_only)
|
||||
|
|
|
@ -1,37 +1,46 @@
|
|||
This file is kill.def, from which is created kill.c.
|
||||
It implements the builtin "kill" in Bash.
|
||||
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES kill.c
|
||||
|
||||
$BUILTIN kill
|
||||
$FUNCTION kill_builtin
|
||||
$DEPENDS_ON JOB_CONTROL
|
||||
$SHORT_DOC kill [-s sigspec | -n signum | -sigspec] [pid | job]... or kill -l [sigspec]
|
||||
Send the processes named by PID (or JOB) the signal SIGSPEC. If
|
||||
SIGSPEC is not present, then SIGTERM is assumed. An argument of `-l'
|
||||
lists the signal names; if arguments follow `-l' they are assumed to
|
||||
be signal numbers for which names should be listed. Kill is a shell
|
||||
builtin for two reasons: it allows job IDs to be used instead of
|
||||
process IDs, and, if you have reached the limit on processes that
|
||||
you can create, you don't have to start a process to kill another one.
|
||||
$SHORT_DOC kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
|
||||
Send a signal to a job.
|
||||
|
||||
Send the processes identified by PID or JOBSPEC the signal named by
|
||||
SIGSPEC or SIGNUM. If neither SIGSPEC nor SIGNUM is present, then
|
||||
SIGTERM is assumed.
|
||||
|
||||
Options:
|
||||
-s sig SIG is a signal name
|
||||
-n sig SIG is a signal number
|
||||
-l list the signal names; if arguments follow `-l' they are
|
||||
assumed to be signal numbers for which names should be listed
|
||||
|
||||
Kill is a shell builtin for two reasons: it allows job IDs to be used
|
||||
instead of process IDs, and allows processes to be killed if the limit
|
||||
on processes that you can create is reached.
|
||||
|
||||
Exit Status:
|
||||
Returns success unless an invalid option is given or an error occurs.
|
||||
$END
|
||||
|
||||
#include <config.h>
|
||||
|
@ -46,6 +55,7 @@ $END
|
|||
#endif
|
||||
|
||||
#include "../bashansi.h"
|
||||
#include "../bashintl.h"
|
||||
|
||||
#include "../shell.h"
|
||||
#include "../trap.h"
|
||||
|
@ -57,9 +67,10 @@ $END
|
|||
extern int errno;
|
||||
#endif /* !errno */
|
||||
|
||||
#if defined (JOB_CONTROL)
|
||||
extern int posixly_correct;
|
||||
|
||||
static void kill_error __P((pid_t, int));
|
||||
|
||||
#if !defined (CONTINUE_AFTER_KILL_ERROR)
|
||||
# define CONTINUE_OR_FAIL return (EXECUTION_FAILURE)
|
||||
#else
|
||||
|
@ -73,7 +84,7 @@ int
|
|||
kill_builtin (list)
|
||||
WORD_LIST *list;
|
||||
{
|
||||
int sig, any_succeeded, listing, saw_signal;
|
||||
int sig, any_succeeded, listing, saw_signal, dflags;
|
||||
char *sigspec, *word;
|
||||
pid_t pid;
|
||||
intmax_t pid_value;
|
||||
|
@ -88,6 +99,7 @@ kill_builtin (list)
|
|||
sig = SIGTERM;
|
||||
sigspec = "TERM";
|
||||
|
||||
dflags = DSIG_NOCASE | ((posixly_correct == 0) ? DSIG_SIGPREFIX : 0);
|
||||
/* Process options. */
|
||||
while (list)
|
||||
{
|
||||
|
@ -107,7 +119,7 @@ kill_builtin (list)
|
|||
if (sigspec[0] == '0' && sigspec[1] == '\0')
|
||||
sig = 0;
|
||||
else
|
||||
sig = decode_signal (sigspec);
|
||||
sig = decode_signal (sigspec, dflags);
|
||||
list = list->next;
|
||||
}
|
||||
else
|
||||
|
@ -132,7 +144,7 @@ kill_builtin (list)
|
|||
else if ((*word == '-') && !saw_signal)
|
||||
{
|
||||
sigspec = word + 1;
|
||||
sig = decode_signal (sigspec);
|
||||
sig = decode_signal (sigspec, dflags);
|
||||
saw_signal++;
|
||||
list = list->next;
|
||||
}
|
||||
|
@ -168,26 +180,34 @@ kill_builtin (list)
|
|||
{
|
||||
pid = (pid_t) pid_value;
|
||||
|
||||
if ((pid < -1 ? kill_pid (-pid, sig, 1) : kill_pid (pid, sig, 0)) < 0)
|
||||
goto signal_error;
|
||||
if (kill_pid (pid, sig, pid < -1) < 0)
|
||||
{
|
||||
if (errno == EINVAL)
|
||||
sh_invalidsig (sigspec);
|
||||
else
|
||||
kill_error (pid, errno);
|
||||
CONTINUE_OR_FAIL;
|
||||
}
|
||||
else
|
||||
any_succeeded++;
|
||||
}
|
||||
#if defined (JOB_CONTROL)
|
||||
else if (*list->word->word && *list->word->word != '%')
|
||||
{
|
||||
builtin_error ("%s: no such pid", list->word->word);
|
||||
builtin_error (_("%s: arguments must be process or job IDs"), list->word->word);
|
||||
CONTINUE_OR_FAIL;
|
||||
}
|
||||
else if (*word && (interactive || job_control))
|
||||
else if (*word)
|
||||
/* Posix.2 says you can kill without job control active (4.32.4) */
|
||||
{ /* Must be a job spec. Check it out. */
|
||||
int job;
|
||||
sigset_t set, oset;
|
||||
JOB *j;
|
||||
|
||||
BLOCK_CHILD (set, oset);
|
||||
job = get_job_spec (list);
|
||||
|
||||
if (job < 0 || job >= job_slots || !jobs[job])
|
||||
if (INVALID_JOB (job))
|
||||
{
|
||||
if (job != DUP_JOB)
|
||||
sh_badjob (list->word->word);
|
||||
|
@ -195,26 +215,27 @@ kill_builtin (list)
|
|||
CONTINUE_OR_FAIL;
|
||||
}
|
||||
|
||||
j = get_job_by_jid (job);
|
||||
/* Job spec used. Kill the process group. If the job was started
|
||||
without job control, then its pgrp == shell_pgrp, so we have
|
||||
to be careful. We take the pid of the first job in the pipeline
|
||||
in that case. */
|
||||
pid = IS_JOBCONTROL (job) ? jobs[job]->pgrp : jobs[job]->pipe->pid;
|
||||
pid = IS_JOBCONTROL (job) ? j->pgrp : j->pipe->pid;
|
||||
|
||||
UNBLOCK_CHILD (oset);
|
||||
|
||||
if (kill_pid (pid, sig, 1) < 0)
|
||||
{
|
||||
signal_error:
|
||||
if (errno == EINVAL)
|
||||
sh_invalidsig (sigspec);
|
||||
else
|
||||
builtin_error ("(%ld) - %s", (long)pid, strerror (errno));
|
||||
kill_error (pid, errno);
|
||||
CONTINUE_OR_FAIL;
|
||||
}
|
||||
else
|
||||
any_succeeded++;
|
||||
}
|
||||
#endif /* !JOB_CONTROL */
|
||||
else
|
||||
{
|
||||
sh_badpid (list->word->word);
|
||||
|
@ -226,4 +247,16 @@ kill_builtin (list)
|
|||
|
||||
return (any_succeeded ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
|
||||
}
|
||||
#endif /* JOB_CONTROL */
|
||||
|
||||
static void
|
||||
kill_error (pid, e)
|
||||
pid_t pid;
|
||||
int e;
|
||||
{
|
||||
char *x;
|
||||
|
||||
x = strerror (e);
|
||||
if (x == 0)
|
||||
x = _("Unknown error");
|
||||
builtin_error ("(%ld) - %s", (long)pid, x);
|
||||
}
|
||||
|
|
|
@ -1,33 +1,34 @@
|
|||
This file is let.def, from which is created let.c.
|
||||
It implements the builtin "let" in Bash.
|
||||
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$BUILTIN let
|
||||
$FUNCTION let_builtin
|
||||
$PRODUCES let.c
|
||||
$SHORT_DOC let arg [arg ...]
|
||||
Each ARG is an arithmetic expression to be evaluated. Evaluation
|
||||
is done in fixed-width integers with no check for overflow, though
|
||||
division by 0 is trapped and flagged as an error. The following
|
||||
list of operators is grouped into levels of equal-precedence operators.
|
||||
The levels are listed in order of decreasing precedence.
|
||||
Evaluate arithmetic expressions.
|
||||
|
||||
Evaluate each ARG as an arithmetic expression. Evaluation is done in
|
||||
fixed-width integers with no check for overflow, though division by 0
|
||||
is trapped and flagged as an error. The following list of operators is
|
||||
grouped into levels of equal-precedence operators. The levels are listed
|
||||
in order of decreasing precedence.
|
||||
|
||||
id++, id-- variable post-increment, post-decrement
|
||||
++id, --id variable pre-increment, pre-decrement
|
||||
|
@ -45,7 +46,7 @@ The levels are listed in order of decreasing precedence.
|
|||
&& logical AND
|
||||
|| logical OR
|
||||
expr ? expr : expr
|
||||
conditional expression
|
||||
conditional operator
|
||||
=, *=, /=, %=,
|
||||
+=, -=, <<=, >>=,
|
||||
&=, ^=, |= assignment
|
||||
|
@ -59,8 +60,8 @@ Operators are evaluated in order of precedence. Sub-expressions in
|
|||
parentheses are evaluated first and may override the precedence
|
||||
rules above.
|
||||
|
||||
If the last ARG evaluates to 0, let returns 1; 0 is returned
|
||||
otherwise.
|
||||
Exit Status:
|
||||
If the last ARG evaluates to 0, let returns 1; let returns 0 otherwise..
|
||||
$END
|
||||
|
||||
#include <config.h>
|
||||
|
@ -72,6 +73,8 @@ $END
|
|||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "../bashintl.h"
|
||||
|
||||
#include "../shell.h"
|
||||
#include "common.h"
|
||||
|
||||
|
@ -89,7 +92,7 @@ let_builtin (list)
|
|||
|
||||
if (list == 0)
|
||||
{
|
||||
builtin_error ("expression expected");
|
||||
builtin_error (_("expression expected"));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
|
@ -114,7 +117,7 @@ exp_builtin (list)
|
|||
|
||||
if (list == 0)
|
||||
{
|
||||
builtin_error ("expression expected");
|
||||
builtin_error (_("expression expected"));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,343 @@
|
|||
This file is mapfile.def, from which is created mapfile.c.
|
||||
It implements the builtin "mapfile" in Bash.
|
||||
|
||||
Copyright (C) 2005-2006 Rocky Bernstein for Free Software Foundation, Inc.
|
||||
Copyright (C) 2008,2009 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 3 of the License, 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. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES mapfile.c
|
||||
|
||||
$BUILTIN mapfile
|
||||
$FUNCTION mapfile_builtin
|
||||
$SHORT_DOC mapfile [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]
|
||||
Read lines from the standard input into an array variable.
|
||||
|
||||
Read lines from the standard input into the array variable ARRAY, or from
|
||||
file descriptor FD if the -u option is supplied. The variable MAPFILE is
|
||||
the default ARRAY.
|
||||
|
||||
Options:
|
||||
-n count Copy at most COUNT lines. If COUNT is 0, all lines are copied.
|
||||
-O origin Begin assigning to ARRAY at index ORIGIN. The default index is 0.
|
||||
-s count Discard the first COUNT lines read.
|
||||
-t Remove a trailing newline from each line read.
|
||||
-u fd Read lines from file descriptor FD instead of the standard input.
|
||||
-C callback Evaluate CALLBACK each time QUANTUM lines are read.
|
||||
-c quantum Specify the number of lines read between each call to CALLBACK.
|
||||
|
||||
Arguments:
|
||||
ARRAY Array variable name to use for file data.
|
||||
|
||||
If -C is supplied without -c, the default quantum is 5000. When
|
||||
CALLBACK is evaluated, it is supplied the index of the next array
|
||||
element to be assigned as an additional argument.
|
||||
|
||||
If not supplied with an explicit origin, mapfile will clear ARRAY before
|
||||
assigning to it.
|
||||
|
||||
Exit Status:
|
||||
Returns success unless an invalid option is given or ARRAY is readonly.
|
||||
$END
|
||||
|
||||
$BUILTIN readarray
|
||||
$FUNCTION mapfile_builtin
|
||||
$SHORT_DOC readarray [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]
|
||||
Read lines from a file into an array variable.
|
||||
|
||||
A synonym for `mapfile'.
|
||||
$END
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "builtins.h"
|
||||
#include "posixstat.h"
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "bashansi.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "../bashintl.h"
|
||||
#include "../shell.h"
|
||||
#include "common.h"
|
||||
#include "bashgetopt.h"
|
||||
|
||||
#if !defined (errno)
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#if defined (ARRAY_VARS)
|
||||
|
||||
#define DEFAULT_ARRAY_NAME "MAPFILE"
|
||||
|
||||
/* The value specifying how frequently `mapfile' calls the callback. */
|
||||
#define DEFAULT_QUANTUM 5000
|
||||
|
||||
/* Values for FLAGS */
|
||||
#define MAPF_CLEARARRAY 0x01
|
||||
#define MAPF_CHOP 0x02
|
||||
|
||||
static int
|
||||
run_callback(callback, current_index)
|
||||
const char *callback;
|
||||
unsigned int current_index;
|
||||
{
|
||||
unsigned int execlen;
|
||||
char *execstr;
|
||||
int flags;
|
||||
|
||||
execlen = strlen (callback) + 10;
|
||||
/* 1 for space between %s and %d,
|
||||
another 1 for the last nul char for C string. */
|
||||
execlen += 2;
|
||||
execstr = xmalloc (execlen);
|
||||
|
||||
flags = 0;
|
||||
#if 0
|
||||
if (interactive)
|
||||
flags |= SEVAL_NOHIST|SEVAL_INTERACT;
|
||||
#endif
|
||||
snprintf (execstr, execlen, "%s %d", callback, current_index);
|
||||
return parse_and_execute(execstr, NULL, flags);
|
||||
}
|
||||
|
||||
static void
|
||||
do_chop(line)
|
||||
char * line;
|
||||
{
|
||||
int length;
|
||||
|
||||
length = strlen (line);
|
||||
if (length && line[length-1] == '\n')
|
||||
line[length-1] = '\0';
|
||||
}
|
||||
|
||||
static int
|
||||
mapfile (fd, line_count_goal, origin, nskip, callback_quantum, callback, array_name, flags)
|
||||
int fd;
|
||||
long line_count_goal, origin, nskip, callback_quantum;
|
||||
char *callback, *array_name;
|
||||
int flags;
|
||||
{
|
||||
char *line;
|
||||
size_t line_length;
|
||||
unsigned int array_index, line_count;
|
||||
SHELL_VAR *entry;
|
||||
int unbuffered_read;
|
||||
|
||||
line = NULL;
|
||||
line_length = 0;
|
||||
unbuffered_read = 0;
|
||||
|
||||
/* The following check should be done before reading any lines. Doing it
|
||||
here allows us to call bind_array_element instead of bind_array_variable
|
||||
and skip the variable lookup on every call. */
|
||||
entry = find_or_make_array_variable (array_name, 1);
|
||||
if (entry == 0 || readonly_p (entry) || noassign_p (entry))
|
||||
{
|
||||
if (readonly_p (entry))
|
||||
err_readonly (array_name);
|
||||
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
if (flags & MAPF_CLEARARRAY)
|
||||
array_flush (array_cell (entry));
|
||||
|
||||
#ifndef __CYGWIN__
|
||||
unbuffered_read = (lseek (fd, 0L, SEEK_CUR) < 0) && (errno == ESPIPE);
|
||||
#else
|
||||
unbuffered_read = 1;
|
||||
#endif
|
||||
|
||||
zreset ();
|
||||
|
||||
/* Skip any lines at beginning of file? */
|
||||
for (line_count = 0; line_count < nskip; line_count++)
|
||||
if (zgetline (fd, &line, &line_length, unbuffered_read) < 0)
|
||||
break;
|
||||
|
||||
line = 0;
|
||||
line_length = 0;
|
||||
|
||||
/* Reset the buffer for bash own stream */
|
||||
interrupt_immediately++;
|
||||
for (array_index = origin, line_count = 1;
|
||||
zgetline (fd, &line, &line_length, unbuffered_read) != -1;
|
||||
array_index++, line_count++)
|
||||
{
|
||||
/* Have we exceeded # of lines to store? */
|
||||
if (line_count_goal != 0 && line_count > line_count_goal)
|
||||
break;
|
||||
|
||||
/* Remove trailing newlines? */
|
||||
if (flags & MAPF_CHOP)
|
||||
do_chop (line);
|
||||
|
||||
/* Has a callback been registered and if so is it time to call it? */
|
||||
if (callback && line_count && (line_count % callback_quantum) == 0)
|
||||
{
|
||||
run_callback (callback, array_index);
|
||||
|
||||
/* Reset the buffer for bash own stream. */
|
||||
if (unbuffered_read == 0)
|
||||
zsyncfd (fd);
|
||||
}
|
||||
|
||||
bind_array_element (entry, array_index, line, 0);
|
||||
}
|
||||
|
||||
xfree (line);
|
||||
|
||||
if (unbuffered_read == 0)
|
||||
zsyncfd (fd);
|
||||
|
||||
interrupt_immediately--;
|
||||
return EXECUTION_SUCCESS;
|
||||
}
|
||||
|
||||
int
|
||||
mapfile_builtin (list)
|
||||
WORD_LIST *list;
|
||||
{
|
||||
int opt, code, fd, clear_array, flags;
|
||||
intmax_t intval;
|
||||
long lines, origin, nskip, callback_quantum;
|
||||
char *array_name, *callback;
|
||||
|
||||
clear_array = 1;
|
||||
fd = 0;
|
||||
lines = origin = nskip = 0;
|
||||
flags = MAPF_CLEARARRAY;
|
||||
callback_quantum = DEFAULT_QUANTUM;
|
||||
callback = 0;
|
||||
|
||||
reset_internal_getopt ();
|
||||
while ((opt = internal_getopt (list, "u:n:O:tC:c:s:")) != -1)
|
||||
{
|
||||
switch (opt)
|
||||
{
|
||||
case 'u':
|
||||
code = legal_number (list_optarg, &intval);
|
||||
if (code == 0 || intval < 0 || intval != (int)intval)
|
||||
{
|
||||
builtin_error (_("%s: invalid file descriptor specification"), list_optarg);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
else
|
||||
fd = intval;
|
||||
|
||||
if (sh_validfd (fd) == 0)
|
||||
{
|
||||
builtin_error (_("%d: invalid file descriptor: %s"), fd, strerror (errno));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
code = legal_number (list_optarg, &intval);
|
||||
if (code == 0 || intval < 0 || intval != (unsigned)intval)
|
||||
{
|
||||
builtin_error (_("%s: invalid line count"), list_optarg);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
else
|
||||
lines = intval;
|
||||
break;
|
||||
|
||||
case 'O':
|
||||
code = legal_number (list_optarg, &intval);
|
||||
if (code == 0 || intval < 0 || intval != (unsigned)intval)
|
||||
{
|
||||
builtin_error (_("%s: invalid array origin"), list_optarg);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
else
|
||||
origin = intval;
|
||||
flags &= ~MAPF_CLEARARRAY;
|
||||
break;
|
||||
case 't':
|
||||
flags |= MAPF_CHOP;
|
||||
break;
|
||||
case 'C':
|
||||
callback = list_optarg;
|
||||
break;
|
||||
case 'c':
|
||||
code = legal_number (list_optarg, &intval);
|
||||
if (code == 0 || intval < 0 || intval != (unsigned)intval)
|
||||
{
|
||||
builtin_error (_("%s: invalid callback quantum"), list_optarg);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
else
|
||||
callback_quantum = intval;
|
||||
break;
|
||||
case 's':
|
||||
code = legal_number (list_optarg, &intval);
|
||||
if (code == 0 || intval < 0 || intval != (unsigned)intval)
|
||||
{
|
||||
builtin_error (_("%s: invalid line count"), list_optarg);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
else
|
||||
nskip = intval;
|
||||
break;
|
||||
default:
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
}
|
||||
}
|
||||
list = loptend;
|
||||
|
||||
if (list == 0)
|
||||
array_name = DEFAULT_ARRAY_NAME;
|
||||
else if (list->word == 0 || list->word->word == 0)
|
||||
{
|
||||
builtin_error ("internal error: getting variable name");
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
else if (list->word->word[0] == '\0')
|
||||
{
|
||||
builtin_error (_("empty array variable name"));
|
||||
return (EX_USAGE);
|
||||
}
|
||||
else
|
||||
array_name = list->word->word;
|
||||
|
||||
if (legal_identifier (array_name) == 0 && valid_array_reference (array_name) == 0)
|
||||
{
|
||||
sh_invalidid (array_name);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
return mapfile (fd, lines, origin, nskip, callback_quantum, callback, array_name, flags);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int
|
||||
mapfile_builtin (list)
|
||||
WORD_LIST *list;
|
||||
{
|
||||
builtin_error (_("array variable support required"));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
#endif /* ARRAY_VARS */
|
|
@ -1,25 +1,34 @@
|
|||
/* mkbuiltins.c - Create builtins.c, builtext.h, and builtdoc.c from
|
||||
a single source file called builtins.def. */
|
||||
|
||||
/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
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 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 3 of the License, 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.
|
||||
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. */
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#if !defined (CROSS_COMPILING)
|
||||
# include <config.h>
|
||||
#else /* CROSS_COMPILING */
|
||||
/* A conservative set of defines based on POSIX/SUS3/XPG6 */
|
||||
# define HAVE_UNISTD_H
|
||||
# define HAVE_STRING_H
|
||||
# define HAVE_STDLIB_H
|
||||
|
||||
# define HAVE_RENAME
|
||||
#endif /* CROSS_COMPILING */
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# ifdef _MINIX
|
||||
|
@ -29,8 +38,10 @@ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
|||
#endif
|
||||
|
||||
#ifndef _MINIX
|
||||
#include "../bashtypes.h"
|
||||
#include <sys/file.h>
|
||||
# include "../bashtypes.h"
|
||||
# if defined (HAVE_SYS_FILE_H)
|
||||
# include <sys/file.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include "posixstat.h"
|
||||
|
@ -60,6 +71,9 @@ extern char *strcpy ();
|
|||
/* Flag values that builtins can have. */
|
||||
#define BUILTIN_FLAG_SPECIAL 0x01
|
||||
#define BUILTIN_FLAG_ASSIGNMENT 0x02
|
||||
#define BUILTIN_FLAG_POSIX_BUILTIN 0x04
|
||||
|
||||
#define BASE_INDENT 4
|
||||
|
||||
/* If this stream descriptor is non-zero, then write
|
||||
texinfo documentation to it. */
|
||||
|
@ -75,6 +89,10 @@ int inhibit_production = 0;
|
|||
the builtin name, in `./helpfiles'. */
|
||||
int separate_helpfiles = 0;
|
||||
|
||||
/* Non-zero means to create single C strings for each `longdoc', with
|
||||
embedded newlines, for ease of translation. */
|
||||
int single_longdoc_strings = 1;
|
||||
|
||||
/* The name of a directory into which the separate external help files will
|
||||
eventually be installed. */
|
||||
char *helpfile_directory;
|
||||
|
@ -129,7 +147,7 @@ ARRAY *saved_builtins = (ARRAY *)NULL;
|
|||
char *special_builtins[] =
|
||||
{
|
||||
":", ".", "source", "break", "continue", "eval", "exec", "exit",
|
||||
"export", "readonly", "return", "set", "shift", "trap", "unset",
|
||||
"export", "readonly", "return", "set", "shift", "times", "trap", "unset",
|
||||
(char *)NULL
|
||||
};
|
||||
|
||||
|
@ -140,9 +158,18 @@ char *assignment_builtins[] =
|
|||
(char *)NULL
|
||||
};
|
||||
|
||||
/* The builtin commands that are special to the POSIX search order. */
|
||||
char *posix_builtins[] =
|
||||
{
|
||||
"alias", "bg", "cd", "command", "false", "fc", "fg", "getopts", "jobs",
|
||||
"kill", "newgrp", "pwd", "read", "true", "umask", "unalias", "wait",
|
||||
(char *)NULL
|
||||
};
|
||||
|
||||
/* Forward declarations. */
|
||||
static int is_special_builtin ();
|
||||
static int is_assignment_builtin ();
|
||||
static int is_posix_builtin ();
|
||||
|
||||
#if !defined (HAVE_RENAME)
|
||||
static int rename ();
|
||||
|
@ -242,6 +269,8 @@ main (argc, argv)
|
|||
separate_helpfiles = 1;
|
||||
helpfile_directory = argv[arg_index++];
|
||||
}
|
||||
else if (strcmp (arg, "-S") == 0)
|
||||
single_longdoc_strings = 0;
|
||||
else
|
||||
{
|
||||
fprintf (stderr, "%s: Unknown flag %s.\n", argv[0], arg);
|
||||
|
@ -390,14 +419,8 @@ array_add (element, array)
|
|||
array->array = (char **)xrealloc
|
||||
(array->array, (array->size += array->growth_rate) * array->width);
|
||||
|
||||
#if defined (HAVE_BCOPY)
|
||||
bcopy (&element, (char *) &(array->array[array->sindex]), array->width);
|
||||
array->sindex++;
|
||||
bzero ((char *) &(array->array[array->sindex]), array->width);
|
||||
#else
|
||||
array->array[array->sindex++] = element;
|
||||
array->array[array->sindex] = (char *)NULL;
|
||||
#endif /* !HAVE_BCOPY */
|
||||
}
|
||||
|
||||
/* Free an allocated array and data pointer. */
|
||||
|
@ -806,6 +829,8 @@ builtin_handler (self, defs, arg)
|
|||
new->flags |= BUILTIN_FLAG_SPECIAL;
|
||||
if (is_assignment_builtin (name))
|
||||
new->flags |= BUILTIN_FLAG_ASSIGNMENT;
|
||||
if (is_posix_builtin (name))
|
||||
new->flags |= BUILTIN_FLAG_POSIX_BUILTIN;
|
||||
|
||||
array_add ((char *)new, defs->builtins);
|
||||
building_builtin = 1;
|
||||
|
@ -927,7 +952,7 @@ produces_handler (self, defs, arg)
|
|||
line_error (defs, "%s already has a %s definition", defs->filename, self);
|
||||
else
|
||||
{
|
||||
char path[255];
|
||||
char path[255];
|
||||
defs->production = get_arg (self, defs, arg);
|
||||
|
||||
if (inhibit_production)
|
||||
|
@ -1078,9 +1103,10 @@ save_builtin (builtin)
|
|||
}
|
||||
|
||||
/* Flags that mean something to write_documentation (). */
|
||||
#define STRING_ARRAY 1
|
||||
#define TEXINFO 2
|
||||
#define PLAINTEXT 4
|
||||
#define STRING_ARRAY 0x01
|
||||
#define TEXINFO 0x02
|
||||
#define PLAINTEXT 0x04
|
||||
#define HELPFILE 0x08
|
||||
|
||||
char *structfile_header[] = {
|
||||
"/* builtins.c -- the built in shell commands. */",
|
||||
|
@ -1088,23 +1114,23 @@ char *structfile_header[] = {
|
|||
"/* This file is manufactured by ./mkbuiltins, and should not be",
|
||||
" edited by hand. See the source to mkbuiltins for details. */",
|
||||
"",
|
||||
"/* Copyright (C) 1987-2002 Free Software Foundation, Inc.",
|
||||
"/* Copyright (C) 1987-2009 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 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 3 of the License, 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.",
|
||||
" 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. */",
|
||||
" along with Bash. If not, see <http://www.gnu.org/licenses/>.",
|
||||
"*/",
|
||||
"",
|
||||
"/* The list of shell builtins. Each element is name, function, flags,",
|
||||
" long-doc, short-doc. The long-doc field contains a pointer to an array",
|
||||
|
@ -1149,6 +1175,9 @@ write_file_headers (structfile, externfile)
|
|||
|
||||
fprintf (structfile, "#include \"%s\"\n",
|
||||
/*extern_filename ? extern_filename : */"builtext.h");
|
||||
|
||||
fprintf (structfile, "#include \"bashintl.h\"\n");
|
||||
|
||||
fprintf (structfile, "\nstruct builtin static_shell_builtins[] = {\n");
|
||||
}
|
||||
|
||||
|
@ -1222,14 +1251,15 @@ write_builtins (defs, structfile, externfile)
|
|||
else
|
||||
fprintf (structfile, "(sh_builtin_func_t *)0x0, ");
|
||||
|
||||
fprintf (structfile, "%s%s%s, %s_doc,\n",
|
||||
fprintf (structfile, "%s%s%s%s, %s_doc,\n",
|
||||
"BUILTIN_ENABLED | STATIC_BUILTIN",
|
||||
(builtin->flags & BUILTIN_FLAG_SPECIAL) ? " | SPECIAL_BUILTIN" : "",
|
||||
(builtin->flags & BUILTIN_FLAG_ASSIGNMENT) ? " | ASSIGNMENT_BUILTIN" : "",
|
||||
(builtin->flags & BUILTIN_FLAG_POSIX_BUILTIN) ? " | POSIX_BUILTIN" : "",
|
||||
document_name (builtin));
|
||||
|
||||
fprintf
|
||||
(structfile, " \"%s\", (char *)NULL },\n",
|
||||
(structfile, " N_(\"%s\"), (char *)NULL },\n",
|
||||
builtin->shortdoc ? builtin->shortdoc : builtin->name);
|
||||
|
||||
}
|
||||
|
@ -1288,7 +1318,7 @@ write_longdocs (stream, builtins)
|
|||
sarray[0] = (char *)xmalloc (l + 1);
|
||||
sprintf (sarray[0], "%s/%s", helpfile_directory, dname);
|
||||
sarray[1] = (char *)NULL;
|
||||
write_documentation (stream, sarray, 0, STRING_ARRAY);
|
||||
write_documentation (stream, sarray, 0, STRING_ARRAY|HELPFILE);
|
||||
free (sarray[0]);
|
||||
}
|
||||
else
|
||||
|
@ -1360,8 +1390,10 @@ write_endifs (stream, defines)
|
|||
fprintf (stream, " */\n");
|
||||
}
|
||||
|
||||
/* Write DOCUMENTAION to STREAM, perhaps surrounding it with double-quotes
|
||||
and quoting special characters in the string. */
|
||||
/* Write DOCUMENTATION to STREAM, perhaps surrounding it with double-quotes
|
||||
and quoting special characters in the string. Handle special things for
|
||||
internationalization (gettext) and the single-string vs. multiple-strings
|
||||
issues. */
|
||||
void
|
||||
write_documentation (stream, documentation, indentation, flags)
|
||||
FILE *stream;
|
||||
|
@ -1370,32 +1402,69 @@ write_documentation (stream, documentation, indentation, flags)
|
|||
{
|
||||
register int i, j;
|
||||
register char *line;
|
||||
int string_array, texinfo;
|
||||
int string_array, texinfo, base_indent, last_cpp, filename_p;
|
||||
|
||||
if (!stream)
|
||||
if (stream == 0)
|
||||
return;
|
||||
|
||||
string_array = flags & STRING_ARRAY;
|
||||
if (string_array)
|
||||
fprintf (stream, " {\n#if defined (HELP_BUILTIN)\n");
|
||||
filename_p = flags & HELPFILE;
|
||||
|
||||
for (i = 0, texinfo = (flags & TEXINFO); line = documentation[i]; i++)
|
||||
if (string_array)
|
||||
{
|
||||
/* Allow #ifdef's to be written out verbatim. */
|
||||
fprintf (stream, " {\n#if defined (HELP_BUILTIN)\n"); /* } */
|
||||
if (single_longdoc_strings)
|
||||
{
|
||||
if (filename_p == 0)
|
||||
{
|
||||
if (documentation && documentation[0] && documentation[0][0])
|
||||
fprintf (stream, "N_(\"");
|
||||
else
|
||||
fprintf (stream, "N_(\" "); /* the empty string translates specially. */
|
||||
}
|
||||
else
|
||||
fprintf (stream, "\"");
|
||||
}
|
||||
}
|
||||
|
||||
base_indent = (string_array && single_longdoc_strings && filename_p == 0) ? BASE_INDENT : 0;
|
||||
|
||||
for (i = last_cpp = 0, texinfo = (flags & TEXINFO); line = documentation[i]; i++)
|
||||
{
|
||||
/* Allow #ifdef's to be written out verbatim, but don't put them into
|
||||
separate help files. */
|
||||
if (*line == '#')
|
||||
{
|
||||
if (string_array)
|
||||
if (string_array && filename_p == 0 && single_longdoc_strings == 0)
|
||||
fprintf (stream, "%s\n", line);
|
||||
last_cpp = 1;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
last_cpp = 0;
|
||||
|
||||
if (string_array)
|
||||
fprintf (stream, " \"");
|
||||
/* prefix with N_( for gettext */
|
||||
if (string_array && single_longdoc_strings == 0)
|
||||
{
|
||||
if (filename_p == 0)
|
||||
{
|
||||
if (line[0])
|
||||
fprintf (stream, " N_(\"");
|
||||
else
|
||||
fprintf (stream, " N_(\" "); /* the empty string translates specially. */
|
||||
}
|
||||
else
|
||||
fprintf (stream, " \"");
|
||||
}
|
||||
|
||||
if (indentation)
|
||||
for (j = 0; j < indentation; j++)
|
||||
fprintf (stream, " ");
|
||||
|
||||
/* Don't indent the first line, because of how the help builtin works. */
|
||||
if (i == 0)
|
||||
indentation += base_indent;
|
||||
|
||||
if (string_array)
|
||||
{
|
||||
for (j = 0; line[j]; j++)
|
||||
|
@ -1412,7 +1481,17 @@ write_documentation (stream, documentation, indentation, flags)
|
|||
}
|
||||
}
|
||||
|
||||
fprintf (stream, "\",\n");
|
||||
/* closing right paren for gettext */
|
||||
if (single_longdoc_strings == 0)
|
||||
{
|
||||
if (filename_p == 0)
|
||||
fprintf (stream, "\"),\n");
|
||||
else
|
||||
fprintf (stream, "\",\n");
|
||||
}
|
||||
else if (documentation[i+1])
|
||||
/* don't add extra newline after last line */
|
||||
fprintf (stream, "\\n\\\n");
|
||||
}
|
||||
else if (texinfo)
|
||||
{
|
||||
|
@ -1436,6 +1515,15 @@ write_documentation (stream, documentation, indentation, flags)
|
|||
fprintf (stream, "%s\n", line);
|
||||
}
|
||||
|
||||
/* closing right paren for gettext */
|
||||
if (string_array && single_longdoc_strings)
|
||||
{
|
||||
if (filename_p == 0)
|
||||
fprintf (stream, "\"),\n");
|
||||
else
|
||||
fprintf (stream, "\",\n");
|
||||
}
|
||||
|
||||
if (string_array)
|
||||
fprintf (stream, "#endif /* HELP_BUILTIN */\n (char *)NULL\n};\n");
|
||||
}
|
||||
|
@ -1508,6 +1596,13 @@ is_assignment_builtin (name)
|
|||
return (_find_in_table (name, assignment_builtins));
|
||||
}
|
||||
|
||||
static int
|
||||
is_posix_builtin (name)
|
||||
char *name;
|
||||
{
|
||||
return (_find_in_table (name, posix_builtins));
|
||||
}
|
||||
|
||||
#if !defined (HAVE_RENAME)
|
||||
static int
|
||||
rename (from, to)
|
||||
|
|
|
@ -1,37 +1,49 @@
|
|||
This file is printf.def, from which is created printf.c.
|
||||
It implements the builtin "printf" in Bash.
|
||||
|
||||
Copyright (C) 1997-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1997-2009 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 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 3 of the License, 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.
|
||||
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, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES printf.c
|
||||
|
||||
$BUILTIN printf
|
||||
$FUNCTION printf_builtin
|
||||
$SHORT_DOC printf format [arguments]
|
||||
printf formats and prints ARGUMENTS under control of the FORMAT. FORMAT
|
||||
is a character string which contains three types of objects: plain
|
||||
characters, which are simply copied to standard output, character escape
|
||||
sequences which are converted and copied to the standard output, and
|
||||
$SHORT_DOC printf [-v var] format [arguments]
|
||||
Formats and prints ARGUMENTS under control of the FORMAT.
|
||||
|
||||
Options:
|
||||
-v var assign the output to shell variable VAR rather than
|
||||
display it on the standard output
|
||||
|
||||
FORMAT is a character string which contains three types of objects: plain
|
||||
characters, which are simply copied to standard output; character escape
|
||||
sequences, which are converted and copied to the standard output; and
|
||||
format specifications, each of which causes printing of the next successive
|
||||
argument. In addition to the standard printf(1) formats, %b means to
|
||||
expand backslash escape sequences in the corresponding argument, and %q
|
||||
means to quote the argument in a way that can be reused as shell input.
|
||||
argument.
|
||||
|
||||
In addition to the standard format specifications described in printf(1)
|
||||
and printf(3), printf interprets:
|
||||
|
||||
%b expand backslash escape sequences in the corresponding argument
|
||||
%q quote the argument in a way that can be reused as shell input
|
||||
|
||||
Exit Status:
|
||||
Returns success unless an invalid option is given or a write or assignment
|
||||
error occurs.
|
||||
$END
|
||||
|
||||
#include <config.h>
|
||||
|
@ -47,6 +59,12 @@ $END
|
|||
# define INT_MIN (-2147483647-1)
|
||||
#endif
|
||||
|
||||
#if defined (PREFER_STDARG)
|
||||
# include <stdarg.h>
|
||||
#else
|
||||
# include <varargs.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <chartypes.h>
|
||||
|
||||
|
@ -55,12 +73,18 @@ $END
|
|||
#endif
|
||||
|
||||
#include "../bashansi.h"
|
||||
#include "../bashintl.h"
|
||||
|
||||
#include "../shell.h"
|
||||
#include "shmbutil.h"
|
||||
#include "stdc.h"
|
||||
#include "bashgetopt.h"
|
||||
#include "common.h"
|
||||
|
||||
#if defined (PRI_MACROS_BROKEN)
|
||||
# undef PRIdMAX
|
||||
#endif
|
||||
|
||||
#if !defined (PRIdMAX)
|
||||
# if HAVE_LONG_LONG
|
||||
# define PRIdMAX "lld"
|
||||
|
@ -73,29 +97,68 @@ $END
|
|||
extern int errno;
|
||||
#endif
|
||||
|
||||
#define PC(c) \
|
||||
do { \
|
||||
char b[2]; \
|
||||
tw++; \
|
||||
b[0] = c; b[1] = '\0'; \
|
||||
if (vflag) \
|
||||
vbadd (b, 1); \
|
||||
else \
|
||||
putchar (c); \
|
||||
} while (0)
|
||||
|
||||
#define PF(f, func) \
|
||||
do { \
|
||||
int nw; \
|
||||
clearerr (stdout); \
|
||||
if (have_fieldwidth && have_precision) \
|
||||
tw += printf(f, fieldwidth, precision, func); \
|
||||
nw = vflag ? vbprintf (f, fieldwidth, precision, func) : printf (f, fieldwidth, precision, func); \
|
||||
else if (have_fieldwidth) \
|
||||
tw += printf(f, fieldwidth, func); \
|
||||
nw = vflag ? vbprintf (f, fieldwidth, func) : printf (f, fieldwidth, func); \
|
||||
else if (have_precision) \
|
||||
tw += printf(f, precision, func); \
|
||||
nw = vflag ? vbprintf (f, precision, func) : printf (f, fieldwidth, func); \
|
||||
else \
|
||||
tw += printf(f, func); \
|
||||
nw = vflag ? vbprintf (f, func) : printf (f, func); \
|
||||
tw += nw; \
|
||||
if (ferror (stdout)) \
|
||||
{ \
|
||||
sh_wrerror (); \
|
||||
clearerr (stdout); \
|
||||
return (EXECUTION_FAILURE); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/* We free the buffer used by mklong() if it's `too big'. */
|
||||
#define PRETURN(value) \
|
||||
do \
|
||||
{ \
|
||||
if (vflag) \
|
||||
{ \
|
||||
bind_variable (vname, vbuf, 0); \
|
||||
stupidly_hack_special_variables (vname); \
|
||||
} \
|
||||
if (conv_bufsize > 4096 ) \
|
||||
{ \
|
||||
free(conv_buf); \
|
||||
free (conv_buf); \
|
||||
conv_bufsize = 0; \
|
||||
conv_buf = 0; \
|
||||
} \
|
||||
if (vbsize > 4096) \
|
||||
{ \
|
||||
free (vbuf); \
|
||||
vbsize = 0; \
|
||||
vbuf = 0; \
|
||||
} \
|
||||
else if (vbuf) \
|
||||
vbuf[0] = 0; \
|
||||
terminate_immediately--; \
|
||||
fflush (stdout); \
|
||||
if (ferror (stdout)) \
|
||||
{ \
|
||||
clearerr (stdout); \
|
||||
return (EXECUTION_FAILURE); \
|
||||
} \
|
||||
return (value); \
|
||||
} \
|
||||
while (0)
|
||||
|
@ -103,10 +166,20 @@ extern int errno;
|
|||
#define SKIP1 "#'-+ 0"
|
||||
#define LENMODS "hjlLtz"
|
||||
|
||||
#ifndef HAVE_ASPRINTF
|
||||
extern int asprintf __P((char **, const char *, ...)) __attribute__((__format__ (printf, 2, 3)));
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_VSNPRINTF
|
||||
extern int vsnprintf __P((char *, size_t, const char *, ...)) __attribute__((__format__ (printf, 3, 4)));
|
||||
#endif
|
||||
|
||||
static void printf_erange __P((char *));
|
||||
static void printstr __P((char *, char *, int, int, int));
|
||||
static int tescape __P((char *, int, char *, int *));
|
||||
static int printstr __P((char *, char *, int, int, int));
|
||||
static int tescape __P((char *, char *, int *));
|
||||
static char *bexpand __P((char *, int, int *, int *));
|
||||
static char *vbadd __P((char *, int));
|
||||
static int vbprintf __P((const char *, ...)) __attribute__((__format__ (printf, 1, 2)));
|
||||
static char *mklong __P((char *, char *, size_t));
|
||||
static int getchr __P((void));
|
||||
static char *getstr __P((void));
|
||||
|
@ -114,7 +187,7 @@ static int getint __P((void));
|
|||
static intmax_t getintmax __P((void));
|
||||
static uintmax_t getuintmax __P((void));
|
||||
|
||||
#if defined (HAVE_LONG_DOUBLE) && HAVE_DECL_STRTOLD
|
||||
#if defined (HAVE_LONG_DOUBLE) && HAVE_DECL_STRTOLD && !defined(STRTOLD_BROKEN)
|
||||
typedef long double floatmax_t;
|
||||
# define FLOATMAX_CONV "L"
|
||||
# define strtofltmax strtold
|
||||
|
@ -125,12 +198,20 @@ typedef double floatmax_t;
|
|||
#endif
|
||||
static floatmax_t getfloatmax __P((void));
|
||||
|
||||
static int asciicode __P((void));
|
||||
static intmax_t asciicode __P((void));
|
||||
|
||||
static WORD_LIST *garglist;
|
||||
static int retval;
|
||||
static int conversion_error;
|
||||
|
||||
/* printf -v var support */
|
||||
static int vflag = 0;
|
||||
static char *vbuf, *vname;
|
||||
static size_t vbsize;
|
||||
static int vblen;
|
||||
|
||||
static intmax_t tw;
|
||||
|
||||
static char *conv_buf;
|
||||
static size_t conv_bufsize;
|
||||
|
||||
|
@ -140,14 +221,37 @@ printf_builtin (list)
|
|||
{
|
||||
int ch, fieldwidth, precision;
|
||||
int have_fieldwidth, have_precision;
|
||||
intmax_t tw;
|
||||
char convch, thisch, nextch, *format, *modstart, *fmt, *start;
|
||||
|
||||
conversion_error = 0;
|
||||
retval = EXECUTION_SUCCESS;
|
||||
|
||||
if (no_options (list))
|
||||
return (EX_USAGE);
|
||||
vflag = 0;
|
||||
|
||||
reset_internal_getopt ();
|
||||
while ((ch = internal_getopt (list, "v:")) != -1)
|
||||
{
|
||||
switch (ch)
|
||||
{
|
||||
case 'v':
|
||||
if (legal_identifier (vname = list_optarg))
|
||||
{
|
||||
vflag = 1;
|
||||
vblen = 0;
|
||||
if (vbuf)
|
||||
vbuf[0] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
sh_invalidid (vname);
|
||||
return (EX_USAGE);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
}
|
||||
}
|
||||
list = loptend; /* skip over possible `--' */
|
||||
|
||||
if (list == 0)
|
||||
|
@ -160,12 +264,15 @@ printf_builtin (list)
|
|||
return (EXECUTION_SUCCESS);
|
||||
|
||||
format = list->word->word;
|
||||
tw = 0;
|
||||
|
||||
garglist = list->next;
|
||||
|
||||
/* If the format string is empty after preprocessing, return immediately. */
|
||||
if (format == 0 || *format == 0)
|
||||
return (EXECUTION_SUCCESS);
|
||||
|
||||
terminate_immediately++;
|
||||
|
||||
/* Basic algorithm is to scan the format string for conversion
|
||||
specifications -- once one is found, find out if the field
|
||||
|
@ -182,21 +289,20 @@ printf_builtin (list)
|
|||
precision = fieldwidth = 0;
|
||||
have_fieldwidth = have_precision = 0;
|
||||
|
||||
|
||||
if (*fmt == '\\')
|
||||
{
|
||||
fmt++;
|
||||
/* A NULL fourth argument to tescape means to not do special
|
||||
processing for \c. */
|
||||
fmt += tescape (fmt, 1, &nextch, (int *)NULL);
|
||||
putchar (nextch);
|
||||
/* A NULL third argument to tescape means to bypass the
|
||||
special processing for arguments to %b. */
|
||||
fmt += tescape (fmt, &nextch, (int *)NULL);
|
||||
PC (nextch);
|
||||
fmt--; /* for loop will increment it for us again */
|
||||
continue;
|
||||
}
|
||||
|
||||
if (*fmt != '%')
|
||||
{
|
||||
putchar (*fmt);
|
||||
PC (*fmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -205,7 +311,7 @@ printf_builtin (list)
|
|||
|
||||
if (*fmt == '%') /* %% prints a % */
|
||||
{
|
||||
putchar ('%');
|
||||
PC ('%');
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -235,8 +341,20 @@ printf_builtin (list)
|
|||
precision = getint ();
|
||||
}
|
||||
else
|
||||
while (DIGIT (*fmt))
|
||||
fmt++;
|
||||
{
|
||||
/* Negative precisions are allowed but treated as if the
|
||||
precision were missing; I would like to allow a leading
|
||||
`+' in the precision number as an extension, but lots
|
||||
of asprintf/fprintf implementations get this wrong. */
|
||||
#if 0
|
||||
if (*fmt == '-' || *fmt == '+')
|
||||
#else
|
||||
if (*fmt == '-')
|
||||
#endif
|
||||
fmt++;
|
||||
while (DIGIT (*fmt))
|
||||
fmt++;
|
||||
}
|
||||
}
|
||||
|
||||
/* skip possible format modifiers */
|
||||
|
@ -246,7 +364,7 @@ printf_builtin (list)
|
|||
|
||||
if (*fmt == 0)
|
||||
{
|
||||
builtin_error ("`%s': missing format character", start);
|
||||
builtin_error (_("`%s': missing format character"), start);
|
||||
PRETURN (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
|
@ -297,21 +415,27 @@ printf_builtin (list)
|
|||
case 'b': /* expand escapes in argument */
|
||||
{
|
||||
char *p, *xp;
|
||||
int rlen;
|
||||
int rlen, r;
|
||||
|
||||
p = getstr ();
|
||||
ch = rlen = 0;
|
||||
ch = rlen = r = 0;
|
||||
xp = bexpand (p, strlen (p), &ch, &rlen);
|
||||
|
||||
if (xp)
|
||||
{
|
||||
/* Have to use printstr because of possible NUL bytes
|
||||
in XP -- printf does not handle that well. */
|
||||
printstr (start, xp, rlen, fieldwidth, precision);
|
||||
r = printstr (start, xp, rlen, fieldwidth, precision);
|
||||
if (r < 0)
|
||||
{
|
||||
sh_wrerror ();
|
||||
clearerr (stdout);
|
||||
retval = EXECUTION_FAILURE;
|
||||
}
|
||||
free (xp);
|
||||
}
|
||||
|
||||
if (ch)
|
||||
if (ch || r < 0)
|
||||
PRETURN (retval);
|
||||
break;
|
||||
}
|
||||
|
@ -319,18 +443,30 @@ printf_builtin (list)
|
|||
case 'q': /* print with shell quoting */
|
||||
{
|
||||
char *p, *xp;
|
||||
int r;
|
||||
|
||||
r = 0;
|
||||
p = getstr ();
|
||||
if (ansic_shouldquote (p))
|
||||
if (p && *p == 0) /* XXX - getstr never returns null */
|
||||
xp = savestring ("''");
|
||||
else if (ansic_shouldquote (p))
|
||||
xp = ansic_quote (p, 0, (int *)0);
|
||||
else
|
||||
xp = sh_backslash_quote (p);
|
||||
if (xp)
|
||||
{
|
||||
/* Use printstr to get fieldwidth and precision right. */
|
||||
printstr (start, xp, strlen (xp), fieldwidth, precision);
|
||||
r = printstr (start, xp, strlen (xp), fieldwidth, precision);
|
||||
if (r < 0)
|
||||
{
|
||||
sh_wrerror ();
|
||||
clearerr (stdout);
|
||||
}
|
||||
free (xp);
|
||||
}
|
||||
|
||||
if (r < 0)
|
||||
PRETURN (EXECUTION_FAILURE);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -405,13 +541,20 @@ printf_builtin (list)
|
|||
/* We don't output unrecognized format characters; we print an
|
||||
error message and return a failure exit status. */
|
||||
default:
|
||||
builtin_error ("`%c': invalid format character", convch);
|
||||
builtin_error (_("`%c': invalid format character"), convch);
|
||||
PRETURN (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
modstart[0] = thisch;
|
||||
modstart[1] = nextch;
|
||||
}
|
||||
|
||||
if (ferror (stdout))
|
||||
{
|
||||
sh_wrerror ();
|
||||
clearerr (stdout);
|
||||
PRETURN (EXECUTION_FAILURE);
|
||||
}
|
||||
}
|
||||
while (garglist && garglist != list->next);
|
||||
|
||||
|
@ -425,11 +568,11 @@ static void
|
|||
printf_erange (s)
|
||||
char *s;
|
||||
{
|
||||
builtin_error ("warning: %s: %s", s, strerror(ERANGE));
|
||||
builtin_error (_("warning: %s: %s"), s, strerror(ERANGE));
|
||||
}
|
||||
|
||||
/* We duplicate a lot of what printf(3) does here. */
|
||||
static void
|
||||
static int
|
||||
printstr (fmt, string, len, fieldwidth, precision)
|
||||
char *fmt; /* format */
|
||||
char *string; /* expanded string argument */
|
||||
|
@ -443,8 +586,12 @@ printstr (fmt, string, len, fieldwidth, precision)
|
|||
int padlen, nc, ljust, i;
|
||||
int fw, pr; /* fieldwidth and precision */
|
||||
|
||||
#if 0
|
||||
if (string == 0 || *string == '\0')
|
||||
return;
|
||||
#else
|
||||
if (string == 0 || len == 0)
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
#if 0
|
||||
s = fmt;
|
||||
|
@ -518,19 +665,22 @@ printstr (fmt, string, len, fieldwidth, precision)
|
|||
|
||||
/* leading pad characters */
|
||||
for (; padlen > 0; padlen--)
|
||||
putchar (' ');
|
||||
PC (' ');
|
||||
|
||||
/* output NC characters from STRING */
|
||||
for (i = 0; i < nc; i++)
|
||||
putchar (string[i]);
|
||||
PC (string[i]);
|
||||
|
||||
/* output any necessary trailing padding */
|
||||
for (; padlen < 0; padlen++)
|
||||
putchar (' ');
|
||||
PC (' ');
|
||||
|
||||
return (ferror (stdout) ? -1 : 0);
|
||||
}
|
||||
|
||||
/* Convert STRING by expanding the escape sequences specified by the
|
||||
POSIX standard for printf's `%b' format string. If SAWC is non-null,
|
||||
perform the processing appropriate for %b arguments. In particular,
|
||||
recognize `\c' and use that as a string terminator. If we see \c, set
|
||||
*SAWC to 1 before returning. LEN is the length of STRING. */
|
||||
|
||||
|
@ -540,11 +690,10 @@ printstr (fmt, string, len, fieldwidth, precision)
|
|||
value. *SAWC is set to 1 if the escape sequence was \c, since that means
|
||||
to short-circuit the rest of the processing. If SAWC is null, we don't
|
||||
do the \c short-circuiting, and \c is treated as an unrecognized escape
|
||||
sequence. */
|
||||
sequence; we also bypass the other processing specific to %b arguments. */
|
||||
static int
|
||||
tescape (estart, trans_squote, cp, sawc)
|
||||
tescape (estart, cp, sawc)
|
||||
char *estart;
|
||||
int trans_squote;
|
||||
char *cp;
|
||||
int *sawc;
|
||||
{
|
||||
|
@ -576,14 +725,13 @@ tescape (estart, trans_squote, cp, sawc)
|
|||
|
||||
case 'v': *cp = '\v'; break;
|
||||
|
||||
/* %b octal constants are `\0' followed by one, two, or three
|
||||
octal digits... */
|
||||
case '0':
|
||||
/* but, as an extension, the other echo-like octal escape
|
||||
sequences are supported as well. */
|
||||
case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7':
|
||||
for (temp = 2+(c=='0'), evalue = c - '0'; ISOCTAL (*p) && temp--; p++)
|
||||
/* The octal escape sequences are `\0' followed by up to three octal
|
||||
digits (if SAWC), or `\' followed by up to three octal digits (if
|
||||
!SAWC). As an extension, we allow the latter form even if SAWC. */
|
||||
case '0': case '1': case '2': case '3':
|
||||
case '4': case '5': case '6': case '7':
|
||||
evalue = OCTVALUE (c);
|
||||
for (temp = 2 + (!evalue && !!sawc); ISOCTAL (*p) && temp--; p++)
|
||||
evalue = (evalue * 8) + OCTVALUE (*p);
|
||||
*cp = evalue & 0xFF;
|
||||
break;
|
||||
|
@ -591,11 +739,15 @@ tescape (estart, trans_squote, cp, sawc)
|
|||
/* And, as another extension, we allow \xNNN, where each N is a
|
||||
hex digit. */
|
||||
case 'x':
|
||||
#if 0
|
||||
for (evalue = 0; ISXDIGIT ((unsigned char)*p); p++)
|
||||
#else
|
||||
for (temp = 2, evalue = 0; ISXDIGIT ((unsigned char)*p) && temp--; p++)
|
||||
#endif
|
||||
evalue = (evalue * 16) + HEXVALUE (*p);
|
||||
if (temp == 2)
|
||||
if (p == estart + 1)
|
||||
{
|
||||
builtin_error ("missing hex digit for \\x");
|
||||
builtin_error (_("missing hex digit for \\x"));
|
||||
*cp = '\\';
|
||||
return 0;
|
||||
}
|
||||
|
@ -606,8 +758,11 @@ tescape (estart, trans_squote, cp, sawc)
|
|||
*cp = c;
|
||||
break;
|
||||
|
||||
case '\'': /* TRANS_SQUOTE != 0 means \' -> ' */
|
||||
if (trans_squote)
|
||||
/* SAWC == 0 means that \', \", and \? are recognized as escape
|
||||
sequences, though the only processing performed is backslash
|
||||
removal. */
|
||||
case '\'': case '"': case '?':
|
||||
if (!sawc)
|
||||
*cp = c;
|
||||
else
|
||||
{
|
||||
|
@ -638,7 +793,11 @@ bexpand (string, len, sawc, lenp)
|
|||
int temp;
|
||||
char *ret, *r, *s, c;
|
||||
|
||||
#if 0
|
||||
if (string == 0 || *string == '\0')
|
||||
#else
|
||||
if (string == 0 || len == 0)
|
||||
#endif
|
||||
{
|
||||
if (sawc)
|
||||
*sawc = 0;
|
||||
|
@ -657,7 +816,7 @@ bexpand (string, len, sawc, lenp)
|
|||
continue;
|
||||
}
|
||||
temp = 0;
|
||||
s += tescape (s, 0, &c, &temp);
|
||||
s += tescape (s, &c, &temp);
|
||||
if (temp)
|
||||
{
|
||||
if (sawc)
|
||||
|
@ -674,6 +833,75 @@ bexpand (string, len, sawc, lenp)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static char *
|
||||
vbadd (buf, blen)
|
||||
char *buf;
|
||||
int blen;
|
||||
{
|
||||
size_t nlen;
|
||||
|
||||
nlen = vblen + blen + 1;
|
||||
if (nlen >= vbsize)
|
||||
{
|
||||
vbsize = ((nlen + 63) >> 6) << 6;
|
||||
vbuf = (char *)xrealloc (vbuf, vbsize);
|
||||
}
|
||||
|
||||
if (blen == 1)
|
||||
vbuf[vblen++] = buf[0];
|
||||
else if (blen > 1)
|
||||
{
|
||||
FASTCOPY (buf, vbuf + vblen, blen);
|
||||
vblen += blen;
|
||||
}
|
||||
vbuf[vblen] = '\0';
|
||||
|
||||
#ifdef DEBUG
|
||||
if (strlen (vbuf) != vblen)
|
||||
internal_error ("printf:vbadd: vblen (%d) != strlen (vbuf) (%d)", vblen, (int)strlen (vbuf));
|
||||
#endif
|
||||
|
||||
return vbuf;
|
||||
}
|
||||
|
||||
static int
|
||||
#if defined (PREFER_STDARG)
|
||||
vbprintf (const char *format, ...)
|
||||
#else
|
||||
vbprintf (format, va_alist)
|
||||
const char *format;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list args;
|
||||
size_t nlen;
|
||||
int blen;
|
||||
|
||||
SH_VA_START (args, format);
|
||||
blen = vsnprintf (vbuf + vblen, vbsize - vblen, format, args);
|
||||
va_end (args);
|
||||
|
||||
nlen = vblen + blen + 1;
|
||||
if (nlen >= vbsize)
|
||||
{
|
||||
vbsize = ((nlen + 63) >> 6) << 6;
|
||||
vbuf = (char *)xrealloc (vbuf, vbsize);
|
||||
SH_VA_START (args, format);
|
||||
blen = vsnprintf (vbuf + vblen, vbsize - vblen, format, args);
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
vblen += blen;
|
||||
vbuf[vblen] = '\0';
|
||||
|
||||
#ifdef DEBUG
|
||||
if (strlen (vbuf) != vblen)
|
||||
internal_error ("printf:vbadd: vblen (%d) != strlen (vbuf) (%d)", vblen, (int)strlen (vbuf));
|
||||
#endif
|
||||
|
||||
return (blen);
|
||||
}
|
||||
|
||||
static char *
|
||||
mklong (str, modifiers, mlen)
|
||||
char *str;
|
||||
|
@ -838,12 +1066,28 @@ getfloatmax ()
|
|||
}
|
||||
|
||||
/* NO check is needed for garglist here. */
|
||||
static int
|
||||
static intmax_t
|
||||
asciicode ()
|
||||
{
|
||||
register int ch;
|
||||
register intmax_t ch;
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
wchar_t wc;
|
||||
size_t mblength, slen;
|
||||
#endif
|
||||
DECLARE_MBSTATE;
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
slen = strlen (garglist->word->word+1);
|
||||
mblength = MBLEN (garglist->word->word+1, slen);
|
||||
if (mblength > 1)
|
||||
{
|
||||
mblength = mbtowc (&wc, garglist->word->word+1, slen);
|
||||
ch = wc; /* XXX */
|
||||
}
|
||||
else
|
||||
#endif
|
||||
ch = (unsigned char)garglist->word->word[1];
|
||||
|
||||
ch = garglist->word->word[1];
|
||||
garglist = garglist->next;
|
||||
return (ch);
|
||||
}
|
||||
|
|
|
@ -4,19 +4,19 @@
|
|||
|
||||
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 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 3 of the License, 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.
|
||||
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. */
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* Write output in 128-byte chunks until we get a sigpipe or write gets an
|
||||
EPIPE. Then report how many bytes we wrote. We assume that this is the
|
||||
|
@ -40,7 +40,10 @@
|
|||
#include "../command.h"
|
||||
#include "../general.h"
|
||||
#include "../sig.h"
|
||||
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
int nw;
|
||||
|
||||
|
|
|
@ -1,94 +1,114 @@
|
|||
This file is pushd.def, from which is created pushd.c. It implements the
|
||||
builtins "pushd", "popd", and "dirs" in Bash.
|
||||
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES pushd.c
|
||||
|
||||
$BUILTIN pushd
|
||||
$FUNCTION pushd_builtin
|
||||
$DEPENDS_ON PUSHD_AND_POPD
|
||||
$SHORT_DOC pushd [dir | +N | -N] [-n]
|
||||
$SHORT_DOC pushd [-n] [+N | -N | dir]
|
||||
Add directories to stack.
|
||||
|
||||
Adds a directory to the top of the directory stack, or rotates
|
||||
the stack, making the new top of the stack the current working
|
||||
directory. With no arguments, exchanges the top two directories.
|
||||
|
||||
+N Rotates the stack so that the Nth directory (counting
|
||||
Options:
|
||||
-n Suppresses the normal change of directory when adding
|
||||
directories to the stack, so only the stack is manipulated.
|
||||
|
||||
Arguments:
|
||||
+N Rotates the stack so that the Nth directory (counting
|
||||
from the left of the list shown by `dirs', starting with
|
||||
zero) is at the top.
|
||||
|
||||
-N Rotates the stack so that the Nth directory (counting
|
||||
-N Rotates the stack so that the Nth directory (counting
|
||||
from the right of the list shown by `dirs', starting with
|
||||
zero) is at the top.
|
||||
|
||||
-n suppress the normal change of directory when adding directories
|
||||
to the stack, so only the stack is manipulated.
|
||||
|
||||
dir adds DIR to the directory stack at the top, making it the
|
||||
dir Adds DIR to the directory stack at the top, making it the
|
||||
new current working directory.
|
||||
|
||||
You can see the directory stack with the `dirs' command.
|
||||
The `dirs' builtin displays the directory stack.
|
||||
|
||||
Exit Status:
|
||||
Returns success unless an invalid argument is supplied or the directory
|
||||
change fails.
|
||||
$END
|
||||
|
||||
$BUILTIN popd
|
||||
$FUNCTION popd_builtin
|
||||
$DEPENDS_ON PUSHD_AND_POPD
|
||||
$SHORT_DOC popd [+N | -N] [-n]
|
||||
Removes entries from the directory stack. With no arguments,
|
||||
removes the top directory from the stack, and cd's to the new
|
||||
top directory.
|
||||
$SHORT_DOC popd [-n] [+N | -N]
|
||||
Remove directories from stack.
|
||||
|
||||
+N removes the Nth entry counting from the left of the list
|
||||
Removes entries from the directory stack. With no arguments, removes
|
||||
the top directory from the stack, and changes to the new top directory.
|
||||
|
||||
Options:
|
||||
-n Suppresses the normal change of directory when removing
|
||||
directories from the stack, so only the stack is manipulated.
|
||||
|
||||
Arguments:
|
||||
+N Removes the Nth entry counting from the left of the list
|
||||
shown by `dirs', starting with zero. For example: `popd +0'
|
||||
removes the first directory, `popd +1' the second.
|
||||
|
||||
-N removes the Nth entry counting from the right of the list
|
||||
-N Removes the Nth entry counting from the right of the list
|
||||
shown by `dirs', starting with zero. For example: `popd -0'
|
||||
removes the last directory, `popd -1' the next to last.
|
||||
|
||||
-n suppress the normal change of directory when removing directories
|
||||
from the stack, so only the stack is manipulated.
|
||||
The `dirs' builtin displays the directory stack.
|
||||
|
||||
You can see the directory stack with the `dirs' command.
|
||||
Exit Status:
|
||||
Returns success unless an invalid argument is supplied or the directory
|
||||
change fails.
|
||||
$END
|
||||
|
||||
$BUILTIN dirs
|
||||
$FUNCTION dirs_builtin
|
||||
$DEPENDS_ON PUSHD_AND_POPD
|
||||
$SHORT_DOC dirs [-clpv] [+N] [-N]
|
||||
Display directory stack.
|
||||
|
||||
Display the list of currently remembered directories. Directories
|
||||
find their way onto the list with the `pushd' command; you can get
|
||||
back up through the list with the `popd' command.
|
||||
|
||||
The -l flag specifies that `dirs' should not print shorthand versions
|
||||
of directories which are relative to your home directory. This means
|
||||
that `~/bin' might be displayed as `/homes/bfox/bin'. The -v flag
|
||||
causes `dirs' to print the directory stack with one entry per line,
|
||||
prepending the directory name with its position in the stack. The -p
|
||||
flag does the same thing, but the stack position is not prepended.
|
||||
The -c flag clears the directory stack by deleting all of the elements.
|
||||
Options:
|
||||
-c clear the directory stack by deleting all of the elements
|
||||
-l do not print tilde-prefixed versions of directories relative
|
||||
to your home directory
|
||||
-p print the directory stack with one entry per line
|
||||
-v print the directory stack with one entry per line prefixed
|
||||
with its position in the stack
|
||||
|
||||
+N displays the Nth entry counting from the left of the list shown by
|
||||
Arguments:
|
||||
+N Displays the Nth entry counting from the left of the list shown by
|
||||
dirs when invoked without options, starting with zero.
|
||||
|
||||
-N displays the Nth entry counting from the right of the list shown by
|
||||
-N Displays the Nth entry counting from the right of the list shown by
|
||||
dirs when invoked without options, starting with zero.
|
||||
|
||||
Exit Status:
|
||||
Returns success unless an invalid option is supplied or an error occurs.
|
||||
$END
|
||||
|
||||
#include <config.h>
|
||||
|
@ -107,6 +127,7 @@ $END
|
|||
#endif
|
||||
|
||||
#include "../bashansi.h"
|
||||
#include "../bashintl.h"
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
|
@ -150,13 +171,20 @@ int
|
|||
pushd_builtin (list)
|
||||
WORD_LIST *list;
|
||||
{
|
||||
WORD_LIST *orig_list;
|
||||
char *temp, *current_directory, *top;
|
||||
int j, flags;
|
||||
int j, flags, skipopt;
|
||||
intmax_t num;
|
||||
char direction;
|
||||
|
||||
orig_list = list;
|
||||
if (list && list->word && ISOPTION (list->word->word, '-'))
|
||||
list = list->next;
|
||||
{
|
||||
list = list->next;
|
||||
skipopt = 1;
|
||||
}
|
||||
else
|
||||
skipopt = 0;
|
||||
|
||||
/* If there is no argument list then switch current and
|
||||
top of list. */
|
||||
|
@ -164,7 +192,7 @@ pushd_builtin (list)
|
|||
{
|
||||
if (directory_list_offset == 0)
|
||||
{
|
||||
builtin_error ("no other directory");
|
||||
builtin_error (_("no other directory"));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
|
@ -180,7 +208,7 @@ pushd_builtin (list)
|
|||
return j;
|
||||
}
|
||||
|
||||
for (flags = 0; list; list = list->next)
|
||||
for (flags = 0; skipopt == 0 && list; list = list->next)
|
||||
{
|
||||
if (ISOPTION (list->word->word, 'n'))
|
||||
{
|
||||
|
@ -264,7 +292,7 @@ pushd_builtin (list)
|
|||
if (current_directory == 0)
|
||||
return (EXECUTION_FAILURE);
|
||||
|
||||
j = ((flags & NOCD) == 0) ? cd_builtin (list) : EXECUTION_SUCCESS;
|
||||
j = ((flags & NOCD) == 0) ? cd_builtin (skipopt ? orig_list : list) : EXECUTION_SUCCESS;
|
||||
if (j == EXECUTION_SUCCESS)
|
||||
{
|
||||
add_dirstack_element ((flags & NOCD) ? savestring (list->word->word) : current_directory);
|
||||
|
@ -431,7 +459,7 @@ dirs_builtin (list)
|
|||
{
|
||||
temp = get_working_directory ("dirs");
|
||||
if (temp == 0)
|
||||
temp = savestring ("<no current directory>");
|
||||
temp = savestring (_("<no current directory>"));
|
||||
if (vflag & 2)
|
||||
printf ("%2d %s", 0, DIRSTACK_FORMAT (temp));
|
||||
else
|
||||
|
@ -440,7 +468,7 @@ dirs_builtin (list)
|
|||
if (index_flag)
|
||||
{
|
||||
putchar ('\n');
|
||||
return EXECUTION_SUCCESS;
|
||||
return (sh_chkwrite (EXECUTION_SUCCESS));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -465,8 +493,8 @@ dirs_builtin (list)
|
|||
printf ("%s%s", (vflag & 1) ? "\n" : " ", DIRSTACK_ENTRY (i));
|
||||
|
||||
putchar ('\n');
|
||||
fflush (stdout);
|
||||
return (EXECUTION_SUCCESS);
|
||||
|
||||
return (sh_chkwrite (EXECUTION_SUCCESS));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -475,9 +503,9 @@ pushd_error (offset, arg)
|
|||
char *arg;
|
||||
{
|
||||
if (offset == 0)
|
||||
builtin_error ("directory stack empty");
|
||||
builtin_error (_("directory stack empty"));
|
||||
else
|
||||
sh_erange (arg, "directory stack index");
|
||||
sh_erange (arg, _("directory stack index"));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -498,9 +526,11 @@ cd_to_string (name)
|
|||
char *name;
|
||||
{
|
||||
WORD_LIST *tlist;
|
||||
WORD_LIST *dir;
|
||||
int result;
|
||||
|
||||
tlist = make_word_list (make_word (name), NULL);
|
||||
dir = make_word_list (make_word (name), NULL);
|
||||
tlist = make_word_list (make_word ("--"), dir);
|
||||
result = cd_builtin (tlist);
|
||||
dispose_words (tlist);
|
||||
return (result);
|
||||
|
@ -610,7 +640,8 @@ set_dirstack_element (ind, sign, value)
|
|||
}
|
||||
|
||||
WORD_LIST *
|
||||
get_directory_stack ()
|
||||
get_directory_stack (flags)
|
||||
int flags;
|
||||
{
|
||||
register int i;
|
||||
WORD_LIST *ret;
|
||||
|
@ -618,7 +649,8 @@ get_directory_stack ()
|
|||
|
||||
for (ret = (WORD_LIST *)NULL, i = 0; i < directory_list_offset; i++)
|
||||
{
|
||||
d = polite_directory_format (pushd_directory_list[i]);
|
||||
d = (flags&1) ? polite_directory_format (pushd_directory_list[i])
|
||||
: pushd_directory_list[i];
|
||||
ret = make_word_list (make_word (d), ret);
|
||||
}
|
||||
/* Now the current directory. */
|
||||
|
@ -647,67 +679,71 @@ get_directory_stack ()
|
|||
}
|
||||
|
||||
#ifdef LOADABLE_BUILTIN
|
||||
static char *dirs_doc[] = {
|
||||
"Display the list of currently remembered directories. Directories",
|
||||
"find their way onto the list with the `pushd' command; you can get",
|
||||
"back up through the list with the `popd' command.",
|
||||
"",
|
||||
"The -l flag specifies that `dirs' should not print shorthand versions",
|
||||
"of directories which are relative to your home directory. This means",
|
||||
"that `~/bin' might be displayed as `/homes/bfox/bin'. The -v flag",
|
||||
"causes `dirs' to print the directory stack with one entry per line,",
|
||||
"prepending the directory name with its position in the stack. The -p",
|
||||
"flag does the same thing, but the stack position is not prepended.",
|
||||
"The -c flag clears the directory stack by deleting all of the elements.",
|
||||
"",
|
||||
"+N displays the Nth entry counting from the left of the list shown by",
|
||||
" dirs when invoked without options, starting with zero.",
|
||||
"",
|
||||
"-N displays the Nth entry counting from the right of the list shown by",
|
||||
" dirs when invoked without options, starting with zero.",
|
||||
char * const dirs_doc[] = {
|
||||
N_("Display the list of currently remembered directories. Directories\n\
|
||||
find their way onto the list with the `pushd' command; you can get\n\
|
||||
back up through the list with the `popd' command.\n\
|
||||
\n\
|
||||
Options:\n\
|
||||
-c clear the directory stack by deleting all of the elements\n\
|
||||
-l do not print tilde-prefixed versions of directories relative\n\
|
||||
to your home directory\n\
|
||||
-p print the directory stack with one entry per line\n\
|
||||
-v print the directory stack with one entry per line prefixed\n\
|
||||
with its position in the stack\n\
|
||||
\n\
|
||||
Arguments:\n\
|
||||
+N Displays the Nth entry counting from the left of the list shown by\n\
|
||||
dirs when invoked without options, starting with zero.\n\
|
||||
\n\
|
||||
-N Displays the Nth entry counting from the right of the list shown by\n\
|
||||
dirs when invoked without options, starting with zero."),
|
||||
(char *)NULL
|
||||
};
|
||||
|
||||
static char *pushd_doc[] = {
|
||||
"Adds a directory to the top of the directory stack, or rotates",
|
||||
"the stack, making the new top of the stack the current working",
|
||||
"directory. With no arguments, exchanges the top two directories.",
|
||||
"",
|
||||
"+N Rotates the stack so that the Nth directory (counting",
|
||||
" from the left of the list shown by `dirs', starting with",
|
||||
" zero) is at the top.",
|
||||
"",
|
||||
"-N Rotates the stack so that the Nth directory (counting",
|
||||
" from the right of the list shown by `dirs', starting with",
|
||||
" zero) is at the top.",
|
||||
"",
|
||||
"-n suppress the normal change of directory when adding directories",
|
||||
" to the stack, so only the stack is manipulated.",
|
||||
"",
|
||||
"dir adds DIR to the directory stack at the top, making it the",
|
||||
" new current working directory.",
|
||||
"",
|
||||
"You can see the directory stack with the `dirs' command.",
|
||||
char * const pushd_doc[] = {
|
||||
N_("Adds a directory to the top of the directory stack, or rotates\n\
|
||||
the stack, making the new top of the stack the current working\n\
|
||||
directory. With no arguments, exchanges the top two directories.\n\
|
||||
\n\
|
||||
Options:\n\
|
||||
-n Suppresses the normal change of directory when adding\n\
|
||||
directories to the stack, so only the stack is manipulated.\n\
|
||||
\n\
|
||||
Arguments:\n\
|
||||
+N Rotates the stack so that the Nth directory (counting\n\
|
||||
from the left of the list shown by `dirs', starting with\n\
|
||||
zero) is at the top.\n\
|
||||
\n\
|
||||
-N Rotates the stack so that the Nth directory (counting\n\
|
||||
from the right of the list shown by `dirs', starting with\n\
|
||||
zero) is at the top.\n\
|
||||
\n\
|
||||
dir Adds DIR to the directory stack at the top, making it the\n\
|
||||
new current working directory.\n\
|
||||
\n\
|
||||
The `dirs' builtin displays the directory stack."),
|
||||
(char *)NULL
|
||||
};
|
||||
|
||||
static char *popd_doc[] = {
|
||||
"Removes entries from the directory stack. With no arguments,",
|
||||
"removes the top directory from the stack, and cd's to the new",
|
||||
"top directory.",
|
||||
"",
|
||||
"+N removes the Nth entry counting from the left of the list",
|
||||
" shown by `dirs', starting with zero. For example: `popd +0'",
|
||||
" removes the first directory, `popd +1' the second.",
|
||||
"",
|
||||
"-N removes the Nth entry counting from the right of the list",
|
||||
" shown by `dirs', starting with zero. For example: `popd -0'",
|
||||
" removes the last directory, `popd -1' the next to last.",
|
||||
"",
|
||||
"-n suppress the normal change of directory when removing directories",
|
||||
" from the stack, so only the stack is manipulated.",
|
||||
"",
|
||||
"You can see the directory stack with the `dirs' command.",
|
||||
char * const popd_doc[] = {
|
||||
N_("Removes entries from the directory stack. With no arguments, removes\n\
|
||||
the top directory from the stack, and changes to the new top directory.\n\
|
||||
\n\
|
||||
Options:\n\
|
||||
-n Suppresses the normal change of directory when removing\n\
|
||||
directories from the stack, so only the stack is manipulated.\n\
|
||||
\n\
|
||||
Arguments:\n\
|
||||
+N Removes the Nth entry counting from the left of the list\n\
|
||||
shown by `dirs', starting with zero. For example: `popd +0'\n\
|
||||
removes the first directory, `popd +1' the second.\n\
|
||||
\n\
|
||||
-N Removes the Nth entry counting from the right of the list\n\
|
||||
shown by `dirs', starting with zero. For example: `popd -0'\n\
|
||||
removes the last directory, `popd -1' the next to last.\n\
|
||||
\n\
|
||||
The `dirs' builtin displays the directory stack."),
|
||||
(char *)NULL
|
||||
};
|
||||
|
||||
|
|
|
@ -1,50 +1,63 @@
|
|||
This file is read.def, from which is created read.c.
|
||||
It implements the builtin "read" in Bash.
|
||||
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES read.c
|
||||
|
||||
$BUILTIN read
|
||||
$FUNCTION read_builtin
|
||||
$SHORT_DOC read [-ers] [-u fd] [-t timeout] [-p prompt] [-a array] [-n nchars] [-d delim] [name ...]
|
||||
One line is read from the standard input, or from file descriptor FD if the
|
||||
-u option is supplied, and the first word is assigned to the first NAME,
|
||||
the second word to the second NAME, and so on, with leftover words assigned
|
||||
to the last NAME. Only the characters found in $IFS are recognized as word
|
||||
delimiters. If no NAMEs are supplied, the line read is stored in the REPLY
|
||||
variable. If the -r option is given, this signifies `raw' input, and
|
||||
backslash escaping is disabled. The -d option causes read to continue
|
||||
until the first character of DELIM is read, rather than newline. If the -p
|
||||
option is supplied, the string PROMPT is output without a trailing newline
|
||||
before attempting to read. If -a is supplied, the words read are assigned
|
||||
to sequential indices of ARRAY, starting at zero. If -e is supplied and
|
||||
the shell is interactive, readline is used to obtain the line. If -n is
|
||||
supplied with a non-zero NCHARS argument, read returns after NCHARS
|
||||
characters have been read. The -s option causes input coming from a
|
||||
terminal to not be echoed.
|
||||
$SHORT_DOC read [-ers] [-a array] [-d delim] [-i text] [-n nchars] [-p prompt] [-t timeout] [-u fd] [name ...]
|
||||
Read a line from the standard input and split it into fields.
|
||||
|
||||
The -t option causes read to time out and return failure if a complete line
|
||||
of input is not read within TIMEOUT seconds. If the TMOUT variable is set,
|
||||
its value is the default timeout. The return code is zero, unless end-of-file
|
||||
is encountered, read times out, or an invalid file descriptor is supplied as
|
||||
the argument to -u.
|
||||
Reads a single line from the standard input, or from file descriptor FD
|
||||
if the -u option is supplied. The line is split into fields as with word
|
||||
splitting, and the first word is assigned to the first NAME, the second
|
||||
word to the second NAME, and so on, with any leftover words assigned to
|
||||
the last NAME. Only the characters found in $IFS are recognized as word
|
||||
delimiters.
|
||||
|
||||
If no NAMEs are supplied, the line read is stored in the REPLY variable.
|
||||
|
||||
Options:
|
||||
-a array assign the words read to sequential indices of the array
|
||||
variable ARRAY, starting at zero
|
||||
-d delim continue until the first character of DELIM is read, rather
|
||||
than newline
|
||||
-e use Readline to obtain the line in an interactive shell
|
||||
-i text Use TEXT as the initial text for Readline
|
||||
-n nchars return after reading NCHARS characters rather than waiting
|
||||
for a newline
|
||||
-p prompt output the string PROMPT without a trailing newline before
|
||||
attempting to read
|
||||
-r do not allow backslashes to escape any characters
|
||||
-s do not echo input coming from a terminal
|
||||
-t timeout time out and return failure if a complete line of input is
|
||||
not read withint TIMEOUT seconds. The value of the TMOUT
|
||||
variable is the default timeout. TIMEOUT may be a
|
||||
fractional number. If TIMEOUT is 0, read returns success only
|
||||
if input is available on the specified file descriptor. The
|
||||
exit status is greater than 128 if the timeout is exceeded
|
||||
-u fd read from file descriptor FD instead of the standard input
|
||||
|
||||
Exit Status:
|
||||
The return code is zero, unless end-of-file is encountered, read times out,
|
||||
or an invalid file descriptor is supplied as the argument to -u.
|
||||
$END
|
||||
|
||||
#include <config.h>
|
||||
|
@ -54,6 +67,8 @@ $END
|
|||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "bashansi.h"
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
@ -66,6 +81,8 @@ $END
|
|||
# include <io.h>
|
||||
#endif
|
||||
|
||||
#include "../bashintl.h"
|
||||
|
||||
#include "../shell.h"
|
||||
#include "common.h"
|
||||
#include "bashgetopt.h"
|
||||
|
@ -77,18 +94,32 @@ $END
|
|||
#include <readline/readline.h>
|
||||
#endif
|
||||
|
||||
#if defined (BUFFERED_INPUT)
|
||||
# include "input.h"
|
||||
#endif
|
||||
|
||||
#if !defined(errno)
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
extern int interrupt_immediately;
|
||||
struct ttsave
|
||||
{
|
||||
int fd;
|
||||
TTYSTRUCT *attrs;
|
||||
};
|
||||
|
||||
#if defined (READLINE)
|
||||
static char *edit_line __P((char *));
|
||||
static void reset_attempted_completion_function __P((char *));
|
||||
static int set_itext __P((void));
|
||||
static char *edit_line __P((char *, char *));
|
||||
static void set_eol_delim __P((int));
|
||||
static void reset_eol_delim __P((char *));
|
||||
#endif
|
||||
static SHELL_VAR *bind_read_variable __P((char *, char *));
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
static int read_mbchar __P((int, char *, int, int, int));
|
||||
#endif
|
||||
static void ttyrestore __P((struct ttsave *));
|
||||
|
||||
static sighandler sigalrm __P((int));
|
||||
static void reset_alarm __P((void));
|
||||
|
@ -108,7 +139,7 @@ static void
|
|||
reset_alarm ()
|
||||
{
|
||||
set_signal_handler (SIGALRM, old_alrm);
|
||||
alarm (0);
|
||||
falarm (0, 0);
|
||||
}
|
||||
|
||||
/* Read the value of the shell variables whose names follow.
|
||||
|
@ -122,32 +153,37 @@ read_builtin (list)
|
|||
WORD_LIST *list;
|
||||
{
|
||||
register char *varname;
|
||||
int size, i, pass_next, saw_escape, eof, opt, retval, code;
|
||||
int input_is_tty, input_is_pipe, unbuffered_read;
|
||||
int size, i, nr, pass_next, saw_escape, eof, opt, retval, code, print_ps2;
|
||||
int input_is_tty, input_is_pipe, unbuffered_read, skip_ctlesc, skip_ctlnul;
|
||||
int raw, edit, nchars, silent, have_timeout, fd;
|
||||
unsigned int tmout;
|
||||
unsigned int tmsec, tmusec;
|
||||
long ival, uval;
|
||||
intmax_t intval;
|
||||
char c;
|
||||
char *input_string, *orig_input_string, *ifs_chars, *prompt, *arrayname;
|
||||
char *e, *t, *t1;
|
||||
char *e, *t, *t1, *ps2, *tofree;
|
||||
struct stat tsb;
|
||||
SHELL_VAR *var;
|
||||
TTYSTRUCT ttattrs, ttset;
|
||||
struct ttsave termsave;
|
||||
#if defined (ARRAY_VARS)
|
||||
WORD_LIST *alist;
|
||||
#endif
|
||||
#if defined (READLINE)
|
||||
char *rlbuf;
|
||||
char *rlbuf, *itext;
|
||||
int rlind;
|
||||
#endif
|
||||
|
||||
USE_VAR(size);
|
||||
USE_VAR(i);
|
||||
USE_VAR(pass_next);
|
||||
USE_VAR(print_ps2);
|
||||
USE_VAR(saw_escape);
|
||||
USE_VAR(input_is_pipe);
|
||||
/* USE_VAR(raw); */
|
||||
USE_VAR(edit);
|
||||
USE_VAR(tmout);
|
||||
USE_VAR(tmsec);
|
||||
USE_VAR(tmusec);
|
||||
USE_VAR(nchars);
|
||||
USE_VAR(silent);
|
||||
USE_VAR(ifs_chars);
|
||||
|
@ -156,8 +192,10 @@ read_builtin (list)
|
|||
#if defined (READLINE)
|
||||
USE_VAR(rlbuf);
|
||||
USE_VAR(rlind);
|
||||
USE_VAR(itext);
|
||||
#endif
|
||||
USE_VAR(list);
|
||||
USE_VAR(ps2);
|
||||
|
||||
i = 0; /* Index into the string that we are reading. */
|
||||
raw = edit = 0; /* Not reading raw input by default. */
|
||||
|
@ -166,16 +204,16 @@ read_builtin (list)
|
|||
fd = 0; /* file descriptor to read from */
|
||||
|
||||
#if defined (READLINE)
|
||||
rlbuf = (char *)0;
|
||||
rlbuf = itext = (char *)0;
|
||||
rlind = 0;
|
||||
#endif
|
||||
|
||||
tmout = 0; /* no timeout */
|
||||
nchars = input_is_tty = input_is_pipe = unbuffered_read = have_timeout = 0;
|
||||
tmsec = tmusec = 0; /* no timeout */
|
||||
nr = nchars = input_is_tty = input_is_pipe = unbuffered_read = have_timeout = 0;
|
||||
delim = '\n'; /* read until newline */
|
||||
|
||||
reset_internal_getopt ();
|
||||
while ((opt = internal_getopt (list, "ersa:d:n:p:t:u:")) != -1)
|
||||
while ((opt = internal_getopt (list, "ersa:d:i:n:p:t:u:")) != -1)
|
||||
{
|
||||
switch (opt)
|
||||
{
|
||||
|
@ -191,6 +229,11 @@ read_builtin (list)
|
|||
case 'e':
|
||||
#if defined (READLINE)
|
||||
edit = 1;
|
||||
#endif
|
||||
break;
|
||||
case 'i':
|
||||
#if defined (READLINE)
|
||||
itext = list_optarg;
|
||||
#endif
|
||||
break;
|
||||
#if defined (ARRAY_VARS)
|
||||
|
@ -199,16 +242,17 @@ read_builtin (list)
|
|||
break;
|
||||
#endif
|
||||
case 't':
|
||||
code = legal_number (list_optarg, &intval);
|
||||
if (code == 0 || intval < 0 || intval != (unsigned int)intval)
|
||||
code = uconvert (list_optarg, &ival, &uval);
|
||||
if (code == 0 || ival < 0 || uval < 0)
|
||||
{
|
||||
builtin_error ("%s: invalid timeout specification", list_optarg);
|
||||
builtin_error (_("%s: invalid timeout specification"), list_optarg);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
else
|
||||
{
|
||||
have_timeout = 1;
|
||||
tmout = intval;
|
||||
tmsec = ival;
|
||||
tmusec = uval;
|
||||
}
|
||||
break;
|
||||
case 'n':
|
||||
|
@ -225,14 +269,14 @@ read_builtin (list)
|
|||
code = legal_number (list_optarg, &intval);
|
||||
if (code == 0 || intval < 0 || intval != (int)intval)
|
||||
{
|
||||
builtin_error ("%s: invalid file descriptor specification", list_optarg);
|
||||
builtin_error (_("%s: invalid file descriptor specification"), list_optarg);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
else
|
||||
fd = intval;
|
||||
if (sh_validfd (fd) == 0)
|
||||
{
|
||||
builtin_error ("%d: invalid file descriptor: %s", fd, strerror (errno));
|
||||
builtin_error (_("%d: invalid file descriptor: %s"), fd, strerror (errno));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
break;
|
||||
|
@ -246,35 +290,49 @@ read_builtin (list)
|
|||
}
|
||||
list = loptend;
|
||||
|
||||
/* `read -t 0 var' returns failure immediately. XXX - should it test
|
||||
whether input is available with select/FIONREAD, and fail if those
|
||||
are unavailable? */
|
||||
if (have_timeout && tmout == 0)
|
||||
/* `read -t 0 var' tests whether input is available with select/FIONREAD,
|
||||
and fails if those are unavailable */
|
||||
if (have_timeout && tmsec == 0 && tmusec == 0)
|
||||
#if 0
|
||||
return (EXECUTION_FAILURE);
|
||||
#else
|
||||
return (input_avail (fd) ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
|
||||
#endif
|
||||
|
||||
/* IF IFS is unset, we use the default of " \t\n". */
|
||||
ifs_chars = getifs ();
|
||||
if (ifs_chars == 0) /* XXX - shouldn't happen */
|
||||
ifs_chars = "";
|
||||
for (skip_ctlesc = skip_ctlnul = 0, e = ifs_chars; *e; e++)
|
||||
skip_ctlesc |= *e == CTLESC, skip_ctlnul |= *e == CTLNUL;
|
||||
|
||||
input_string = (char *)xmalloc (size = 112); /* XXX was 128 */
|
||||
input_string[0] = '\0';
|
||||
|
||||
/* $TMOUT, if set, is the default timeout for read. */
|
||||
if (have_timeout == 0 && (e = get_string_value ("TMOUT")))
|
||||
{
|
||||
code = legal_number (e, &intval);
|
||||
if (code == 0 || intval < 0 || intval != (unsigned int)intval)
|
||||
tmout = 0;
|
||||
code = uconvert (e, &ival, &uval);
|
||||
if (code == 0 || ival < 0 || uval < 0)
|
||||
tmsec = tmusec = 0;
|
||||
else
|
||||
tmout = intval;
|
||||
{
|
||||
tmsec = ival;
|
||||
tmusec = uval;
|
||||
}
|
||||
}
|
||||
|
||||
begin_unwind_frame ("read_builtin");
|
||||
|
||||
#if defined (BUFFERED_INPUT)
|
||||
if (interactive == 0 && default_buffered_input >= 0 && fd_is_bash_input (fd))
|
||||
sync_buffered_stream (default_buffered_input);
|
||||
#endif
|
||||
|
||||
input_is_tty = isatty (fd);
|
||||
if (input_is_tty == 0)
|
||||
#ifndef __CYGWIN__
|
||||
input_is_pipe = (lseek (0, 0L, SEEK_CUR) < 0) && (errno == ESPIPE);
|
||||
input_is_pipe = (lseek (fd, 0L, SEEK_CUR) < 0) && (errno == ESPIPE);
|
||||
#else
|
||||
input_is_pipe = 1;
|
||||
#endif
|
||||
|
@ -284,6 +342,9 @@ read_builtin (list)
|
|||
if ((prompt || edit || silent) && input_is_tty == 0)
|
||||
{
|
||||
prompt = (char *)NULL;
|
||||
#if defined (READLINE)
|
||||
itext = (char *)NULL;
|
||||
#endif
|
||||
edit = silent = 0;
|
||||
}
|
||||
|
||||
|
@ -292,34 +353,38 @@ read_builtin (list)
|
|||
add_unwind_protect (xfree, rlbuf);
|
||||
#endif
|
||||
|
||||
if (prompt && edit == 0)
|
||||
{
|
||||
fprintf (stderr, "%s", prompt);
|
||||
fflush (stderr);
|
||||
}
|
||||
|
||||
pass_next = 0; /* Non-zero signifies last char was backslash. */
|
||||
saw_escape = 0; /* Non-zero signifies that we saw an escape char */
|
||||
|
||||
if (tmout > 0)
|
||||
if (tmsec > 0 || tmusec > 0)
|
||||
{
|
||||
/* Turn off the timeout if stdin is a regular file (e.g. from
|
||||
input redirection). */
|
||||
if ((fstat (fd, &tsb) < 0) || S_ISREG (tsb.st_mode))
|
||||
tmout = 0;
|
||||
tmsec = tmusec = 0;
|
||||
}
|
||||
|
||||
if (tmout > 0)
|
||||
if (tmsec > 0 || tmusec > 0)
|
||||
{
|
||||
code = setjmp (alrmbuf);
|
||||
if (code)
|
||||
{
|
||||
#if 0
|
||||
run_unwind_frame ("read_builtin");
|
||||
return (EXECUTION_FAILURE);
|
||||
#else
|
||||
input_string[i] = '\0'; /* make sure it's terminated */
|
||||
retval = 128+SIGALRM;;
|
||||
goto assign_vars;
|
||||
#endif
|
||||
}
|
||||
old_alrm = set_signal_handler (SIGALRM, sigalrm);
|
||||
add_unwind_protect (reset_alarm, (char *)NULL);
|
||||
alarm (tmout);
|
||||
#if defined (READLINE)
|
||||
if (edit)
|
||||
add_unwind_protect (reset_attempted_completion_function, (char *)NULL);
|
||||
#endif
|
||||
falarm (tmsec, tmusec);
|
||||
}
|
||||
|
||||
/* If we've been asked to read only NCHARS chars, or we're using some
|
||||
|
@ -345,33 +410,53 @@ read_builtin (list)
|
|||
#endif
|
||||
if (input_is_tty)
|
||||
{
|
||||
ttsave ();
|
||||
if (silent)
|
||||
ttcbreak ();
|
||||
else
|
||||
ttonechar ();
|
||||
add_unwind_protect ((Function *)ttrestore, (char *)NULL);
|
||||
/* ttsave() */
|
||||
termsave.fd = fd;
|
||||
ttgetattr (fd, &ttattrs);
|
||||
termsave.attrs = &ttattrs;
|
||||
|
||||
ttset = ttattrs;
|
||||
i = silent ? ttfd_cbreak (fd, &ttset) : ttfd_onechar (fd, &ttset);
|
||||
if (i < 0)
|
||||
sh_ttyerror (1);
|
||||
add_unwind_protect ((Function *)ttyrestore, (char *)&termsave);
|
||||
}
|
||||
}
|
||||
else if (silent) /* turn off echo but leave term in canonical mode */
|
||||
{
|
||||
ttsave ();
|
||||
ttnoecho ();
|
||||
add_unwind_protect ((Function *)ttrestore, (char *)NULL);
|
||||
/* ttsave (); */
|
||||
termsave.fd = fd;
|
||||
ttgetattr (fd, &ttattrs);
|
||||
termsave.attrs = &ttattrs;
|
||||
|
||||
ttset = ttattrs;
|
||||
i = ttfd_noecho (fd, &ttset); /* ttnoecho (); */
|
||||
if (i < 0)
|
||||
sh_ttyerror (1);
|
||||
|
||||
add_unwind_protect ((Function *)ttyrestore, (char *)&termsave);
|
||||
}
|
||||
|
||||
/* This *must* be the top unwind-protect on the stack, so the manipulation
|
||||
of the unwind-protect stack after the realloc() works right. */
|
||||
add_unwind_protect (xfree, input_string);
|
||||
interrupt_immediately++;
|
||||
terminate_immediately++;
|
||||
|
||||
unbuffered_read = (nchars > 0) || (delim != '\n') || input_is_pipe;
|
||||
|
||||
if (prompt && edit == 0)
|
||||
{
|
||||
fprintf (stderr, "%s", prompt);
|
||||
fflush (stderr);
|
||||
}
|
||||
|
||||
#if defined (__CYGWIN__) && defined (O_TEXT)
|
||||
setmode (0, O_TEXT);
|
||||
#endif
|
||||
|
||||
for (eof = retval = 0;;)
|
||||
ps2 = 0;
|
||||
for (print_ps2 = eof = retval = 0;;)
|
||||
{
|
||||
#if defined (READLINE)
|
||||
if (edit)
|
||||
|
@ -383,7 +468,7 @@ read_builtin (list)
|
|||
}
|
||||
if (rlbuf == 0)
|
||||
{
|
||||
rlbuf = edit_line (prompt ? prompt : "");
|
||||
rlbuf = edit_line (prompt ? prompt : "", itext);
|
||||
rlind = 0;
|
||||
}
|
||||
if (rlbuf == 0)
|
||||
|
@ -397,6 +482,15 @@ read_builtin (list)
|
|||
{
|
||||
#endif
|
||||
|
||||
if (print_ps2)
|
||||
{
|
||||
if (ps2 == 0)
|
||||
ps2 = get_string_value ("PS2");
|
||||
fprintf (stderr, "%s", ps2 ? ps2 : "");
|
||||
fflush (stderr);
|
||||
print_ps2 = 0;
|
||||
}
|
||||
|
||||
if (unbuffered_read)
|
||||
retval = zread (fd, &c, 1);
|
||||
else
|
||||
|
@ -412,7 +506,7 @@ read_builtin (list)
|
|||
}
|
||||
#endif
|
||||
|
||||
if (i + 2 >= size)
|
||||
if (i + 4 >= size) /* XXX was i + 2; use i + 4 for multibyte/read_mbchar */
|
||||
{
|
||||
input_string = (char *)xrealloc (input_string, size += 128);
|
||||
remove_unwind_protect ();
|
||||
|
@ -423,34 +517,53 @@ read_builtin (list)
|
|||
newline pair still disappears from the input. */
|
||||
if (pass_next)
|
||||
{
|
||||
if (c == '\n')
|
||||
i--; /* back up over the CTLESC */
|
||||
else
|
||||
input_string[i++] = c;
|
||||
pass_next = 0;
|
||||
if (c == '\n')
|
||||
{
|
||||
i--; /* back up over the CTLESC */
|
||||
if (interactive && input_is_tty && raw == 0)
|
||||
print_ps2 = 1;
|
||||
}
|
||||
else
|
||||
goto add_char;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* This may cause problems if IFS contains CTLESC */
|
||||
if (c == '\\' && raw == 0)
|
||||
{
|
||||
pass_next++;
|
||||
saw_escape++;
|
||||
input_string[i++] = CTLESC;
|
||||
if (skip_ctlesc == 0)
|
||||
{
|
||||
saw_escape++;
|
||||
input_string[i++] = CTLESC;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((unsigned char)c == delim)
|
||||
break;
|
||||
|
||||
if (c == CTLESC || c == CTLNUL)
|
||||
if ((skip_ctlesc == 0 && c == CTLESC) || (skip_ctlnul == 0 && c == CTLNUL))
|
||||
{
|
||||
saw_escape++;
|
||||
input_string[i++] = CTLESC;
|
||||
}
|
||||
|
||||
add_char:
|
||||
input_string[i++] = c;
|
||||
|
||||
if (nchars > 0 && i >= nchars)
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
if (nchars > 0 && MB_CUR_MAX > 1)
|
||||
{
|
||||
input_string[i] = '\0'; /* for simplicity and debugging */
|
||||
i += read_mbchar (fd, input_string, i, c, unbuffered_read);
|
||||
}
|
||||
#endif
|
||||
|
||||
nr++;
|
||||
|
||||
if (nchars > 0 && nr >= nchars)
|
||||
break;
|
||||
}
|
||||
input_string[i] = '\0';
|
||||
|
@ -458,12 +571,13 @@ read_builtin (list)
|
|||
#if 1
|
||||
if (retval < 0)
|
||||
{
|
||||
builtin_error ("read error: %d: %s", fd, strerror (errno));
|
||||
builtin_error (_("read error: %d: %s"), fd, strerror (errno));
|
||||
run_unwind_frame ("read_builtin");
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (tmout > 0)
|
||||
if (tmsec > 0 || tmusec > 0)
|
||||
reset_alarm ();
|
||||
|
||||
if (nchars > 0 || delim != '\n')
|
||||
|
@ -479,33 +593,50 @@ read_builtin (list)
|
|||
else
|
||||
#endif
|
||||
if (input_is_tty)
|
||||
ttrestore ();
|
||||
ttyrestore (&termsave);
|
||||
}
|
||||
else if (silent)
|
||||
ttrestore ();
|
||||
ttyrestore (&termsave);
|
||||
|
||||
if (unbuffered_read == 0)
|
||||
zsyncfd (fd);
|
||||
|
||||
interrupt_immediately--;
|
||||
terminate_immediately--;
|
||||
discard_unwind_frame ("read_builtin");
|
||||
|
||||
retval = eof ? EXECUTION_FAILURE : EXECUTION_SUCCESS;
|
||||
|
||||
assign_vars:
|
||||
|
||||
#if defined (ARRAY_VARS)
|
||||
/* If -a was given, take the string read, break it into a list of words,
|
||||
an assign them to `arrayname' in turn. */
|
||||
if (arrayname)
|
||||
{
|
||||
if (legal_identifier (arrayname) == 0)
|
||||
{
|
||||
sh_invalidid (arrayname);
|
||||
xfree (input_string);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
var = find_or_make_array_variable (arrayname, 1);
|
||||
if (var == 0)
|
||||
return EXECUTION_FAILURE; /* readonly or noassign */
|
||||
{
|
||||
xfree (input_string);
|
||||
return EXECUTION_FAILURE; /* readonly or noassign */
|
||||
}
|
||||
array_flush (array_cell (var));
|
||||
|
||||
alist = list_string (input_string, ifs_chars, 0);
|
||||
if (alist)
|
||||
{
|
||||
assign_array_var_from_word_list (var, alist);
|
||||
if (saw_escape)
|
||||
dequote_list (alist);
|
||||
else
|
||||
word_list_remove_quoted_nulls (alist);
|
||||
assign_array_var_from_word_list (var, alist, 0);
|
||||
dispose_words (alist);
|
||||
}
|
||||
xfree (input_string);
|
||||
|
@ -534,11 +665,11 @@ read_builtin (list)
|
|||
if (saw_escape)
|
||||
{
|
||||
t = dequote_string (input_string);
|
||||
var = bind_variable ("REPLY", t);
|
||||
var = bind_variable ("REPLY", t, 0);
|
||||
free (t);
|
||||
}
|
||||
else
|
||||
var = bind_variable ("REPLY", input_string);
|
||||
var = bind_variable ("REPLY", input_string, 0);
|
||||
VUNSETATTR (var, att_invisible);
|
||||
|
||||
free (input_string);
|
||||
|
@ -554,7 +685,6 @@ read_builtin (list)
|
|||
for (t = input_string; ifs_chars && *ifs_chars && spctabnl(*t) && isifs(*t); t++)
|
||||
;
|
||||
input_string = t;
|
||||
|
||||
for (; list->next; list = list->next)
|
||||
{
|
||||
varname = list->word->word;
|
||||
|
@ -617,10 +747,25 @@ read_builtin (list)
|
|||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* This has to be done this way rather than using string_list
|
||||
and list_string because Posix.2 says that the last variable gets the
|
||||
remaining words and their intervening separators. */
|
||||
input_string = strip_trailing_ifs_whitespace (input_string, ifs_chars, saw_escape);
|
||||
#else
|
||||
/* Check whether or not the number of fields is exactly the same as the
|
||||
number of variables. */
|
||||
tofree = NULL;
|
||||
if (*input_string)
|
||||
{
|
||||
t1 = input_string;
|
||||
t = get_word_from_string (&input_string, ifs_chars, &e);
|
||||
if (*input_string == 0)
|
||||
tofree = input_string = t;
|
||||
else
|
||||
input_string = strip_trailing_ifs_whitespace (t1, ifs_chars, saw_escape);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (saw_escape)
|
||||
{
|
||||
|
@ -631,6 +776,8 @@ read_builtin (list)
|
|||
else
|
||||
var = bind_read_variable (list->word->word, input_string);
|
||||
stupidly_hack_special_variables (list->word->word);
|
||||
FREE (tofree);
|
||||
|
||||
if (var)
|
||||
VUNSETATTR (var, att_invisible);
|
||||
xfree (orig_input_string);
|
||||
|
@ -644,30 +791,124 @@ bind_read_variable (name, value)
|
|||
{
|
||||
#if defined (ARRAY_VARS)
|
||||
if (valid_array_reference (name) == 0)
|
||||
return (bind_variable (name, value));
|
||||
return (bind_variable (name, value, 0));
|
||||
else
|
||||
return (assign_array_element (name, value));
|
||||
return (assign_array_element (name, value, 0));
|
||||
#else /* !ARRAY_VARS */
|
||||
return bind_variable (name, value);
|
||||
return bind_variable (name, value, 0);
|
||||
#endif /* !ARRAY_VARS */
|
||||
}
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
static int
|
||||
read_mbchar (fd, string, ind, ch, unbuffered)
|
||||
int fd;
|
||||
char *string;
|
||||
int ind, ch, unbuffered;
|
||||
{
|
||||
char mbchar[MB_LEN_MAX + 1];
|
||||
int i, n, r;
|
||||
char c;
|
||||
size_t ret;
|
||||
mbstate_t ps, ps_back;
|
||||
wchar_t wc;
|
||||
|
||||
memset (&ps, '\0', sizeof (mbstate_t));
|
||||
memset (&ps_back, '\0', sizeof (mbstate_t));
|
||||
|
||||
mbchar[0] = ch;
|
||||
i = 1;
|
||||
for (n = 0; n <= MB_LEN_MAX; n++)
|
||||
{
|
||||
ps_back = ps;
|
||||
ret = mbrtowc (&wc, mbchar, i, &ps);
|
||||
if (ret == (size_t)-2)
|
||||
{
|
||||
ps = ps_back;
|
||||
if (unbuffered)
|
||||
r = zread (fd, &c, 1);
|
||||
else
|
||||
r = zreadc (fd, &c);
|
||||
if (r < 0)
|
||||
goto mbchar_return;
|
||||
mbchar[i++] = c;
|
||||
continue;
|
||||
}
|
||||
else if (ret == (size_t)-1 || ret == (size_t)0 || ret > (size_t)0)
|
||||
break;
|
||||
}
|
||||
|
||||
mbchar_return:
|
||||
if (i > 1) /* read a multibyte char */
|
||||
/* mbchar[0] is already string[ind-1] */
|
||||
for (r = 1; r < i; r++)
|
||||
string[ind+r-1] = mbchar[r];
|
||||
return i - 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static void
|
||||
ttyrestore (ttp)
|
||||
struct ttsave *ttp;
|
||||
{
|
||||
ttsetattr (ttp->fd, ttp->attrs);
|
||||
}
|
||||
|
||||
#if defined (READLINE)
|
||||
static rl_completion_func_t *old_attempted_completion_function;
|
||||
static rl_completion_func_t *old_attempted_completion_function = 0;
|
||||
static rl_hook_func_t *old_startup_hook;
|
||||
static char *deftext;
|
||||
|
||||
static void
|
||||
reset_attempted_completion_function (cp)
|
||||
char *cp;
|
||||
{
|
||||
if (rl_attempted_completion_function == 0 && old_attempted_completion_function)
|
||||
rl_attempted_completion_function = old_attempted_completion_function;
|
||||
}
|
||||
|
||||
static int
|
||||
set_itext ()
|
||||
{
|
||||
int r1, r2;
|
||||
|
||||
r1 = r2 = 0;
|
||||
if (old_startup_hook)
|
||||
r1 = (*old_startup_hook) ();
|
||||
if (deftext)
|
||||
{
|
||||
r2 = rl_insert_text (deftext);
|
||||
deftext = (char *)NULL;
|
||||
rl_startup_hook = old_startup_hook;
|
||||
old_startup_hook = (rl_hook_func_t *)NULL;
|
||||
}
|
||||
return (r1 || r2);
|
||||
}
|
||||
|
||||
static char *
|
||||
edit_line (p)
|
||||
edit_line (p, itext)
|
||||
char *p;
|
||||
char *itext;
|
||||
{
|
||||
char *ret;
|
||||
int len;
|
||||
|
||||
if (!bash_readline_initialized)
|
||||
if (bash_readline_initialized == 0)
|
||||
initialize_readline ();
|
||||
|
||||
old_attempted_completion_function = rl_attempted_completion_function;
|
||||
rl_attempted_completion_function = (rl_completion_func_t *)NULL;
|
||||
if (itext)
|
||||
{
|
||||
old_startup_hook = rl_startup_hook;
|
||||
rl_startup_hook = set_itext;
|
||||
deftext = itext;
|
||||
}
|
||||
ret = readline (p);
|
||||
rl_attempted_completion_function = old_attempted_completion_function;
|
||||
old_attempted_completion_function = (rl_completion_func_t *)NULL;
|
||||
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
len = strlen (ret);
|
||||
|
|
|
@ -2,35 +2,41 @@ This file is reserved.def, in which the shell reserved words are defined.
|
|||
It has no direct C file production, but defines builtins for the Bash
|
||||
builtin help command.
|
||||
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$BUILTIN for
|
||||
$SHORT_DOC for NAME [in WORDS ... ;] do COMMANDS; done
|
||||
$SHORT_DOC for NAME [in WORDS ... ] ; do COMMANDS; done
|
||||
Execute commands for each member in a list.
|
||||
|
||||
The `for' loop executes a sequence of commands for each member in a
|
||||
list of items. If `in WORDS ...;' is not present, then `in "$@"' is
|
||||
assumed. For each element in WORDS, NAME is set to that element, and
|
||||
the COMMANDS are executed.
|
||||
|
||||
Exit Status:
|
||||
Returns the status of the last command executed.
|
||||
$END
|
||||
|
||||
$BUILTIN for ((
|
||||
$DOCNAME arith_for
|
||||
$SHORT_DOC for (( exp1; exp2; exp3 )); do COMMANDS; done
|
||||
Arithmetic for loop.
|
||||
|
||||
Equivalent to
|
||||
(( EXP1 ))
|
||||
while (( EXP2 )); do
|
||||
|
@ -39,10 +45,15 @@ Equivalent to
|
|||
done
|
||||
EXP1, EXP2, and EXP3 are arithmetic expressions. If any expression is
|
||||
omitted, it behaves as if it evaluates to 1.
|
||||
|
||||
Exit Status:
|
||||
Returns the status of the last command executed.
|
||||
$END
|
||||
|
||||
$BUILTIN select
|
||||
$SHORT_DOC select NAME [in WORDS ... ;] do COMMANDS; done
|
||||
Select words from a list and execute commands.
|
||||
|
||||
The WORDS are expanded, generating a list of words. The
|
||||
set of expanded words is printed on the standard error, each
|
||||
preceded by a number. If `in WORDS' is not present, `in "$@"'
|
||||
|
@ -54,112 +65,187 @@ redisplayed. If EOF is read, the command completes. Any other
|
|||
value read causes NAME to be set to null. The line read is saved
|
||||
in the variable REPLY. COMMANDS are executed after each selection
|
||||
until a break command is executed.
|
||||
|
||||
Exit Status:
|
||||
Returns the status of the last command executed.
|
||||
$END
|
||||
|
||||
$BUILTIN time
|
||||
$SHORT_DOC time [-p] PIPELINE
|
||||
$SHORT_DOC time [-p] pipeline
|
||||
Report time consumed by pipeline's execution.
|
||||
|
||||
Execute PIPELINE and print a summary of the real time, user CPU time,
|
||||
and system CPU time spent executing PIPELINE when it terminates.
|
||||
The return status is the return status of PIPELINE. The `-p' option
|
||||
prints the timing summary in a slightly different format. This uses
|
||||
the value of the TIMEFORMAT variable as the output format.
|
||||
|
||||
Options:
|
||||
-p print the timing summary in the portable Posix format
|
||||
|
||||
The value of the TIMEFORMAT variable is used as the output format.
|
||||
|
||||
Exit Status:
|
||||
The return status is the return status of PIPELINE.
|
||||
$END
|
||||
|
||||
$BUILTIN case
|
||||
$SHORT_DOC case WORD in [PATTERN [| PATTERN]...) COMMANDS ;;]... esac
|
||||
Execute commands based on pattern matching.
|
||||
|
||||
Selectively execute COMMANDS based upon WORD matching PATTERN. The
|
||||
`|' is used to separate multiple patterns.
|
||||
|
||||
Exit Status:
|
||||
Returns the status of the last command executed.
|
||||
$END
|
||||
|
||||
$BUILTIN if
|
||||
$SHORT_DOC if COMMANDS; then COMMANDS; [ elif COMMANDS; then COMMANDS; ]... [ else COMMANDS; ] fi
|
||||
The if COMMANDS are executed. If the exit status is zero, then the then
|
||||
COMMANDS are executed. Otherwise, each of the elif COMMANDS are executed
|
||||
in turn, and if the exit status is zero, the corresponding then COMMANDS
|
||||
are executed and the if command completes. Otherwise, the else COMMANDS
|
||||
are executed, if present. The exit status is the exit status of the last
|
||||
command executed, or zero if no condition tested true.
|
||||
Execute commands based on conditional.
|
||||
|
||||
The `if COMMANDS' list is executed. If its exit status is zero, then the
|
||||
`then COMMANDS' list is executed. Otherwise, each `elif COMMANDS' list is
|
||||
executed in turn, and if its exit status is zero, the corresponding
|
||||
`then COMMANDS' list is executed and the if command completes. Otherwise,
|
||||
the `else COMMANDS' list is executed, if present. The exit status of the
|
||||
entire construct is the exit status of the last command executed, or zero
|
||||
if no condition tested true.
|
||||
|
||||
Exit Status:
|
||||
Returns the status of the last command executed.
|
||||
$END
|
||||
|
||||
$BUILTIN while
|
||||
$SHORT_DOC while COMMANDS; do COMMANDS; done
|
||||
Execute commands as long as a test succeeds.
|
||||
|
||||
Expand and execute COMMANDS as long as the final command in the
|
||||
`while' COMMANDS has an exit status of zero.
|
||||
|
||||
Exit Status:
|
||||
Returns the status of the last command executed.
|
||||
$END
|
||||
|
||||
$BUILTIN until
|
||||
$SHORT_DOC until COMMANDS; do COMMANDS; done
|
||||
Execute commands as long as a test does not succeed.
|
||||
|
||||
Expand and execute COMMANDS as long as the final command in the
|
||||
`until' COMMANDS has an exit status which is not zero.
|
||||
|
||||
Exit Status:
|
||||
Returns the status of the last command executed.
|
||||
$END
|
||||
|
||||
$BUILTIN coproc
|
||||
$SHORT_DOC coproc [NAME] command [redirections]
|
||||
Create a coprocess named NAME.
|
||||
|
||||
Execute COMMAND asynchronously, with the standard output and standard
|
||||
input of the command connected via a pipe to file descriptors assigned
|
||||
to indices 0 and 1 of an array variable NAME in the executing shell.
|
||||
The default NAME is "COPROC".
|
||||
|
||||
Exit Status:
|
||||
Returns the exit status of COMMAND.
|
||||
$END
|
||||
|
||||
$BUILTIN function
|
||||
$SHORT_DOC function NAME { COMMANDS ; } or NAME () { COMMANDS ; }
|
||||
Create a simple command invoked by NAME which runs COMMANDS.
|
||||
Arguments on the command line along with NAME are passed to the
|
||||
function as $0 .. $n.
|
||||
$SHORT_DOC function name { COMMANDS ; } or name () { COMMANDS ; }
|
||||
Define shell function.
|
||||
|
||||
Create a shell function named NAME. When invoked as a simple command,
|
||||
NAME runs COMMANDs in the calling shell's context. When NAME is invoked,
|
||||
the arguments are passed to the function as $1...$n, and the function's
|
||||
name is in $FUNCNAME.
|
||||
|
||||
Exit Status:
|
||||
Returns success unless NAME is readonly.
|
||||
$END
|
||||
|
||||
$BUILTIN { ... }
|
||||
$DOCNAME grouping_braces
|
||||
$SHORT_DOC { COMMANDS ; }
|
||||
Group commands as a unit.
|
||||
|
||||
Run a set of commands in a group. This is one way to redirect an
|
||||
entire set of commands.
|
||||
|
||||
Exit Status:
|
||||
Returns the status of the last command executed.
|
||||
$END
|
||||
|
||||
$BUILTIN %
|
||||
$DOCNAME fg_percent
|
||||
$SHORT_DOC %[DIGITS | WORD] [&]
|
||||
This is similar to the `fg' command. Resume a stopped or background
|
||||
job. If you specifiy DIGITS, then that job is used. If you specify
|
||||
WORD, then the job whose name begins with WORD is used. Following the
|
||||
job specification with a `&' places the job in the background.
|
||||
$SHORT_DOC job_spec [&]
|
||||
Resume job in foreground.
|
||||
|
||||
Equivalent to the JOB_SPEC argument to the `fg' command. Resume a
|
||||
stopped or background job. JOB_SPEC can specify either a job name
|
||||
or a job number. Following JOB_SPEC with a `&' places the job in
|
||||
the background, as if the job specification had been supplied as an
|
||||
argument to `bg'.
|
||||
|
||||
Exit Status:
|
||||
Returns the status of the resumed job.
|
||||
$END
|
||||
|
||||
$BUILTIN (( ... ))
|
||||
$DOCNAME arith
|
||||
$SHORT_DOC (( expression ))
|
||||
Evaluate arithmetic expression.
|
||||
|
||||
The EXPRESSION is evaluated according to the rules for arithmetic
|
||||
evaluation. Equivalent to "let EXPRESSION".
|
||||
|
||||
Exit Status:
|
||||
Returns 1 if EXPRESSION evaluates to 0; returns 0 otherwise.
|
||||
$END
|
||||
|
||||
$BUILTIN [[ ... ]]
|
||||
$DOCNAME conditional
|
||||
$SHORT_DOC [[ expression ]]
|
||||
Execute conditional command.
|
||||
|
||||
Returns a status of 0 or 1 depending on the evaluation of the conditional
|
||||
expression EXPRESSION. Expressions are composed of the same primaries used
|
||||
by the `test' builtin, and may be combined using the following operators
|
||||
by the `test' builtin, and may be combined using the following operators:
|
||||
|
||||
( EXPRESSION ) Returns the value of EXPRESSION
|
||||
! EXPRESSION True if EXPRESSION is false; else false
|
||||
EXPR1 && EXPR2 True if both EXPR1 and EXPR2 are true; else false
|
||||
EXPR1 || EXPR2 True if either EXPR1 or EXPR2 is true; else false
|
||||
( EXPRESSION ) Returns the value of EXPRESSION
|
||||
! EXPRESSION True if EXPRESSION is false; else false
|
||||
EXPR1 && EXPR2 True if both EXPR1 and EXPR2 are true; else false
|
||||
EXPR1 || EXPR2 True if either EXPR1 or EXPR2 is true; else false
|
||||
|
||||
When the `==' and `!=' operators are used, the string to the right of the
|
||||
operator is used as a pattern and pattern matching is performed. The
|
||||
&& and || operators do not evaluate EXPR2 if EXPR1 is sufficient to
|
||||
When the `==' and `!=' operators are used, the string to the right of
|
||||
the operator is used as a pattern and pattern matching is performed.
|
||||
When the `=~' operator is used, the string to the right of the operator
|
||||
is matched as a regular expression.
|
||||
|
||||
The && and || operators do not evaluate EXPR2 if EXPR1 is sufficient to
|
||||
determine the expression's value.
|
||||
|
||||
Exit Status:
|
||||
0 or 1 depending on value of EXPRESSION.
|
||||
$END
|
||||
|
||||
$BUILTIN variables
|
||||
$DOCNAME variable_help
|
||||
$SHORT_DOC variables - Some variable names and meanings
|
||||
BASH_VERSION Version information for this Bash.
|
||||
CDPATH A colon separated list of directories to search
|
||||
when the argument to `cd' is not found in the current
|
||||
directory.
|
||||
$SHORT_DOC variables - Names and meanings of some shell variables
|
||||
Common shell variable names and usage.
|
||||
|
||||
BASH_VERSION Version information for this Bash.
|
||||
CDPATH A colon-separated list of directories to search
|
||||
for directories given as arguments to `cd'.
|
||||
GLOBIGNORE A colon-separated list of patterns describing filenames to
|
||||
be ignored by pathname expansion.
|
||||
#if defined (HISTORY)
|
||||
HISTFILE The name of the file where your command history is stored.
|
||||
HISTFILESIZE The maximum number of lines this file can contain.
|
||||
HISTSIZE The maximum number of history lines that a running
|
||||
HISTFILE The name of the file where your command history is stored.
|
||||
HISTFILESIZE The maximum number of lines this file can contain.
|
||||
HISTSIZE The maximum number of history lines that a running
|
||||
shell can access.
|
||||
#endif /* HISTORY */
|
||||
HOME The complete pathname to your login directory.
|
||||
HOME The complete pathname to your login directory.
|
||||
HOSTNAME The name of the current host.
|
||||
HOSTTYPE The type of CPU this version of Bash is running under.
|
||||
IGNOREEOF Controls the action of the shell on receipt of an EOF
|
||||
HOSTTYPE The type of CPU this version of Bash is running under.
|
||||
IGNOREEOF Controls the action of the shell on receipt of an EOF
|
||||
character as the sole input. If set, then the value
|
||||
of it is the number of EOF characters that can be seen
|
||||
in a row on an empty line before the shell will exit
|
||||
|
@ -168,19 +254,19 @@ MACHTYPE A string describing the current system Bash is running on.
|
|||
MAILCHECK How often, in seconds, Bash checks for new mail.
|
||||
MAILPATH A colon-separated list of filenames which Bash checks
|
||||
for new mail.
|
||||
OSTYPE The version of Unix this version of Bash is running on.
|
||||
PATH A colon-separated list of directories to search when
|
||||
OSTYPE The version of Unix this version of Bash is running on.
|
||||
PATH A colon-separated list of directories to search when
|
||||
looking for commands.
|
||||
PROMPT_COMMAND A command to be executed before the printing of each
|
||||
PROMPT_COMMAND A command to be executed before the printing of each
|
||||
primary prompt.
|
||||
PS1 The primary prompt string.
|
||||
PS2 The secondary prompt string.
|
||||
PS1 The primary prompt string.
|
||||
PS2 The secondary prompt string.
|
||||
PWD The full pathname of the current directory.
|
||||
SHELLOPTS A colon-separated list of enabled shell options.
|
||||
TERM The name of the current terminal type.
|
||||
TERM The name of the current terminal type.
|
||||
TIMEFORMAT The output format for timing statistics displayed by the
|
||||
`time' reserved word.
|
||||
auto_resume Non-null means a command word appearing on a line by
|
||||
auto_resume Non-null means a command word appearing on a line by
|
||||
itself is first looked for in the list of currently
|
||||
stopped jobs. If found there, that job is foregrounded.
|
||||
A value of `exact' means that the command word must
|
||||
|
@ -190,7 +276,7 @@ auto_resume Non-null means a command word appearing on a line by
|
|||
the command must be a prefix of a stopped job.
|
||||
#if defined (HISTORY)
|
||||
# if defined (BANG_HISTORY)
|
||||
histchars Characters controlling history expansion and quick
|
||||
histchars Characters controlling history expansion and quick
|
||||
substitution. The first character is the history
|
||||
substitution character, usually `!'. The second is
|
||||
the `quick substitution' character, usually `^'. The
|
||||
|
|
|
@ -1,23 +1,22 @@
|
|||
This file is return.def, from which is created return.c.
|
||||
It implements the builtin "return" in Bash.
|
||||
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES return.c
|
||||
|
||||
|
@ -25,8 +24,14 @@ $BUILTIN return
|
|||
|
||||
$FUNCTION return_builtin
|
||||
$SHORT_DOC return [n]
|
||||
Causes a function to exit with the return value specified by N. If N
|
||||
is omitted, the return status is that of the last command.
|
||||
Return from a shell function.
|
||||
|
||||
Causes a function or sourced script to exit with the return value
|
||||
specified by N. If N is omitted, the return status is that of the
|
||||
last command executed within the function or script.
|
||||
|
||||
Exit Status:
|
||||
Returns N, or failure if the shell is not executing a function or script.
|
||||
$END
|
||||
|
||||
#include <config.h>
|
||||
|
@ -38,8 +43,11 @@ $END
|
|||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "../bashintl.h"
|
||||
|
||||
#include "../shell.h"
|
||||
#include "common.h"
|
||||
#include "bashgetopt.h"
|
||||
|
||||
extern int last_command_exit_value;
|
||||
extern int subshell_environment;
|
||||
|
@ -52,13 +60,17 @@ int
|
|||
return_builtin (list)
|
||||
WORD_LIST *list;
|
||||
{
|
||||
if (no_options (list))
|
||||
return (EX_USAGE);
|
||||
list = loptend; /* skip over possible `--' */
|
||||
|
||||
return_catch_value = get_exitstat (list);
|
||||
|
||||
if (return_catch_flag)
|
||||
longjmp (return_catch, 1);
|
||||
else
|
||||
{
|
||||
builtin_error ("can only `return' from a function or sourced script");
|
||||
builtin_error (_("can only `return' from a function or sourced script"));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,23 +1,22 @@
|
|||
This file is set.def, from which is created set.c.
|
||||
It implements the "set" and "unset" builtins in Bash.
|
||||
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES set.c
|
||||
|
||||
|
@ -33,6 +32,7 @@ $PRODUCES set.c
|
|||
#include <stdio.h>
|
||||
|
||||
#include "../bashansi.h"
|
||||
#include "../bashintl.h"
|
||||
|
||||
#include "../shell.h"
|
||||
#include "../flags.h"
|
||||
|
@ -59,78 +59,96 @@ extern int no_line_editing;
|
|||
|
||||
$BUILTIN set
|
||||
$FUNCTION set_builtin
|
||||
$SHORT_DOC set [--abefhkmnptuvxBCHP] [-o option] [arg ...]
|
||||
-a Mark variables which are modified or created for export.
|
||||
-b Notify of job termination immediately.
|
||||
-e Exit immediately if a command exits with a non-zero status.
|
||||
-f Disable file name generation (globbing).
|
||||
-h Remember the location of commands as they are looked up.
|
||||
-k All assignment arguments are placed in the environment for a
|
||||
command, not just those that precede the command name.
|
||||
-m Job control is enabled.
|
||||
-n Read commands but do not execute them.
|
||||
-o option-name
|
||||
Set the variable corresponding to option-name:
|
||||
allexport same as -a
|
||||
braceexpand same as -B
|
||||
$SHORT_DOC set [--abefhkmnptuvxBCHP] [-o option-name] [arg ...]
|
||||
Set or unset values of shell options and positional parameters.
|
||||
|
||||
Change the value of shell attributes and positional parameters, or
|
||||
display the names and values of shell variables.
|
||||
|
||||
Options:
|
||||
-a Mark variables which are modified or created for export.
|
||||
-b Notify of job termination immediately.
|
||||
-e Exit immediately if a command exits with a non-zero status.
|
||||
-f Disable file name generation (globbing).
|
||||
-h Remember the location of commands as they are looked up.
|
||||
-k All assignment arguments are placed in the environment for a
|
||||
command, not just those that precede the command name.
|
||||
-m Job control is enabled.
|
||||
-n Read commands but do not execute them.
|
||||
-o option-name
|
||||
Set the variable corresponding to option-name:
|
||||
allexport same as -a
|
||||
braceexpand same as -B
|
||||
#if defined (READLINE)
|
||||
emacs use an emacs-style line editing interface
|
||||
emacs use an emacs-style line editing interface
|
||||
#endif /* READLINE */
|
||||
errexit same as -e
|
||||
hashall same as -h
|
||||
errexit same as -e
|
||||
errtrace same as -E
|
||||
functrace same as -T
|
||||
hashall same as -h
|
||||
#if defined (BANG_HISTORY)
|
||||
histexpand same as -H
|
||||
histexpand same as -H
|
||||
#endif /* BANG_HISTORY */
|
||||
#if defined (HISTORY)
|
||||
history enable command history
|
||||
history enable command history
|
||||
#endif
|
||||
ignoreeof the shell will not exit upon reading EOF
|
||||
interactive-comments
|
||||
allow comments to appear in interactive commands
|
||||
keyword same as -k
|
||||
monitor same as -m
|
||||
noclobber same as -C
|
||||
noexec same as -n
|
||||
noglob same as -f
|
||||
nolog currently accepted but ignored
|
||||
notify same as -b
|
||||
nounset same as -u
|
||||
onecmd same as -t
|
||||
physical same as -P
|
||||
posix change the behavior of bash where the default
|
||||
operation differs from the 1003.2 standard to
|
||||
match the standard
|
||||
privileged same as -p
|
||||
verbose same as -v
|
||||
ignoreeof the shell will not exit upon reading EOF
|
||||
interactive-comments
|
||||
allow comments to appear in interactive commands
|
||||
keyword same as -k
|
||||
monitor same as -m
|
||||
noclobber same as -C
|
||||
noexec same as -n
|
||||
noglob same as -f
|
||||
nolog currently accepted but ignored
|
||||
notify same as -b
|
||||
nounset same as -u
|
||||
onecmd same as -t
|
||||
physical same as -P
|
||||
pipefail the return value of a pipeline is the status of
|
||||
the last command to exit with a non-zero status,
|
||||
or zero if no command exited with a non-zero status
|
||||
posix change the behavior of bash where the default
|
||||
operation differs from the Posix standard to
|
||||
match the standard
|
||||
privileged same as -p
|
||||
verbose same as -v
|
||||
#if defined (READLINE)
|
||||
vi use a vi-style line editing interface
|
||||
vi use a vi-style line editing interface
|
||||
#endif /* READLINE */
|
||||
xtrace same as -x
|
||||
-p Turned on whenever the real and effective user ids do not match.
|
||||
Disables processing of the $ENV file and importing of shell
|
||||
functions. Turning this option off causes the effective uid and
|
||||
gid to be set to the real uid and gid.
|
||||
-t Exit after reading and executing one command.
|
||||
-u Treat unset variables as an error when substituting.
|
||||
-v Print shell input lines as they are read.
|
||||
-x Print commands and their arguments as they are executed.
|
||||
xtrace same as -x
|
||||
-p Turned on whenever the real and effective user ids do not match.
|
||||
Disables processing of the $ENV file and importing of shell
|
||||
functions. Turning this option off causes the effective uid and
|
||||
gid to be set to the real uid and gid.
|
||||
-t Exit after reading and executing one command.
|
||||
-u Treat unset variables as an error when substituting.
|
||||
-v Print shell input lines as they are read.
|
||||
-x Print commands and their arguments as they are executed.
|
||||
#if defined (BRACE_EXPANSION)
|
||||
-B the shell will perform brace expansion
|
||||
-B the shell will perform brace expansion
|
||||
#endif /* BRACE_EXPANSION */
|
||||
-C If set, disallow existing regular files to be overwritten
|
||||
by redirection of output.
|
||||
-C If set, disallow existing regular files to be overwritten
|
||||
by redirection of output.
|
||||
-E If set, the ERR trap is inherited by shell functions.
|
||||
#if defined (BANG_HISTORY)
|
||||
-H Enable ! style history substitution. This flag is on
|
||||
by default.
|
||||
-H Enable ! style history substitution. This flag is on
|
||||
by default when the shell is interactive.
|
||||
#endif /* BANG_HISTORY */
|
||||
-P If set, do not follow symbolic links when executing commands
|
||||
such as cd which change the current directory.
|
||||
-P If set, do not follow symbolic links when executing commands
|
||||
such as cd which change the current directory.
|
||||
-T If set, the DEBUG trap is inherited by shell functions.
|
||||
- Assign any remaining arguments to the positional parameters.
|
||||
The -x and -v options are turned off.
|
||||
|
||||
Using + rather than - causes these flags to be turned off. The
|
||||
flags can also be used upon invocation of the shell. The current
|
||||
set of flags may be found in $-. The remaining n ARGs are positional
|
||||
parameters and are assigned, in order, to $1, $2, .. $n. If no
|
||||
ARGs are given, all shell variables are printed.
|
||||
|
||||
Exit Status:
|
||||
Returns success unless an invalid option is given.
|
||||
$END
|
||||
|
||||
typedef int setopt_set_func_t __P((int, char *));
|
||||
|
@ -151,13 +169,13 @@ static int get_edit_mode __P((char *));
|
|||
static int bash_set_history __P((int, char *));
|
||||
#endif
|
||||
|
||||
static char *on = "on";
|
||||
static char *off = "off";
|
||||
static const char * const on = "on";
|
||||
static const char * const off = "off";
|
||||
|
||||
/* A struct used to match long options for set -o to the corresponding
|
||||
option letter or internal variable. The functions can be called to
|
||||
dynamically generate values. */
|
||||
struct {
|
||||
const struct {
|
||||
char *name;
|
||||
int letter;
|
||||
int *variable;
|
||||
|
@ -172,12 +190,14 @@ struct {
|
|||
{ "emacs", '\0', (int *)NULL, set_edit_mode, get_edit_mode },
|
||||
#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 },
|
||||
#endif /* BANG_HISTORY */
|
||||
#if defined (HISTORY)
|
||||
{ "history", '\0', &remember_on_history, bash_set_history, (setopt_get_func_t *)NULL },
|
||||
{ "history", '\0', &enable_history_list, bash_set_history, (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 },
|
||||
|
@ -195,6 +215,7 @@ struct {
|
|||
{ "nounset", 'u', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL },
|
||||
{ "onecmd", 't', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL },
|
||||
{ "physical", 'P', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL },
|
||||
{ "pipefail", '\0', &pipefail_opt, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL },
|
||||
{ "posix", '\0', &posixly_correct, set_posix_mode, (setopt_get_func_t *)NULL },
|
||||
{ "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 },
|
||||
|
@ -300,7 +321,7 @@ set_ignoreeof (on_or_off, option_name)
|
|||
ignoreeof = on_or_off == FLAG_ON;
|
||||
unbind_variable ("ignoreeof");
|
||||
if (ignoreeof)
|
||||
bind_variable ("IGNOREEOF", "10");
|
||||
bind_variable ("IGNOREEOF", "10", 0);
|
||||
else
|
||||
unbind_variable ("IGNOREEOF");
|
||||
sv_ignoreeof ("IGNOREEOF");
|
||||
|
@ -316,7 +337,7 @@ set_posix_mode (on_or_off, option_name)
|
|||
if (posixly_correct == 0)
|
||||
unbind_variable ("POSIXLY_CORRECT");
|
||||
else
|
||||
bind_variable ("POSIXLY_CORRECT", "y");
|
||||
bind_variable ("POSIXLY_CORRECT", "y", 0);
|
||||
sv_strict_posix ("POSIXLY_CORRECT");
|
||||
return (0);
|
||||
}
|
||||
|
@ -368,13 +389,17 @@ bash_set_history (on_or_off, option_name)
|
|||
{
|
||||
if (on_or_off == FLAG_ON)
|
||||
{
|
||||
enable_history_list = 1;
|
||||
bash_history_enable ();
|
||||
if (history_lines_this_session == 0)
|
||||
load_history ();
|
||||
}
|
||||
else
|
||||
bash_history_disable ();
|
||||
return (1 - remember_on_history);
|
||||
{
|
||||
enable_history_list = 0;
|
||||
bash_history_disable ();
|
||||
}
|
||||
return (1 - enable_history_list);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -409,7 +434,7 @@ set_minus_o_option (on_or_off, option_name)
|
|||
}
|
||||
|
||||
sh_invalidoptname (option_name);
|
||||
return (EXECUTION_FAILURE);
|
||||
return (EX_USAGE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -492,7 +517,7 @@ set_shellopts ()
|
|||
else
|
||||
exported = 0;
|
||||
|
||||
v = bind_variable ("SHELLOPTS", value);
|
||||
v = bind_variable ("SHELLOPTS", value, 0);
|
||||
|
||||
/* Turn the read-only attribute back on, and turn off the export attribute
|
||||
if it was set implicitly by mark_modified_vars and SHELLOPTS was not
|
||||
|
@ -532,7 +557,7 @@ initialize_shell_options (no_shellopts)
|
|||
/* set up any shell options we may have inherited. */
|
||||
if (var && imported_p (var))
|
||||
{
|
||||
temp = (array_p (var)) ? (char *)NULL : savestring (value_cell (var));
|
||||
temp = (array_p (var) || assoc_p (var)) ? (char *)NULL : savestring (value_cell (var));
|
||||
if (temp)
|
||||
{
|
||||
parse_shellopts (temp);
|
||||
|
@ -552,7 +577,7 @@ void
|
|||
reset_shell_options ()
|
||||
{
|
||||
#if defined (HISTORY)
|
||||
remember_on_history = 1;
|
||||
remember_on_history = enable_history_list = 1;
|
||||
#endif
|
||||
ignoreeof = 0;
|
||||
}
|
||||
|
@ -564,18 +589,18 @@ int
|
|||
set_builtin (list)
|
||||
WORD_LIST *list;
|
||||
{
|
||||
int on_or_off, flag_name, force_assignment, opts_changed;
|
||||
WORD_LIST *l;
|
||||
int on_or_off, flag_name, force_assignment, opts_changed, rv, r;
|
||||
register char *arg;
|
||||
char s[3];
|
||||
|
||||
if (list == 0)
|
||||
{
|
||||
print_all_shell_variables ();
|
||||
return (EXECUTION_SUCCESS);
|
||||
return (sh_chkwrite (EXECUTION_SUCCESS));
|
||||
}
|
||||
|
||||
/* Check validity of flag arguments. */
|
||||
rv = EXECUTION_SUCCESS;
|
||||
reset_internal_getopt ();
|
||||
while ((flag_name = internal_getopt (list, optflags)) != -1)
|
||||
{
|
||||
|
@ -638,6 +663,7 @@ set_builtin (list)
|
|||
if (opt == 0)
|
||||
{
|
||||
list_minus_o_opts (-1, (on_or_off == '+'));
|
||||
rv = sh_chkwrite (rv);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -652,10 +678,10 @@ set_builtin (list)
|
|||
list = list->next; /* Skip over option name. */
|
||||
|
||||
opts_changed = 1;
|
||||
if (set_minus_o_option (on_or_off, option_name) != EXECUTION_SUCCESS)
|
||||
if ((r = set_minus_o_option (on_or_off, option_name)) != EXECUTION_SUCCESS)
|
||||
{
|
||||
set_shellopts ();
|
||||
return (EXECUTION_FAILURE);
|
||||
return (r);
|
||||
}
|
||||
}
|
||||
else if (change_flag (flag_name, on_or_off) == FLAG_ERROR)
|
||||
|
@ -684,17 +710,27 @@ set_builtin (list)
|
|||
/* Set up new value of $SHELLOPTS */
|
||||
if (opts_changed)
|
||||
set_shellopts ();
|
||||
return (EXECUTION_SUCCESS);
|
||||
return (rv);
|
||||
}
|
||||
|
||||
$BUILTIN unset
|
||||
$FUNCTION unset_builtin
|
||||
$SHORT_DOC unset [-f] [-v] [name ...]
|
||||
For each NAME, remove the corresponding variable or function. Given
|
||||
the `-v', unset will only act on variables. Given the `-f' flag,
|
||||
unset will only act on functions. With neither flag, unset first
|
||||
tries to unset a variable, and if that fails, then tries to unset a
|
||||
function. Some variables cannot be unset; also see readonly.
|
||||
Unset values and attributes of shell variables and functions.
|
||||
|
||||
For each NAME, remove the corresponding variable or function.
|
||||
|
||||
Options:
|
||||
-f treat each NAME as a shell function
|
||||
-v treat each NAME as a shell variable
|
||||
|
||||
Without options, unset first tries to unset a variable, and if that fails,
|
||||
tries to unset a function.
|
||||
|
||||
Some variables cannot be unset; also see `readonly'.
|
||||
|
||||
Exit Status:
|
||||
Returns success unless an invalid option is given or a NAME is read-only.
|
||||
$END
|
||||
|
||||
#define NEXT_VARIABLE() any_failed++; list = list->next; continue;
|
||||
|
@ -729,7 +765,7 @@ unset_builtin (list)
|
|||
|
||||
if (unset_function && unset_variable)
|
||||
{
|
||||
builtin_error ("cannot simultaneously unset a function and a variable");
|
||||
builtin_error (_("cannot simultaneously unset a function and a variable"));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
|
@ -766,14 +802,14 @@ unset_builtin (list)
|
|||
|
||||
if (var && !unset_function && non_unsettable_p (var))
|
||||
{
|
||||
builtin_error ("%s: cannot unset", name);
|
||||
builtin_error (_("%s: cannot unset"), name);
|
||||
NEXT_VARIABLE ();
|
||||
}
|
||||
|
||||
/* Posix.2 says that unsetting readonly variables is an error. */
|
||||
if (var && readonly_p (var))
|
||||
{
|
||||
builtin_error ("%s: cannot unset: readonly %s",
|
||||
builtin_error (_("%s: cannot unset: readonly %s"),
|
||||
name, unset_function ? "function" : "variable");
|
||||
NEXT_VARIABLE ();
|
||||
}
|
||||
|
@ -782,9 +818,9 @@ unset_builtin (list)
|
|||
#if defined (ARRAY_VARS)
|
||||
if (var && unset_array)
|
||||
{
|
||||
if (array_p (var) == 0)
|
||||
if (array_p (var) == 0 && assoc_p (var) == 0)
|
||||
{
|
||||
builtin_error ("%s: not an array variable", name);
|
||||
builtin_error (_("%s: not an array variable"), name);
|
||||
NEXT_VARIABLE ();
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1,23 +1,22 @@
|
|||
This file is setattr.def, from which is created setattr.c.
|
||||
It implements the builtins "export" and "readonly", in Bash.
|
||||
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES setattr.c
|
||||
|
||||
|
@ -32,6 +31,7 @@ $PRODUCES setattr.c
|
|||
|
||||
#include <stdio.h>
|
||||
#include "../bashansi.h"
|
||||
#include "../bashintl.h"
|
||||
|
||||
#include "../shell.h"
|
||||
#include "common.h"
|
||||
|
@ -51,14 +51,21 @@ extern int declare_builtin __P((WORD_LIST *));
|
|||
|
||||
$BUILTIN export
|
||||
$FUNCTION export_builtin
|
||||
$SHORT_DOC export [-nf] [name[=value] ...] or export -p
|
||||
NAMEs are marked for automatic export to the environment of
|
||||
subsequently executed commands. If the -f option is given,
|
||||
the NAMEs refer to functions. If no NAMEs are given, or if `-p'
|
||||
is given, a list of all names that are exported in this shell is
|
||||
printed. An argument of `-n' says to remove the export property
|
||||
from subsequent NAMEs. An argument of `--' disables further option
|
||||
processing.
|
||||
$SHORT_DOC export [-fn] [name[=value] ...] or export -p
|
||||
Set export attribute for shell variables.
|
||||
|
||||
Marks each NAME for automatic export to the environment of subsequently
|
||||
executed commands. If VALUE is supplied, assign VALUE before exporting.
|
||||
|
||||
Options:
|
||||
-f refer to shell functions
|
||||
-n remove the export property from each NAME
|
||||
-p display a list of all exported variables and functions
|
||||
|
||||
An argument of `--' disables further option processing.
|
||||
|
||||
Exit Status:
|
||||
Returns success unless an invalid option is given or NAME is invalid.
|
||||
$END
|
||||
|
||||
/* For each variable name in LIST, make that variable appear in the
|
||||
|
@ -75,15 +82,23 @@ export_builtin (list)
|
|||
|
||||
$BUILTIN readonly
|
||||
$FUNCTION readonly_builtin
|
||||
$SHORT_DOC readonly [-anf] [name[=value] ...] or readonly -p
|
||||
The given NAMEs are marked readonly and the values of these NAMEs may
|
||||
not be changed by subsequent assignment. If the -f option is given,
|
||||
then functions corresponding to the NAMEs are so marked. If no
|
||||
arguments are given, or if `-p' is given, a list of all readonly names
|
||||
is printed. An argument of `-n' says to remove the readonly property
|
||||
from subsequent NAMEs. The `-a' option means to treat each NAME as
|
||||
an array variable. An argument of `--' disables further option
|
||||
processing.
|
||||
$SHORT_DOC readonly [-af] [name[=value] ...] or readonly -p
|
||||
Mark shell variables as unchangeable.
|
||||
|
||||
Mark each NAME as read-only; the values of these NAMEs may not be
|
||||
changed by subsequent assignment. If VALUE is supplied, assign VALUE
|
||||
before marking as read-only.
|
||||
|
||||
Options:
|
||||
-a refer to indexed array variables
|
||||
-A refer to associative array variables
|
||||
-f refer to shell functions
|
||||
-p display a list of all readonly variables and functions
|
||||
|
||||
An argument of `--' disables further option processing.
|
||||
|
||||
Exit Status:
|
||||
Returns success unless an invalid option is given or NAME is invalid.
|
||||
$END
|
||||
|
||||
/* For each variable name in LIST, make that variable readonly. Given an
|
||||
|
@ -96,28 +111,31 @@ readonly_builtin (list)
|
|||
}
|
||||
|
||||
#if defined (ARRAY_VARS)
|
||||
# define ATTROPTS "afnp"
|
||||
# define ATTROPTS "aAfnp"
|
||||
#else
|
||||
# define ATTROPTS "fnp"
|
||||
#endif
|
||||
|
||||
/* For each variable name in LIST, make that variable have the specified
|
||||
ATTRIBUTE. An arg of `-n' says to remove the attribute from the the
|
||||
remaining names in LIST. */
|
||||
remaining names in LIST (doesn't work for readonly). */
|
||||
int
|
||||
set_or_show_attributes (list, attribute, nodefs)
|
||||
register WORD_LIST *list;
|
||||
int attribute, nodefs;
|
||||
{
|
||||
register SHELL_VAR *var;
|
||||
int assign, undo, functions_only, arrays_only, any_failed, assign_error, opt;
|
||||
int assign, undo, any_failed, assign_error, opt;
|
||||
int functions_only, arrays_only, assoc_only;
|
||||
int aflags;
|
||||
char *name;
|
||||
#if defined (ARRAY_VARS)
|
||||
WORD_LIST *nlist, *tlist;
|
||||
WORD_DESC *w;
|
||||
#endif
|
||||
|
||||
undo = functions_only = arrays_only = any_failed = assign_error = 0;
|
||||
functions_only = arrays_only = assoc_only = 0;
|
||||
undo = any_failed = assign_error = 0;
|
||||
/* Read arguments from the front of the list. */
|
||||
reset_internal_getopt ();
|
||||
while ((opt = internal_getopt (list, ATTROPTS)) != -1)
|
||||
|
@ -132,8 +150,11 @@ set_or_show_attributes (list, attribute, nodefs)
|
|||
break;
|
||||
#if defined (ARRAY_VARS)
|
||||
case 'a':
|
||||
arrays_only = 1;
|
||||
break;
|
||||
arrays_only = 1;
|
||||
break;
|
||||
case 'A':
|
||||
assoc_only = 1;
|
||||
break;
|
||||
#endif
|
||||
case 'p':
|
||||
break;
|
||||
|
@ -162,7 +183,7 @@ set_or_show_attributes (list, attribute, nodefs)
|
|||
var = find_function (name);
|
||||
if (var == 0)
|
||||
{
|
||||
builtin_error ("%s: not a function", name);
|
||||
builtin_error (_("%s: not a function"), name);
|
||||
any_failed++;
|
||||
}
|
||||
else
|
||||
|
@ -173,10 +194,18 @@ set_or_show_attributes (list, attribute, nodefs)
|
|||
}
|
||||
|
||||
/* xxx [-np] name[=value] */
|
||||
assign = assignment (name);
|
||||
assign = assignment (name, 0);
|
||||
|
||||
aflags = 0;
|
||||
if (assign)
|
||||
name[assign] = '\0';
|
||||
{
|
||||
name[assign] = '\0';
|
||||
if (name[assign - 1] == '+')
|
||||
{
|
||||
aflags |= ASS_APPEND;
|
||||
name[assign - 1] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
if (legal_identifier (name) == 0)
|
||||
{
|
||||
|
@ -192,14 +221,16 @@ set_or_show_attributes (list, attribute, nodefs)
|
|||
if (assign) /* xxx [-np] name=value */
|
||||
{
|
||||
name[assign] = '=';
|
||||
if (aflags & ASS_APPEND)
|
||||
name[assign - 1] = '+';
|
||||
#if defined (ARRAY_VARS)
|
||||
/* Let's try something here. Turn readonly -a xxx=yyy into
|
||||
declare -ra xxx=yyy and see what that gets us. */
|
||||
if (arrays_only)
|
||||
if (arrays_only || assoc_only)
|
||||
{
|
||||
tlist = list->next;
|
||||
list->next = (WORD_LIST *)NULL;
|
||||
w = make_word ("-ra");
|
||||
w = arrays_only ? make_word ("-ra") : make_word ("-rA");
|
||||
nlist = make_word_list (w, list);
|
||||
opt = declare_builtin (nlist);
|
||||
if (opt != EXECUTION_SUCCESS)
|
||||
|
@ -217,6 +248,8 @@ set_or_show_attributes (list, attribute, nodefs)
|
|||
if (do_assignment_no_expand (name) == 0)
|
||||
assign_error++;
|
||||
name[assign] = '\0';
|
||||
if (aflags & ASS_APPEND)
|
||||
name[assign - 1] = '\0';
|
||||
}
|
||||
|
||||
set_var_attribute (name, attribute, undo);
|
||||
|
@ -244,6 +277,12 @@ set_or_show_attributes (list, attribute, nodefs)
|
|||
if (attribute != att_array)
|
||||
attribute &= ~att_array;
|
||||
}
|
||||
else if (attribute & att_assoc)
|
||||
{
|
||||
assoc_only++;
|
||||
if (attribute != att_assoc)
|
||||
attribute &= ~att_assoc;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (variable_list)
|
||||
|
@ -253,9 +292,15 @@ set_or_show_attributes (list, attribute, nodefs)
|
|||
#if defined (ARRAY_VARS)
|
||||
if (arrays_only && array_p (var) == 0)
|
||||
continue;
|
||||
else if (assoc_only && assoc_p (var) == 0)
|
||||
continue;
|
||||
#endif
|
||||
if ((var->attributes & attribute))
|
||||
show_var_attributes (var, READONLY_OR_EXPORT, nodefs);
|
||||
{
|
||||
show_var_attributes (var, READONLY_OR_EXPORT, nodefs);
|
||||
if (any_failed = sh_chkwrite (any_failed))
|
||||
break;
|
||||
}
|
||||
}
|
||||
free (variable_list);
|
||||
}
|
||||
|
@ -266,6 +311,30 @@ set_or_show_attributes (list, attribute, nodefs)
|
|||
: EXECUTION_FAILURE));
|
||||
}
|
||||
|
||||
/* Show all variable variables (v == 1) or functions (v == 0) with
|
||||
attributes. */
|
||||
int
|
||||
show_all_var_attributes (v, nodefs)
|
||||
int v, nodefs;
|
||||
{
|
||||
SHELL_VAR **variable_list, *var;
|
||||
int any_failed;
|
||||
register int i;
|
||||
|
||||
variable_list = v ? all_shell_variables () : all_shell_functions ();
|
||||
if (variable_list == 0)
|
||||
return (EXECUTION_SUCCESS);
|
||||
|
||||
for (i = any_failed = 0; var = variable_list[i]; i++)
|
||||
{
|
||||
show_var_attributes (var, READONLY_OR_EXPORT, nodefs);
|
||||
if (any_failed = sh_chkwrite (any_failed))
|
||||
break;
|
||||
}
|
||||
free (variable_list);
|
||||
return (any_failed == 0 ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
/* Show the attributes for shell variable VAR. If NODEFS is non-zero,
|
||||
don't show function definitions along with the name. If PATTR is
|
||||
non-zero, it indicates we're being called from `export' or `readonly'.
|
||||
|
@ -277,7 +346,7 @@ show_var_attributes (var, pattr, nodefs)
|
|||
SHELL_VAR *var;
|
||||
int pattr, nodefs;
|
||||
{
|
||||
char flags[8], *x;
|
||||
char flags[16], *x;
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
|
@ -288,6 +357,9 @@ show_var_attributes (var, pattr, nodefs)
|
|||
#if defined (ARRAY_VARS)
|
||||
if (array_p (var))
|
||||
flags[i++] = 'a';
|
||||
|
||||
if (assoc_p (var))
|
||||
flags[i++] = 'A';
|
||||
#endif
|
||||
|
||||
if (function_p (var))
|
||||
|
@ -304,12 +376,24 @@ show_var_attributes (var, pattr, nodefs)
|
|||
|
||||
if (exported_p (var))
|
||||
flags[i++] = 'x';
|
||||
|
||||
if (capcase_p (var))
|
||||
flags[i++] = 'c';
|
||||
|
||||
if (lowercase_p (var))
|
||||
flags[i++] = 'l';
|
||||
|
||||
if (uppercase_p (var))
|
||||
flags[i++] = 'u';
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined (ARRAY_VARS)
|
||||
if (array_p (var))
|
||||
flags[i++] = 'a';
|
||||
|
||||
if (assoc_p (var))
|
||||
flags[i++] = 'A';
|
||||
#endif
|
||||
|
||||
if (function_p (var))
|
||||
|
@ -323,7 +407,7 @@ show_var_attributes (var, pattr, nodefs)
|
|||
reused as input to recreate the current state. */
|
||||
if (function_p (var) && nodefs == 0 && (pattr == 0 || posixly_correct == 0))
|
||||
{
|
||||
printf ("%s\n", named_function_string (var->name, function_cell (var), 1));
|
||||
printf ("%s\n", named_function_string (var->name, function_cell (var), FUNC_MULTILINE|FUNC_EXTERNAL));
|
||||
nodefs++;
|
||||
if (pattr == 0 && i == 1 && flags[0] == 'f')
|
||||
return 0; /* don't print `declare -f name' */
|
||||
|
@ -337,8 +421,10 @@ show_var_attributes (var, pattr, nodefs)
|
|||
printf ("%s ", this_command_name);
|
||||
|
||||
#if defined (ARRAY_VARS)
|
||||
if (array_p (var))
|
||||
if (array_p (var))
|
||||
print_array_assignment (var, 1);
|
||||
else if (assoc_p (var))
|
||||
print_assoc_assignment (var, 1);
|
||||
else
|
||||
#endif
|
||||
/* force `readonly' and `export' to not print out function definitions
|
||||
|
@ -346,7 +432,7 @@ show_var_attributes (var, pattr, nodefs)
|
|||
if (nodefs || (function_p (var) && pattr != 0 && posixly_correct))
|
||||
printf ("%s\n", var->name);
|
||||
else if (function_p (var))
|
||||
printf ("%s\n", named_function_string (var->name, function_cell (var), 1));
|
||||
printf ("%s\n", named_function_string (var->name, function_cell (var), FUNC_MULTILINE|FUNC_EXTERNAL));
|
||||
else if (invisible_p (var))
|
||||
printf ("%s\n", var->name);
|
||||
else
|
||||
|
@ -396,13 +482,15 @@ set_var_attribute (name, attribute, undo)
|
|||
{
|
||||
tvalue = var_isset (tv) ? savestring (value_cell (tv)) : savestring ("");
|
||||
|
||||
var = bind_variable (tv->name, tvalue);
|
||||
var = bind_variable (tv->name, tvalue, 0);
|
||||
var->attributes |= tv->attributes & ~att_tempvar;
|
||||
VSETATTR (tv, att_propagate);
|
||||
if (var->context != 0)
|
||||
VSETATTR (var, att_propagate);
|
||||
SETVARATTR (tv, attribute, undo); /* XXX */
|
||||
|
||||
stupidly_hack_special_variables (tv->name);
|
||||
|
||||
free (tvalue);
|
||||
}
|
||||
else
|
||||
|
@ -410,7 +498,7 @@ set_var_attribute (name, attribute, undo)
|
|||
var = find_variable_internal (name, 0);
|
||||
if (var == 0)
|
||||
{
|
||||
var = bind_variable (name, (char *)NULL);
|
||||
var = bind_variable (name, (char *)NULL, 0);
|
||||
VSETATTR (var, att_invisible);
|
||||
}
|
||||
else if (var->context != 0)
|
||||
|
|
|
@ -1,23 +1,22 @@
|
|||
This file is shift.def, from which is created shift.c.
|
||||
It implements the builtin "shift" in Bash.
|
||||
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES shift.c
|
||||
|
||||
|
@ -31,6 +30,7 @@ $PRODUCES shift.c
|
|||
#endif
|
||||
|
||||
#include "../bashansi.h"
|
||||
#include "../bashintl.h"
|
||||
|
||||
#include "../shell.h"
|
||||
#include "common.h"
|
||||
|
@ -38,8 +38,13 @@ $PRODUCES shift.c
|
|||
$BUILTIN shift
|
||||
$FUNCTION shift_builtin
|
||||
$SHORT_DOC shift [n]
|
||||
The positional parameters from $N+1 ... are renamed to $1 ... If N is
|
||||
Shift positional parameters.
|
||||
|
||||
Rename the positional parameters $N+1,$N+2 ... to $1,$2 ... If N is
|
||||
not given, it is assumed to be 1.
|
||||
|
||||
Exit Status:
|
||||
Returns success unless N is negative or greater than $#.
|
||||
$END
|
||||
|
||||
int print_shift_error;
|
||||
|
@ -56,19 +61,20 @@ shift_builtin (list)
|
|||
register int count;
|
||||
WORD_LIST *temp;
|
||||
|
||||
times = get_numeric_arg (list, 0);
|
||||
if (get_numeric_arg (list, 0, ×) == 0)
|
||||
return (EXECUTION_FAILURE);
|
||||
|
||||
if (times == 0)
|
||||
return (EXECUTION_SUCCESS);
|
||||
else if (times < 0)
|
||||
{
|
||||
sh_erange (list->word->word, "shift count");
|
||||
sh_erange (list ? list->word->word : NULL, _("shift count"));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
else if (times > number_of_args ())
|
||||
{
|
||||
if (print_shift_error)
|
||||
sh_erange (list->word->word, "shift count");
|
||||
sh_erange (list ? list->word->word : NULL, _("shift count"));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,37 +1,44 @@
|
|||
This file is shopt.def, from which is created shopt.c.
|
||||
It implements the Bash `shopt' builtin.
|
||||
|
||||
Copyright (C) 1994-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1994-2009 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES shopt.c
|
||||
|
||||
$BUILTIN shopt
|
||||
$FUNCTION shopt_builtin
|
||||
$SHORT_DOC shopt [-pqsu] [-o long-option] optname [optname...]
|
||||
Toggle the values of variables controlling optional behavior.
|
||||
The -s flag means to enable (set) each OPTNAME; the -u flag
|
||||
unsets each OPTNAME. The -q flag suppresses output; the exit
|
||||
status indicates whether each OPTNAME is set or unset. The -o
|
||||
option restricts the OPTNAMEs to those defined for use with
|
||||
`set -o'. With no options, or with the -p option, a list of all
|
||||
settable options is displayed, with an indication of whether or
|
||||
not each is set.
|
||||
$SHORT_DOC shopt [-pqsu] [-o] [optname ...]
|
||||
Set and unset shell options.
|
||||
|
||||
Change the setting of each shell option OPTNAME. Without any option
|
||||
arguments, list all shell options with an indication of whether or not each
|
||||
is set.
|
||||
|
||||
Options:
|
||||
-o restrict OPTNAMEs to those defined for use with `set -o'
|
||||
-p print each shell option with an indication of its status
|
||||
-q suppress output
|
||||
-s enable (set) each OPTNAME
|
||||
-u disable (unset) each OPTNAME
|
||||
|
||||
Exit Status:
|
||||
Returns success if OPTNAME is enabled; fails if an invalid option is
|
||||
given or OPTNAME is disabled.
|
||||
$END
|
||||
|
||||
#include <config.h>
|
||||
|
@ -45,38 +52,49 @@ $END
|
|||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "version.h"
|
||||
|
||||
#include "../bashintl.h"
|
||||
|
||||
#include "../shell.h"
|
||||
#include "../flags.h"
|
||||
#include "common.h"
|
||||
#include "bashgetopt.h"
|
||||
|
||||
#if defined (HISTORY)
|
||||
# include "../bashhist.h"
|
||||
#endif
|
||||
|
||||
#define UNSETOPT 0
|
||||
#define SETOPT 1
|
||||
|
||||
#define OPTFMT "%-15s\t%s\n"
|
||||
|
||||
extern int allow_null_glob_expansion, glob_dot_filenames;
|
||||
extern int allow_null_glob_expansion, fail_glob_expansion, glob_dot_filenames;
|
||||
extern int cdable_vars, mail_warning, source_uses_path;
|
||||
extern int no_exit_on_failed_exec, print_shift_error;
|
||||
extern int check_hashed_filenames, promptvars;
|
||||
extern int cdspelling, expand_aliases;
|
||||
extern int extended_quote;
|
||||
extern int check_window_size;
|
||||
extern int glob_ignore_case;
|
||||
extern int glob_ignore_case, match_ignore_case;
|
||||
extern int hup_on_exit;
|
||||
extern int xpg_echo;
|
||||
extern int gnu_error_format;
|
||||
extern int check_jobs_at_exit;
|
||||
extern int autocd;
|
||||
extern int glob_star;
|
||||
|
||||
#if defined (EXTENDED_GLOB)
|
||||
extern int extended_glob;
|
||||
#endif
|
||||
|
||||
#if defined (HISTORY)
|
||||
extern int literal_history, command_oriented_history;
|
||||
extern int force_append_history;
|
||||
#endif
|
||||
|
||||
#if defined (READLINE)
|
||||
extern int hist_verify, history_reediting, perform_hostname_completion;
|
||||
extern int no_empty_command_completion;
|
||||
extern int force_fignore;
|
||||
extern int dircomplete_spelling;
|
||||
|
||||
extern int enable_hostname_completion __P((int));
|
||||
#endif
|
||||
|
||||
|
@ -88,15 +106,23 @@ extern int prog_completion_enabled;
|
|||
extern char *shell_name;
|
||||
#endif
|
||||
|
||||
#if defined (DEBUGGER)
|
||||
extern int debugging_mode;
|
||||
#endif
|
||||
|
||||
static void shopt_error __P((char *));
|
||||
|
||||
static int set_interactive_comments __P((int));
|
||||
static int set_shellopts_after_change __P((int));
|
||||
|
||||
static int set_compatibility_level __P((int));
|
||||
|
||||
#if defined (RESTRICTED_SHELL)
|
||||
static int set_restricted_shell __P((int));
|
||||
#endif
|
||||
|
||||
static int shopt_login_shell;
|
||||
static int shopt_compat31;
|
||||
static int shopt_compat32;
|
||||
|
||||
typedef int shopt_set_func_t __P((int));
|
||||
|
||||
|
@ -105,31 +131,48 @@ static struct {
|
|||
int *value;
|
||||
shopt_set_func_t *set_func;
|
||||
} shopt_vars[] = {
|
||||
{ "autocd", &autocd, (shopt_set_func_t *)NULL },
|
||||
{ "cdable_vars", &cdable_vars, (shopt_set_func_t *)NULL },
|
||||
{ "cdspell", &cdspelling, (shopt_set_func_t *)NULL },
|
||||
{ "checkhash", &check_hashed_filenames, (shopt_set_func_t *)NULL },
|
||||
#if defined (JOB_CONTROL)
|
||||
{ "checkjobs", &check_jobs_at_exit, (shopt_set_func_t *)NULL },
|
||||
#endif
|
||||
{ "checkwinsize", &check_window_size, (shopt_set_func_t *)NULL },
|
||||
#if defined (HISTORY)
|
||||
{ "cmdhist", &command_oriented_history, (shopt_set_func_t *)NULL },
|
||||
#endif
|
||||
{ "compat31", &shopt_compat31, set_compatibility_level },
|
||||
{ "compat32", &shopt_compat32, set_compatibility_level },
|
||||
#if defined (READLINE)
|
||||
{ "dirspell", &dircomplete_spelling, (shopt_set_func_t *)NULL },
|
||||
#endif
|
||||
{ "dotglob", &glob_dot_filenames, (shopt_set_func_t *)NULL },
|
||||
{ "execfail", &no_exit_on_failed_exec, (shopt_set_func_t *)NULL },
|
||||
{ "expand_aliases", &expand_aliases, (shopt_set_func_t *)NULL },
|
||||
#if defined (DEBUGGER)
|
||||
{ "extdebug", &debugging_mode, (shopt_set_func_t *)NULL },
|
||||
#endif
|
||||
#if defined (EXTENDED_GLOB)
|
||||
{ "extglob", &extended_glob, (shopt_set_func_t *)NULL },
|
||||
#endif
|
||||
{ "extquote", &extended_quote, (shopt_set_func_t *)NULL },
|
||||
{ "failglob", &fail_glob_expansion, (shopt_set_func_t *)NULL },
|
||||
#if defined (READLINE)
|
||||
{ "histreedit", &history_reediting, (shopt_set_func_t *)NULL },
|
||||
{ "force_fignore", &force_fignore, (shopt_set_func_t *)NULL },
|
||||
#endif
|
||||
{ "globstar", &glob_star, (shopt_set_func_t *)NULL },
|
||||
{ "gnu_errfmt", &gnu_error_format, (shopt_set_func_t *)NULL },
|
||||
#if defined (HISTORY)
|
||||
{ "histappend", &force_append_history, (shopt_set_func_t *)NULL },
|
||||
#endif
|
||||
#if defined (READLINE)
|
||||
{ "histreedit", &history_reediting, (shopt_set_func_t *)NULL },
|
||||
{ "histverify", &hist_verify, (shopt_set_func_t *)NULL },
|
||||
{ "hostcomplete", &perform_hostname_completion, enable_hostname_completion },
|
||||
#endif
|
||||
{ "huponexit", &hup_on_exit, (shopt_set_func_t *)NULL },
|
||||
{ "interactive_comments", &interactive_comments, set_interactive_comments },
|
||||
{ "interactive_comments", &interactive_comments, set_shellopts_after_change },
|
||||
#if defined (HISTORY)
|
||||
{ "lithist", &literal_history, (shopt_set_func_t *)NULL },
|
||||
#endif
|
||||
|
@ -139,6 +182,7 @@ static struct {
|
|||
{ "no_empty_cmd_completion", &no_empty_command_completion, (shopt_set_func_t *)NULL },
|
||||
#endif
|
||||
{ "nocaseglob", &glob_ignore_case, (shopt_set_func_t *)NULL },
|
||||
{ "nocasematch", &match_ignore_case, (shopt_set_func_t *)NULL },
|
||||
{ "nullglob", &allow_null_glob_expansion, (shopt_set_func_t *)NULL },
|
||||
#if defined (PROGRAMMABLE_COMPLETION)
|
||||
{ "progcomp", &prog_completion_enabled, (shopt_set_func_t *)NULL },
|
||||
|
@ -153,8 +197,8 @@ static struct {
|
|||
{ (char *)0, (int *)0, (shopt_set_func_t *)NULL }
|
||||
};
|
||||
|
||||
static char *on = "on";
|
||||
static char *off = "off";
|
||||
static const char * const on = "on";
|
||||
static const char * const off = "off";
|
||||
|
||||
static int find_shopt __P((char *));
|
||||
static int toggle_shopts __P((int, WORD_LIST *, int));
|
||||
|
@ -207,7 +251,7 @@ shopt_builtin (list)
|
|||
|
||||
if ((flags & (SFLAG|UFLAG)) == (SFLAG|UFLAG))
|
||||
{
|
||||
builtin_error ("cannot set and unset shell options simultaneously");
|
||||
builtin_error (_("cannot set and unset shell options simultaneously"));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
|
@ -272,7 +316,7 @@ static void
|
|||
shopt_error (s)
|
||||
char *s;
|
||||
{
|
||||
builtin_error ("%s: invalid shell option name", s);
|
||||
builtin_error (_("%s: invalid shell option name"), s);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -331,7 +375,7 @@ list_shopts (list, flags)
|
|||
if ((flags & QFLAG) == 0)
|
||||
print_shopt (shopt_vars[i].name, val, flags);
|
||||
}
|
||||
return (EXECUTION_SUCCESS);
|
||||
return (sh_chkwrite (EXECUTION_SUCCESS));
|
||||
}
|
||||
|
||||
for (l = list, rval = EXECUTION_SUCCESS; l; l = l->next)
|
||||
|
@ -350,7 +394,7 @@ list_shopts (list, flags)
|
|||
print_shopt (l->word->word, val, flags);
|
||||
}
|
||||
|
||||
return (rval);
|
||||
return (sh_chkwrite (rval));
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -365,7 +409,7 @@ list_some_shopts (mode, flags)
|
|||
if (((flags & QFLAG) == 0) && mode == val)
|
||||
print_shopt (shopt_vars[i].name, val, flags);
|
||||
}
|
||||
return (EXECUTION_SUCCESS);
|
||||
return (sh_chkwrite (EXECUTION_SUCCESS));
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -380,7 +424,7 @@ list_shopt_o_options (list, flags)
|
|||
{
|
||||
if ((flags & QFLAG) == 0)
|
||||
list_minus_o_opts (-1, (flags & PFLAG));
|
||||
return (EXECUTION_SUCCESS);
|
||||
return (sh_chkwrite (EXECUTION_SUCCESS));
|
||||
}
|
||||
|
||||
for (l = list, rval = EXECUTION_SUCCESS; l; l = l->next)
|
||||
|
@ -402,7 +446,7 @@ list_shopt_o_options (list, flags)
|
|||
printf (OPTFMT, l->word->word, val ? on : off);
|
||||
}
|
||||
}
|
||||
return (rval);
|
||||
return (sh_chkwrite (rval));
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -411,7 +455,7 @@ list_some_o_options (mode, flags)
|
|||
{
|
||||
if ((flags & QFLAG) == 0)
|
||||
list_minus_o_opts (mode, (flags & PFLAG));
|
||||
return (EXECUTION_SUCCESS);
|
||||
return (sh_chkwrite (EXECUTION_SUCCESS));
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -435,13 +479,27 @@ set_shopt_o_options (mode, list, quiet)
|
|||
/* If we set or unset interactive_comments with shopt, make sure the
|
||||
change is reflected in $SHELLOPTS. */
|
||||
static int
|
||||
set_interactive_comments (mode)
|
||||
set_shellopts_after_change (mode)
|
||||
int mode;
|
||||
{
|
||||
set_shellopts ();
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
set_compatibility_level (mode)
|
||||
int mode;
|
||||
{
|
||||
/* Need to change logic here as we add more compatibility levels */
|
||||
if (shopt_compat31)
|
||||
shell_compatibility_level = 31;
|
||||
else if (shopt_compat32)
|
||||
shell_compatibility_level = 32;
|
||||
else
|
||||
shell_compatibility_level = DEFAULT_COMPAT_LEVEL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined (RESTRICTED_SHELL)
|
||||
/* Don't allow the value of restricted_shell to be modified. */
|
||||
|
||||
|
@ -519,5 +577,5 @@ shopt_listopt (name, reusable)
|
|||
}
|
||||
|
||||
print_shopt (name, *shopt_vars[i].value, reusable ? PFLAG : 0);
|
||||
return (EXECUTION_SUCCESS);
|
||||
return (sh_chkwrite (EXECUTION_SUCCESS));
|
||||
}
|
||||
|
|
|
@ -1,47 +1,62 @@
|
|||
This file is source.def, from which is created source.c.
|
||||
It implements the builtins "." and "source" in Bash.
|
||||
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES source.c
|
||||
|
||||
$BUILTIN source
|
||||
$FUNCTION source_builtin
|
||||
$SHORT_DOC source filename
|
||||
Read and execute commands from FILENAME and return. The pathnames
|
||||
in $PATH are used to find the directory containing FILENAME.
|
||||
$SHORT_DOC source filename [arguments]
|
||||
Execute commands from a file in the current shell.
|
||||
|
||||
Read and execute commands from FILENAME in the current shell. The
|
||||
entries in $PATH are used to find the directory containing FILENAME.
|
||||
If any ARGUMENTS are supplied, they become the positional parameters
|
||||
when FILENAME is executed.
|
||||
|
||||
Exit Status:
|
||||
Returns the status of the last command executed in FILENAME; fails if
|
||||
FILENAME cannot be read.
|
||||
$END
|
||||
|
||||
$BUILTIN .
|
||||
$DOCNAME dot
|
||||
$FUNCTION source_builtin
|
||||
$SHORT_DOC . filename
|
||||
Read and execute commands from FILENAME and return. The pathnames
|
||||
in $PATH are used to find the directory containing FILENAME.
|
||||
$SHORT_DOC . filename [arguments]
|
||||
Execute commands from a file in the current shell.
|
||||
|
||||
Read and execute commands from FILENAME in the current shell. The
|
||||
entries in $PATH are used to find the directory containing FILENAME.
|
||||
If any ARGUMENTS are supplied, they become the positional parameters
|
||||
when FILENAME is executed.
|
||||
|
||||
Exit Status:
|
||||
Returns the status of the last command executed in FILENAME; fails if
|
||||
FILENAME cannot be read.
|
||||
$END
|
||||
/* source.c - Implements the `.' and `source' builtins. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "../bashtypes.h"
|
||||
#include "posixstat.h"
|
||||
#include "filecntl.h"
|
||||
#if defined (HAVE_SYS_FILE_H)
|
||||
#if ! defined(_MINIX) && defined (HAVE_SYS_FILE_H)
|
||||
# include <sys/file.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
|
@ -51,19 +66,22 @@ $END
|
|||
#endif
|
||||
|
||||
#include "../bashansi.h"
|
||||
#include "../bashintl.h"
|
||||
|
||||
#include "../shell.h"
|
||||
#include "../flags.h"
|
||||
#include "../findcmd.h"
|
||||
#include "common.h"
|
||||
#include "bashgetopt.h"
|
||||
#include "../trap.h"
|
||||
|
||||
#if !defined (errno)
|
||||
extern int errno;
|
||||
#endif /* !errno */
|
||||
|
||||
#if defined (RESTRICTED_SHELL)
|
||||
extern int restricted;
|
||||
#endif
|
||||
extern int posixly_correct;
|
||||
|
||||
static void maybe_pop_dollar_vars __P((void));
|
||||
|
||||
/* If non-zero, `.' uses $PATH to look up the script to be sourced. */
|
||||
int source_uses_path = 1;
|
||||
|
@ -85,6 +103,8 @@ maybe_pop_dollar_vars ()
|
|||
dispose_saved_dollar_vars ();
|
||||
else
|
||||
pop_dollar_vars ();
|
||||
if (debugging_mode)
|
||||
pop_args (); /* restore BASH_ARGC and BASH_ARGV */
|
||||
set_dollar_vars_unchanged ();
|
||||
}
|
||||
|
||||
|
@ -97,7 +117,7 @@ source_builtin (list)
|
|||
WORD_LIST *list;
|
||||
{
|
||||
int result;
|
||||
char *filename;
|
||||
char *filename, *debug_trap;
|
||||
|
||||
if (no_options (list))
|
||||
return (EX_USAGE);
|
||||
|
@ -105,7 +125,7 @@ source_builtin (list)
|
|||
|
||||
if (list == 0)
|
||||
{
|
||||
builtin_error ("filename argument required");
|
||||
builtin_error (_("filename argument required"));
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
}
|
||||
|
@ -119,13 +139,18 @@ source_builtin (list)
|
|||
#endif
|
||||
|
||||
filename = (char *)NULL;
|
||||
if (source_uses_path)
|
||||
/* XXX -- should this be absolute_pathname? */
|
||||
if (posixly_correct && strchr (list->word->word, '/'))
|
||||
filename = savestring (list->word->word);
|
||||
else if (absolute_pathname (list->word->word))
|
||||
filename = savestring (list->word->word);
|
||||
else if (source_uses_path)
|
||||
filename = find_path_file (list->word->word);
|
||||
if (filename == 0)
|
||||
{
|
||||
if (source_searches_cwd == 0)
|
||||
{
|
||||
builtin_error ("%s: file not found", list->word->word);
|
||||
builtin_error (_("%s: file not found"), list->word->word);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
else
|
||||
|
@ -140,10 +165,24 @@ source_builtin (list)
|
|||
push_dollar_vars ();
|
||||
add_unwind_protect ((Function *)maybe_pop_dollar_vars, (char *)NULL);
|
||||
remember_args (list->next, 1);
|
||||
if (debugging_mode)
|
||||
push_args (list->next); /* Update BASH_ARGV and BASH_ARGC */
|
||||
}
|
||||
set_dollar_vars_unchanged ();
|
||||
|
||||
result = source_file (filename);
|
||||
/* Don't inherit the DEBUG trap unless function_trace_mode (overloaded)
|
||||
is set. XXX - should sourced files inherit the RETURN trap? Functions
|
||||
don't. */
|
||||
debug_trap = TRAP_STRING (DEBUG_TRAP);
|
||||
if (debug_trap && function_trace_mode == 0)
|
||||
{
|
||||
debug_trap = savestring (debug_trap);
|
||||
add_unwind_protect (xfree, debug_trap);
|
||||
add_unwind_protect (set_debug_trap, debug_trap);
|
||||
restore_default_signal (DEBUG_TRAP);
|
||||
}
|
||||
|
||||
result = source_file (filename, (list && list->next));
|
||||
|
||||
run_unwind_frame ("source");
|
||||
|
||||
|
|
|
@ -1,23 +1,22 @@
|
|||
This file is suspend.def, from which is created suspend.c.
|
||||
It implements the builtin "suspend" in Bash.
|
||||
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES suspend.c
|
||||
|
||||
|
@ -25,9 +24,16 @@ $BUILTIN suspend
|
|||
$DEPENDS_ON JOB_CONTROL
|
||||
$FUNCTION suspend_builtin
|
||||
$SHORT_DOC suspend [-f]
|
||||
Suspend the execution of this shell until it receives a SIGCONT
|
||||
signal. The `-f' if specified says not to complain about this
|
||||
being a login shell if it is; just suspend anyway.
|
||||
Suspend shell execution.
|
||||
|
||||
Suspend the execution of this shell until it receives a SIGCONT signal.
|
||||
Unless forced, login shells cannot be suspended.
|
||||
|
||||
Options:
|
||||
-f force the suspend, even if the shell is a login shell
|
||||
|
||||
Exit Status:
|
||||
Returns success unless job control is not enabled or an error occurs.
|
||||
$END
|
||||
|
||||
#include <config.h>
|
||||
|
@ -42,18 +48,21 @@ $END
|
|||
|
||||
#include "../bashtypes.h"
|
||||
#include <signal.h>
|
||||
#include "../bashintl.h"
|
||||
#include "../shell.h"
|
||||
#include "../jobs.h"
|
||||
#include "common.h"
|
||||
#include "bashgetopt.h"
|
||||
|
||||
static sighandler suspend_continue __P((int));
|
||||
|
||||
static SigHandler *old_cont;
|
||||
#if 0
|
||||
static SigHandler *old_stop;
|
||||
#endif
|
||||
|
||||
/* Continue handler. */
|
||||
sighandler
|
||||
static sighandler
|
||||
suspend_continue (sig)
|
||||
int sig;
|
||||
{
|
||||
|
@ -89,7 +98,7 @@ suspend_builtin (list)
|
|||
|
||||
if (job_control == 0)
|
||||
{
|
||||
sh_nojobs ("cannot suspend");
|
||||
sh_nojobs (_("cannot suspend"));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
|
@ -99,11 +108,14 @@ suspend_builtin (list)
|
|||
|
||||
if (login_shell)
|
||||
{
|
||||
builtin_error ("cannot suspend a login shell");
|
||||
builtin_error (_("cannot suspend a login shell"));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
/* XXX - should we put ourselves back into the original pgrp now? If so,
|
||||
call end_job_control() here and do the right thing in suspend_continue
|
||||
(that is, call restart_job_control()). */
|
||||
old_cont = (SigHandler *)set_signal_handler (SIGCONT, suspend_continue);
|
||||
#if 0
|
||||
old_stop = (SigHandler *)set_signal_handler (SIGSTOP, SIG_DFL);
|
||||
|
|
|
@ -1,29 +1,30 @@
|
|||
This file is test.def, from which is created test.c.
|
||||
It implements the builtin "test" in Bash.
|
||||
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES test.c
|
||||
|
||||
$BUILTIN test
|
||||
$FUNCTION test_builtin
|
||||
$SHORT_DOC test [expr]
|
||||
Evaluate conditional expression.
|
||||
|
||||
Exits with a status of 0 (true) or 1 (false) depending on
|
||||
the evaluation of EXPR. Expressions may be unary or binary. Unary
|
||||
expressions are often used to examine the status of a file. There
|
||||
|
@ -31,27 +32,27 @@ are string operators as well, and numeric comparison operators.
|
|||
|
||||
File operators:
|
||||
|
||||
-a FILE True if file exists.
|
||||
-b FILE True if file is block special.
|
||||
-c FILE True if file is character special.
|
||||
-d FILE True if file is a directory.
|
||||
-e FILE True if file exists.
|
||||
-f FILE True if file exists and is a regular file.
|
||||
-g FILE True if file is set-group-id.
|
||||
-h FILE True if file is a symbolic link.
|
||||
-L FILE True if file is a symbolic link.
|
||||
-k FILE True if file has its `sticky' bit set.
|
||||
-p FILE True if file is a named pipe.
|
||||
-r FILE True if file is readable by you.
|
||||
-s FILE True if file exists and is not empty.
|
||||
-S FILE True if file is a socket.
|
||||
-t FD True if FD is opened on a terminal.
|
||||
-u FILE True if the file is set-user-id.
|
||||
-w FILE True if the file is writable by you.
|
||||
-x FILE True if the file is executable by you.
|
||||
-O FILE True if the file is effectively owned by you.
|
||||
-G FILE True if the file is effectively owned by your group.
|
||||
-N FILE True if the file has been modified since it was last read.
|
||||
-a FILE True if file exists.
|
||||
-b FILE True if file is block special.
|
||||
-c FILE True if file is character special.
|
||||
-d FILE True if file is a directory.
|
||||
-e FILE True if file exists.
|
||||
-f FILE True if file exists and is a regular file.
|
||||
-g FILE True if file is set-group-id.
|
||||
-h FILE True if file is a symbolic link.
|
||||
-L FILE True if file is a symbolic link.
|
||||
-k FILE True if file has its `sticky' bit set.
|
||||
-p FILE True if file is a named pipe.
|
||||
-r FILE True if file is readable by you.
|
||||
-s FILE True if file exists and is not empty.
|
||||
-S FILE True if file is a socket.
|
||||
-t FD True if FD is opened on a terminal.
|
||||
-u FILE True if the file is set-user-id.
|
||||
-w FILE True if the file is writable by you.
|
||||
-x FILE True if the file is executable by you.
|
||||
-O FILE True if the file is effectively owned by you.
|
||||
-G FILE True if the file is effectively owned by your group.
|
||||
-N FILE True if the file has been modified since it was last read.
|
||||
|
||||
FILE1 -nt FILE2 True if file1 is newer than file2 (according to
|
||||
modification date).
|
||||
|
@ -62,41 +63,47 @@ File operators:
|
|||
|
||||
String operators:
|
||||
|
||||
-z STRING True if string is empty.
|
||||
-z STRING True if string is empty.
|
||||
|
||||
-n STRING
|
||||
STRING True if string is not empty.
|
||||
-n STRING
|
||||
STRING True if string is not empty.
|
||||
|
||||
STRING1 = STRING2
|
||||
True if the strings are equal.
|
||||
STRING1 != STRING2
|
||||
True if the strings are not equal.
|
||||
STRING1 < STRING2
|
||||
True if STRING1 sorts before STRING2 lexicographically.
|
||||
STRING1 > STRING2
|
||||
True if STRING1 sorts after STRING2 lexicographically.
|
||||
STRING1 = STRING2
|
||||
True if the strings are equal.
|
||||
STRING1 != STRING2
|
||||
True if the strings are not equal.
|
||||
STRING1 < STRING2
|
||||
True if STRING1 sorts before STRING2 lexicographically.
|
||||
STRING1 > STRING2
|
||||
True if STRING1 sorts after STRING2 lexicographically.
|
||||
|
||||
Other operators:
|
||||
|
||||
-o OPTION True if the shell option OPTION is enabled.
|
||||
! EXPR True if expr is false.
|
||||
EXPR1 -a EXPR2 True if both expr1 AND expr2 are true.
|
||||
EXPR1 -o EXPR2 True if either expr1 OR expr2 is true.
|
||||
-o OPTION True if the shell option OPTION is enabled.
|
||||
! EXPR True if expr is false.
|
||||
EXPR1 -a EXPR2 True if both expr1 AND expr2 are true.
|
||||
EXPR1 -o EXPR2 True if either expr1 OR expr2 is true.
|
||||
|
||||
arg1 OP arg2 Arithmetic tests. OP is one of -eq, -ne,
|
||||
-lt, -le, -gt, or -ge.
|
||||
arg1 OP arg2 Arithmetic tests. OP is one of -eq, -ne,
|
||||
-lt, -le, -gt, or -ge.
|
||||
|
||||
Arithmetic binary operators return true if ARG1 is equal, not-equal,
|
||||
less-than, less-than-or-equal, greater-than, or greater-than-or-equal
|
||||
than ARG2.
|
||||
|
||||
Exit Status:
|
||||
Returns success if EXPR evaluates to true; fails if EXPR evaluates to
|
||||
false or an invalid argument is given.
|
||||
$END
|
||||
|
||||
$BUILTIN [
|
||||
$DOCNAME test_bracket
|
||||
$FUNCTION test_builtin
|
||||
$SHORT_DOC [ arg... ]
|
||||
This is a synonym for the "test" builtin, but the last
|
||||
argument must be a literal `]', to match the opening `['.
|
||||
Evaluate conditional expression.
|
||||
|
||||
This is a synonym for the "test" builtin, but the last argument must
|
||||
be a literal `]', to match the opening `['.
|
||||
$END
|
||||
|
||||
#include <config.h>
|
||||
|
@ -109,6 +116,7 @@ $END
|
|||
#endif
|
||||
|
||||
#include "../bashansi.h"
|
||||
#include "../bashintl.h"
|
||||
|
||||
#include "../shell.h"
|
||||
#include "../test.h"
|
||||
|
@ -131,7 +139,7 @@ test_builtin (list)
|
|||
{
|
||||
if (this_command_name[0] == '[' && !this_command_name[1])
|
||||
{
|
||||
builtin_error ("missing `]'");
|
||||
builtin_error (_("missing `]'"));
|
||||
return (EX_BADUSAGE);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,31 +1,35 @@
|
|||
This file is times.def, from which is created times.c.
|
||||
It implements the builtin "times" in Bash.
|
||||
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES times.c
|
||||
|
||||
$BUILTIN times
|
||||
$FUNCTION times_builtin
|
||||
$SHORT_DOC times
|
||||
Print the accumulated user and system times for processes run from
|
||||
the shell.
|
||||
Display process times.
|
||||
|
||||
Prints the accumulated user and system times for the shell and all of its
|
||||
child processes.
|
||||
|
||||
Exit Status:
|
||||
Always succeeds.
|
||||
$END
|
||||
|
||||
#include <config.h>
|
||||
|
@ -111,5 +115,5 @@ times_builtin (list)
|
|||
# endif /* HAVE_TIMES */
|
||||
#endif /* !HAVE_TIMES */
|
||||
|
||||
return (EXECUTION_SUCCESS);
|
||||
return (sh_chkwrite (EXECUTION_SUCCESS));
|
||||
}
|
||||
|
|
|
@ -1,42 +1,55 @@
|
|||
This file is trap.def, from which is created trap.c.
|
||||
It implements the builtin "trap" in Bash.
|
||||
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES trap.c
|
||||
|
||||
$BUILTIN trap
|
||||
$FUNCTION trap_builtin
|
||||
$SHORT_DOC trap [arg] [signal_spec ...] or trap -l
|
||||
The command ARG is to be read and executed when the shell receives
|
||||
signal(s) SIGNAL_SPEC. If ARG is absent all specified signals are
|
||||
reset to their original values. If ARG is the null string each
|
||||
SIGNAL_SPEC is ignored by the shell and by the commands it invokes.
|
||||
If a SIGNAL_SPEC is EXIT (0) the command ARG is executed on exit from
|
||||
the shell. If a SIGNAL_SPEC is DEBUG, ARG is executed after every
|
||||
command. If ARG is `-p' then the trap commands associated with
|
||||
each SIGNAL_SPEC are displayed. If no arguments are supplied or if
|
||||
only `-p' is given, trap prints the list of commands associated with
|
||||
each signal number. Each SIGNAL_SPEC is either a signal name in <signal.h>
|
||||
or a signal number. `trap -l' prints a list of signal names and their
|
||||
corresponding numbers. Note that a signal can be sent to the shell
|
||||
with "kill -signal $$".
|
||||
$SHORT_DOC trap [-lp] [[arg] signal_spec ...]
|
||||
Trap signals and other events.
|
||||
|
||||
Defines and activates handlers to be run when the shell receives signals
|
||||
or other conditions.
|
||||
|
||||
ARG is a command to be read and executed when the shell receives the
|
||||
signal(s) SIGNAL_SPEC. If ARG is absent (and a single SIGNAL_SPEC
|
||||
is supplied) or `-', each specified signal is reset to its original
|
||||
value. If ARG is the null string each SIGNAL_SPEC is ignored by the
|
||||
shell and by the commands it invokes.
|
||||
|
||||
If a SIGNAL_SPEC is EXIT (0) ARG is executed on exit from the shell. If
|
||||
a SIGNAL_SPEC is DEBUG, ARG is executed before every simple command.
|
||||
|
||||
If no arguments are supplied, trap prints the list of commands associated
|
||||
with each signal.
|
||||
|
||||
Options:
|
||||
-l print a list of signal names and their corresponding numbers
|
||||
-p display the trap commands associated with each SIGNAL_SPEC
|
||||
|
||||
Each SIGNAL_SPEC is either a signal name in <signal.h> or a signal number.
|
||||
Signal names are case insensitive and the SIG prefix is optional. A
|
||||
signal may be sent to the shell with "kill -signal $$".
|
||||
|
||||
Exit Status:
|
||||
Returns success unless a SIGSPEC is invalid or an invalid option is given.
|
||||
$END
|
||||
|
||||
#include <config.h>
|
||||
|
@ -108,24 +121,43 @@ trap_builtin (list)
|
|||
}
|
||||
list = loptend;
|
||||
|
||||
opt = DSIG_NOCASE|DSIG_SIGPREFIX; /* flags for decode_signal */
|
||||
|
||||
if (list_signal_names)
|
||||
return (display_signal_list ((WORD_LIST *)NULL, 1));
|
||||
return (sh_chkwrite (display_signal_list ((WORD_LIST *)NULL, 1)));
|
||||
else if (display || list == 0)
|
||||
return (display_traps (list));
|
||||
return (sh_chkwrite (display_traps (list)));
|
||||
else
|
||||
{
|
||||
char *first_arg;
|
||||
int operation, sig;
|
||||
int operation, sig, first_signal;
|
||||
|
||||
operation = SET;
|
||||
first_arg = list->word->word;
|
||||
if (first_arg && *first_arg && (*first_arg != '-' || first_arg[1]) &&
|
||||
signal_object_p (first_arg))
|
||||
first_signal = first_arg && *first_arg && all_digits (first_arg) && signal_object_p (first_arg, opt);
|
||||
|
||||
/* Backwards compatibility. XXX - question about whether or not we
|
||||
should throw an error if an all-digit argument doesn't correspond
|
||||
to a valid signal number (e.g., if it's `50' on a system with only
|
||||
32 signals). */
|
||||
if (first_signal)
|
||||
operation = REVERT;
|
||||
/* When in posix mode, the historical behavior of looking for a
|
||||
missing first argument is disabled. To revert to the original
|
||||
signal handling disposition, use `-' as the first argument. */
|
||||
else if (posixly_correct == 0 && first_arg && *first_arg &&
|
||||
(*first_arg != '-' || first_arg[1]) &&
|
||||
signal_object_p (first_arg, opt) && list->next == 0)
|
||||
operation = REVERT;
|
||||
else
|
||||
{
|
||||
list = list->next;
|
||||
if (*first_arg == '\0')
|
||||
if (list == 0)
|
||||
{
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
}
|
||||
else if (*first_arg == '\0')
|
||||
operation = IGNORE;
|
||||
else if (first_arg[0] == '-' && !first_arg[1])
|
||||
operation = REVERT;
|
||||
|
@ -133,7 +165,7 @@ trap_builtin (list)
|
|||
|
||||
while (list)
|
||||
{
|
||||
sig = decode_signal (list->word->word);
|
||||
sig = decode_signal (list->word->word, opt);
|
||||
|
||||
if (sig == NO_SIG)
|
||||
{
|
||||
|
@ -159,7 +191,7 @@ trap_builtin (list)
|
|||
if (interactive)
|
||||
set_signal_handler (SIGINT, sigint_sighandler);
|
||||
else
|
||||
set_signal_handler (SIGINT, termination_unwind_protect);
|
||||
set_signal_handler (SIGINT, termsig_sighandler);
|
||||
break;
|
||||
|
||||
case SIGQUIT:
|
||||
|
@ -197,7 +229,6 @@ showtrap (i)
|
|||
char *t, *p, *sn;
|
||||
|
||||
p = trap_list[i];
|
||||
|
||||
if (p == (char *)DEFAULT_SIG)
|
||||
return;
|
||||
|
||||
|
@ -235,7 +266,7 @@ display_traps (list)
|
|||
|
||||
for (result = EXECUTION_SUCCESS; list; list = list->next)
|
||||
{
|
||||
i = decode_signal (list->word->word);
|
||||
i = decode_signal (list->word->word, DSIG_NOCASE|DSIG_SIGPREFIX);
|
||||
if (i == NO_SIG)
|
||||
{
|
||||
sh_invalidsig (list->word->word);
|
||||
|
|
|
@ -1,50 +1,53 @@
|
|||
This file is type.def, from which is created type.c.
|
||||
It implements the builtin "type" in Bash.
|
||||
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES type.c
|
||||
|
||||
$BUILTIN type
|
||||
$FUNCTION type_builtin
|
||||
$SHORT_DOC type [-afptP] name [name ...]
|
||||
Display information about command type.
|
||||
|
||||
For each NAME, indicate how it would be interpreted if used as a
|
||||
command name.
|
||||
|
||||
If the -t option is used, `type' outputs a single word which is one of
|
||||
`alias', `keyword', `function', `builtin', `file' or `', if NAME is an
|
||||
alias, shell reserved word, shell function, shell builtin, disk file,
|
||||
or unfound, respectively.
|
||||
Options:
|
||||
-a display all locations containing an executable named NAME;
|
||||
includes aliases, builtins, and functions, if and only if
|
||||
the `-p' option is not also used
|
||||
-f suppress shell function lookup
|
||||
-P force a PATH search for each NAME, even if it is an alias,
|
||||
builtin, or function, and returns the name of the disk file
|
||||
that would be executed
|
||||
-p returns either the name of the disk file that would be executed,
|
||||
or nothing if `type -t NAME' would not return `file'.
|
||||
-t output a single word which is one of `alias', `keyword',
|
||||
`function', `builtin', `file' or `', if NAME is an alias, shell
|
||||
reserved word, shell function, shell builtin, disk file, or not
|
||||
found, respectively
|
||||
|
||||
If the -p flag is used, `type' either returns the name of the disk
|
||||
file that would be executed, or nothing if `type -t NAME' would not
|
||||
return `file'.
|
||||
Arguments:
|
||||
NAME Command name to be interpreted.
|
||||
|
||||
If the -a flag is used, `type' displays all of the places that contain
|
||||
an executable named `file'. This includes aliases, builtins, and
|
||||
functions, if and only if the -p flag is not also used.
|
||||
|
||||
The -f flag suppresses shell function lookup.
|
||||
|
||||
The -P flag forces a PATH search for each NAME, even if it is an alias,
|
||||
builtin, or function, and returns the name of the disk file that would
|
||||
be executed.
|
||||
Exit Status:
|
||||
Returns success if all of the NAMEs are found; fails if any are not found.
|
||||
$END
|
||||
|
||||
#include <config.h>
|
||||
|
@ -58,6 +61,7 @@ $END
|
|||
|
||||
#include <stdio.h>
|
||||
#include "../bashansi.h"
|
||||
#include "../bashintl.h"
|
||||
|
||||
#include "../shell.h"
|
||||
#include "../findcmd.h"
|
||||
|
@ -73,6 +77,7 @@ $END
|
|||
extern int find_reserved_word __P((char *));
|
||||
|
||||
extern char *this_command_name;
|
||||
extern int expand_aliases, posixly_correct;
|
||||
|
||||
/* For each word in LIST, find out what the shell is going to do with
|
||||
it as a simple command. i.e., which file would this shell use to
|
||||
|
@ -106,14 +111,14 @@ int
|
|||
type_builtin (list)
|
||||
WORD_LIST *list;
|
||||
{
|
||||
int dflags, successful_finds, opt;
|
||||
int dflags, any_failed, opt;
|
||||
WORD_LIST *this;
|
||||
|
||||
if (list == 0)
|
||||
return (EXECUTION_SUCCESS);
|
||||
|
||||
dflags = CDESC_SHORTDESC; /* default */
|
||||
successful_finds = 0;
|
||||
any_failed = 0;
|
||||
|
||||
/* Handle the obsolescent `-type', `-path', and `-all' by prescanning
|
||||
the arguments and converting those options to the form that
|
||||
|
@ -179,13 +184,12 @@ type_builtin (list)
|
|||
if (!found && (dflags & (CDESC_PATH_ONLY|CDESC_TYPE)) == 0)
|
||||
sh_notfound (list->word->word);
|
||||
|
||||
successful_finds += found;
|
||||
any_failed += found == 0;
|
||||
list = list->next;
|
||||
}
|
||||
|
||||
fflush (stdout);
|
||||
|
||||
return ((successful_finds != 0) ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
|
||||
opt = (any_failed == 0) ? EXECUTION_SUCCESS : EXECUTION_FAILURE;
|
||||
return (sh_chkwrite (opt));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -199,6 +203,7 @@ type_builtin (list)
|
|||
* CDESC_PATH_ONLY print the path for type -p
|
||||
* CDESC_FORCE_PATH force a path search for type -P
|
||||
* CDESC_NOFUNCS skip function lookup for type -f
|
||||
* CDESC_ABSPATH convert to absolute path, no ./ prefix
|
||||
*
|
||||
* CDESC_ALL says whether or not to look for all occurrences of COMMAND, or
|
||||
* return after finding it once.
|
||||
|
@ -221,12 +226,12 @@ describe_command (command, dflags)
|
|||
|
||||
#if defined (ALIAS)
|
||||
/* Command is an alias? */
|
||||
if (((dflags & CDESC_FORCE_PATH) == 0) && (alias = find_alias (command)))
|
||||
if (((dflags & CDESC_FORCE_PATH) == 0) && expand_aliases && (alias = find_alias (command)))
|
||||
{
|
||||
if (dflags & CDESC_TYPE)
|
||||
puts ("alias");
|
||||
else if (dflags & CDESC_SHORTDESC)
|
||||
printf ("%s is aliased to `%s'\n", command, alias->value);
|
||||
printf (_("%s is aliased to `%s'\n"), command, alias->value);
|
||||
else if (dflags & CDESC_REUSABLE)
|
||||
{
|
||||
x = sh_single_quote (alias->value);
|
||||
|
@ -247,7 +252,7 @@ describe_command (command, dflags)
|
|||
if (dflags & CDESC_TYPE)
|
||||
puts ("keyword");
|
||||
else if (dflags & CDESC_SHORTDESC)
|
||||
printf ("%s is a shell keyword\n", command);
|
||||
printf (_("%s is a shell keyword\n"), command);
|
||||
else if (dflags & CDESC_REUSABLE)
|
||||
printf ("%s\n", command);
|
||||
|
||||
|
@ -264,18 +269,14 @@ describe_command (command, dflags)
|
|||
puts ("function");
|
||||
else if (dflags & CDESC_SHORTDESC)
|
||||
{
|
||||
#define PRETTY_PRINT_FUNC 1
|
||||
char *result;
|
||||
|
||||
printf ("%s is a function\n", command);
|
||||
printf (_("%s is a function\n"), command);
|
||||
|
||||
/* We're blowing away THE_PRINTED_COMMAND here... */
|
||||
|
||||
result = named_function_string (command,
|
||||
(COMMAND *) function_cell (func),
|
||||
PRETTY_PRINT_FUNC);
|
||||
result = named_function_string (command, function_cell (func), FUNC_MULTILINE|FUNC_EXTERNAL);
|
||||
printf ("%s\n", result);
|
||||
#undef PRETTY_PRINT_FUNC
|
||||
}
|
||||
else if (dflags & CDESC_REUSABLE)
|
||||
printf ("%s\n", command);
|
||||
|
@ -292,7 +293,7 @@ describe_command (command, dflags)
|
|||
if (dflags & CDESC_TYPE)
|
||||
puts ("builtin");
|
||||
else if (dflags & CDESC_SHORTDESC)
|
||||
printf ("%s is a shell builtin\n", command);
|
||||
printf (_("%s is a shell builtin\n"), command);
|
||||
else if (dflags & CDESC_REUSABLE)
|
||||
printf ("%s\n", command);
|
||||
|
||||
|
@ -313,7 +314,7 @@ describe_command (command, dflags)
|
|||
if (dflags & CDESC_TYPE)
|
||||
puts ("file");
|
||||
else if (dflags & CDESC_SHORTDESC)
|
||||
printf ("%s is %s\n", command, command);
|
||||
printf (_("%s is %s\n"), command, command);
|
||||
else if (dflags & (CDESC_REUSABLE|CDESC_PATH_ONLY))
|
||||
printf ("%s\n", command);
|
||||
|
||||
|
@ -333,7 +334,7 @@ describe_command (command, dflags)
|
|||
if (dflags & CDESC_TYPE)
|
||||
puts ("file");
|
||||
else if (dflags & CDESC_SHORTDESC)
|
||||
printf ("%s is hashed (%s)\n", command, full_path);
|
||||
printf (_("%s is hashed (%s)\n"), command, full_path);
|
||||
else if (dflags & (CDESC_REUSABLE|CDESC_PATH_ONLY))
|
||||
printf ("%s\n", full_path);
|
||||
|
||||
|
@ -357,8 +358,9 @@ describe_command (command, dflags)
|
|||
|
||||
/* If we found the command as itself by looking through $PATH, it
|
||||
probably doesn't exist. Check whether or not the command is an
|
||||
executable file. If it's not, don't report a match. */
|
||||
if (STREQ (full_path, command))
|
||||
executable file. If it's not, don't report a match. This is
|
||||
the default posix mode behavior */
|
||||
if (STREQ (full_path, command) || posixly_correct)
|
||||
{
|
||||
f = file_status (full_path);
|
||||
if ((f & FS_EXECABLE) == 0)
|
||||
|
@ -368,9 +370,17 @@ describe_command (command, dflags)
|
|||
if (all == 0)
|
||||
break;
|
||||
}
|
||||
else if (ABSPATH (full_path))
|
||||
; /* placeholder; don't need to do anything yet */
|
||||
else if (dflags & (CDESC_REUSABLE|CDESC_PATH_ONLY|CDESC_SHORTDESC))
|
||||
full_path = sh_makepath ((char *)NULL, full_path, MP_DOCWD);
|
||||
{
|
||||
f = MP_DOCWD | ((dflags & CDESC_ABSPATH) ? MP_RMDOT : 0);
|
||||
full_path = sh_makepath ((char *)NULL, full_path, f);
|
||||
}
|
||||
}
|
||||
/* If we require a full path and don't have one, make one */
|
||||
else if ((dflags & CDESC_ABSPATH) && ABSPATH (full_path) == 0)
|
||||
full_path = sh_makepath ((char *)NULL, full_path, MP_DOCWD|MP_RMDOT);
|
||||
|
||||
found_file++;
|
||||
found = 1;
|
||||
|
@ -378,7 +388,7 @@ describe_command (command, dflags)
|
|||
if (dflags & CDESC_TYPE)
|
||||
puts ("file");
|
||||
else if (dflags & CDESC_SHORTDESC)
|
||||
printf ("%s is %s\n", command, full_path);
|
||||
printf (_("%s is %s\n"), command, full_path);
|
||||
else if (dflags & (CDESC_REUSABLE|CDESC_PATH_ONLY))
|
||||
printf ("%s\n", full_path);
|
||||
|
||||
|
|
|
@ -1,57 +1,68 @@
|
|||
This file is ulimit.def, from which is created ulimit.c.
|
||||
It implements the builtin "ulimit" in Bash.
|
||||
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES ulimit.c
|
||||
|
||||
$BUILTIN ulimit
|
||||
$FUNCTION ulimit_builtin
|
||||
$DEPENDS_ON !_MINIX
|
||||
$SHORT_DOC ulimit [-SHacdflmnpstuv] [limit]
|
||||
Ulimit provides control over the resources available to processes
|
||||
started by the shell, on systems that allow such control. If an
|
||||
option is given, it is interpreted as follows:
|
||||
$SHORT_DOC ulimit [-SHacdefilmnpqrstuvx] [limit]
|
||||
Modify shell resource limits.
|
||||
|
||||
-S use the `soft' resource limit
|
||||
-H use the `hard' resource limit
|
||||
-a all current limits are reported
|
||||
-c the maximum size of core files created
|
||||
-d the maximum size of a process's data segment
|
||||
-f the maximum size of files created by the shell
|
||||
-l the maximum size a process may lock into memory
|
||||
-m the maximum resident set size
|
||||
-n the maximum number of open file descriptors
|
||||
-p the pipe buffer size
|
||||
-s the maximum stack size
|
||||
-t the maximum amount of cpu time in seconds
|
||||
-u the maximum number of user processes
|
||||
-v the size of virtual memory
|
||||
Provides control over the resources available to the shell and processes
|
||||
it creates, on systems that allow such control.
|
||||
|
||||
If LIMIT is given, it is the new value of the specified resource;
|
||||
the special LIMIT values `soft', `hard', and `unlimited' stand for
|
||||
the current soft limit, the current hard limit, and no limit, respectively.
|
||||
Otherwise, the current value of the specified resource is printed.
|
||||
If no option is given, then -f is assumed. Values are in 1024-byte
|
||||
increments, except for -t, which is in seconds, -p, which is in
|
||||
increments of 512 bytes, and -u, which is an unscaled number of
|
||||
processes.
|
||||
Options:
|
||||
-S use the `soft' resource limit
|
||||
-H use the `hard' resource limit
|
||||
-a all current limits are reported
|
||||
-b the socket buffer size
|
||||
-c the maximum size of core files created
|
||||
-d the maximum size of a process's data segment
|
||||
-e the maximum scheduling priority (`nice')
|
||||
-f the maximum size of files written by the shell and its children
|
||||
-i the maximum number of pending signals
|
||||
-l the maximum size a process may lock into memory
|
||||
-m the maximum resident set size
|
||||
-n the maximum number of open file descriptors
|
||||
-p the pipe buffer size
|
||||
-q the maximum number of bytes in POSIX message queues
|
||||
-r the maximum real-time scheduling priority
|
||||
-s the maximum stack size
|
||||
-t the maximum amount of cpu time in seconds
|
||||
-u the maximum number of user processes
|
||||
-v the size of virtual memory
|
||||
-x the maximum number of file locks
|
||||
|
||||
If LIMIT is given, it is the new value of the specified resource; the
|
||||
special LIMIT values `soft', `hard', and `unlimited' stand for the
|
||||
current soft limit, the current hard limit, and no limit, respectively.
|
||||
Otherwise, the current value of the specified resource is printed. If
|
||||
no option is given, then -f is assumed.
|
||||
|
||||
Values are in 1024-byte increments, except for -t, which is in seconds,
|
||||
-p, which is in increments of 512 bytes, and -u, which is an unscaled
|
||||
number of processes.
|
||||
|
||||
Exit Status:
|
||||
Returns success unless an invalid option is supplied or an error occurs.
|
||||
$END
|
||||
|
||||
#if !defined (_MINIX)
|
||||
|
@ -70,6 +81,8 @@ $END
|
|||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "../bashintl.h"
|
||||
|
||||
#include "../shell.h"
|
||||
#include "common.h"
|
||||
#include "bashgetopt.h"
|
||||
|
@ -91,7 +104,7 @@ extern int errno;
|
|||
# if defined (HPUX) && defined (RLIMIT_NEEDS_KERNEL)
|
||||
# undef _KERNEL
|
||||
# endif
|
||||
#else
|
||||
#elif defined (HAVE_SYS_TIMES_H)
|
||||
# include <sys/times.h>
|
||||
#endif
|
||||
|
||||
|
@ -165,6 +178,14 @@ extern int errno;
|
|||
#define LIMIT_HARD 0x01
|
||||
#define LIMIT_SOFT 0x02
|
||||
|
||||
/* "Blocks" are defined as 512 bytes when in Posix mode and 1024 bytes
|
||||
otherwise. */
|
||||
#define POSIXBLK -2
|
||||
|
||||
#define BLOCKSIZE(x) (((x) == POSIXBLK) ? (posixly_correct ? 512 : 1024) : (x))
|
||||
|
||||
extern int posixly_correct;
|
||||
|
||||
static int _findlim __P((int));
|
||||
|
||||
static int ulimit_internal __P((int, char *, int, int));
|
||||
|
@ -186,18 +207,30 @@ typedef struct {
|
|||
int option; /* The ulimit option for this limit. */
|
||||
int parameter; /* Parameter to pass to get_limit (). */
|
||||
int block_factor; /* Blocking factor for specific limit. */
|
||||
char *description; /* Descriptive string to output. */
|
||||
char *units; /* scale */
|
||||
const char * const description; /* Descriptive string to output. */
|
||||
const char * const units; /* scale */
|
||||
} RESOURCE_LIMITS;
|
||||
|
||||
static RESOURCE_LIMITS limits[] = {
|
||||
#ifdef RLIMIT_PTHREAD
|
||||
{ 'T', RLIMIT_PTHREAD, 1, "number of threads", (char *)NULL },
|
||||
#endif
|
||||
#ifdef RLIMIT_SBSIZE
|
||||
{ 'b', RLIMIT_SBSIZE, 1, "socket buffer size", "bytes" },
|
||||
#endif
|
||||
#ifdef RLIMIT_CORE
|
||||
{ 'c', RLIMIT_CORE, 1024, "core file size", "blocks" },
|
||||
{ 'c', RLIMIT_CORE, POSIXBLK, "core file size", "blocks" },
|
||||
#endif
|
||||
#ifdef RLIMIT_DATA
|
||||
{ 'd', RLIMIT_DATA, 1024, "data seg size", "kbytes" },
|
||||
#endif
|
||||
{ 'f', RLIMIT_FILESIZE, 1024, "file size", "blocks" },
|
||||
#ifdef RLIMIT_NICE
|
||||
{ 'e', RLIMIT_NICE, 1, "scheduling priority", (char *)NULL },
|
||||
#endif
|
||||
{ 'f', RLIMIT_FILESIZE, POSIXBLK, "file size", "blocks" },
|
||||
#ifdef RLIMIT_SIGPENDING
|
||||
{ 'i', RLIMIT_SIGPENDING, 1, "pending signals", (char *)NULL },
|
||||
#endif
|
||||
#ifdef RLIMIT_MEMLOCK
|
||||
{ 'l', RLIMIT_MEMLOCK, 1024, "max locked memory", "kbytes" },
|
||||
#endif
|
||||
|
@ -206,6 +239,12 @@ static RESOURCE_LIMITS limits[] = {
|
|||
#endif /* RLIMIT_RSS */
|
||||
{ 'n', RLIMIT_OPENFILES, 1, "open files", (char *)NULL},
|
||||
{ 'p', RLIMIT_PIPESIZE, 512, "pipe size", "512 bytes" },
|
||||
#ifdef RLIMIT_MSGQUEUE
|
||||
{ 'q', RLIMIT_MSGQUEUE, 1, "POSIX message queues", "bytes" },
|
||||
#endif
|
||||
#ifdef RLIMIT_RTPRIO
|
||||
{ 'r', RLIMIT_RTPRIO, 1, "real-time priority", (char *)NULL },
|
||||
#endif
|
||||
#ifdef RLIMIT_STACK
|
||||
{ 's', RLIMIT_STACK, 1024, "stack size", "kbytes" },
|
||||
#endif
|
||||
|
@ -218,6 +257,9 @@ static RESOURCE_LIMITS limits[] = {
|
|||
#endif
|
||||
#ifdef RLIMIT_SWAP
|
||||
{ 'w', RLIMIT_SWAP, 1024, "swap size", "kbytes" },
|
||||
#endif
|
||||
#ifdef RLIMIT_LOCKS
|
||||
{ 'x', RLIMIT_LOCKS, 1, "file locks", (char *)NULL },
|
||||
#endif
|
||||
{ -1, -1, -1, (char *)NULL, (char *)NULL }
|
||||
};
|
||||
|
@ -330,14 +372,14 @@ ulimit_builtin (list)
|
|||
{
|
||||
if (STREQ (list->word->word, "unlimited") == 0)
|
||||
{
|
||||
builtin_error ("%s: invalid limit argument", list->word->word);
|
||||
builtin_error (_("%s: invalid limit argument"), list->word->word);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
return (set_all_limits (mode == 0 ? LIMIT_SOFT|LIMIT_HARD : mode, RLIM_INFINITY));
|
||||
}
|
||||
#endif
|
||||
print_all_limits (mode == 0 ? LIMIT_SOFT : mode);
|
||||
return (EXECUTION_SUCCESS);
|
||||
return (sh_chkwrite (EXECUTION_SUCCESS));
|
||||
}
|
||||
|
||||
/* default is `ulimit -f' */
|
||||
|
@ -356,7 +398,7 @@ ulimit_builtin (list)
|
|||
limind = _findlim (cmdlist[c].cmd);
|
||||
if (limind == -1)
|
||||
{
|
||||
builtin_error ("`%c': bad command", cmdlist[c].cmd);
|
||||
builtin_error (_("`%c': bad command"), cmdlist[c].cmd);
|
||||
return (EX_USAGE);
|
||||
}
|
||||
}
|
||||
|
@ -385,7 +427,7 @@ ulimit_internal (cmd, cmdarg, mode, multiple)
|
|||
opt = get_limit (limind, &soft_limit, &hard_limit);
|
||||
if (opt < 0)
|
||||
{
|
||||
builtin_error ("%s: cannot get limit: %s", limits[limind].description,
|
||||
builtin_error (_("%s: cannot get limit: %s"), limits[limind].description,
|
||||
strerror (errno));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
@ -406,12 +448,12 @@ ulimit_internal (cmd, cmdarg, mode, multiple)
|
|||
else if (all_digits (cmdarg))
|
||||
{
|
||||
limit = string_to_rlimtype (cmdarg);
|
||||
block_factor = limits[limind].block_factor;
|
||||
block_factor = BLOCKSIZE(limits[limind].block_factor);
|
||||
real_limit = limit * block_factor;
|
||||
|
||||
if ((real_limit / block_factor) != limit)
|
||||
{
|
||||
sh_erange (cmdarg, "limit");
|
||||
sh_erange (cmdarg, _("limit"));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
}
|
||||
|
@ -423,7 +465,7 @@ ulimit_internal (cmd, cmdarg, mode, multiple)
|
|||
|
||||
if (set_limit (limind, real_limit, mode) < 0)
|
||||
{
|
||||
builtin_error ("%s: cannot modify limit: %s", limits[limind].description,
|
||||
builtin_error (_("%s: cannot modify limit: %s"), limits[limind].description,
|
||||
strerror (errno));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
@ -606,14 +648,19 @@ pipesize (valuep)
|
|||
*valuep = (RLIMTYPE) PIPE_BUF;
|
||||
return 0;
|
||||
#else
|
||||
# if defined (PIPESIZE)
|
||||
# if defined (_POSIX_PIPE_BUF)
|
||||
*valuep = (RLIMTYPE) _POSIX_PIPE_BUF;
|
||||
return 0;
|
||||
# else
|
||||
# if defined (PIPESIZE)
|
||||
/* This is defined by running a program from the Makefile. */
|
||||
*valuep = (RLIMTYPE) PIPESIZE;
|
||||
return 0;
|
||||
# else
|
||||
# else
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
# endif /* PIPESIZE */
|
||||
# endif /* PIPESIZE */
|
||||
# endif /* _POSIX_PIPE_BUF */
|
||||
#endif /* PIPE_BUF */
|
||||
}
|
||||
|
||||
|
@ -648,11 +695,11 @@ print_all_limits (mode)
|
|||
|
||||
for (i = 0; limits[i].option > 0; i++)
|
||||
{
|
||||
if (get_limit (i, &softlim, &hardlim) < 0)
|
||||
if (get_limit (i, &softlim, &hardlim) == 0)
|
||||
printone (i, (mode & LIMIT_SOFT) ? softlim : hardlim, 1);
|
||||
else if (errno != EINVAL)
|
||||
builtin_error ("%s: cannot get limit: %s", limits[i].description,
|
||||
strerror (errno));
|
||||
else
|
||||
printone (i, (mode & LIMIT_SOFT) ? softlim : hardlim, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -663,7 +710,9 @@ printone (limind, curlim, pdesc)
|
|||
int pdesc;
|
||||
{
|
||||
char unitstr[64];
|
||||
int factor;
|
||||
|
||||
factor = BLOCKSIZE(limits[limind].block_factor);
|
||||
if (pdesc)
|
||||
{
|
||||
if (limits[limind].units)
|
||||
|
@ -671,7 +720,7 @@ printone (limind, curlim, pdesc)
|
|||
else
|
||||
sprintf (unitstr, "(-%c) ", limits[limind].option);
|
||||
|
||||
printf ("%-18s %16s", limits[limind].description, unitstr);
|
||||
printf ("%-20s %16s", limits[limind].description, unitstr);
|
||||
}
|
||||
if (curlim == RLIM_INFINITY)
|
||||
puts ("unlimited");
|
||||
|
@ -680,7 +729,7 @@ printone (limind, curlim, pdesc)
|
|||
else if (curlim == RLIM_SAVED_CUR)
|
||||
puts ("soft");
|
||||
else
|
||||
print_rlimtype ((curlim / limits[limind].block_factor), 1);
|
||||
print_rlimtype ((curlim / factor), 1);
|
||||
}
|
||||
|
||||
/* Set all limits to NEWLIM. NEWLIM currently must be RLIM_INFINITY, which
|
||||
|
@ -716,7 +765,7 @@ set_all_limits (mode, newlim)
|
|||
for (retval = i = 0; limits[i].option > 0; i++)
|
||||
if (set_limit (i, newlim, mode) < 0)
|
||||
{
|
||||
builtin_error ("%s: cannot modify limit: %s", limits[i].description,
|
||||
builtin_error (_("%s: cannot modify limit: %s"), limits[i].description,
|
||||
strerror (errno));
|
||||
retval = 1;
|
||||
}
|
||||
|
|
|
@ -1,43 +1,49 @@
|
|||
This file is umask.def, from which is created umask.c.
|
||||
It implements the builtin "umask" in Bash.
|
||||
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES umask.c
|
||||
|
||||
$BUILTIN umask
|
||||
$FUNCTION umask_builtin
|
||||
$SHORT_DOC umask [-p] [-S] [mode]
|
||||
The user file-creation mask is set to MODE. If MODE is omitted, or if
|
||||
`-S' is supplied, the current value of the mask is printed. The `-S'
|
||||
option makes the output symbolic; otherwise an octal number is output.
|
||||
If `-p' is supplied, and MODE is omitted, the output is in a form
|
||||
that may be used as input. If MODE begins with a digit, it is
|
||||
interpreted as an octal number, otherwise it is a symbolic mode string
|
||||
like that accepted by chmod(1).
|
||||
Display or set file mode mask.
|
||||
|
||||
Sets the user file-creation mask to MODE. If MODE is omitted, prints
|
||||
the current value of the mask.
|
||||
|
||||
If MODE begins with a digit, it is interpreted as an octal number;
|
||||
otherwise it is a symbolic mode string like that accepted by chmod(1).
|
||||
|
||||
Options:
|
||||
-p if MODE is omitted, output in a form that may be reused as input
|
||||
-S makes the output symbolic; otherwise an octal number is output
|
||||
|
||||
Exit Status:
|
||||
Returns success unless MODE is invalid or an invalid option is given.
|
||||
$END
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "../bashtypes.h"
|
||||
#include "filecntl.h"
|
||||
#if defined (HAVE_SYS_FILE_H)
|
||||
#if ! defined(_MINIX) && defined (HAVE_SYS_FILE_H)
|
||||
# include <sys/file.h>
|
||||
#endif
|
||||
|
||||
|
@ -48,6 +54,8 @@ $END
|
|||
#include <stdio.h>
|
||||
#include <chartypes.h>
|
||||
|
||||
#include "../bashintl.h"
|
||||
|
||||
#include "../shell.h"
|
||||
#include "posixstat.h"
|
||||
#include "common.h"
|
||||
|
@ -107,7 +115,7 @@ umask_builtin (list)
|
|||
is lousy. */
|
||||
if (umask_value == -1)
|
||||
{
|
||||
sh_erange (list->word->word, "octal number");
|
||||
sh_erange (list->word->word, _("octal number"));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
}
|
||||
|
@ -135,8 +143,7 @@ umask_builtin (list)
|
|||
printf ("%04lo\n", (unsigned long)umask_arg);
|
||||
}
|
||||
|
||||
fflush (stdout);
|
||||
return (EXECUTION_SUCCESS);
|
||||
return (sh_chkwrite (EXECUTION_SUCCESS));
|
||||
}
|
||||
|
||||
/* Print the umask in a symbolic form. In the output, a letter is
|
||||
|
@ -221,7 +228,7 @@ parse_symbolic_mode (mode, initial_bits)
|
|||
case '=':
|
||||
break;
|
||||
default:
|
||||
builtin_error ("`%c': invalid symbolic mode operator", op);
|
||||
builtin_error (_("`%c': invalid symbolic mode operator"), op);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
@ -260,6 +267,8 @@ parse_symbolic_mode (mode, initial_bits)
|
|||
bits &= ~perm;
|
||||
break;
|
||||
case '=':
|
||||
if (who == 0)
|
||||
who = S_IRWXU | S_IRWXG | S_IRWXO;
|
||||
bits &= ~who;
|
||||
bits |= perm;
|
||||
break;
|
||||
|
@ -274,7 +283,7 @@ parse_symbolic_mode (mode, initial_bits)
|
|||
}
|
||||
else
|
||||
{
|
||||
builtin_error ("`%c': invalid symbolic mode character", *s);
|
||||
builtin_error (_("`%c': invalid symbolic mode character"), *s);
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
@ -298,7 +307,7 @@ symbolic_umask (list)
|
|||
/* All work is done with the complement of the umask -- it's
|
||||
more intuitive and easier to deal with. It is complemented
|
||||
again before being returned. */
|
||||
bits = parse_symbolic_mode (list->word->word, ~um);
|
||||
bits = parse_symbolic_mode (list->word->word, ~um & 0777);
|
||||
if (bits == -1)
|
||||
return (-1);
|
||||
|
||||
|
|
|
@ -1,44 +1,54 @@
|
|||
This file is wait.def, from which is created wait.c.
|
||||
It implements the builtin "wait" in Bash.
|
||||
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$BUILTIN wait
|
||||
$FUNCTION wait_builtin
|
||||
$DEPENDS_ON JOB_CONTROL
|
||||
$PRODUCES wait.c
|
||||
$SHORT_DOC wait [n]
|
||||
Wait for the specified process and report its termination status. If
|
||||
N is not given, all currently active child processes are waited for,
|
||||
and the return code is zero. N may be a process ID or a job
|
||||
specification; if a job spec is given, all processes in the job's
|
||||
pipeline are waited for.
|
||||
$SHORT_DOC wait [id]
|
||||
Wait for job completion and return exit status.
|
||||
|
||||
Waits for the process identified by ID, which may be a process ID or a
|
||||
job specification, and reports its termination status. If ID is not
|
||||
given, waits for all currently active child processes, and the return
|
||||
status is zero. If ID is a a job specification, waits for all processes
|
||||
in the job's pipeline.
|
||||
|
||||
Exit Status:
|
||||
Returns the status of ID; fails if ID is invalid or an invalid option is
|
||||
given.
|
||||
$END
|
||||
|
||||
$BUILTIN wait
|
||||
$FUNCTION wait_builtin
|
||||
$DEPENDS_ON !JOB_CONTROL
|
||||
$SHORT_DOC wait [n]
|
||||
Wait for the specified process and report its termination status. If
|
||||
N is not given, all currently active child processes are waited for,
|
||||
and the return code is zero. N is a process ID; if it is not given,
|
||||
all child processes of the shell are waited for.
|
||||
$SHORT_DOC wait [pid]
|
||||
Wait for process completion and return exit status.
|
||||
|
||||
Waits for the specified process and reports its termination status. If
|
||||
PID is not given, all currently active child processes are waited for,
|
||||
and the return code is zero. PID must be a process ID.
|
||||
|
||||
Exit Status:
|
||||
Returns the status of ID; fails if ID is invalid or an invalid option is
|
||||
given.
|
||||
$END
|
||||
|
||||
#include <config.h>
|
||||
|
@ -59,7 +69,6 @@ $END
|
|||
#include "common.h"
|
||||
#include "bashgetopt.h"
|
||||
|
||||
extern int interrupt_immediately;
|
||||
extern int wait_signal_received;
|
||||
|
||||
procenv_t wait_intr_buf;
|
||||
|
@ -141,7 +150,7 @@ wait_builtin (list)
|
|||
}
|
||||
}
|
||||
#if defined (JOB_CONTROL)
|
||||
else if (job_control && *w)
|
||||
else if (*w && *w == '%')
|
||||
/* Must be a job spec. Check it out. */
|
||||
{
|
||||
int job;
|
||||
|
@ -150,7 +159,7 @@ wait_builtin (list)
|
|||
BLOCK_CHILD (set, oset);
|
||||
job = get_job_spec (list);
|
||||
|
||||
if (job < 0 || job >= job_slots || !jobs[job])
|
||||
if (INVALID_JOB (job))
|
||||
{
|
||||
if (job != DUP_JOB)
|
||||
sh_badjob (list->word->word);
|
||||
|
@ -164,12 +173,6 @@ wait_builtin (list)
|
|||
UNBLOCK_CHILD (oset);
|
||||
status = wait_for_job (job);
|
||||
}
|
||||
else if (job_control == 0 && *w == '%')
|
||||
{
|
||||
/* can't use jobspecs as arguments if job control is not active. */
|
||||
sh_nojobs ((char *)NULL);
|
||||
status = EXECUTION_FAILURE;
|
||||
}
|
||||
#endif /* JOB_CONTROL */
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
/* command.h -- The structures used internally to represent commands, and
|
||||
the extern declarations of the functions used to create them. */
|
||||
|
||||
/* Copyright (C) 1993 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1993-2009 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 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 3 of the License, 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.
|
||||
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. */
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if !defined (_COMMAND_H_)
|
||||
#define _COMMAND_H_
|
||||
|
@ -31,7 +31,8 @@ enum r_instruction {
|
|||
r_duplicating_input, r_duplicating_output, r_deblank_reading_until,
|
||||
r_close_this, r_err_and_out, r_input_output, r_output_force,
|
||||
r_duplicating_input_word, r_duplicating_output_word,
|
||||
r_move_input, r_move_output, r_move_input_word, r_move_output_word
|
||||
r_move_input, r_move_output, r_move_input_word, r_move_output_word,
|
||||
r_append_err_and_out
|
||||
};
|
||||
|
||||
/* Redirection errors. */
|
||||
|
@ -44,7 +45,7 @@ enum r_instruction {
|
|||
(ri == r_output_direction || ri == r_err_and_out)
|
||||
|
||||
#define OUTPUT_REDIRECT(ri) \
|
||||
(ri == r_output_direction || ri == r_input_output || ri == r_err_and_out)
|
||||
(ri == r_output_direction || ri == r_input_output || ri == r_err_and_out || ri == r_append_err_and_out)
|
||||
|
||||
#define INPUT_REDIRECT(ri) \
|
||||
(ri == r_input_direction || ri == r_inputa_direction || ri == r_input_output)
|
||||
|
@ -54,6 +55,7 @@ enum r_instruction {
|
|||
ri == r_input_output || \
|
||||
ri == r_err_and_out || \
|
||||
ri == r_appending_to || \
|
||||
ri == r_append_err_and_out || \
|
||||
ri == r_output_force)
|
||||
|
||||
/* redirection needs translation */
|
||||
|
@ -64,17 +66,32 @@ enum r_instruction {
|
|||
/* Command Types: */
|
||||
enum command_type { cm_for, cm_case, cm_while, cm_if, cm_simple, cm_select,
|
||||
cm_connection, cm_function_def, cm_until, cm_group,
|
||||
cm_arith, cm_cond, cm_arith_for, cm_subshell };
|
||||
cm_arith, cm_cond, cm_arith_for, cm_subshell, cm_coproc };
|
||||
|
||||
/* Possible values for the `flags' field of a WORD_DESC. */
|
||||
#define W_HASDOLLAR 0x01 /* Dollar sign present. */
|
||||
#define W_QUOTED 0x02 /* Some form of quote character is present. */
|
||||
#define W_ASSIGNMENT 0x04 /* This word is a variable assignment. */
|
||||
#define W_GLOBEXP 0x08 /* This word is the result of a glob expansion. */
|
||||
#define W_NOSPLIT 0x10 /* Do not perform word splitting on this word. */
|
||||
#define W_NOGLOB 0x20 /* Do not perform globbing on this word. */
|
||||
#define W_NOSPLIT2 0x40 /* Don't split word except for $@ expansion. */
|
||||
#define W_TILDEEXP 0x80 /* Tilde expand this assignment word */
|
||||
#define W_HASDOLLAR 0x000001 /* Dollar sign present. */
|
||||
#define W_QUOTED 0x000002 /* Some form of quote character is present. */
|
||||
#define W_ASSIGNMENT 0x000004 /* This word is a variable assignment. */
|
||||
#define W_GLOBEXP 0x000008 /* This word is the result of a glob expansion. */
|
||||
#define W_NOSPLIT 0x000010 /* Do not perform word splitting on this word. */
|
||||
#define W_NOGLOB 0x000020 /* Do not perform globbing on this word. */
|
||||
#define W_NOSPLIT2 0x000040 /* Don't split word except for $@ expansion. */
|
||||
#define W_TILDEEXP 0x000080 /* Tilde expand this assignment word */
|
||||
#define W_DOLLARAT 0x000100 /* $@ and its special handling */
|
||||
#define W_DOLLARSTAR 0x000200 /* $* and its special handling */
|
||||
#define W_NOCOMSUB 0x000400 /* Don't perform command substitution on this word */
|
||||
#define W_ASSIGNRHS 0x000800 /* Word is rhs of an assignment statement */
|
||||
#define W_NOTILDE 0x001000 /* Don't perform tilde expansion on this word */
|
||||
#define W_ITILDE 0x002000 /* Internal flag for word expansion */
|
||||
#define W_NOEXPAND 0x004000 /* Don't expand at all -- do quote removal */
|
||||
#define W_COMPASSIGN 0x008000 /* Compound assignment */
|
||||
#define W_ASSNBLTIN 0x010000 /* word is a builtin command that takes assignments */
|
||||
#define W_ASSIGNARG 0x020000 /* word is assignment argument to command */
|
||||
#define W_HASQUOTEDNULL 0x040000 /* word contains a quoted null character */
|
||||
#define W_DQUOTE 0x080000 /* word should be treated as if double-quoted */
|
||||
#define W_NOPROCSUB 0x100000 /* don't perform process substitution */
|
||||
#define W_HASCTLESC 0x200000 /* word contains literal CTLESC characters */
|
||||
#define W_ASSIGNASSOC 0x400000 /* word looks like associative array assignment */
|
||||
|
||||
/* Possible values for subshell_environment */
|
||||
#define SUBSHELL_ASYNC 0x01 /* subshell caused by `command &' */
|
||||
|
@ -82,6 +99,8 @@ enum command_type { cm_for, cm_case, cm_while, cm_if, cm_simple, cm_select,
|
|||
#define SUBSHELL_COMSUB 0x04 /* subshell caused by `command` or $(command) */
|
||||
#define SUBSHELL_FORK 0x08 /* subshell caused by executing a disk command */
|
||||
#define SUBSHELL_PIPE 0x10 /* subshell from a pipeline element */
|
||||
#define SUBSHELL_PROCSUB 0x20 /* subshell caused by <(command) or >(command) */
|
||||
#define SUBSHELL_COPROC 0x40 /* subshell from a coproc pipeline */
|
||||
|
||||
/* A structure which represents a word. */
|
||||
typedef struct word_desc {
|
||||
|
@ -143,6 +162,7 @@ typedef struct element {
|
|||
#define CMD_AMPERSAND 0x200 /* command & */
|
||||
#define CMD_STDIN_REDIR 0x400 /* async command needs implicit </dev/null */
|
||||
#define CMD_COMMAND_BUILTIN 0x0800 /* command executed by `command' builtin */
|
||||
#define CMD_COPROC_SUBSHELL 0x1000
|
||||
|
||||
/* What a command looks like. */
|
||||
typedef struct command {
|
||||
|
@ -172,6 +192,7 @@ typedef struct command {
|
|||
struct arith_for_com *ArithFor;
|
||||
#endif
|
||||
struct subshell_com *Subshell;
|
||||
struct coproc_com *Coproc;
|
||||
} value;
|
||||
} COMMAND;
|
||||
|
||||
|
@ -185,16 +206,22 @@ typedef struct connection {
|
|||
|
||||
/* Structures used to represent the CASE command. */
|
||||
|
||||
/* Values for FLAGS word in a PATTERN_LIST */
|
||||
#define CASEPAT_FALLTHROUGH 0x01
|
||||
#define CASEPAT_TESTNEXT 0x02
|
||||
|
||||
/* Pattern/action structure for CASE_COM. */
|
||||
typedef struct pattern_list {
|
||||
struct pattern_list *next; /* Clause to try in case this one failed. */
|
||||
WORD_LIST *patterns; /* Linked list of patterns to test. */
|
||||
COMMAND *action; /* Thing to execute if a pattern matches. */
|
||||
int flags;
|
||||
} PATTERN_LIST;
|
||||
|
||||
/* The CASE command. */
|
||||
typedef struct case_com {
|
||||
int flags; /* See description of CMD flags. */
|
||||
int line; /* line number the `case' keyword appears on */
|
||||
WORD_DESC *word; /* The thing to test. */
|
||||
PATTERN_LIST *clauses; /* The clauses to test against, or NULL. */
|
||||
} CASE_COM;
|
||||
|
@ -202,6 +229,7 @@ typedef struct case_com {
|
|||
/* FOR command. */
|
||||
typedef struct for_com {
|
||||
int flags; /* See description of CMD flags. */
|
||||
int line; /* line number the `for' keyword appears on */
|
||||
WORD_DESC *name; /* The variable name to get mapped over. */
|
||||
WORD_LIST *map_list; /* The things to map over. This is never NULL. */
|
||||
COMMAND *action; /* The action to execute.
|
||||
|
@ -224,6 +252,7 @@ typedef struct arith_for_com {
|
|||
/* KSH SELECT command. */
|
||||
typedef struct select_com {
|
||||
int flags; /* See description of CMD flags. */
|
||||
int line; /* line number the `select' keyword appears on */
|
||||
WORD_DESC *name; /* The variable name to get mapped over. */
|
||||
WORD_LIST *map_list; /* The things to map over. This is never NULL. */
|
||||
COMMAND *action; /* The action to execute.
|
||||
|
@ -253,8 +282,8 @@ typedef struct while_com {
|
|||
time being. */
|
||||
typedef struct arith_com {
|
||||
int flags;
|
||||
WORD_LIST *exp;
|
||||
int line;
|
||||
WORD_LIST *exp;
|
||||
} ARITH_COM;
|
||||
#endif /* DPAREN_ARITHMETIC */
|
||||
|
||||
|
@ -278,18 +307,19 @@ typedef struct cond_com {
|
|||
/* The "simple" command. Just a collection of words and redirects. */
|
||||
typedef struct simple_com {
|
||||
int flags; /* See description of CMD flags. */
|
||||
int line; /* line number the command starts on */
|
||||
WORD_LIST *words; /* The program name, the arguments,
|
||||
variable assignments, etc. */
|
||||
REDIRECT *redirects; /* Redirections to perform. */
|
||||
int line; /* line number the command starts on */
|
||||
} SIMPLE_COM;
|
||||
|
||||
/* The "function definition" command. */
|
||||
typedef struct function_def {
|
||||
int flags; /* See description of CMD flags. */
|
||||
int line; /* Line number the function def starts on. */
|
||||
WORD_DESC *name; /* The name of the function. */
|
||||
COMMAND *command; /* The parsed execution tree. */
|
||||
int line; /* Line number the function def starts on. */
|
||||
char *source_file; /* file in which function was defined, if any */
|
||||
} FUNCTION_DEF;
|
||||
|
||||
/* A command that is `grouped' allows pipes and redirections to affect all
|
||||
|
@ -304,7 +334,28 @@ typedef struct subshell_com {
|
|||
COMMAND *command;
|
||||
} SUBSHELL_COM;
|
||||
|
||||
#define COPROC_RUNNING 0x01
|
||||
#define COPROC_DEAD 0x02
|
||||
|
||||
typedef struct coproc {
|
||||
char *c_name;
|
||||
pid_t c_pid;
|
||||
int c_rfd;
|
||||
int c_wfd;
|
||||
int c_rsave;
|
||||
int c_wsave;
|
||||
int c_flags;
|
||||
int c_status;
|
||||
} Coproc;
|
||||
|
||||
typedef struct coproc_com {
|
||||
int flags;
|
||||
char *name;
|
||||
COMMAND *command;
|
||||
} COPROC_COM;
|
||||
|
||||
extern COMMAND *global_command;
|
||||
extern Coproc sh_coproc;
|
||||
|
||||
/* Possible command errors */
|
||||
#define CMDERR_DEFAULT 0
|
||||
|
@ -316,6 +367,9 @@ extern COMMAND *global_command;
|
|||
|
||||
/* Forward declarations of functions declared in copy_cmd.c. */
|
||||
|
||||
extern FUNCTION_DEF *copy_function_def_contents __P((FUNCTION_DEF *, FUNCTION_DEF *));
|
||||
extern FUNCTION_DEF *copy_function_def __P((FUNCTION_DEF *));
|
||||
|
||||
extern WORD_DESC *copy_word __P((WORD_DESC *));
|
||||
extern WORD_LIST *copy_word_list __P((WORD_LIST *));
|
||||
extern REDIRECT *copy_redirect __P((REDIRECT *));
|
||||
|
|
|
@ -1,41 +1,33 @@
|
|||
/* config-bot.h */
|
||||
/* modify settings or make new ones based on what autoconf tells us. */
|
||||
|
||||
/* Copyright (C) 1989-2002 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1989-2009 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 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 3 of the License, 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.
|
||||
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. */
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*********************************************************/
|
||||
/* Modify or set defines based on the configure results. */
|
||||
/*********************************************************/
|
||||
|
||||
#if !defined (HAVE_VPRINTF) && defined (HAVE_DOPRNT)
|
||||
# define USE_VFPRINTF_EMULATION
|
||||
# define HAVE_VPRINTF
|
||||
#endif
|
||||
|
||||
/* Ultrix botches type-ahead when switching from canonical to
|
||||
non-canonical mode, at least through version 4.3 */
|
||||
#if !defined (HAVE_TERMIOS_H) || !defined (HAVE_TCGETATTR) || defined (ultrix)
|
||||
# define TERMIOS_MISSING
|
||||
#endif
|
||||
|
||||
/* If we have a getcwd(3), but it calls popen(), #undef HAVE_GETCWD so
|
||||
the replacement in getcwd.c will be built. */
|
||||
#if defined (HAVE_GETCWD) && defined (GETCWD_BROKEN)
|
||||
# undef HAVE_GETCWD
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_SYS_RESOURCE_H) && defined (HAVE_GETRLIMIT)
|
||||
# define HAVE_RESOURCE
|
||||
#endif
|
||||
|
@ -44,15 +36,73 @@
|
|||
# define HAVE_BSD_PGRP
|
||||
#endif
|
||||
|
||||
/* Try this without testing __STDC__ for the time being. */
|
||||
#if defined (HAVE_STDARG_H)
|
||||
# define PREFER_STDARG
|
||||
# define USE_VARARGS
|
||||
#else
|
||||
# if defined (HAVE_VARARGS_H)
|
||||
# define PREFER_VARARGS
|
||||
# define USE_VARARGS
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_SYS_SOCKET_H) && defined (HAVE_GETPEERNAME) && defined (HAVE_NETINET_IN_H)
|
||||
# define HAVE_NETWORK
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_REGEX_H) && defined (HAVE_REGCOMP) && defined (HAVE_REGEXEC)
|
||||
# define HAVE_POSIX_REGEXP
|
||||
#endif
|
||||
|
||||
/* backwards compatibility between different autoconf versions */
|
||||
#if HAVE_DECL_SYS_SIGLIST && !defined (SYS_SIGLIST_DECLARED)
|
||||
# define SYS_SIGLIST_DECLARED
|
||||
#endif
|
||||
|
||||
/***********************************************************************/
|
||||
/* Unset defines based on what configure reports as missing or broken. */
|
||||
/***********************************************************************/
|
||||
|
||||
/* Ultrix botches type-ahead when switching from canonical to
|
||||
non-canonical mode, at least through version 4.3 */
|
||||
#if !defined (HAVE_TERMIOS_H) || !defined (HAVE_TCGETATTR) || defined (ultrix)
|
||||
# define TERMIOS_MISSING
|
||||
#endif
|
||||
|
||||
/* If we have a getcwd(3), but one that does not dynamically allocate memory,
|
||||
#undef HAVE_GETCWD so the replacement in getcwd.c will be built. We do
|
||||
not do this on Solaris, because their implementation of loopback mounts
|
||||
breaks the traditional file system assumptions that getcwd uses. */
|
||||
#if defined (HAVE_GETCWD) && defined (GETCWD_BROKEN) && !defined (SOLARIS)
|
||||
# undef HAVE_GETCWD
|
||||
#endif
|
||||
|
||||
#if !defined (HAVE_DEV_FD) && defined (NAMED_PIPES_MISSING)
|
||||
# undef PROCESS_SUBSTITUTION
|
||||
#endif
|
||||
|
||||
#if defined (JOB_CONTROL_MISSING)
|
||||
# undef JOB_CONTROL
|
||||
#endif
|
||||
|
||||
#if defined (STRCOLL_BROKEN)
|
||||
# undef HAVE_STRCOLL
|
||||
#endif
|
||||
|
||||
#if !defined (HAVE_POSIX_REGEXP)
|
||||
# undef COND_REGEXP
|
||||
#endif
|
||||
|
||||
/* If the shell is called by this name, it will become restricted. */
|
||||
#if defined (RESTRICTED_SHELL)
|
||||
# define RESTRICTED_SHELL_NAME "rbash"
|
||||
#endif
|
||||
|
||||
/***********************************************************/
|
||||
/* Make sure feature defines have necessary prerequisites. */
|
||||
/***********************************************************/
|
||||
|
||||
/* BANG_HISTORY requires HISTORY. */
|
||||
#if defined (BANG_HISTORY) && !defined (HISTORY)
|
||||
# define HISTORY
|
||||
|
@ -70,28 +120,6 @@
|
|||
# undef DEFAULT_ECHO_TO_XPG
|
||||
#endif
|
||||
|
||||
#if defined (JOB_CONTROL_MISSING)
|
||||
# undef JOB_CONTROL
|
||||
#endif
|
||||
|
||||
#if defined (__STDC__) && defined (HAVE_STDARG_H)
|
||||
# define PREFER_STDARG
|
||||
# define USE_VARARGS
|
||||
#else
|
||||
# if defined (HAVE_VARARGS_H)
|
||||
# define PREFER_VARARGS
|
||||
# define USE_VARARGS
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined (STRCOLL_BROKEN)
|
||||
# undef HAVE_STRCOLL
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_SYS_SOCKET_H) && defined (HAVE_GETPEERNAME) && defined (HAVE_NETINET_IN_H)
|
||||
# define HAVE_NETWORK
|
||||
#endif
|
||||
|
||||
#if !defined (PROMPT_STRING_DECODE)
|
||||
# undef PPROMPT
|
||||
# define PPROMPT "$ "
|
||||
|
@ -104,14 +132,33 @@
|
|||
/* For platforms which support the ISO C amendement 1 functionality we
|
||||
support user defined character classes. */
|
||||
/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>. */
|
||||
#if defined (HAVE_WCTYPE_H) && defined (HAVE_WCHAR_H)
|
||||
#if defined (HAVE_WCTYPE_H) && defined (HAVE_WCHAR_H) && defined (HAVE_LOCALE_H)
|
||||
# include <wchar.h>
|
||||
# include <wctype.h>
|
||||
# if defined (HAVE_MBSRTOWCS) /* system is supposed to support XPG5 */
|
||||
# if defined (HAVE_ISWCTYPE) && \
|
||||
defined (HAVE_ISWLOWER) && \
|
||||
defined (HAVE_ISWUPPER) && \
|
||||
defined (HAVE_MBSRTOWCS) && \
|
||||
defined (HAVE_MBRTOWC) && \
|
||||
defined (HAVE_MBRLEN) && \
|
||||
defined (HAVE_TOWLOWER) && \
|
||||
defined (HAVE_TOWUPPER) && \
|
||||
defined (HAVE_WCHAR_T) && \
|
||||
defined (HAVE_WCTYPE_T) && \
|
||||
defined (HAVE_WINT_T) && \
|
||||
defined (HAVE_WCWIDTH) && \
|
||||
defined (HAVE_WCTYPE)
|
||||
/* system is supposed to support XPG5 */
|
||||
# define HANDLE_MULTIBYTE 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* If we don't want multibyte chars even on a system that supports them, let
|
||||
the configuring user turn multibyte support off. */
|
||||
#if defined (NO_MULTIBYTE_SUPPORT)
|
||||
# undef HANDLE_MULTIBYTE
|
||||
#endif
|
||||
|
||||
/* Some systems, like BeOS, have multibyte encodings but lack mbstate_t. */
|
||||
#if HANDLE_MULTIBYTE && !defined (HAVE_MBSTATE_T)
|
||||
# define wcsrtombs(dest, src, len, ps) (wcsrtombs) (dest, src, len, 0)
|
||||
|
@ -137,3 +184,12 @@
|
|||
/************************************************/
|
||||
/* end of multibyte capability checks for I18N */
|
||||
/************************************************/
|
||||
|
||||
/******************************************************************/
|
||||
/* Placeholder for builders to #undef any unwanted features from */
|
||||
/* config-top.h or created by configure (such as the default mail */
|
||||
/* file for mail checking). */
|
||||
/******************************************************************/
|
||||
|
||||
/* If you don't want bash to provide a default mail file to check. */
|
||||
/* #undef DEFAULT_MAIL_DIRECTORY */
|
||||
|
|
|
@ -1,25 +1,22 @@
|
|||
/* config-top.h */
|
||||
/* config-top.h - various user-settable options not under the control of autoconf. */
|
||||
|
||||
/* This contains various user-settable options not under the control of
|
||||
autoconf. */
|
||||
|
||||
/* Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 2002-2009 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 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 3 of the License, 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.
|
||||
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. */
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* Define CONTINUE_AFTER_KILL_ERROR if you want the kill command to
|
||||
continue processing arguments after one of them fails. This is
|
||||
|
@ -46,8 +43,13 @@
|
|||
#define V9_ECHO
|
||||
|
||||
/* Define DONT_REPORT_SIGPIPE if you don't want to see `Broken pipe' messages
|
||||
when a job like `cat jobs.c | exit 1' is executed. */
|
||||
/* #define DONT_REPORT_SIGPIPE */
|
||||
when a job like `cat jobs.c | exit 1' terminates due to a SIGPIPE. */
|
||||
#define DONT_REPORT_SIGPIPE
|
||||
|
||||
/* Define DONT_REPORT_BROKEN_PIPE_WRITE_ERRORS if you don't want builtins
|
||||
like `echo' and `printf' to report errors when output does not succeed
|
||||
due to EPIPE. */
|
||||
/* #define DONT_REPORT_BROKEN_PIPE_WRITE_ERRORS */
|
||||
|
||||
/* The default value of the PATH variable. */
|
||||
#ifndef DEFAULT_PATH_VALUE
|
||||
|
@ -59,7 +61,7 @@
|
|||
the Posix.2 confstr () function, or CS_PATH define are not present. */
|
||||
#ifndef STANDARD_UTILS_PATH
|
||||
#define STANDARD_UTILS_PATH \
|
||||
"/bin:/usr/bin:/usr/ucb:/sbin:/usr/sbin:/etc:/usr/etc"
|
||||
"/bin:/usr/bin:/sbin:/usr/sbin:/etc:/usr/etc"
|
||||
#endif
|
||||
|
||||
/* Default primary and secondary prompt strings. */
|
||||
|
@ -83,5 +85,16 @@
|
|||
/* #define NON_INTERACTIVE_LOGIN_SHELLS */
|
||||
|
||||
/* Define this if you want bash to try to check whether it's being run by
|
||||
sshd and source the .bashrc if so (like the rshd behavior). */
|
||||
sshd and source the .bashrc if so (like the rshd behavior). This checks
|
||||
for the presence of SSH_CLIENT or SSH2_CLIENT in the initial environment,
|
||||
which can be fooled under certain not-uncommon circumstances. */
|
||||
/* #define SSH_SOURCE_BASHRC */
|
||||
|
||||
/* Define if you want the case-capitalizing operators (~[~]) and the
|
||||
`capcase' variable attribute (declare -c). */
|
||||
#define CASEMOD_CAPCASE
|
||||
|
||||
/* This is used as the name of a shell function to call when a command
|
||||
name is not found. If you want to name it something other than the
|
||||
default ("command_not_found_handle"), change it here. */
|
||||
/* #define NOTFOUND_HOOK "command_not_found_handle" */
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
/* config.h. Generated automatically by configure. */
|
||||
/* config.h. Generated from config.h.in by configure. */
|
||||
/* config.h -- Configuration file for bash. */
|
||||
|
||||
/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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. */
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _CONFIG_H_
|
||||
#define _CONFIG_H_
|
||||
|
@ -26,9 +26,7 @@
|
|||
|
||||
/* Define JOB_CONTROL if your operating system supports
|
||||
BSD-like job control. */
|
||||
#if __HAIKU__
|
||||
#define JOB_CONTROL 1
|
||||
#endif
|
||||
|
||||
/* Define ALIAS if you want the alias features. */
|
||||
#define ALIAS 1
|
||||
|
@ -122,6 +120,14 @@
|
|||
command. */
|
||||
#define COND_COMMAND 1
|
||||
|
||||
/* Define COND_REGEXP if you want extended regular expression matching and the
|
||||
=~ binary operator in the [[...]] conditional command. */
|
||||
#define COND_REGEXP 1
|
||||
|
||||
/* Define COPROCESS_SUPPORT if you want support for ksh-like coprocesses and
|
||||
the `coproc' reserved word */
|
||||
#define COPROCESS_SUPPORT 1
|
||||
|
||||
/* Define ARITH_FOR_COMMAND if you want the ksh93-style
|
||||
for (( init; test; step )) do list; done
|
||||
arithmetic for command. */
|
||||
|
@ -129,12 +135,24 @@
|
|||
|
||||
/* Define NETWORK_REDIRECTIONS if you want /dev/(tcp|udp)/host/port to open
|
||||
socket connections when used in redirections */
|
||||
//#define NETWORK_REDIRECTIONS 1
|
||||
#define NETWORK_REDIRECTIONS 1
|
||||
|
||||
/* Define PROGRAMMABLE_COMPLETION for the programmable completion features
|
||||
and the complete builtin. */
|
||||
#define PROGRAMMABLE_COMPLETION 1
|
||||
|
||||
/* Define NO_MULTIBYTE_SUPPORT to not compile in support for multibyte
|
||||
characters, even if the OS supports them. */
|
||||
/* #undef NO_MULTIBYTE_SUPPORT */
|
||||
|
||||
/* Define DEBUGGER if you want to compile in some features used only by the
|
||||
bash debugger. */
|
||||
#define DEBUGGER 1
|
||||
|
||||
/* Define STRICT_POSIX if you want bash to be strictly posix.2 conformant by
|
||||
default (except for echo; that is controlled separately). */
|
||||
/* #undef STRICT_POSIX */
|
||||
|
||||
/* Define MEMSCRAMBLE if you want the bash malloc and free to scramble
|
||||
memory contents on malloc() and free(). */
|
||||
#define MEMSCRAMBLE 1
|
||||
|
@ -142,6 +160,15 @@
|
|||
/* Define AFS if you are using Transarc's AFS. */
|
||||
/* #undef AFS */
|
||||
|
||||
/* Define for case-modifying variable attributes; variables modified on
|
||||
assignment */
|
||||
#define CASEMOD_ATTRS 1
|
||||
|
||||
/* Define for case-modifying word expansions */
|
||||
#define CASEMOD_EXPANSIONS 1
|
||||
|
||||
#define ENABLE_NLS 0
|
||||
|
||||
/* End of configuration settings controllable by autoconf. */
|
||||
/* Other settable options appear in config-top.h. */
|
||||
|
||||
|
@ -154,11 +181,15 @@
|
|||
|
||||
/* #undef inline */
|
||||
|
||||
#define restrict __restrict
|
||||
|
||||
/* #undef volatile */
|
||||
|
||||
/* Define if cpp supports the ANSI-C stringizing `#' operator */
|
||||
#define HAVE_STRINGIZE 1
|
||||
|
||||
/* Define if the compiler supports `long double' variables. */
|
||||
#define HAVE_LONG_DOUBLE 1
|
||||
/* #undef HAVE_LONG_DOUBLE */
|
||||
|
||||
#define PROTOTYPES 1
|
||||
|
||||
|
@ -207,7 +238,7 @@
|
|||
/* Memory management functions. */
|
||||
|
||||
/* Define if using the bash version of malloc in lib/malloc/malloc.c */
|
||||
/* #undef USING_BASH_MALLOC */
|
||||
//#define USING_BASH_MALLOC 1
|
||||
|
||||
/* #undef DISABLE_MALLOC_WRAPPERS */
|
||||
|
||||
|
@ -274,7 +305,7 @@
|
|||
|
||||
/* Define to `unsigned long' if <stdint.h> doesn't define. */
|
||||
/* #undef uintmax_t */
|
||||
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
/* #undef uid_t */
|
||||
|
||||
|
@ -288,12 +319,26 @@
|
|||
/* #undef gid_t */
|
||||
|
||||
/* Define to `unsigned int' if <sys/socket.h> doesn't define. */
|
||||
// #define socklen_t int
|
||||
/* #undef socklen_t */
|
||||
|
||||
/* Define to `int' if <signal.h> doesn't define. */
|
||||
/* #undef sig_atomic_t */
|
||||
|
||||
#define HAVE_MBSTATE_T 1
|
||||
|
||||
/* Define if you have quad_t in <sys/types.h>. */
|
||||
/* #undef HAVE_QUAD_T */
|
||||
|
||||
/* #undef RLIMTYPE */
|
||||
/* Define if you have wchar_t in <wctype.h>. */
|
||||
#define HAVE_WCHAR_T 1
|
||||
|
||||
/* Define if you have wctype_t in <wctype.h>. */
|
||||
#define HAVE_WCTYPE_T 1
|
||||
|
||||
/* Define if you have wint_t in <wctype.h>. */
|
||||
#define HAVE_WINT_T 1
|
||||
|
||||
#define RLIMTYPE rlim_t
|
||||
|
||||
/* Define to the type of elements in the array set by `getgroups'.
|
||||
Usually this is either `int' or `gid_t'. */
|
||||
|
@ -317,31 +362,32 @@
|
|||
libraries. */
|
||||
|
||||
/* Define if `sys_siglist' is declared by <signal.h> or <unistd.h>. */
|
||||
#define SYS_SIGLIST_DECLARED 1
|
||||
#define HAVE_DECL_SYS_SIGLIST 1
|
||||
/* #undef SYS_SIGLIST_DECLARED */
|
||||
|
||||
/* Define if `_sys_siglist' is declared by <signal.h> or <unistd.h>. */
|
||||
/* #undef UNDER_SYS_SIGLIST_DECLARED */
|
||||
|
||||
#define HAVE_SYS_SIGLIST 1
|
||||
|
||||
#define HAVE_UNDER_SYS_SIGLIST 1
|
||||
/* #undef HAVE_UNDER_SYS_SIGLIST */
|
||||
|
||||
#define HAVE_SYS_ERRLIST 1
|
||||
|
||||
#define HAVE_TIMEVAL 1
|
||||
|
||||
/* #undef HAVE_TZNAME */
|
||||
|
||||
/* #undef HAVE_DECL_TZNAME */
|
||||
|
||||
/* Characteristics of some of the system structures. */
|
||||
|
||||
#define STRUCT_DIRENT_HAS_D_INO 1
|
||||
#define HAVE_STRUCT_DIRENT_D_INO 1
|
||||
|
||||
/* #undef STRUCT_DIRENT_HAS_D_FILENO */
|
||||
/* #undef HAVE_STRUCT_DIRENT_D_FILENO */
|
||||
|
||||
/* #undef HAVE_STRUCT_DIRENT_D_NAMLEN */
|
||||
|
||||
/* #undef TIOCSTAT_IN_SYS_IOCTL */
|
||||
|
||||
/* #undef FIONREAD_IN_SYS_IOCTL */
|
||||
#define FIONREAD_IN_SYS_IOCTL 1
|
||||
|
||||
/* #undef GWINSZ_IN_SYS_IOCTL */
|
||||
|
||||
|
@ -357,11 +403,15 @@
|
|||
|
||||
/* #undef TERMIO_LDISC */
|
||||
|
||||
/* #undef HAVE_STRUCT_STAT_ST_BLOCKS */
|
||||
#define HAVE_STRUCT_STAT_ST_BLOCKS 1
|
||||
|
||||
#define HAVE_STRUCT_TM_TM_ZONE 1
|
||||
#define HAVE_TM_ZONE 1
|
||||
|
||||
#define HAVE_TIMEVAL 1
|
||||
|
||||
#define HAVE_STRUCT_TIMEZONE 1
|
||||
|
||||
/* Characteristics of definitions in the system header files. */
|
||||
|
||||
#define HAVE_GETPW_DECLS 1
|
||||
|
@ -370,8 +420,7 @@
|
|||
|
||||
/* #undef HAVE_LIBC_FNM_EXTMATCH */
|
||||
|
||||
|
||||
#define HAVE_DECL_CONFSTR 0
|
||||
#define HAVE_DECL_CONFSTR 1
|
||||
|
||||
#define HAVE_DECL_PRINTF 1
|
||||
|
||||
|
@ -383,8 +432,12 @@
|
|||
|
||||
#define HAVE_DECL_STRTOLD 0
|
||||
|
||||
/* #undef PRI_MACROS_BROKEN */
|
||||
|
||||
/* #undef HAVE_MBSTATE_T */
|
||||
/* #undef STRTOLD_BROKEN */
|
||||
|
||||
/* Define if WCONTINUED is defined in system headers, but rejected by waitpid */
|
||||
/* #undef WCONTINUED_BROKEN */
|
||||
|
||||
/* These are checked with BASH_CHECK_DECL */
|
||||
|
||||
|
@ -404,7 +457,7 @@
|
|||
|
||||
/* #undef OPENDIR_NOT_ROBUST */
|
||||
|
||||
#define PGRP_PIPE 1
|
||||
/* #undef PGRP_PIPE */
|
||||
|
||||
/* Define if the setvbuf function takes the buffering type as its second
|
||||
argument and the buffer pointer as the third, as on System V
|
||||
|
@ -419,11 +472,11 @@
|
|||
|
||||
/* #undef HAVE_STD_PUTENV */
|
||||
|
||||
#if __HAIKU__
|
||||
#define HAVE_STD_UNSETENV 1
|
||||
#endif
|
||||
|
||||
/* #undef HAVE_PRINTF_A_FORMAT */
|
||||
#define HAVE_PRINTF_A_FORMAT 1
|
||||
|
||||
/* #undef CTYPE_NON_ASCII */
|
||||
|
||||
/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
|
||||
/* #undef HAVE_LANGINFO_CODESET */
|
||||
|
@ -470,9 +523,6 @@
|
|||
/* Define if you have the bcopy function. */
|
||||
#define HAVE_BCOPY 1
|
||||
|
||||
/* Define if you have the bindtextdomain function. */
|
||||
//#define HAVE_BINDTEXTDOMAIN 1
|
||||
|
||||
/* Define if you have the bzero function. */
|
||||
#define HAVE_BZERO 1
|
||||
|
||||
|
@ -480,22 +530,36 @@
|
|||
#define HAVE_CONFSTR 1
|
||||
|
||||
/* Define if you have the dlclose function. */
|
||||
//#define HAVE_DLCLOSE 1
|
||||
#define HAVE_DLCLOSE 1
|
||||
|
||||
/* Define if you have the dlopen function. */
|
||||
//#define HAVE_DLOPEN 1
|
||||
#define HAVE_DLOPEN 1
|
||||
|
||||
/* Define if you have the dlsym function. */
|
||||
#define HAVE_DLSYM 1
|
||||
|
||||
/* Define if you don't have vprintf but do have _doprnt. */
|
||||
#define HAVE_DOPRNT 1
|
||||
/* #undef HAVE_DOPRNT */
|
||||
|
||||
/* Define if you have the dup2 function. */
|
||||
#define HAVE_DUP2 1
|
||||
|
||||
/* Define if you have the eaccess function. */
|
||||
/* #undef HAVE_EACCESS */
|
||||
|
||||
/* Define if you have the fcntl function. */
|
||||
#define HAVE_FCNTL 1
|
||||
|
||||
/* Define if you have the fdprintf function. */
|
||||
/* #undef HAVE_FDPRINTF */
|
||||
|
||||
/* Define if you have the fpurge/__fpurge function. */
|
||||
#define HAVE_FPURGE 1
|
||||
#define HAVE___FPURGE 1
|
||||
#define HAVE_DECL_FPURGE 1
|
||||
|
||||
/* Define if you have the getaddrinfo function. */
|
||||
//#define HAVE_GETADDRINFO 1
|
||||
/* #undef HAVE_GETADDRINFO */
|
||||
|
||||
/* Define if you have the getcwd function. */
|
||||
#define HAVE_GETCWD 1
|
||||
|
@ -507,7 +571,7 @@
|
|||
#define HAVE_GETGROUPS 1
|
||||
|
||||
/* Define if you have the gethostbyname function. */
|
||||
#define HAVE_GETHOSTBYNAME 1
|
||||
/* #undef HAVE_GETHOSTBYNAME */
|
||||
|
||||
/* Define if you have the gethostname function. */
|
||||
#define HAVE_GETHOSTNAME 1
|
||||
|
@ -516,22 +580,28 @@
|
|||
#define HAVE_GETPAGESIZE 1
|
||||
|
||||
/* Define if you have the getpeername function. */
|
||||
#define HAVE_GETPEERNAME 1
|
||||
/* #undef HAVE_GETPEERNAME */
|
||||
|
||||
/* Define if you have the getpwent function. */
|
||||
#define HAVE_GETPWENT 1
|
||||
|
||||
/* Define if you have the getpwnam function. */
|
||||
#define HAVE_GETPWNAM 1
|
||||
|
||||
/* Define if you have the getpwuid function. */
|
||||
#define HAVE_GETPWUID 1
|
||||
|
||||
/* Define if you have the getrlimit function. */
|
||||
//#define HAVE_GETRLIMIT 1
|
||||
#define HAVE_GETRLIMIT 1
|
||||
|
||||
/* Define if you have the getrusage function. */
|
||||
#define HAVE_GETRUSAGE 1
|
||||
|
||||
/* Define if you have the getservbyname function. */
|
||||
#define HAVE_GETSERVBYNAME 1
|
||||
/* #undef HAVE_GETSERVBYNAME */
|
||||
|
||||
/* Define if you have the getservent function. */
|
||||
//#define HAVE_GETSERVENT 1
|
||||
|
||||
/* Define if you have the gettext function. */
|
||||
//#define HAVE_GETTEXT 1
|
||||
/* #undef HAVE_GETSERVENT */
|
||||
|
||||
/* Define if you have the gettimeofday function. */
|
||||
#define HAVE_GETTIMEOFDAY 1
|
||||
|
@ -540,7 +610,7 @@
|
|||
/* #undef HAVE_GETWD */
|
||||
|
||||
/* Define if you have the inet_aton function. */
|
||||
//#define HAVE_INET_ATON 1
|
||||
/* #undef HAVE_INET_ATON */
|
||||
|
||||
/* Define if you have the isascii function. */
|
||||
#define HAVE_ISASCII 1
|
||||
|
@ -551,24 +621,48 @@
|
|||
/* Define if you have the isgraph function. */
|
||||
#define HAVE_ISGRAPH 1
|
||||
|
||||
/* Define if you have the isint function in libc */
|
||||
/* Define if you have the isinf function in libc */
|
||||
#define HAVE_ISINF_IN_LIBC 1
|
||||
|
||||
/* Define if you have the isnan function in libc */
|
||||
#define HAVE_ISNAN_IN_LIBC 1
|
||||
|
||||
/* Define if you have the isprint function. */
|
||||
#define HAVE_ISPRINT 1
|
||||
|
||||
/* Define if you have the isspace function. */
|
||||
#define HAVE_ISSPACE 1
|
||||
|
||||
/* Define if you have the iswctype function. */
|
||||
#define HAVE_ISWCTYPE 1
|
||||
|
||||
/* Define if you have the iswlower function. */
|
||||
#define HAVE_ISWLOWER 1
|
||||
|
||||
/* Define if you have the iswupper function. */
|
||||
#define HAVE_ISWUPPER 1
|
||||
|
||||
/* Define if you have the isxdigit function. */
|
||||
#define HAVE_ISXDIGIT 1
|
||||
|
||||
/* Define if you have the kill function. */
|
||||
#define HAVE_KILL 1
|
||||
|
||||
/* Define if you have the killpg function. */
|
||||
//#define HAVE_KILLPG 1
|
||||
#define HAVE_KILLPG 1
|
||||
|
||||
/* Define if you have the lstat function. */
|
||||
#define HAVE_LSTAT 1
|
||||
|
||||
/* Define if you have the mbrlen function. */
|
||||
#define HAVE_MBRLEN 1
|
||||
|
||||
/* Define if you have the mbrtowc function. */
|
||||
#define HAVE_MBRTOWC 1
|
||||
|
||||
/* Define if you have the mbscmp function. */
|
||||
/* #undef HAVE_MBSCMP */
|
||||
|
||||
/* Define if you have the mbsrtowcs function. */
|
||||
#define HAVE_MBSRTOWCS 1
|
||||
|
||||
|
@ -587,9 +681,18 @@
|
|||
/* Define if you have the putenv function. */
|
||||
#define HAVE_PUTENV 1
|
||||
|
||||
/* Define if you have the raise function. */
|
||||
#define HAVE_RAISE 1
|
||||
|
||||
/* Define if you have the readlink function. */
|
||||
#define HAVE_READLINK 1
|
||||
|
||||
/* Define if you have the regcomp function. */
|
||||
#define HAVE_REGCOMP 1
|
||||
|
||||
/* Define if you have the regexec function. */
|
||||
#define HAVE_REGEXEC 1
|
||||
|
||||
/* Define if you have the rename function. */
|
||||
#define HAVE_RENAME 1
|
||||
|
||||
|
@ -597,14 +700,17 @@
|
|||
#define HAVE_SBRK 1
|
||||
|
||||
/* Define if you have the select function. */
|
||||
//#define HAVE_SELECT 1
|
||||
#define HAVE_SELECT 1
|
||||
|
||||
/* Define if you have the setdtablesize function. */
|
||||
//#define HAVE_SETDTABLESIZE 1
|
||||
/* #undef HAVE_SETDTABLESIZE */
|
||||
|
||||
/* Define if you have the setenv function. */
|
||||
#define HAVE_SETENV 1
|
||||
|
||||
/* Define if you have the setitimer function. */
|
||||
#define HAVE_SETITIMER 1
|
||||
|
||||
/* Define if you have the setlinebuf function. */
|
||||
#define HAVE_SETLINEBUF 1
|
||||
|
||||
|
@ -612,13 +718,17 @@
|
|||
#define HAVE_SETLOCALE 1
|
||||
|
||||
/* Define if you have the setostype function. */
|
||||
#define HAVE_SETOSTYPE 1
|
||||
/* #undef HAVE_SETOSTYPE */
|
||||
|
||||
/* Define if you have the setregid function. */
|
||||
/* #undef HAVE_SETREGID */
|
||||
#define HAVE_DECL_SETREGID 1
|
||||
|
||||
/* Define if you have the setvbuf function. */
|
||||
#define HAVE_SETVBUF 1
|
||||
|
||||
/* Define if you have the siginterrupt function. */
|
||||
//#define HAVE_SIGINTERRUPT 1
|
||||
#define HAVE_SIGINTERRUPT 1
|
||||
|
||||
/* Define if you have the POSIX.1-style sigsetjmp function. */
|
||||
#define HAVE_POSIX_SIGSETJMP 1
|
||||
|
@ -641,9 +751,15 @@
|
|||
/* Define if you have the strftime function. */
|
||||
#define HAVE_STRFTIME 1
|
||||
|
||||
/* Define if you have the strnlen function. */
|
||||
#define HAVE_STRNLEN 1
|
||||
|
||||
/* Define if you have the strpbrk function. */
|
||||
#define HAVE_STRPBRK 1
|
||||
|
||||
/* Define if you have the strstr function. */
|
||||
#define HAVE_STRSTR 1
|
||||
|
||||
/* Define if you have the strtod function. */
|
||||
#define HAVE_STRTOD 1
|
||||
|
||||
|
@ -677,12 +793,15 @@
|
|||
/* Define if you have the tcgetpgrp function. */
|
||||
#define HAVE_TCGETPGRP 1
|
||||
|
||||
/* Define if you have the textdomain function. */
|
||||
//#define HAVE_TEXTDOMAIN 1
|
||||
|
||||
/* Define if you have the times function. */
|
||||
#define HAVE_TIMES 1
|
||||
|
||||
/* Define if you have the towlower function. */
|
||||
#define HAVE_TOWLOWER 1
|
||||
|
||||
/* Define if you have the towupper function. */
|
||||
#define HAVE_TOWUPPER 1
|
||||
|
||||
/* Define if you have the ttyname function. */
|
||||
#define HAVE_TTYNAME 1
|
||||
|
||||
|
@ -690,7 +809,7 @@
|
|||
#define HAVE_TZSET 1
|
||||
|
||||
/* Define if you have the ulimit function. */
|
||||
//#define HAVE_ULIMIT 1
|
||||
/* #undef HAVE_ULIMIT */
|
||||
|
||||
/* Define if you have the uname function. */
|
||||
#define HAVE_UNAME 1
|
||||
|
@ -711,7 +830,19 @@
|
|||
#define HAVE_WAITPID 1
|
||||
|
||||
/* Define if you have the wait3 function. */
|
||||
#define HAVE_WAIT3 1
|
||||
/* #undef HAVE_WAIT3 */
|
||||
|
||||
/* Define if you have the wcrtomb function. */
|
||||
#define HAVE_WCRTOMB 1
|
||||
|
||||
/* Define if you have the wcscoll function. */
|
||||
#define HAVE_WCSCOLL 1
|
||||
|
||||
/* Define if you have the wcsdup function. */
|
||||
#define HAVE_WCSDUP 1
|
||||
|
||||
/* Define if you have the wctype function. */
|
||||
#define HAVE_WCTYPE 1
|
||||
|
||||
/* Define if you have the wcwidth function. */
|
||||
#define HAVE_WCWIDTH 1
|
||||
|
@ -719,13 +850,13 @@
|
|||
/* Presence of certain system include files. */
|
||||
|
||||
/* Define if you have the <arpa/inet.h> header file. */
|
||||
/* #undef HAVE_ARPA_INET_H */
|
||||
#define HAVE_ARPA_INET_H 1
|
||||
|
||||
/* Define if you have the <dirent.h> header file. */
|
||||
#define HAVE_DIRENT_H 1
|
||||
|
||||
/* Define if you have the <dlfcn.h> header file. */
|
||||
/* #undef HAVE_DLFCN_H */
|
||||
#define HAVE_DLFCN_H 1
|
||||
|
||||
/* Define if you have the <grp.h> header file. */
|
||||
#define HAVE_GRP_H 1
|
||||
|
@ -754,6 +885,12 @@
|
|||
/* Define if you have the <netinet/in.h> header file. */
|
||||
#define HAVE_NETINET_IN_H 1
|
||||
|
||||
/* Define if you have the <pwd.h> header file. */
|
||||
#define HAVE_PWD_H 1
|
||||
|
||||
/* Define if you have the <regex.h> header file. */
|
||||
#define HAVE_REGEX_H 1
|
||||
|
||||
/* Define if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
|
@ -779,7 +916,7 @@
|
|||
/* #undef HAVE_SYS_DIR_H */
|
||||
|
||||
/* Define if you have the <sys/file.h> header file. */
|
||||
/* #undef HAVE_SYS_FILE_H */
|
||||
#define HAVE_SYS_FILE_H 1
|
||||
|
||||
/* Define if you have the <sys/ndir.h> header file. */
|
||||
/* #undef HAVE_SYS_NDIR_H */
|
||||
|
@ -797,11 +934,14 @@
|
|||
#define HAVE_SYS_RESOURCE_H 1
|
||||
|
||||
/* Define if you have the <sys/select.h> header file. */
|
||||
/* #undef HAVE_SYS_SELECT_H */
|
||||
#define HAVE_SYS_SELECT_H 1
|
||||
|
||||
/* Define if you have the <sys/socket.h> header file. */
|
||||
#define HAVE_SYS_SOCKET_H 1
|
||||
|
||||
/* Define if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define if you have the <sys/stream.h> header file. */
|
||||
/* #undef HAVE_SYS_STREAM_H */
|
||||
|
||||
|
@ -813,6 +953,9 @@
|
|||
/* Define if you have <sys/times.h> */
|
||||
#define HAVE_SYS_TIMES_H 1
|
||||
|
||||
/* Define if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
|
||||
#define HAVE_SYS_WAIT_H 1
|
||||
|
||||
|
@ -835,7 +978,7 @@
|
|||
#define HAVE_WCHAR_H 1
|
||||
|
||||
/* Define if you have the <varargs.h> header file. */
|
||||
/* #undef HAVE_WCTYPE_H */
|
||||
#define HAVE_WCTYPE_H 1
|
||||
|
||||
/* Presence of certain system libraries. */
|
||||
|
||||
|
@ -878,6 +1021,64 @@
|
|||
|
||||
/* #undef GETCWD_BROKEN */
|
||||
|
||||
/* Additional defines for configuring lib/intl, maintained by autoscan/autoheader */
|
||||
|
||||
/* Define if you have the <argz.h> header file. */
|
||||
/* #undef HAVE_ARGZ_H */
|
||||
|
||||
/* Define if you have the <errno.h> header file. */
|
||||
#define HAVE_ERRNO_H 1
|
||||
|
||||
/* Define if you have the <fcntl.h> header file. */
|
||||
#define HAVE_FCNTL_H 1
|
||||
|
||||
/* Define if you have the <malloc.h> header file. */
|
||||
#define HAVE_MALLOC_H 1
|
||||
|
||||
/* Define if you have the <stdio_ext.h> header file. */
|
||||
#define HAVE_STDIO_EXT_H 1
|
||||
|
||||
/* Define if you have the `dcgettext' function. */
|
||||
/* #undef HAVE_DCGETTEXT */
|
||||
|
||||
/* Define if you have the `localeconv' function. */
|
||||
#define HAVE_LOCALECONV 1
|
||||
|
||||
/* Define if your system has a working `malloc' function. */
|
||||
/* #undef HAVE_MALLOC */
|
||||
|
||||
/* Define if you have the `mempcpy' function. */
|
||||
/* #undef HAVE_MEMPCPY */
|
||||
|
||||
/* Define if you have a working `mmap' system call. */
|
||||
/* #undef HAVE_MMAP */
|
||||
|
||||
/* Define if you have the `munmap' function. */
|
||||
#define HAVE_MUNMAP 1
|
||||
|
||||
/* Define if you have the `nl_langinfo' function. */
|
||||
/* #undef HAVE_NL_LANGINFO */
|
||||
|
||||
/* Define if you have the `stpcpy' function. */
|
||||
#define HAVE_STPCPY 1
|
||||
|
||||
/* Define if you have the `strcspn' function. */
|
||||
#define HAVE_STRCSPN 1
|
||||
|
||||
/* Define if you have the `strdup' function. */
|
||||
#define HAVE_STRDUP 1
|
||||
|
||||
/* Define if you have the `__argz_count' function. */
|
||||
/* #undef HAVE___ARGZ_COUNT */
|
||||
|
||||
/* Define if you have the `__argz_next' function. */
|
||||
/* #undef HAVE___ARGZ_NEXT */
|
||||
|
||||
/* Define if you have the `__argz_stringify' function. */
|
||||
/* #undef HAVE___ARGZ_STRINGIFY */
|
||||
|
||||
/* End additions for lib/intl */
|
||||
|
||||
#include "config-bot.h"
|
||||
|
||||
#endif /* _CONFIG_H_ */
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
/* config.h -- Configuration file for bash. */
|
||||
|
||||
/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2009 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 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 3 of the License, 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.
|
||||
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. */
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _CONFIG_H_
|
||||
#define _CONFIG_H_
|
||||
|
@ -119,6 +119,14 @@
|
|||
command. */
|
||||
#undef COND_COMMAND
|
||||
|
||||
/* Define COND_REGEXP if you want extended regular expression matching and the
|
||||
=~ binary operator in the [[...]] conditional command. */
|
||||
#define COND_REGEXP
|
||||
|
||||
/* Define COPROCESS_SUPPORT if you want support for ksh-like coprocesses and
|
||||
the `coproc' reserved word */
|
||||
#define COPROCESS_SUPPORT
|
||||
|
||||
/* Define ARITH_FOR_COMMAND if you want the ksh93-style
|
||||
for (( init; test; step )) do list; done
|
||||
arithmetic for command. */
|
||||
|
@ -132,6 +140,18 @@
|
|||
and the complete builtin. */
|
||||
#undef PROGRAMMABLE_COMPLETION
|
||||
|
||||
/* Define NO_MULTIBYTE_SUPPORT to not compile in support for multibyte
|
||||
characters, even if the OS supports them. */
|
||||
#undef NO_MULTIBYTE_SUPPORT
|
||||
|
||||
/* Define DEBUGGER if you want to compile in some features used only by the
|
||||
bash debugger. */
|
||||
#undef DEBUGGER
|
||||
|
||||
/* Define STRICT_POSIX if you want bash to be strictly posix.2 conformant by
|
||||
default (except for echo; that is controlled separately). */
|
||||
#undef STRICT_POSIX
|
||||
|
||||
/* Define MEMSCRAMBLE if you want the bash malloc and free to scramble
|
||||
memory contents on malloc() and free(). */
|
||||
#undef MEMSCRAMBLE
|
||||
|
@ -139,6 +159,15 @@
|
|||
/* Define AFS if you are using Transarc's AFS. */
|
||||
#undef AFS
|
||||
|
||||
/* Define for case-modifying variable attributes; variables modified on
|
||||
assignment */
|
||||
#undef CASEMOD_ATTRS
|
||||
|
||||
/* Define for case-modifying word expansions */
|
||||
#undef CASEMOD_EXPANSIONS
|
||||
|
||||
#undef ENABLE_NLS
|
||||
|
||||
/* End of configuration settings controllable by autoconf. */
|
||||
/* Other settable options appear in config-top.h. */
|
||||
|
||||
|
@ -151,6 +180,10 @@
|
|||
|
||||
#undef inline
|
||||
|
||||
#undef restrict
|
||||
|
||||
#undef volatile
|
||||
|
||||
/* Define if cpp supports the ANSI-C stringizing `#' operator */
|
||||
#undef HAVE_STRINGIZE
|
||||
|
||||
|
@ -287,9 +320,23 @@
|
|||
/* Define to `unsigned int' if <sys/socket.h> doesn't define. */
|
||||
#undef socklen_t
|
||||
|
||||
/* Define to `int' if <signal.h> doesn't define. */
|
||||
#undef sig_atomic_t
|
||||
|
||||
#undef HAVE_MBSTATE_T
|
||||
|
||||
/* Define if you have quad_t in <sys/types.h>. */
|
||||
#undef HAVE_QUAD_T
|
||||
|
||||
/* Define if you have wchar_t in <wctype.h>. */
|
||||
#undef HAVE_WCHAR_T
|
||||
|
||||
/* Define if you have wctype_t in <wctype.h>. */
|
||||
#undef HAVE_WCTYPE_T
|
||||
|
||||
/* Define if you have wint_t in <wctype.h>. */
|
||||
#undef HAVE_WINT_T
|
||||
|
||||
#undef RLIMTYPE
|
||||
|
||||
/* Define to the type of elements in the array set by `getgroups'.
|
||||
|
@ -314,6 +361,7 @@
|
|||
libraries. */
|
||||
|
||||
/* Define if `sys_siglist' is declared by <signal.h> or <unistd.h>. */
|
||||
#undef HAVE_DECL_SYS_SIGLIST
|
||||
#undef SYS_SIGLIST_DECLARED
|
||||
|
||||
/* Define if `_sys_siglist' is declared by <signal.h> or <unistd.h>. */
|
||||
|
@ -325,16 +373,16 @@
|
|||
|
||||
#undef HAVE_SYS_ERRLIST
|
||||
|
||||
#undef HAVE_TIMEVAL
|
||||
|
||||
#undef HAVE_TZNAME
|
||||
|
||||
#undef HAVE_DECL_TZNAME
|
||||
|
||||
/* Characteristics of some of the system structures. */
|
||||
|
||||
#undef STRUCT_DIRENT_HAS_D_INO
|
||||
#undef HAVE_STRUCT_DIRENT_D_INO
|
||||
|
||||
#undef STRUCT_DIRENT_HAS_D_FILENO
|
||||
#undef HAVE_STRUCT_DIRENT_D_FILENO
|
||||
|
||||
#undef HAVE_STRUCT_DIRENT_D_NAMLEN
|
||||
|
||||
#undef TIOCSTAT_IN_SYS_IOCTL
|
||||
|
||||
|
@ -359,6 +407,10 @@
|
|||
#undef HAVE_STRUCT_TM_TM_ZONE
|
||||
#undef HAVE_TM_ZONE
|
||||
|
||||
#undef HAVE_TIMEVAL
|
||||
|
||||
#undef HAVE_STRUCT_TIMEZONE
|
||||
|
||||
/* Characteristics of definitions in the system header files. */
|
||||
|
||||
#undef HAVE_GETPW_DECLS
|
||||
|
@ -367,7 +419,6 @@
|
|||
|
||||
#undef HAVE_LIBC_FNM_EXTMATCH
|
||||
|
||||
|
||||
#undef HAVE_DECL_CONFSTR
|
||||
|
||||
#undef HAVE_DECL_PRINTF
|
||||
|
@ -380,8 +431,12 @@
|
|||
|
||||
#undef HAVE_DECL_STRTOLD
|
||||
|
||||
#undef PRI_MACROS_BROKEN
|
||||
|
||||
#undef HAVE_MBSTATE_T
|
||||
#undef STRTOLD_BROKEN
|
||||
|
||||
/* Define if WCONTINUED is defined in system headers, but rejected by waitpid */
|
||||
#undef WCONTINUED_BROKEN
|
||||
|
||||
/* These are checked with BASH_CHECK_DECL */
|
||||
|
||||
|
@ -420,6 +475,8 @@
|
|||
|
||||
#undef HAVE_PRINTF_A_FORMAT
|
||||
|
||||
#undef CTYPE_NON_ASCII
|
||||
|
||||
/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
|
||||
#undef HAVE_LANGINFO_CODESET
|
||||
|
||||
|
@ -465,9 +522,6 @@
|
|||
/* Define if you have the bcopy function. */
|
||||
#undef HAVE_BCOPY
|
||||
|
||||
/* Define if you have the bindtextdomain function. */
|
||||
#undef HAVE_BINDTEXTDOMAIN
|
||||
|
||||
/* Define if you have the bzero function. */
|
||||
#undef HAVE_BZERO
|
||||
|
||||
|
@ -489,6 +543,20 @@
|
|||
/* Define if you have the dup2 function. */
|
||||
#undef HAVE_DUP2
|
||||
|
||||
/* Define if you have the eaccess function. */
|
||||
#undef HAVE_EACCESS
|
||||
|
||||
/* Define if you have the fcntl function. */
|
||||
#undef HAVE_FCNTL
|
||||
|
||||
/* Define if you have the fdprintf function. */
|
||||
#undef HAVE_FDPRINTF
|
||||
|
||||
/* Define if you have the fpurge/__fpurge function. */
|
||||
#undef HAVE_FPURGE
|
||||
#undef HAVE___FPURGE
|
||||
#undef HAVE_DECL_FPURGE
|
||||
|
||||
/* Define if you have the getaddrinfo function. */
|
||||
#undef HAVE_GETADDRINFO
|
||||
|
||||
|
@ -513,6 +581,15 @@
|
|||
/* Define if you have the getpeername function. */
|
||||
#undef HAVE_GETPEERNAME
|
||||
|
||||
/* Define if you have the getpwent function. */
|
||||
#undef HAVE_GETPWENT
|
||||
|
||||
/* Define if you have the getpwnam function. */
|
||||
#undef HAVE_GETPWNAM
|
||||
|
||||
/* Define if you have the getpwuid function. */
|
||||
#undef HAVE_GETPWUID
|
||||
|
||||
/* Define if you have the getrlimit function. */
|
||||
#undef HAVE_GETRLIMIT
|
||||
|
||||
|
@ -525,9 +602,6 @@
|
|||
/* Define if you have the getservent function. */
|
||||
#undef HAVE_GETSERVENT
|
||||
|
||||
/* Define if you have the gettext function. */
|
||||
#undef HAVE_GETTEXT
|
||||
|
||||
/* Define if you have the gettimeofday function. */
|
||||
#undef HAVE_GETTIMEOFDAY
|
||||
|
||||
|
@ -546,24 +620,48 @@
|
|||
/* Define if you have the isgraph function. */
|
||||
#undef HAVE_ISGRAPH
|
||||
|
||||
/* Define if you have the isint function in libc */
|
||||
/* Define if you have the isinf function in libc */
|
||||
#undef HAVE_ISINF_IN_LIBC
|
||||
|
||||
/* Define if you have the isnan function in libc */
|
||||
#undef HAVE_ISNAN_IN_LIBC
|
||||
|
||||
/* Define if you have the isprint function. */
|
||||
#undef HAVE_ISPRINT
|
||||
|
||||
/* Define if you have the isspace function. */
|
||||
#undef HAVE_ISSPACE
|
||||
|
||||
/* Define if you have the iswctype function. */
|
||||
#undef HAVE_ISWCTYPE
|
||||
|
||||
/* Define if you have the iswlower function. */
|
||||
#undef HAVE_ISWLOWER
|
||||
|
||||
/* Define if you have the iswupper function. */
|
||||
#undef HAVE_ISWUPPER
|
||||
|
||||
/* Define if you have the isxdigit function. */
|
||||
#undef HAVE_ISXDIGIT
|
||||
|
||||
/* Define if you have the kill function. */
|
||||
#undef HAVE_KILL
|
||||
|
||||
/* Define if you have the killpg function. */
|
||||
#undef HAVE_KILLPG
|
||||
|
||||
/* Define if you have the lstat function. */
|
||||
#undef HAVE_LSTAT
|
||||
|
||||
/* Define if you have the mbrlen function. */
|
||||
#undef HAVE_MBRLEN
|
||||
|
||||
/* Define if you have the mbrtowc function. */
|
||||
#undef HAVE_MBRTOWC
|
||||
|
||||
/* Define if you have the mbscmp function. */
|
||||
#undef HAVE_MBSCMP
|
||||
|
||||
/* Define if you have the mbsrtowcs function. */
|
||||
#undef HAVE_MBSRTOWCS
|
||||
|
||||
|
@ -582,9 +680,18 @@
|
|||
/* Define if you have the putenv function. */
|
||||
#undef HAVE_PUTENV
|
||||
|
||||
/* Define if you have the raise function. */
|
||||
#undef HAVE_RAISE
|
||||
|
||||
/* Define if you have the readlink function. */
|
||||
#undef HAVE_READLINK
|
||||
|
||||
/* Define if you have the regcomp function. */
|
||||
#undef HAVE_REGCOMP
|
||||
|
||||
/* Define if you have the regexec function. */
|
||||
#undef HAVE_REGEXEC
|
||||
|
||||
/* Define if you have the rename function. */
|
||||
#undef HAVE_RENAME
|
||||
|
||||
|
@ -600,6 +707,9 @@
|
|||
/* Define if you have the setenv function. */
|
||||
#undef HAVE_SETENV
|
||||
|
||||
/* Define if you have the setitimer function. */
|
||||
#undef HAVE_SETITIMER
|
||||
|
||||
/* Define if you have the setlinebuf function. */
|
||||
#undef HAVE_SETLINEBUF
|
||||
|
||||
|
@ -609,6 +719,10 @@
|
|||
/* Define if you have the setostype function. */
|
||||
#undef HAVE_SETOSTYPE
|
||||
|
||||
/* Define if you have the setregid function. */
|
||||
#undef HAVE_SETREGID
|
||||
#undef HAVE_DECL_SETREGID
|
||||
|
||||
/* Define if you have the setvbuf function. */
|
||||
#undef HAVE_SETVBUF
|
||||
|
||||
|
@ -636,9 +750,15 @@
|
|||
/* Define if you have the strftime function. */
|
||||
#undef HAVE_STRFTIME
|
||||
|
||||
/* Define if you have the strnlen function. */
|
||||
#undef HAVE_STRNLEN
|
||||
|
||||
/* Define if you have the strpbrk function. */
|
||||
#undef HAVE_STRPBRK
|
||||
|
||||
/* Define if you have the strstr function. */
|
||||
#undef HAVE_STRSTR
|
||||
|
||||
/* Define if you have the strtod function. */
|
||||
#undef HAVE_STRTOD
|
||||
|
||||
|
@ -672,12 +792,15 @@
|
|||
/* Define if you have the tcgetpgrp function. */
|
||||
#undef HAVE_TCGETPGRP
|
||||
|
||||
/* Define if you have the textdomain function. */
|
||||
#undef HAVE_TEXTDOMAIN
|
||||
|
||||
/* Define if you have the times function. */
|
||||
#undef HAVE_TIMES
|
||||
|
||||
/* Define if you have the towlower function. */
|
||||
#undef HAVE_TOWLOWER
|
||||
|
||||
/* Define if you have the towupper function. */
|
||||
#undef HAVE_TOWUPPER
|
||||
|
||||
/* Define if you have the ttyname function. */
|
||||
#undef HAVE_TTYNAME
|
||||
|
||||
|
@ -708,6 +831,18 @@
|
|||
/* Define if you have the wait3 function. */
|
||||
#undef HAVE_WAIT3
|
||||
|
||||
/* Define if you have the wcrtomb function. */
|
||||
#undef HAVE_WCRTOMB
|
||||
|
||||
/* Define if you have the wcscoll function. */
|
||||
#undef HAVE_WCSCOLL
|
||||
|
||||
/* Define if you have the wcsdup function. */
|
||||
#undef HAVE_WCSDUP
|
||||
|
||||
/* Define if you have the wctype function. */
|
||||
#undef HAVE_WCTYPE
|
||||
|
||||
/* Define if you have the wcwidth function. */
|
||||
#undef HAVE_WCWIDTH
|
||||
|
||||
|
@ -749,6 +884,12 @@
|
|||
/* Define if you have the <netinet/in.h> header file. */
|
||||
#undef HAVE_NETINET_IN_H
|
||||
|
||||
/* Define if you have the <pwd.h> header file. */
|
||||
#undef HAVE_PWD_H
|
||||
|
||||
/* Define if you have the <regex.h> header file. */
|
||||
#undef HAVE_REGEX_H
|
||||
|
||||
/* Define if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
|
@ -797,6 +938,9 @@
|
|||
/* Define if you have the <sys/socket.h> header file. */
|
||||
#undef HAVE_SYS_SOCKET_H
|
||||
|
||||
/* Define if you have the <sys/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define if you have the <sys/stream.h> header file. */
|
||||
#undef HAVE_SYS_STREAM_H
|
||||
|
||||
|
@ -808,6 +952,9 @@
|
|||
/* Define if you have <sys/times.h> */
|
||||
#undef HAVE_SYS_TIMES_H
|
||||
|
||||
/* Define if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
|
||||
#undef HAVE_SYS_WAIT_H
|
||||
|
||||
|
@ -873,6 +1020,64 @@
|
|||
|
||||
#undef GETCWD_BROKEN
|
||||
|
||||
/* Additional defines for configuring lib/intl, maintained by autoscan/autoheader */
|
||||
|
||||
/* Define if you have the <argz.h> header file. */
|
||||
#undef HAVE_ARGZ_H
|
||||
|
||||
/* Define if you have the <errno.h> header file. */
|
||||
#undef HAVE_ERRNO_H
|
||||
|
||||
/* Define if you have the <fcntl.h> header file. */
|
||||
#undef HAVE_FCNTL_H
|
||||
|
||||
/* Define if you have the <malloc.h> header file. */
|
||||
#undef HAVE_MALLOC_H
|
||||
|
||||
/* Define if you have the <stdio_ext.h> header file. */
|
||||
#undef HAVE_STDIO_EXT_H
|
||||
|
||||
/* Define if you have the `dcgettext' function. */
|
||||
#undef HAVE_DCGETTEXT
|
||||
|
||||
/* Define if you have the `localeconv' function. */
|
||||
#undef HAVE_LOCALECONV
|
||||
|
||||
/* Define if your system has a working `malloc' function. */
|
||||
/* #undef HAVE_MALLOC */
|
||||
|
||||
/* Define if you have the `mempcpy' function. */
|
||||
#undef HAVE_MEMPCPY
|
||||
|
||||
/* Define if you have a working `mmap' system call. */
|
||||
#undef HAVE_MMAP
|
||||
|
||||
/* Define if you have the `munmap' function. */
|
||||
#undef HAVE_MUNMAP
|
||||
|
||||
/* Define if you have the `nl_langinfo' function. */
|
||||
#undef HAVE_NL_LANGINFO
|
||||
|
||||
/* Define if you have the `stpcpy' function. */
|
||||
#undef HAVE_STPCPY
|
||||
|
||||
/* Define if you have the `strcspn' function. */
|
||||
#undef HAVE_STRCSPN
|
||||
|
||||
/* Define if you have the `strdup' function. */
|
||||
#undef HAVE_STRDUP
|
||||
|
||||
/* Define if you have the `__argz_count' function. */
|
||||
#undef HAVE___ARGZ_COUNT
|
||||
|
||||
/* Define if you have the `__argz_next' function. */
|
||||
#undef HAVE___ARGZ_NEXT
|
||||
|
||||
/* Define if you have the `__argz_stringify' function. */
|
||||
#undef HAVE___ARGZ_STRINGIFY
|
||||
|
||||
/* End additions for lib/intl */
|
||||
|
||||
#include "config-bot.h"
|
||||
|
||||
#endif /* _CONFIG_H_ */
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,30 +1,32 @@
|
|||
dnl
|
||||
dnl Configure script for bash-2.05
|
||||
dnl Configure script for bash-4.0
|
||||
dnl
|
||||
dnl report bugs to chet@po.cwru.edu
|
||||
dnl
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
|
||||
# Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1987-2009 Free Software Foundation, Inc.
|
||||
|
||||
# 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, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# 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.
|
||||
AC_REVISION([for Bash 4.0, version 4.013])dnl
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
# 02111-1307, USA.
|
||||
define(bashvers, 4.0)
|
||||
define(relstatus, release)
|
||||
|
||||
AC_REVISION([for Bash 2.05b, version 2.144, from autoconf version] AC_ACVERSION)dnl
|
||||
|
||||
AC_INIT(bash, 2.05b, bug-bash@gnu.org)
|
||||
AC_INIT([bash], bashvers-relstatus, [bug-bash@gnu.org])
|
||||
|
||||
dnl make sure we are using a recent autoconf version
|
||||
AC_PREREQ(2.50)
|
||||
|
@ -35,12 +37,12 @@ AC_CONFIG_AUX_DIR(./support)
|
|||
AC_CONFIG_HEADERS(config.h)
|
||||
|
||||
dnl checks for version info
|
||||
BASHVERS=2.05b
|
||||
RELSTATUS=release
|
||||
BASHVERS=bashvers
|
||||
RELSTATUS=relstatus
|
||||
|
||||
dnl defaults for debug settings
|
||||
case "$RELSTATUS" in
|
||||
alp*|bet*|dev*|rc*) DEBUG='-DDEBUG' MALLOC_DEBUG='-DMALLOC_DEBUG' ;;
|
||||
alp*|bet*|dev*|rc*|maint*) DEBUG='-DDEBUG' MALLOC_DEBUG='-DMALLOC_DEBUG' ;;
|
||||
*) DEBUG= MALLOC_DEBUG= ;;
|
||||
esac
|
||||
|
||||
|
@ -70,6 +72,7 @@ sparc-netbsd*) opt_bash_malloc=no ;; # needs 8-byte alignment
|
|||
mips-irix6*) opt_bash_malloc=no ;; # needs 8-byte alignment
|
||||
m68k-sysv) opt_bash_malloc=no ;; # fixes file descriptor leak in closedir
|
||||
sparc-linux*) opt_bash_malloc=no ;; # sparc running linux; requires ELF
|
||||
#*-freebsd*-gnu) opt_bash_malloc=no ;; # there's some undetermined problem here
|
||||
#*-freebsd*) opt_bash_malloc=no ;; # they claim it's better; I disagree
|
||||
*-openbsd*) opt_bash_malloc=no ;; # they claim it needs eight-bit alignment
|
||||
*-aix*) opt_bash_malloc=no ;; # AIX machines
|
||||
|
@ -78,7 +81,7 @@ sparc-linux*) opt_bash_malloc=no ;; # sparc running linux; requires ELF
|
|||
*-rhapsody*) opt_bash_malloc=no ;; # Apple Rhapsody (MacOS X)
|
||||
*-darwin*) opt_bash_malloc=no ;; # Apple Darwin (MacOS X)
|
||||
*-dgux*) opt_bash_malloc=no ;; # DG/UX machines
|
||||
*-qnx*) opt_bash_malloc=no ;; # QNX 4.2
|
||||
*-qnx*) opt_bash_malloc=no ;; # QNX 4.2, QNX 6.x
|
||||
*-machten4) opt_bash_malloc=no ;; # MachTen 4.x
|
||||
*-bsdi2.1|*-bsdi3.?) opt_bash_malloc=no ; : ${CC:=shlicc2} ;; # for loadable builtins
|
||||
*-beos*) opt_bash_malloc=no ;; # they say it's suitable
|
||||
|
@ -92,6 +95,12 @@ sco3.2v5*|sco3.2v4*) opt_memscramble=no ;;
|
|||
*) opt_memscramble=yes ;;
|
||||
esac
|
||||
|
||||
dnl
|
||||
dnl macros for the bash debugger
|
||||
dnl
|
||||
AM_PATH_LISPDIR
|
||||
AC_ARG_VAR(DEBUGGER_START_FILE, [location of bash debugger initialization file])
|
||||
|
||||
dnl arguments to configure
|
||||
dnl packages
|
||||
AC_ARG_WITH(afs, AC_HELP_STRING([--with-afs], [if you are running AFS]), opt_afs=$withval)
|
||||
|
@ -138,6 +147,10 @@ if test "$opt_curses" = yes; then
|
|||
prefer_curses=yes
|
||||
fi
|
||||
|
||||
if test -z "${DEBUGGER_START_FILE}"; then
|
||||
DEBUGGER_START_FILE='${datadir}/bashdb/bashdb-main.inc'
|
||||
fi
|
||||
|
||||
dnl optional shell features in config.h.in
|
||||
opt_minimal_config=no
|
||||
|
||||
|
@ -159,11 +172,19 @@ opt_brace_expansion=yes
|
|||
opt_disabled_builtins=no
|
||||
opt_command_timing=yes
|
||||
opt_xpg_echo=no
|
||||
opt_strict_posix=no
|
||||
opt_cond_command=yes
|
||||
opt_cond_regexp=yes
|
||||
opt_coproc=yes
|
||||
opt_arith_for_command=yes
|
||||
opt_net_redirs=yes
|
||||
opt_progcomp=yes
|
||||
opt_separate_help=no
|
||||
opt_multibyte=yes
|
||||
opt_debugger=yes
|
||||
opt_single_longdoc_strings=yes
|
||||
opt_casemod_attrs=yes
|
||||
opt_casemod_expansions=yes
|
||||
|
||||
dnl options that affect how bash is compiled and linked
|
||||
opt_static_link=no
|
||||
|
@ -182,6 +203,8 @@ if test $opt_minimal_config = yes; then
|
|||
opt_brace_expansion=no opt_disabled_builtins=no opt_command_timing=no
|
||||
opt_extended_glob=no opt_cond_command=no opt_arith_for_command=no
|
||||
opt_net_redirs=no opt_progcomp=no opt_separate_help=no
|
||||
opt_multibyte=yes opt_cond_regexp=no opt_coproc=no
|
||||
opt_casemod_attrs=no opt_casemod_expansions=no
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(alias, AC_HELP_STRING([--enable-alias], [enable shell aliases]), opt_alias=$enableval)
|
||||
|
@ -189,8 +212,13 @@ AC_ARG_ENABLE(arith-for-command, AC_HELP_STRING([--enable-arith-for-command], [e
|
|||
AC_ARG_ENABLE(array-variables, AC_HELP_STRING([--enable-array-variables], [include shell array variables]), opt_array_variables=$enableval)
|
||||
AC_ARG_ENABLE(bang-history, AC_HELP_STRING([--enable-bang-history], [turn on csh-style history substitution]), opt_bang_history=$enableval)
|
||||
AC_ARG_ENABLE(brace-expansion, AC_HELP_STRING([--enable-brace-expansion], [include brace expansion]), opt_brace_expansion=$enableval)
|
||||
AC_ARG_ENABLE(casemod-attributes, AC_HELP_STRING([--enable-casemod-attributes], [include case-modifying variable attributes]), opt_casemod_attrs=$enableval)
|
||||
AC_ARG_ENABLE(casemod-expansions, AC_HELP_STRING([--enable-casemod-expansions], [include case-modifying word expansions]), opt_casemod_expansions=$enableval)
|
||||
AC_ARG_ENABLE(command-timing, AC_HELP_STRING([--enable-command-timing], [enable the time reserved word and command timing]), opt_command_timing=$enableval)
|
||||
AC_ARG_ENABLE(cond-command, AC_HELP_STRING([--enable-cond-command], [enable the conditional command]), opt_cond_command=$enableval)
|
||||
AC_ARG_ENABLE(cond-regexp, AC_HELP_STRING([--enable-cond-regexp], [enable extended regular expression matching in conditional commands]), opt_cond_regexp=$enableval)
|
||||
AC_ARG_ENABLE(coprocesses, AC_HELP_STRING([--enable-coprocesses], [enable coprocess support and the coproc reserved word]), opt_coproc=$enableval)
|
||||
AC_ARG_ENABLE(debugger, AC_HELP_STRING([--enable-debugger], [enable support for bash debugger]), opt_debugger=$enableval)
|
||||
AC_ARG_ENABLE(directory-stack, AC_HELP_STRING([--enable-directory-stack], [enable builtins pushd/popd/dirs]), opt_dirstack=$enableval)
|
||||
AC_ARG_ENABLE(disabled-builtins, AC_HELP_STRING([--enable-disabled-builtins], [allow disabled builtins to still be invoked]), opt_disabled_builtins=$enableval)
|
||||
AC_ARG_ENABLE(dparen-arithmetic, AC_HELP_STRING([--enable-dparen-arithmetic], [include ((...)) command]), opt_dparen_arith=$enableval)
|
||||
|
@ -198,6 +226,7 @@ AC_ARG_ENABLE(extended-glob, AC_HELP_STRING([--enable-extended-glob], [include k
|
|||
AC_ARG_ENABLE(help-builtin, AC_HELP_STRING([--enable-help-builtin], [include the help builtin]), opt_help=$enableval)
|
||||
AC_ARG_ENABLE(history, AC_HELP_STRING([--enable-history], [turn on command history]), opt_history=$enableval)
|
||||
AC_ARG_ENABLE(job-control, AC_HELP_STRING([--enable-job-control], [enable job control features]), opt_job_control=$enableval)
|
||||
AC_ARG_ENABLE(multibyte, AC_HELP_STRING([--enable-multibyte], [enable multibyte characters if OS supports them]), opt_multibyte=$enableval)
|
||||
AC_ARG_ENABLE(net-redirections, AC_HELP_STRING([--enable-net-redirections], [enable /dev/tcp/host/port redirection]), opt_net_redirs=$enableval)
|
||||
AC_ARG_ENABLE(process-substitution, AC_HELP_STRING([--enable-process-substitution], [enable process substitution]), opt_process_subst=$enableval)
|
||||
AC_ARG_ENABLE(progcomp, AC_HELP_STRING([--enable-progcomp], [enable programmable completion and the complete builtin]), opt_progcomp=$enableval)
|
||||
|
@ -206,6 +235,8 @@ AC_ARG_ENABLE(readline, AC_HELP_STRING([--enable-readline], [turn on command lin
|
|||
AC_ARG_ENABLE(restricted, AC_HELP_STRING([--enable-restricted], [enable a restricted shell]), opt_restricted=$enableval)
|
||||
AC_ARG_ENABLE(select, AC_HELP_STRING([--enable-select], [include select command]), opt_select=$enableval)
|
||||
AC_ARG_ENABLE(separate-helpfiles, AC_HELP_STRING([--enable-separate-helpfiles], [use external files for help builtin documentation]), opt_separate_help=$enableval)
|
||||
AC_ARG_ENABLE(single-help-strings, AC_HELP_STRING([--enable-single-help-strings], [store help documentation as a single string to ease translation]), opt_single_longdoc_strings=$enableval)
|
||||
AC_ARG_ENABLE(strict-posix-default, AC_HELP_STRING([--enable-strict-posix-default], [configure bash to be posix-conformant by default]), opt_strict_posix=$enableval)
|
||||
AC_ARG_ENABLE(usg-echo-default, AC_HELP_STRING([--enable-usg-echo-default], [a synonym for --enable-xpg-echo-default]), opt_xpg_echo=$enableval)
|
||||
AC_ARG_ENABLE(xpg-echo-default, AC_HELP_STRING([--enable-xpg-echo-default], [make the echo builtin expand escape sequences by default]), opt_xpg_echo=$enableval)
|
||||
|
||||
|
@ -259,12 +290,21 @@ fi
|
|||
if test $opt_xpg_echo = yes ; then
|
||||
AC_DEFINE(DEFAULT_ECHO_TO_XPG)
|
||||
fi
|
||||
if test $opt_strict_posix = yes; then
|
||||
AC_DEFINE(STRICT_POSIX)
|
||||
fi
|
||||
if test $opt_extended_glob = yes ; then
|
||||
AC_DEFINE(EXTENDED_GLOB)
|
||||
fi
|
||||
if test $opt_cond_command = yes ; then
|
||||
AC_DEFINE(COND_COMMAND)
|
||||
fi
|
||||
if test $opt_cond_regexp = yes ; then
|
||||
AC_DEFINE(COND_REGEXP)
|
||||
fi
|
||||
if test $opt_coproc = yes; then
|
||||
AC_DEFINE(COPROCESS_SUPPORT)
|
||||
fi
|
||||
if test $opt_arith_for_command = yes; then
|
||||
AC_DEFINE(ARITH_FOR_COMMAND)
|
||||
fi
|
||||
|
@ -274,6 +314,18 @@ fi
|
|||
if test $opt_progcomp = yes; then
|
||||
AC_DEFINE(PROGRAMMABLE_COMPLETION)
|
||||
fi
|
||||
if test $opt_multibyte = no; then
|
||||
AC_DEFINE(NO_MULTIBYTE_SUPPORT)
|
||||
fi
|
||||
if test $opt_debugger = yes; then
|
||||
AC_DEFINE(DEBUGGER)
|
||||
fi
|
||||
if test $opt_casemod_attrs = yes; then
|
||||
AC_DEFINE(CASEMOD_ATTRS)
|
||||
fi
|
||||
if test $opt_casemod_expansions = yes; then
|
||||
AC_DEFINE(CASEMOD_EXPANSIONS)
|
||||
fi
|
||||
|
||||
if test $opt_memscramble = yes; then
|
||||
AC_DEFINE(MEMSCRAMBLE)
|
||||
|
@ -295,6 +347,10 @@ if test "$opt_separate_help" != no; then
|
|||
HELPDIRDEFINE='-H ${HELPDIR}'
|
||||
HELPINSTALL='install-help'
|
||||
fi
|
||||
HELPSTRINGS=
|
||||
if test "$opt_single_longdoc_strings" != "yes"; then
|
||||
HELPSTRINGS='-S'
|
||||
fi
|
||||
|
||||
dnl now substitute in the values generated by arguments
|
||||
AC_SUBST(TESTSCRIPT)
|
||||
|
@ -312,6 +368,7 @@ AC_SUBST(htmldir)
|
|||
AC_SUBST(HELPDIR)
|
||||
AC_SUBST(HELPDIRDEFINE)
|
||||
AC_SUBST(HELPINSTALL)
|
||||
AC_SUBST(HELPSTRINGS)
|
||||
|
||||
echo ""
|
||||
echo "Beginning configuration for bash-$BASHVERS-$RELSTATUS for ${host_cpu}-${host_vendor}-${host_os}"
|
||||
|
@ -326,14 +383,12 @@ dnl test for Unix variants
|
|||
AC_ISC_POSIX
|
||||
AC_MINIX
|
||||
|
||||
dnl test for non-Unix variants
|
||||
AC_CYGWIN
|
||||
AC_MINGW32
|
||||
|
||||
AC_SYS_LARGEFILE
|
||||
|
||||
dnl BEGIN changes for cross-building for cygwin and BeOS
|
||||
dnl BEGIN changes for cross-building (currently cygwin, minGW, and
|
||||
dnl (obsolete) BeOS)
|
||||
|
||||
SIGNAMES_O=
|
||||
SIGNAMES_H=lsignames.h
|
||||
|
||||
dnl load up the cross-building cache file -- add more cases and cache
|
||||
|
@ -343,15 +398,17 @@ dnl Note that host and target machine are the same, and different than the
|
|||
dnl build machine.
|
||||
dnl Set SIGNAMES_H based on whether or not we're cross-compiling.
|
||||
|
||||
CROSS_COMPILE=
|
||||
if test "x$cross_compiling" = "xyes"; then
|
||||
case "${host}" in
|
||||
*-cygwin*)
|
||||
cross_cache=${srcdir}/cross-build/cygwin32.cache
|
||||
SIGNAMES_H='$(srcdir)/cross-build/win32sig.h'
|
||||
;;
|
||||
*-mingw*)
|
||||
cross_cache=${srcdir}/cross-build/cygwin32.cache
|
||||
;;
|
||||
i[[3456]]86-*-beos*)
|
||||
cross_cache=${srcdir}/cross-build/x86-beos.cache
|
||||
SIGNAMES_H='${srcdir}/cross-build/beos-sig.h'
|
||||
;;
|
||||
*) echo "configure: cross-compiling for $host is not supported" >&2
|
||||
;;
|
||||
|
@ -361,8 +418,12 @@ if test "x$cross_compiling" = "xyes"; then
|
|||
. ${cross_cache}
|
||||
fi
|
||||
unset cross_cache
|
||||
SIGNAMES_O='signames.o'
|
||||
CROSS_COMPILE='-DCROSS_COMPILING'
|
||||
AC_SUBST(CROSS_COMPILE)
|
||||
fi
|
||||
AC_SUBST(SIGNAMES_H)
|
||||
AC_SUBST(SIGNAMES_O)
|
||||
|
||||
if test -z "$CC_FOR_BUILD"; then
|
||||
if test "x$cross_compiling" = "xno"; then
|
||||
|
@ -403,7 +464,14 @@ if test "$opt_static_link" = yes; then
|
|||
fi
|
||||
fi
|
||||
|
||||
test -z "$CPPFLAGS_FOR_BUILD" && CPPFLAGS_FOR_BUILD="$CPPFLAGS"
|
||||
if test "X$cross_compiling" = "Xno"; then
|
||||
CPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-"$CPPFLAGS"}
|
||||
LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-'$(LDFLAGS)'}
|
||||
else
|
||||
CPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-""}
|
||||
LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-""}
|
||||
fi
|
||||
|
||||
test -z "$CFLAGS_FOR_BUILD" && CFLAGS_FOR_BUILD="-g"
|
||||
|
||||
AC_SUBST(CFLAGS)
|
||||
|
@ -430,7 +498,7 @@ then
|
|||
RL_LIB_READLINE_VERSION
|
||||
|
||||
case "$ac_cv_rl_version" in
|
||||
4.[[3-9]]*|5*|6*|7*|8*|9*) ;;
|
||||
5*|6*|7*|8*|9*) ;;
|
||||
*) opt_with_installed_readline=no
|
||||
AC_MSG_WARN(installed readline library is too old to be linked with bash)
|
||||
AC_MSG_WARN(using private bash version)
|
||||
|
@ -438,18 +506,36 @@ then
|
|||
esac
|
||||
fi
|
||||
|
||||
TILDE_LIB=-ltilde
|
||||
if test $opt_readline = yes; then
|
||||
AC_DEFINE(READLINE)
|
||||
READLINE_LIB=-lreadline
|
||||
if test "$opt_with_installed_readline" != "no" ; then
|
||||
case "$RL_INCLUDEDIR" in
|
||||
/usr/include) ;;
|
||||
*) RL_INCLUDE='-I${RL_INCLUDEDIR}'
|
||||
case "$opt_with_installed_readline" in
|
||||
yes) RL_INCLUDE= ;;
|
||||
*) case "$RL_INCLUDEDIR" in
|
||||
/usr/include) ;;
|
||||
*) RL_INCLUDE='-I${RL_INCLUDEDIR}' ;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
READLINE_DEP=
|
||||
READLINE_LIB=-lreadline
|
||||
# section for OS versions that don't allow unresolved symbols
|
||||
# to be compiled into dynamic libraries.
|
||||
case "$host_os" in
|
||||
cygwin*) TILDE_LIB= ;;
|
||||
esac
|
||||
else
|
||||
RL_LIBDIR='$(dot)/$(LIBSUBDIR)/readline'
|
||||
READLINE_DEP='$(READLINE_LIBRARY)'
|
||||
# section for OS versions that ship an older/broken version of
|
||||
# readline as a standard dynamic library and don't allow a
|
||||
# static version specified as -llibname to override the
|
||||
# dynamic version
|
||||
case "${host_os}" in
|
||||
darwin[[89]]*) READLINE_LIB='${READLINE_LIBRARY}' ;;
|
||||
*) READLINE_LIB=-lreadline ;;
|
||||
esac
|
||||
fi
|
||||
else
|
||||
RL_LIBDIR='$(dot)/$(LIBSUBDIR)/readline'
|
||||
|
@ -462,17 +548,29 @@ if test $opt_history = yes || test $opt_bang_history = yes; then
|
|||
if test $opt_bang_history = yes; then
|
||||
AC_DEFINE(BANG_HISTORY)
|
||||
fi
|
||||
HISTORY_LIB=-lhistory
|
||||
if test "$opt_with_installed_readline" != "no"; then
|
||||
HIST_LIBDIR=$RL_LIBDIR
|
||||
HISTORY_DEP=
|
||||
case "$RL_INCLUDEDIR" in
|
||||
/usr/include) ;;
|
||||
*) RL_INCLUDE='-I${RL_INCLUDEDIR}'
|
||||
HISTORY_LIB=-lhistory
|
||||
case "$opt_with_installed_readline" in
|
||||
yes) RL_INCLUDE= ;;
|
||||
*) case "$RL_INCLUDEDIR" in
|
||||
/usr/include) ;;
|
||||
*) RL_INCLUDE='-I${RL_INCLUDEDIR}' ;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
else
|
||||
HIST_LIBDIR='$(dot)/$(LIBSUBDIR)/readline'
|
||||
HISTORY_DEP='$(HISTORY_LIBRARY)'
|
||||
# section for OS versions that ship an older version of
|
||||
# readline as a standard dynamic library and don't allow a
|
||||
# static version specified as -llibname to override the
|
||||
# dynamic version
|
||||
case "${host_os}" in
|
||||
darwin[[89]]*) HISTORY_LIB='${HISTORY_LIBRARY}' ;;
|
||||
*) HISTORY_LIB=-lhistory ;;
|
||||
esac
|
||||
fi
|
||||
else
|
||||
HIST_LIBDIR='$(dot)/$(LIBSUBDIR)/readline'
|
||||
|
@ -486,6 +584,7 @@ AC_SUBST(RL_INCLUDE)
|
|||
AC_SUBST(HISTORY_LIB)
|
||||
AC_SUBST(HISTORY_DEP)
|
||||
AC_SUBST(HIST_LIBDIR)
|
||||
AC_SUBST(TILDE_LIB)
|
||||
|
||||
dnl END READLINE and HISTORY LIBRARY SECTION
|
||||
|
||||
|
@ -505,6 +604,28 @@ opennt*|interix*) MAKE_SHELL="$INTERIX_ROOT/bin/sh" ;;
|
|||
esac
|
||||
AC_SUBST(MAKE_SHELL)
|
||||
|
||||
dnl this is similar to the expanded AC_PROG_RANLIB
|
||||
if test x$SIZE = x; then
|
||||
if test x$ac_tool_prefix = x; then
|
||||
SIZE=size
|
||||
else
|
||||
SIZE=${ac_tool_prefix}size
|
||||
save_IFS=$IFS ; IFS=:
|
||||
size_found=0
|
||||
for dir in $PATH; do
|
||||
if test -x $dir/$SIZE ; then
|
||||
size_found=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
if test $size_found -eq 0; then
|
||||
SIZE=:
|
||||
fi
|
||||
IFS=$save_IFS
|
||||
fi
|
||||
fi
|
||||
AC_SUBST(SIZE)
|
||||
|
||||
dnl Turn on any extensions available in the GNU C library.
|
||||
AC_DEFINE(_GNU_SOURCE, 1)
|
||||
|
||||
|
@ -516,6 +637,11 @@ AC_C_STRINGIZE
|
|||
AC_C_LONG_DOUBLE
|
||||
AC_C_PROTOTYPES
|
||||
AC_C_CHAR_UNSIGNED
|
||||
AC_C_VOLATILE
|
||||
AC_C_RESTRICT
|
||||
|
||||
dnl initialize GNU gettext
|
||||
AM_GNU_GETTEXT([no-libtool], [need-ngettext], [lib/intl])
|
||||
|
||||
dnl header files
|
||||
AC_HEADER_DIRENT
|
||||
|
@ -525,12 +651,20 @@ BASH_HEADER_INTTYPES
|
|||
|
||||
AC_CHECK_HEADERS(unistd.h stdlib.h stdarg.h varargs.h limits.h string.h \
|
||||
memory.h locale.h termcap.h termio.h termios.h dlfcn.h \
|
||||
stddef.h stdint.h netdb.h grp.h strings.h)
|
||||
AC_CHECK_HEADERS(sys/ptem.h sys/pte.h sys/stream.h sys/select.h sys/file.h \
|
||||
sys/resource.h sys/param.h sys/socket.h \
|
||||
sys/time.h sys/times.h sys/wait.h)
|
||||
stddef.h stdint.h netdb.h pwd.h grp.h strings.h regex.h)
|
||||
AC_CHECK_HEADERS(sys/pte.h sys/stream.h sys/select.h sys/file.h \
|
||||
sys/resource.h sys/param.h sys/socket.h sys/stat.h \
|
||||
sys/time.h sys/times.h sys/types.h sys/wait.h)
|
||||
AC_CHECK_HEADERS(netinet/in.h arpa/inet.h)
|
||||
|
||||
dnl sys/ptem.h requires definitions from sys/stream.h on systems where it
|
||||
dnl exists
|
||||
AC_CHECK_HEADER(sys/ptem.h, , ,[[
|
||||
#if HAVE_SYS_STREAM_H
|
||||
# include <sys/stream.h>
|
||||
#endif
|
||||
]])
|
||||
|
||||
dnl special checks for libc functions
|
||||
AC_FUNC_ALLOCA
|
||||
AC_FUNC_GETPGRP
|
||||
|
@ -572,33 +706,56 @@ dnl checks for certain version-specific system calls and libc functions
|
|||
AC_CHECK_FUNC(__setostype, AC_DEFINE(HAVE_SETOSTYPE))
|
||||
AC_CHECK_FUNC(wait3, AC_DEFINE(HAVE_WAIT3))
|
||||
AC_CHECK_FUNC(isinf, AC_DEFINE(HAVE_ISINF_IN_LIBC))
|
||||
AC_CHECK_FUNC(isnan, AC_DEFINE(HAVE_ISNAN_IN_LIBC))
|
||||
|
||||
dnl checks for missing libc functions
|
||||
AC_CHECK_FUNC(mkfifo,AC_DEFINE(HAVE_MKFIFO),AC_DEFINE(MKFIFO_MISSING))
|
||||
|
||||
dnl checks for system calls
|
||||
AC_CHECK_FUNCS(dup2 select getdtablesize getgroups gethostname \
|
||||
setdtablesize getpagesize killpg lstat getpeername sbrk \
|
||||
getrlimit getrusage gettimeofday waitpid tcgetpgrp \
|
||||
readlink)
|
||||
AC_CHECK_FUNCS(dup2 eaccess fcntl getdtablesize getgroups gethostname \
|
||||
getpagesize getpeername getrlimit getrusage gettimeofday \
|
||||
kill killpg lstat readlink sbrk select setdtablesize \
|
||||
setitimer tcgetpgrp uname ulimit waitpid)
|
||||
AC_REPLACE_FUNCS(rename)
|
||||
|
||||
dnl checks for c library functions
|
||||
AC_CHECK_FUNCS(bcopy bzero confstr sysconf pathconf setenv putenv unsetenv \
|
||||
setlinebuf setvbuf setlocale strchr tcgetattr uname \
|
||||
ulimit tzset siginterrupt memmove ttyname times \
|
||||
AC_CHECK_FUNCS(bcopy bzero confstr fnmatch \
|
||||
getaddrinfo gethostbyname getservbyname getservent inet_aton \
|
||||
vsnprintf snprintf vasprintf asprintf fnmatch)
|
||||
memmove pathconf putenv raise regcomp regexec \
|
||||
setenv setlinebuf setlocale setvbuf siginterrupt strchr \
|
||||
sysconf tcgetattr times ttyname tzset unsetenv)
|
||||
|
||||
AC_CHECK_FUNCS(vsnprintf snprintf vasprintf asprintf)
|
||||
AC_CHECK_FUNCS(isascii isblank isgraph isprint isspace isxdigit)
|
||||
AC_REPLACE_FUNCS(getcwd strcasecmp strerror strftime strpbrk memset)
|
||||
AC_CHECK_FUNCS(getpwent getpwnam getpwuid)
|
||||
AC_REPLACE_FUNCS(getcwd memset strcasecmp strerror strftime strnlen strpbrk strstr)
|
||||
AC_REPLACE_FUNCS(strtod strtol strtoul strtoll strtoull strtoimax strtoumax)
|
||||
AC_REPLACE_FUNCS(fdprintf)
|
||||
|
||||
AC_CHECK_DECLS([confstr])
|
||||
AC_CHECK_DECLS([printf])
|
||||
AC_CHECK_DECLS([sbrk])
|
||||
AC_CHECK_DECLS([setregid])
|
||||
AC_CHECK_DECLS([strcpy])
|
||||
AC_CHECK_DECLS([strsignal])
|
||||
AC_CHECK_DECLS([strtold])
|
||||
|
||||
dnl Extra test to detect the horribly broken HP/UX 11.00 strtold(3)
|
||||
AC_CHECK_DECLS([strtold], [
|
||||
AC_MSG_CHECKING([for broken strtold])
|
||||
AC_CACHE_VAL(bash_cv_strtold_broken,
|
||||
[AC_TRY_COMPILE(
|
||||
[#include <stdlib.h>],
|
||||
[int main() { long double r; char *foo, bar; r = strtold(foo, &bar);}],
|
||||
bash_cv_strtold_broken=no, bash_cv_strtold_broken=yes,
|
||||
[AC_MSG_WARN(cannot check for broken strtold if cross-compiling, defaulting to no)])
|
||||
]
|
||||
)
|
||||
AC_MSG_RESULT($bash_cv_strtold_broken)
|
||||
if test "$bash_cv_strtold_broken" = "yes" ; then
|
||||
AC_DEFINE(STRTOLD_BROKEN)
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
BASH_CHECK_DECL(strtoimax)
|
||||
BASH_CHECK_DECL(strtol)
|
||||
|
@ -609,22 +766,31 @@ BASH_CHECK_DECL(strtoumax)
|
|||
|
||||
AC_FUNC_MKTIME
|
||||
|
||||
dnl checks for locale functions
|
||||
AC_CHECK_HEADERS(libintl.h)
|
||||
AC_CHECK_FUNCS(gettext textdomain bindtextdomain)
|
||||
dnl
|
||||
dnl Checks for lib/intl and related code (uses some of the output from
|
||||
dnl AM_GNU_GETTEXT)
|
||||
dnl
|
||||
|
||||
dnl check for GNU libintl if gettext/textdomain/bindtextdomain
|
||||
dnl are not found in libc
|
||||
if test "$ac_cv_func_bindtextdomain" = "no"; then
|
||||
AC_CHECK_LIB(intl,bindtextdomain)
|
||||
if test "$ac_cv_lib_intl_bindtextdomain" = "yes"; then
|
||||
dnl undo caching
|
||||
unset ac_cv_func_gettext
|
||||
unset ac_cv_func_textdomain
|
||||
unset ac_cv_func_bindtextdomain
|
||||
AC_CHECK_FUNCS(gettext textdomain bindtextdomain)
|
||||
fi
|
||||
AC_CHECK_HEADERS([argz.h errno.h fcntl.h malloc.h stdio_ext.h])
|
||||
|
||||
dnl AC_FUNC_MALLOC
|
||||
AC_FUNC_MMAP
|
||||
AC_CHECK_FUNCS([__argz_count __argz_next __argz_stringify dcgettext mempcpy \
|
||||
munmap stpcpy strcspn strdup])
|
||||
|
||||
INTL_DEP= INTL_INC= LIBINTL_H=
|
||||
if test "x$USE_INCLUDED_LIBINTL" = "xyes"; then
|
||||
INTL_DEP='${INTL_LIBDIR}/libintl.a'
|
||||
INTL_INC='-I${INTL_LIBSRC} -I${INTL_BUILDDIR}'
|
||||
LIBINTL_H='${INTL_BUILDDIR}/libintl.h'
|
||||
fi
|
||||
AC_SUBST(INTL_DEP)
|
||||
AC_SUBST(INTL_INC)
|
||||
AC_SUBST(LIBINTL_H)
|
||||
|
||||
dnl
|
||||
dnl End of checks needed by files in lib/intl
|
||||
dnl
|
||||
|
||||
BASH_CHECK_MULTIBYTE
|
||||
|
||||
|
@ -634,7 +800,7 @@ AC_CHECK_LIB(dl, dlopen)
|
|||
AC_CHECK_FUNCS(dlopen dlclose dlsym)
|
||||
fi
|
||||
|
||||
dnl this defines SYS_SIGLIST_DECLARED
|
||||
dnl this defines HAVE_DECL_SYS_SIGLIST
|
||||
AC_DECL_SYS_SIGLIST
|
||||
|
||||
dnl libraries
|
||||
|
@ -673,6 +839,7 @@ BASH_TYPE_LONG_LONG
|
|||
BASH_TYPE_UNSIGNED_LONG_LONG
|
||||
|
||||
AC_TYPE_SIGNAL
|
||||
BASH_TYPE_SIG_ATOMIC_T
|
||||
|
||||
AC_CHECK_SIZEOF(char, 1)
|
||||
AC_CHECK_SIZEOF(short, 2)
|
||||
|
@ -708,6 +875,7 @@ BASH_FUNC_LSTAT
|
|||
fi
|
||||
|
||||
dnl behavior of system calls and library functions
|
||||
BASH_FUNC_CTYPE_NONASCII
|
||||
BASH_FUNC_DUP2_CLOEXEC_CHECK
|
||||
BASH_SYS_PGRP_SYNC
|
||||
BASH_SYS_SIGNAL_VINTAGE
|
||||
|
@ -734,16 +902,19 @@ BASH_STRUCT_TERMIOS_LDISC
|
|||
BASH_STRUCT_TERMIO_LDISC
|
||||
BASH_STRUCT_DIRENT_D_INO
|
||||
BASH_STRUCT_DIRENT_D_FILENO
|
||||
BASH_STRUCT_DIRENT_D_NAMLEN
|
||||
BASH_STRUCT_WINSIZE
|
||||
BASH_STRUCT_TIMEVAL
|
||||
AC_CHECK_MEMBERS([struct stat.st_blocks])
|
||||
AC_STRUCT_TM
|
||||
AC_STRUCT_TIMEZONE
|
||||
BASH_STRUCT_TIMEZONE
|
||||
|
||||
dnl presence and behavior of C library functions
|
||||
BASH_FUNC_STRSIGNAL
|
||||
BASH_FUNC_OPENDIR_CHECK
|
||||
BASH_FUNC_ULIMIT_MAXFDS
|
||||
BASH_FUNC_FPURGE
|
||||
BASH_FUNC_GETENV
|
||||
if test "$ac_cv_func_getcwd" = "yes"; then
|
||||
BASH_FUNC_GETCWD
|
||||
|
@ -765,18 +936,6 @@ else
|
|||
AC_DEFINE(HAVE_STD_UNSETENV)
|
||||
fi
|
||||
|
||||
dnl I have removed this check. The existing libc FNM_EXTMATCH implementation
|
||||
dnl (glibc-2.2.4) disagrees with bash on the matching of incorrectly-formed
|
||||
dnl patterns (bash treats them as strings or characters to be matched without
|
||||
dnl any special meaning) and has one outright bug: a[X-]b should match
|
||||
dnl both a-b and aXb.
|
||||
dnl
|
||||
dnl Once Ulrich and I get together on this, the check can return
|
||||
dnl
|
||||
dnl chet 10/31/2001
|
||||
dnl
|
||||
dnl BASH_FUNC_FNMATCH_EXTMATCH
|
||||
|
||||
BASH_FUNC_PRINTF_A_FORMAT
|
||||
|
||||
dnl presence and behavior of OS functions
|
||||
|
@ -789,6 +948,8 @@ AC_HEADER_TIOCGWINSZ
|
|||
BASH_HAVE_TIOCSTAT
|
||||
BASH_HAVE_FIONREAD
|
||||
|
||||
BASH_CHECK_WCONTINUED
|
||||
|
||||
dnl miscellaneous
|
||||
BASH_CHECK_SPEED_T
|
||||
BASH_CHECK_GETPW_FUNCS
|
||||
|
@ -833,7 +994,7 @@ dnl like glob and readline
|
|||
LOCAL_DEFS=-DSHELL
|
||||
|
||||
dnl use this section to possibly define more cpp variables, specify local
|
||||
dnl libraries, and specify any additional local cc flags
|
||||
dnl libraries, and specify any additional local cc or ld flags
|
||||
dnl
|
||||
dnl this should really go away someday
|
||||
|
||||
|
@ -852,13 +1013,21 @@ sco3.2v5*) LOCAL_CFLAGS="-b elf -DWAITPID_BROKEN -DPATH_MAX=1024" ;;
|
|||
sco3.2v4*) LOCAL_CFLAGS="-DMUST_UNBLOCK_CHLD -DPATH_MAX=1024" ;;
|
||||
sco3.2*) LOCAL_CFLAGS=-DMUST_UNBLOCK_CHLD ;;
|
||||
sunos4*) LOCAL_CFLAGS=-DSunOS4 ;;
|
||||
solaris2.5*) LOCAL_CFLAGS=-DSunOS5 ;;
|
||||
solaris2.5*) LOCAL_CFLAGS="-DSunOS5 -DSOLARIS" ;;
|
||||
solaris2.8*) LOCAL_CFLAGS=-DSOLARIS ;;
|
||||
solaris2.9*) LOCAL_CFLAGS=-DSOLARIS ;;
|
||||
solaris2.10*) LOCAL_CFLAGS=-DSOLARIS ;;
|
||||
solaris2*) LOCAL_CFLAGS=-DSOLARIS ;;
|
||||
lynxos*) LOCAL_CFLAGS=-DRECYCLES_PIDS ;;
|
||||
linux*) LOCAL_LDFLAGS=-rdynamic ;; # allow dynamic loading
|
||||
linux*) LOCAL_LDFLAGS=-rdynamic # allow dynamic loading
|
||||
case "`uname -r`" in
|
||||
2.[[456789]]*|3*) AC_DEFINE(PGRP_PIPE) ;;
|
||||
esac ;;
|
||||
*qnx6*) LOCAL_CFLAGS="-Dqnx -Dqnx6" LOCAL_LIBS="-lncurses" ;;
|
||||
*qnx*) LOCAL_CFLAGS="-Dqnx -F -3s" LOCAL_LDFLAGS="-3s" LOCAL_LIBS="-lunix -lncurses" ;;
|
||||
powerux*) LOCAL_LIBS="-lgen" ;;
|
||||
cygwin*) LOCAL_LIBS="-luser32" ;;
|
||||
opennt*|interix*) LOCAL_CFLAGS="-DNO_MAIN_ENV_ARG -DBROKEN_DIRENT_D_INO" ;;
|
||||
cygwin*) LOCAL_CFLAGS=-DRECYCLES_PIDS ;;
|
||||
opennt*|interix*) LOCAL_CFLAGS="-DNO_MAIN_ENV_ARG -DBROKEN_DIRENT_D_INO -D_POSIX_SOURCE" ;;
|
||||
esac
|
||||
|
||||
dnl Stanza for OS/compiler pair-specific flags
|
||||
|
@ -875,6 +1044,7 @@ freebsd[[3-9]]*)
|
|||
LOCAL_LDFLAGS=-rdynamic # allow dynamic loading
|
||||
fi ;;
|
||||
freebsdelf*) LOCAL_LDFLAGS=-rdynamic ;; # allow dynamic loading
|
||||
dragonfly*) LOCAL_LDFLAGS=-rdynamic ;; # allow dynamic loading
|
||||
esac
|
||||
|
||||
case "$host_cpu" in
|
||||
|
@ -924,12 +1094,27 @@ case "$srcdir" in
|
|||
esac
|
||||
|
||||
BUILD_DIR=`pwd`
|
||||
case "$BUILD_DIR" in
|
||||
*\ *) BUILD_DIR=`echo "$BUILD_DIR" | sed 's: :\\\\ :g'` ;;
|
||||
*) ;;
|
||||
esac
|
||||
|
||||
if test -z "$localedir"; then
|
||||
localedir='${datarootdir}/locale'
|
||||
fi
|
||||
if test -z "$datarootdir"; then
|
||||
datarootdir='${prefix}/share'
|
||||
fi
|
||||
|
||||
AC_SUBST(PROFILE_FLAGS)
|
||||
|
||||
AC_SUBST(incdir)
|
||||
AC_SUBST(BUILD_DIR)
|
||||
|
||||
# Some versions of autoconf don't substitute these automatically
|
||||
AC_SUBST(datarootdir)
|
||||
AC_SUBST(localedir)
|
||||
|
||||
AC_SUBST(YACC)
|
||||
AC_SUBST(AR)
|
||||
AC_SUBST(ARFLAGS)
|
||||
|
@ -952,8 +1137,9 @@ AC_SUBST(LOCAL_DEFS)
|
|||
#AC_SUBST(ALLOCA_OBJECT)
|
||||
|
||||
AC_OUTPUT([Makefile builtins/Makefile lib/readline/Makefile lib/glob/Makefile \
|
||||
lib/intl/Makefile \
|
||||
lib/malloc/Makefile lib/sh/Makefile lib/termcap/Makefile \
|
||||
lib/tilde/Makefile doc/Makefile support/Makefile \
|
||||
lib/tilde/Makefile doc/Makefile support/Makefile po/Makefile.in \
|
||||
examples/loadables/Makefile examples/loadables/perl/Makefile],
|
||||
[
|
||||
# Makefile uses this timestamp file to record whether config.h is up to date.
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
/* conftypes.h -- defines for build and host system. */
|
||||
|
||||
/* Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 2001, 2005, 2008,2009 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 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 3 of the License, 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.
|
||||
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. */
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if !defined (_CONFTYPES_H_)
|
||||
#define _CONFTYPES_H_
|
||||
|
@ -24,7 +24,7 @@
|
|||
/* Placeholder for future modifications if cross-compiling or building a
|
||||
`fat' binary, e.g. on Apple Rhapsody. These values are used in multiple
|
||||
files, so they appear here. */
|
||||
#if !defined (RHAPSODY)
|
||||
#if !defined (RHAPSODY) && !defined (MACOSX)
|
||||
# define HOSTTYPE CONF_HOSTTYPE
|
||||
# define OSTYPE CONF_OSTYPE
|
||||
# define MACHTYPE CONF_MACHTYPE
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue