mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-10 09:41:16 -03:00
Compare commits
463 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6d0b6e5de5 | ||
|
|
fd6bf06f15 | ||
|
|
d2e11ea61d | ||
|
|
dad2b93d1e | ||
|
|
1075ca69b0 | ||
|
|
e29f5c5474 | ||
|
|
22bfa6638a | ||
|
|
1a48941f6b | ||
|
|
68e0c94dbb | ||
|
|
ca04fc745d | ||
|
|
3afead1827 | ||
|
|
0ea69dab7b | ||
|
|
a4a025b786 | ||
|
|
328c3a39a1 | ||
|
|
5aa019a0b5 | ||
|
|
92aa99104a | ||
|
|
6b544bc3c2 | ||
|
|
ea0005e16d | ||
|
|
6901ad361d | ||
|
|
b21cccf5f0 | ||
|
|
7740035d14 | ||
|
|
7dc3934997 | ||
|
|
845e15876c | ||
|
|
c4e7a7992f | ||
|
|
43ab84397b | ||
|
|
0840c9248f | ||
|
|
dd79d75504 | ||
|
|
7073f0b58b | ||
|
|
15916bfbdc | ||
|
|
228fdbef5a | ||
|
|
7f7f8fb156 | ||
|
|
2ae9735858 | ||
|
|
8ac1688c89 | ||
|
|
9cd2dbc9e7 | ||
|
|
a74055bc33 | ||
|
|
e1d0b9370e | ||
|
|
5dfa28059e | ||
|
|
7ead45d899 | ||
|
|
5c9ac72c19 | ||
|
|
343cafef34 | ||
|
|
95a01f3c8f | ||
|
|
cfa367f14c | ||
|
|
94cae410f3 | ||
|
|
cc69afc4fe | ||
|
|
777a559e12 | ||
|
|
0427ccbb55 | ||
|
|
f9a4699147 | ||
|
|
e6e287ae1f | ||
|
|
143602e5f6 | ||
|
|
1c2d3583e7 | ||
|
|
e58110da2c | ||
|
|
0d1683edc8 | ||
|
|
c94b9e504d | ||
|
|
8be3bf3e5d | ||
|
|
3e165297ce | ||
|
|
7ac922def6 | ||
|
|
f12127c775 | ||
|
|
73d84fe136 | ||
|
|
c595448f9c | ||
|
|
5a2aeb1511 | ||
|
|
5fb9d9aa38 | ||
|
|
8258961c29 | ||
|
|
0dab94a54c | ||
|
|
3097f71abd | ||
|
|
ea5e1b70db | ||
|
|
6b393d35a9 | ||
|
|
a5dde6021c | ||
|
|
a015472739 | ||
|
|
6affa4452b | ||
|
|
7ebfa380dd | ||
|
|
370336e7c7 | ||
|
|
bad4269dc9 | ||
|
|
effe6f47a3 | ||
|
|
7eb3a5a17d | ||
|
|
b6cd723eb7 | ||
|
|
a2cd8c8a8d | ||
|
|
3b03bd6a10 | ||
|
|
6caff2d85d | ||
|
|
eeaa241be8 | ||
|
|
8fdb4d2a17 | ||
|
|
7c7f744b4c | ||
|
|
5718ea41df | ||
|
|
20c83ba605 | ||
|
|
e9e32f980b | ||
|
|
4b2cc49aaa | ||
|
|
28f65c07b0 | ||
|
|
18279c3867 | ||
|
|
d1c9bca2e9 | ||
|
|
49973b85da | ||
|
|
47373c4f68 | ||
|
|
cbf1dbaa2e | ||
|
|
fdaa79416a | ||
|
|
7c3700c190 | ||
|
|
a0e1f9113e | ||
|
|
133b682793 | ||
|
|
824f4ee566 | ||
|
|
1cb9b65744 | ||
|
|
35dde5de15 | ||
|
|
4d9bb19467 | ||
|
|
2555353161 | ||
|
|
73a9c8bcb8 | ||
|
|
47b652c76e | ||
|
|
0b044b785a | ||
|
|
ddff3561e3 | ||
|
|
c4dfdfa849 | ||
|
|
08251dcc98 | ||
|
|
57d53c70e3 | ||
|
|
4e77ee4516 | ||
|
|
6291be256b | ||
|
|
e756f7d619 | ||
|
|
cf3d30d4e4 | ||
|
|
585191310b | ||
|
|
530bbfc9ac | ||
|
|
a521fa4165 | ||
|
|
0f76f77173 | ||
|
|
c743ebf211 | ||
|
|
04ce9ecf16 | ||
|
|
bde5921258 | ||
|
|
89ae02976f | ||
|
|
d8382acc74 | ||
|
|
749c44fe27 | ||
|
|
88ec924323 | ||
|
|
7ff069a2e1 | ||
|
|
8e05c8bee8 | ||
|
|
0fa3c15114 | ||
|
|
58667673d9 | ||
|
|
a53a9aa293 | ||
|
|
09402223e8 | ||
|
|
4f947015d2 | ||
|
|
9f3a7543aa | ||
|
|
7ae6805698 | ||
|
|
1401c44a79 | ||
|
|
40ea5987b2 | ||
|
|
6920f039eb | ||
|
|
ff00354305 | ||
|
|
f9c63a142b | ||
|
|
3733fe3997 | ||
|
|
7e3128f097 | ||
|
|
727472d5bd | ||
|
|
3616a23bdd | ||
|
|
f13262d87e | ||
|
|
f71cd494de | ||
|
|
264c065006 | ||
|
|
07c89c71d8 | ||
|
|
19c67db731 | ||
|
|
294da72d11 | ||
|
|
847b6daa34 | ||
|
|
807a0b8dbd | ||
|
|
c3a1473419 | ||
|
|
29707e66e6 | ||
|
|
a97b652046 | ||
|
|
91b46b305d | ||
|
|
fbe66f54aa | ||
|
|
ff03fe7e41 | ||
|
|
06fd1aa9f8 | ||
|
|
5942a6d6c1 | ||
|
|
a781736fb7 | ||
|
|
feabc032f6 | ||
|
|
9f9f7bf95a | ||
|
|
02f638ad2b | ||
|
|
e95effb043 | ||
|
|
7a1a5a6f01 | ||
|
|
bfefe7f262 | ||
|
|
44e8dcd331 | ||
|
|
3580811f8e | ||
|
|
35cf20640f | ||
|
|
eff36003db | ||
|
|
0eab394c24 | ||
|
|
028e1f36a1 | ||
|
|
f59e9baab9 | ||
|
|
1c6f685522 | ||
|
|
c8a36c9889 | ||
|
|
521d09b6d0 | ||
|
|
3efb0bf5cf | ||
|
|
003c4d776f | ||
|
|
00dea8a082 | ||
|
|
7f195b2f23 | ||
|
|
ecc2fbca98 | ||
|
|
631acd529d | ||
|
|
369f1709be | ||
|
|
1505cc3d81 | ||
|
|
78ae6d3bea | ||
|
|
ea81321ccb | ||
|
|
1977d3beb3 | ||
|
|
285984196d | ||
|
|
5f8e6c85e4 | ||
|
|
e01ccb14af | ||
|
|
86b7ae6d21 | ||
|
|
bc42309dd8 | ||
|
|
877b602d6b | ||
|
|
37eb6c340d | ||
|
|
7cd98a670b | ||
|
|
db0eccdc86 | ||
|
|
0f10a3a277 | ||
|
|
312c7ab7b2 | ||
|
|
2e35e1ea60 | ||
|
|
b9c88f4c83 | ||
|
|
5054492c6a | ||
|
|
5893154823 | ||
|
|
4a4e1788e5 | ||
|
|
3d56d7ee32 | ||
|
|
18d06cf10f | ||
|
|
452558624c | ||
|
|
b7ef6852c7 | ||
|
|
fef420d648 | ||
|
|
f2c4becde7 | ||
|
|
e0d6b5c438 | ||
|
|
265d016721 | ||
|
|
495460066c | ||
|
|
8df21a1cb1 | ||
|
|
ba177b48d5 | ||
|
|
29c488c6dc | ||
|
|
14ae10daf7 | ||
|
|
ecdc5bdbc7 | ||
|
|
64fee9865e | ||
|
|
89eb80f3a4 | ||
|
|
9853286bf9 | ||
|
|
7d645ccc53 | ||
|
|
820da6e7f7 | ||
|
|
3466f55ea0 | ||
|
|
b969a175d4 | ||
|
|
bb079f5446 | ||
|
|
250d20bfa8 | ||
|
|
58761f82e7 | ||
|
|
0ccc657aa6 | ||
|
|
7f01570caf | ||
|
|
0dadd83fdd | ||
|
|
3e3541a05a | ||
|
|
a824646d61 | ||
|
|
74fb5bd5e5 | ||
|
|
f2d6ae3220 | ||
|
|
487c275926 | ||
|
|
2f143303b7 | ||
|
|
78296d4fac | ||
|
|
fea22833cd | ||
|
|
b9b09babbe | ||
|
|
ba261cbb55 | ||
|
|
4eb3370edf | ||
|
|
f7a5ca5f1f | ||
|
|
f3c93c1690 | ||
|
|
e55bd063eb | ||
|
|
bdf4214b1f | ||
|
|
9fd20e63cf | ||
|
|
a47065f648 | ||
|
|
70351b0e4f | ||
|
|
12a0f6d72b | ||
|
|
d2c12e760c | ||
|
|
e0c2ce24fb | ||
|
|
1e7dd4f928 | ||
|
|
3259da8f4a | ||
|
|
619f076958 | ||
|
|
588bc1103a | ||
|
|
13e94c0617 | ||
|
|
efd01ae6c6 | ||
|
|
9017df15a8 | ||
|
|
5340d2a18a | ||
|
|
e5298a99f8 | ||
|
|
05736978bb | ||
|
|
e15c7fd7e0 | ||
|
|
509b3598f7 | ||
|
|
aa783fc657 | ||
|
|
84bbbe4252 | ||
|
|
90fbe5eb0b | ||
|
|
d5f4df15d4 | ||
|
|
fd78f67d35 | ||
|
|
28c29f569b | ||
|
|
064581c7f8 | ||
|
|
94b1c4c076 | ||
|
|
85c87fe267 | ||
|
|
5bd66ee2ce | ||
|
|
e593f9be53 | ||
|
|
25e363e729 | ||
|
|
5db192347c | ||
|
|
18bbb5ad01 | ||
|
|
24ca6ceb47 | ||
|
|
3607c555be | ||
|
|
cad14db27b | ||
|
|
2fb5632212 | ||
|
|
56ad85d8a8 | ||
|
|
ee66520863 | ||
|
|
83629e28c8 | ||
|
|
645af56d77 | ||
|
|
9501dc83e6 | ||
|
|
9942e2f19f | ||
|
|
6d6644b907 | ||
|
|
11273a7be0 | ||
|
|
1562b8148d | ||
|
|
d7b659d8e8 | ||
|
|
6050850081 | ||
|
|
95d68e48f2 | ||
|
|
2b7781d3cb | ||
|
|
f0b2d7532a | ||
|
|
6b91433881 | ||
|
|
16cb9dfa05 | ||
|
|
10fec8abb6 | ||
|
|
da058aa141 | ||
|
|
67333a23f1 | ||
|
|
72bb5ae06f | ||
|
|
d4034fc253 | ||
|
|
be9208412a | ||
|
|
f66689d415 | ||
|
|
aca0511762 | ||
|
|
68df730980 | ||
|
|
032a736840 | ||
|
|
d9663a4ec4 | ||
|
|
5392533f33 | ||
|
|
bf0957d8dd | ||
|
|
630abb56f6 | ||
|
|
c45e457492 | ||
|
|
fef1e1db32 | ||
|
|
8ed80deb6b | ||
|
|
b7c551a348 | ||
|
|
810d9104fc | ||
|
|
54c502c3cf | ||
|
|
faa23a33ec | ||
|
|
ae511451fe | ||
|
|
ce689e69d5 | ||
|
|
906495d713 | ||
|
|
690648e1b0 | ||
|
|
b33d3f78b1 | ||
|
|
343c280dbf | ||
|
|
f6b2b9f9a5 | ||
|
|
6a0460f51e | ||
|
|
e12902fe3c | ||
|
|
48030576e4 | ||
|
|
33177e75a6 | ||
|
|
c1304a05d9 | ||
|
|
038d7e725e | ||
|
|
6408486336 | ||
|
|
ec43c635cc | ||
|
|
26de6ba26b | ||
|
|
8f121dce9c | ||
|
|
7eec1a6625 | ||
|
|
02a3288db7 | ||
|
|
b069489792 | ||
|
|
b37eeb92ef | ||
|
|
b6630b5087 | ||
|
|
3a69fc997c | ||
|
|
c216e36a72 | ||
|
|
00778832f1 | ||
|
|
cdbd233e62 | ||
|
|
9ce93164bb | ||
|
|
20b269130c | ||
|
|
891c2fc379 | ||
|
|
00be44a69a | ||
|
|
b8ea709c1e | ||
|
|
7bdcfacee4 | ||
|
|
61706b4490 | ||
|
|
443ddb509e | ||
|
|
e6774cc944 | ||
|
|
78cd8fa089 | ||
|
|
9229041385 | ||
|
|
e6bd3dbc40 | ||
|
|
a91bf6d88a | ||
|
|
fa75fc3901 | ||
|
|
e4a95cb989 | ||
|
|
9cf4a2a0b3 | ||
|
|
0ff374a4a0 | ||
|
|
0817962300 | ||
|
|
8b69c5416d | ||
|
|
1071fedaee | ||
|
|
ab207b64a3 | ||
|
|
418e26c0ac | ||
|
|
de3a28874e | ||
|
|
9dd842ea96 | ||
|
|
5d069de71d | ||
|
|
16333b0c69 | ||
|
|
e4fa0e1000 | ||
|
|
3e52bd0132 | ||
|
|
211663a549 | ||
|
|
659b99ed1a | ||
|
|
86d7e8bb8e | ||
|
|
8bf0a14bd5 | ||
|
|
9c32709fe1 | ||
|
|
00bdd2cb48 | ||
|
|
0a8284c981 | ||
|
|
ddbb50acd7 | ||
|
|
5262f3ce99 | ||
|
|
28dd48a76a | ||
|
|
b1c61bcf1f | ||
|
|
bb591a69c9 | ||
|
|
1d69e70b7a | ||
|
|
2cac04850b | ||
|
|
2619f1752d | ||
|
|
33e2c81748 | ||
|
|
f05da41159 | ||
|
|
780ecc46fc | ||
|
|
9b98df8310 | ||
|
|
5a8205ac2b | ||
|
|
2490da31ce | ||
|
|
092bb90569 | ||
|
|
39ca027706 | ||
|
|
22433f2717 | ||
|
|
f6e194447d | ||
|
|
e2ed5d0977 | ||
|
|
fe5bf8f80e | ||
|
|
0a713a7939 | ||
|
|
4ba2709452 | ||
|
|
0c877183b9 | ||
|
|
a46be4cadb | ||
|
|
8b4637e900 | ||
|
|
ab13c4caad | ||
|
|
479696a8ec | ||
|
|
acde745e34 | ||
|
|
064d49215a | ||
|
|
78d3b37e11 | ||
|
|
12aa33fad4 | ||
|
|
e4ade8f41b | ||
|
|
9d7723b330 | ||
|
|
2bc2e0b9ec | ||
|
|
02083a1bd7 | ||
|
|
e534a952b7 | ||
|
|
754d8d3712 | ||
|
|
86230813de | ||
|
|
2faba57e5a | ||
|
|
3789127d28 | ||
|
|
32e833f331 | ||
|
|
9b4c34aa4c | ||
|
|
e2ebc0e443 | ||
|
|
8ff66e718c | ||
|
|
2789da6a1a | ||
|
|
51c345311a | ||
|
|
4a68a34c50 | ||
|
|
9993ff07f2 | ||
|
|
fc8b56da0d | ||
|
|
02981a1750 | ||
|
|
c2e6b07b35 | ||
|
|
8fcacdd5df | ||
|
|
6bf58e44f4 | ||
|
|
bda7948719 | ||
|
|
e800fca499 | ||
|
|
eed4b75389 | ||
|
|
5974dd68b0 | ||
|
|
680c0aff05 | ||
|
|
4a2bdeebef | ||
|
|
dfa251a1ab | ||
|
|
82cb97d3e3 | ||
|
|
7d334914f7 | ||
|
|
27a60f465d | ||
|
|
279159384e | ||
|
|
d748e05cb9 | ||
|
|
d50c051eec | ||
|
|
8d58e58d7b | ||
|
|
c8c3715aac | ||
|
|
7ffcebb9f8 | ||
|
|
831d95b600 | ||
|
|
0ffeb41c28 | ||
|
|
e8d02159da | ||
|
|
b78fba810c | ||
|
|
43213ee458 | ||
|
|
da316dd588 | ||
|
|
c8bc79005c | ||
|
|
5ba0affdd7 | ||
|
|
721f616964 | ||
|
|
ef4345968e | ||
|
|
319956c26b | ||
|
|
a9bf64465c | ||
|
|
ddcb84aa07 | ||
|
|
d332293245 | ||
|
|
48afe8062e | ||
|
|
277f9b7e60 | ||
|
|
f8de9de13d | ||
|
|
ba6ad5025e |
47
INSTALL
47
INSTALL
@@ -2,41 +2,43 @@
|
||||
Known issues
|
||||
============
|
||||
|
||||
Older versions of Doxygen has bugs in the man-page generation which
|
||||
cause the builtin help to render incorrectly. Version 1.2.14 is known
|
||||
to have this problem.
|
||||
Fish currently requires a semi-modern GCC version to
|
||||
compile. Specifically, GCC 2.95.* won't compile fish, but GCC 3.23
|
||||
should work. Fish has not been coded with an C99- or GNU-specific
|
||||
features in mind, so it is hoped that it should be possible to make
|
||||
fish work with other compilers. Patches are welcome.
|
||||
|
||||
In version 1.9.2, the installation prefix for fish rpms and debs has
|
||||
changed from /usr/local to /usr. The package should automatically
|
||||
change any instances of /usr/local/bin/fish in /etc/passwd to
|
||||
/usr/bin/fish, but some programs, like screen, may need to be
|
||||
restarted to notice the changes. You may also run into problems when
|
||||
switching between using a package and personal builds.
|
||||
Older versions of Doxygen has bugs in the man-page generation which
|
||||
cause the builtin help to render incorrectly. Doxygen 1.2.14 is known
|
||||
to have this problem.
|
||||
|
||||
|
||||
Prerequisites
|
||||
=============
|
||||
|
||||
Fish requires the following packages to build:
|
||||
Fish requires the following programs and libraries to build:
|
||||
|
||||
- Doxygen
|
||||
- Curses or Ncurses
|
||||
- GNU make
|
||||
- GCC
|
||||
|
||||
fish also relies on standard unix tools such as cat, cut, grep, sed,
|
||||
whoami and echo. Fish does not support cross-compilation, separate
|
||||
build directories or any other fancy configure options. Use a recent
|
||||
version of Doxygen, since older versions have bugs that make the
|
||||
builtin help pages render incorrectly. Version 1.2.14 is known to be
|
||||
broken.
|
||||
whoami, bc and echo. Fish does not yet support cross-compilation,
|
||||
separate build directories or any other fancy configure options.
|
||||
|
||||
|
||||
Simple install procedure
|
||||
========================
|
||||
|
||||
If you have downloaded the darcs repository of fish, you need to run
|
||||
the autoconf command first. Then use the following commands to compile
|
||||
fish:
|
||||
|
||||
% ./configure
|
||||
% make #Compile fish
|
||||
% make install #Install fish
|
||||
% echo /usr/local/bin/fish >>/etc/shells #Add fish to list of shells
|
||||
% make # Compile fish
|
||||
% make install # Install fish
|
||||
% echo /usr/local/bin/fish >>/etc/shells # Add fish to list of shells
|
||||
|
||||
If you wish to use fish as your default shell, use the following
|
||||
command:
|
||||
@@ -49,6 +51,9 @@ chsh will prompt you for your password, and change your default shell.
|
||||
Local install procedure
|
||||
=======================
|
||||
|
||||
If you have downloaded the darcs repository of fish, you need to run
|
||||
autoconf first.
|
||||
|
||||
To install fish in your own home directory (typically as non-root),
|
||||
type:
|
||||
|
||||
@@ -57,6 +62,6 @@ type:
|
||||
% make install # Install fish
|
||||
|
||||
You will not be able to use fish as the default shell unless you also
|
||||
add the corresponding line to /etc/shells, which kind of defeats the
|
||||
point of a local install. But you can at least build and run fish.
|
||||
|
||||
add the corresponding line to /etc/shells, which mostly defeats the
|
||||
point of a local install. As a workaround, you can add fish as the
|
||||
last command of the init files for your regular shell.
|
||||
|
||||
471
Makefile.in
471
Makefile.in
@@ -16,6 +16,10 @@
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
|
||||
#
|
||||
# @configure_input@
|
||||
#
|
||||
|
||||
#
|
||||
# Makefile for the fish shell. Can build fish and associated
|
||||
# applications, install them, recalculate dependencies and also create
|
||||
@@ -28,47 +32,68 @@
|
||||
# hallucinations.
|
||||
#
|
||||
|
||||
# Compiler flags
|
||||
|
||||
# Programs
|
||||
CC := @CC@
|
||||
CFLAGS := @CFLAGS@ @INCLUDEDIR@ -Wall -std=gnu99 -fno-strict-aliasing
|
||||
CPPFLAGS=@CPPFLAGS@
|
||||
LDFLAGS:= -l@CURSESLIB@ @LIBS@ @LDFLAGS@ @LIBDIR@
|
||||
INSTALL:=@INSTALL@
|
||||
|
||||
# Compiler flags
|
||||
CFLAGS:=@CFLAGS@ -Wall -std=gnu99 -fno-strict-aliasing
|
||||
CPPFLAGS=@CPPFLAGS@
|
||||
LDFLAGS:= @LIBS@ @LDFLAGS@
|
||||
|
||||
# Installation directories
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
datadir = @datadir@
|
||||
bindir = @bindir@
|
||||
mandir = @mandir@
|
||||
sysconfdir = @sysconfdir@
|
||||
fishdir = @fishdir@
|
||||
fishfile = @fishfile@
|
||||
fishinputfile = @fishinputfile@
|
||||
docdir = @docdir@
|
||||
|
||||
#etc files to install
|
||||
ETC_DIR_INSTALL = etc/fish_interactive.fish
|
||||
|
||||
# Set to 1 if we have gettext
|
||||
HAVE_GETTEXT=@HAVE_GETTEXT@
|
||||
|
||||
CORE_OBJS := util.o common.o halloc.o halloc_util.o
|
||||
|
||||
# All objects used by fish, that are compiled from an ordinary .c file
|
||||
# using an ordinary .h file.
|
||||
COMMON_OBJS := function.o builtin.o common.o complete.o env.o exec.o \
|
||||
COMMON_OBJS := function.o builtin.o complete.o env.o exec.o \
|
||||
expand.o highlight.o history.o kill.o parser.o proc.o reader.o \
|
||||
sanity.o tokenizer.o util.o wildcard.o wgetopt.o wutil.o input.o \
|
||||
sanity.o tokenizer.o wildcard.o wgetopt.o wutil.o input.o \
|
||||
output.o intern.o env_universal.o env_universal_common.o \
|
||||
input_common.o event.o signal.o io.o
|
||||
input_common.o event.o signal.o io.o translate.o parse_util.o \
|
||||
$(CORE_OBJS)
|
||||
|
||||
# builtin_help.h exists, but builtin_help.c is autogenerated
|
||||
COMMON_OBJS_WITH_HEADER := builtin_help.o
|
||||
|
||||
# main.c exists, but main.h does not, etc.
|
||||
COMMON_OBJS_WITH_CODE := builtin_set.o builtin_commandline.o builtin_ulimit.c
|
||||
COMMON_OBJS_WITH_CODE := builtin_set.o builtin_commandline.o \
|
||||
builtin_ulimit.c builtin_complete.o
|
||||
|
||||
# All objects that the system needs to build fish
|
||||
FISH_OBJS := $(COMMON_OBJS) $(COMMON_OBJS_WITH_CODE) $(COMMON_OBJS_WITH_HEADER) main.o
|
||||
FISH_PAGER_OBJS := fish_pager.o common.o output.o util.o wutil.o tokenizer.o input_common.o env_universal.o env_universal_common.o
|
||||
FISH_TESTS_OBJS := $(COMMON_OBJS) $(COMMON_OBJS_WITH_CODE) $(COMMON_OBJS_WITH_HEADER) fish_tests.o
|
||||
FISHD_OBJS := fishd.o env_universal_common.o common.o util.o wutil.o \
|
||||
FISH_OBJS := $(COMMON_OBJS) $(COMMON_OBJS_WITH_CODE) \
|
||||
$(COMMON_OBJS_WITH_HEADER) main.o
|
||||
|
||||
# All objects that the system needs to build fish_pager
|
||||
FISH_PAGER_OBJS := fish_pager.o output.o wutil.o \
|
||||
tokenizer.o input_common.o env_universal.o env_universal_common.o \
|
||||
translate.o $(CORE_OBJS)
|
||||
|
||||
#All objects that the system needs to build mimedb
|
||||
MIME_OBJS := mimedb.o xdgmimealias.o xdgmime.o xdgmimeglob.o \
|
||||
# All objects that the system needs to build fish_tests
|
||||
FISH_TESTS_OBJS := $(COMMON_OBJS) $(COMMON_OBJS_WITH_CODE) \
|
||||
$(COMMON_OBJS_WITH_HEADER) fish_tests.o
|
||||
|
||||
# All objects that the system needs to build fishd
|
||||
FISHD_OBJS := fishd.o env_universal_common.o wutil.o \
|
||||
doc_src/fishd.o $(CORE_OBJS)
|
||||
|
||||
# All objects needed to build mimedb
|
||||
MIME_OBJS := mimedb.o xdgmimealias.o xdgmime.o xdgmimeglob.o \
|
||||
xdgmimeint.o xdgmimemagic.o xdgmimeparent.o wutil.o
|
||||
|
||||
#
|
||||
@@ -76,16 +101,15 @@ MIME_OBJS := mimedb.o xdgmimealias.o xdgmime.o xdgmimeglob.o \
|
||||
# alphabetically, since this is the order in which they will be written
|
||||
# in the help file.
|
||||
#
|
||||
|
||||
BUILTIN_DOC_SRC := doc_src/source.txt doc_src/and.txt \
|
||||
doc_src/begin.txt doc_src/bg.txt doc_src/bind.txt \
|
||||
doc_src/break.txt doc_src/builtin.txt doc_src/case.txt \
|
||||
doc_src/cd.txt doc_src/command.txt doc_src/commandline.txt \
|
||||
doc_src/complete.txt doc_src/continue.txt doc_src/else.txt \
|
||||
doc_src/end.txt doc_src/eval.txt doc_src/exec.txt doc_src/exit.txt \
|
||||
doc_src/fg.txt doc_src/for.txt doc_src/function.txt \
|
||||
doc_src/functions.txt doc_src/if.txt doc_src/jobs.txt \
|
||||
doc_src/not.txt doc_src/or.txt doc_src/random.txt \
|
||||
doc_src/block.txt doc_src/break.txt doc_src/builtin.txt \
|
||||
doc_src/case.txt doc_src/cd.txt doc_src/command.txt \
|
||||
doc_src/commandline.txt doc_src/complete.txt doc_src/continue.txt \
|
||||
doc_src/else.txt doc_src/end.txt doc_src/eval.txt doc_src/exec.txt \
|
||||
doc_src/exit.txt doc_src/fg.txt doc_src/for.txt \
|
||||
doc_src/function.txt doc_src/functions.txt doc_src/if.txt \
|
||||
doc_src/jobs.txt doc_src/not.txt doc_src/or.txt doc_src/random.txt \
|
||||
doc_src/return.txt doc_src/read.txt doc_src/set.txt \
|
||||
doc_src/status.txt doc_src/switch.txt doc_src/ulimit.txt \
|
||||
doc_src/while.txt
|
||||
@@ -100,19 +124,22 @@ BUILTIN_DOC_HDR := $(BUILTIN_DOC_SRC:.txt=.doxygen)
|
||||
# alphabetically, since this is the order in which they will be written
|
||||
# in the help file.
|
||||
#
|
||||
|
||||
CMD_DOC_SRC := doc_src/count.txt doc_src/dirh.txt doc_src/dirs.txt \
|
||||
doc_src/fishd.txt doc_src/help.txt doc_src/mimedb.txt \
|
||||
doc_src/nextd.txt doc_src/open.txt doc_src/popd.txt \
|
||||
doc_src/prevd.txt doc_src/psub.txt doc_src/pushd.txt \
|
||||
doc_src/set_color.txt doc_src/tokenize.txt doc_src/type.txt \
|
||||
doc_src/umask.txt
|
||||
CMD_DOC_SRC := doc_src/contains.txt doc_src/count.txt doc_src/dirh.txt \
|
||||
doc_src/dirs.txt doc_src/fish_pager.txt doc_src/fishd.txt \
|
||||
doc_src/help.txt doc_src/mimedb.txt doc_src/nextd.txt \
|
||||
doc_src/open.txt doc_src/popd.txt doc_src/prevd.txt \
|
||||
doc_src/psub.txt doc_src/pushd.txt doc_src/set_color.txt \
|
||||
doc_src/trap.txt doc_src/type.txt doc_src/umask.txt \
|
||||
doc_src/vared.txt
|
||||
|
||||
#
|
||||
# Files generated by running doxygen on the files in $(CMD_DOC_SRC)
|
||||
#
|
||||
CMD_DOC_HDR := $(CMD_DOC_SRC:.txt=.doxygen)
|
||||
|
||||
#
|
||||
# Files in the test directory
|
||||
#
|
||||
TEST_IN := $(wildcard tests/test*.in)
|
||||
|
||||
#
|
||||
@@ -126,42 +153,58 @@ DOC_SRC_DIR_FILES := doc_src/Doxyfile.in doc_src/doc.hdr \
|
||||
# Files in ./
|
||||
MAIN_DIR_FILES := Doxyfile Doxyfile.user Makefile.in configure \
|
||||
configure.ac config.h.in install-sh set_color.c count.c \
|
||||
key_reader.c tokenize.c gen_hdr.sh gen_hdr2.c $(MIME_OBJS:.o=.h) \
|
||||
key_reader.c gen_hdr.sh gen_hdr2.c $(MIME_OBJS:.o=.h) \
|
||||
$(MIME_OBJS:.o=.c) $(COMMON_OBJS_WITH_HEADER:.o=.h) \
|
||||
$(COMMON_OBJS:.o=.h) $(COMMON_OBJS_WITH_CODE:.o=.c) \
|
||||
$(COMMON_OBJS:.o=.c) builtin_help.hdr fish.spec.in INSTALL README \
|
||||
user_doc.head.html xsel-0.9.6.tar ChangeLog config.sub \
|
||||
config.guess fish_tests.c main.c fish_pager.c fishd.c
|
||||
config.guess fish_tests.c main.c fish_pager.c fishd.c seq.in
|
||||
|
||||
# Files in ./init/
|
||||
INIT_DIR_FILES :=init/fish.in init/fish_complete.fish \
|
||||
init/fish_function.fish init/fish_inputrc \
|
||||
init/fish_interactive.fish
|
||||
# Files in ./etc/
|
||||
ETC_DIR_FILES :=etc/fish.in etc/fish_inputrc \
|
||||
etc/fish_interactive.fish.in
|
||||
|
||||
# Files in ./share/
|
||||
SHARE_DIR_FILES :=share/fish
|
||||
|
||||
# Files in ./tests/
|
||||
TESTS_DIR_FILES := $(TEST_IN) $(TEST_IN:.in=.out) $(TEST_IN:.in=.err) \
|
||||
$(TEST_IN:.in=.status) tests/test.fish tests/gen_output.fish
|
||||
|
||||
COMPLETIONS_DIR_FILES := $(wildcard init/completions/*.fish)
|
||||
COMPLETIONS_DIR_FILES := $(wildcard share/completions/*.fish)
|
||||
|
||||
FUNCTIONS_DIR_FILES := $(wildcard share/functions/*.fish)
|
||||
|
||||
# Programs to build
|
||||
PROGRAMS:=fish set_color tokenize @XSEL@ mimedb count fish_pager fishd
|
||||
PROGRAMS:=fish set_color @XSEL@ @SEQ_FALLBACK@ mimedb count fish_pager fishd
|
||||
|
||||
# Manuals to install
|
||||
MANUALS:=doc_src/fish.1 @XSEL_MAN_PATH@ \
|
||||
doc_src/builtin_doc/man/man1/mimedb.1 \
|
||||
doc_src/builtin_doc/man/man1/set_color.1 \
|
||||
doc_src/builtin_doc/man/man1/tokenize.1 \
|
||||
doc_src/builtin_doc/man/man1/count.1
|
||||
doc_src/builtin_doc/man/man1/count.1 \
|
||||
doc_src/builtin_doc/man/man1/fishd.1 \
|
||||
doc_src/builtin_doc/man/man1/fish_pager.1
|
||||
|
||||
#All translation message catalogs
|
||||
TRANSLATIONS_SRC := $(wildcard po/*.po)
|
||||
TRANSLATIONS := $(TRANSLATIONS_SRC:.po=.gmo)
|
||||
|
||||
#Make everything needed for installing fish
|
||||
all: $(PROGRAMS) user_doc
|
||||
all: $(PROGRAMS) user_doc
|
||||
@echo fish has now been built.
|
||||
@echo Use \'make install\' to install fish.
|
||||
.PHONY: all
|
||||
|
||||
debug:
|
||||
make fish CFLAGS="-O0 -Wno-unused -Werror -g -Wall -std=gnu99 -fno-strict-aliasing"
|
||||
.PHONY: debug
|
||||
|
||||
# User documentation, describing the features of the fish shell.
|
||||
user_doc: doc.h Doxyfile.user user_doc.head.html
|
||||
doxygen Doxyfile.user
|
||||
|
||||
#Source code documentation. Also includes user documentation.
|
||||
# Source code documentation. Also includes user documentation.
|
||||
doc: *.h *.c doc.h Doxyfile builtin_help.c
|
||||
doxygen;
|
||||
|
||||
@@ -175,6 +218,7 @@ doc/refman.pdf: doc
|
||||
|
||||
test: $(PROGRAMS) fish_tests
|
||||
./fish_tests; cd tests; ../fish <test.fish;
|
||||
.PHONY: test
|
||||
|
||||
xsel-0.9.6:
|
||||
tar -xf xsel-0.9.6.tar
|
||||
@@ -205,6 +249,33 @@ doc.h:$(BUILTIN_DOC_SRC) $(CMD_DOC_SRC) doc_src/doc.hdr
|
||||
cat $*.txt >>$@;
|
||||
echo "*/" >>$@
|
||||
|
||||
# Compile translation file
|
||||
%.gmo:
|
||||
if test $(HAVE_GETTEXT) = 1; then \
|
||||
msgfmt $*.po -o $*.gmo; \
|
||||
fi
|
||||
|
||||
# Update existing po file or copy messages.pot
|
||||
%.po:messages.pot
|
||||
if test $(HAVE_GETTEXT) = 1;then \
|
||||
if test -f $*.po; then \
|
||||
msgmerge -U --backup=existing $*.po messages.pot;\
|
||||
else \
|
||||
cp messages.pot $*.po;\
|
||||
fi; \
|
||||
fi
|
||||
|
||||
# Create a template translation object
|
||||
messages.pot: *.c *.h etc/*.in share/fish share/completions/*.fish share/functions/*.fish seq
|
||||
if test $(HAVE_GETTEXT) = 1;then \
|
||||
xgettext -k_ -kN_ -kcomplete_desc *.c *.h -o messages.pot; \
|
||||
if ! xgettext -j -k_ -LShell etc/*.in share/fish share/completions/*.fish share/functions/*.fish seq -o messages.pot; then \
|
||||
echo "Your xgettext version is too old to build the messages.pot file"\
|
||||
rm messages.pot\
|
||||
false;\
|
||||
fi; \
|
||||
fi
|
||||
|
||||
# Generate the internal help functions by making doxygen create
|
||||
# man-pages which are then converted into C code. The convertion path
|
||||
# looks like this:
|
||||
@@ -240,6 +311,7 @@ doc.h:$(BUILTIN_DOC_SRC) $(CMD_DOC_SRC) doc_src/doc.hdr
|
||||
builtin_help.c: $(BUILTIN_DOC_HDR) doc_src/count.doxygen gen_hdr2 gen_hdr.sh builtin_help.hdr $(CMD_DOC_HDR)
|
||||
cd doc_src; doxygen; cd ..;
|
||||
cp builtin_help.hdr builtin_help.c;
|
||||
chmod 755 gen_hdr.sh
|
||||
for i in $(BUILTIN_DOC_HDR) doc_src/count.doxygen ; do \
|
||||
echo ' hash_put( &tbl, L"'`basename $$i .doxygen`'",' >>$@; \
|
||||
./gen_hdr.sh $$i >>$@; \
|
||||
@@ -261,58 +333,150 @@ builtin_help.c: $(BUILTIN_DOC_HDR) doc_src/count.doxygen gen_hdr2 gen_hdr.sh bui
|
||||
echo "void print_help()" >>$@
|
||||
echo "{" >>$@
|
||||
echo ' printf( "%s",' >>$@
|
||||
chmod 755 gen_hdr.sh
|
||||
./gen_hdr.sh $*.doxygen >>$@
|
||||
echo ");" >>$@
|
||||
echo "}" >>$@
|
||||
#man -- doc_src/builtin_doc/man/man1/`basename $@ .c`.1 | cat -s | ./gen_hdr2 >>$@
|
||||
|
||||
install: all
|
||||
#
|
||||
# The build rules for installing/uninstalling fish
|
||||
#
|
||||
|
||||
# Check for an incompatible installed fish version, and fail with an
|
||||
# error if found
|
||||
|
||||
check-uninstall:
|
||||
if test -f $(DESTDIR)$(sysconfdir)/fish.d/fish_function.fish -o -f $(DESTDIR)$(sysconfdir)/fish.d/fish_complete.fish; then \
|
||||
echo;\
|
||||
echo ERROR;\
|
||||
echo;\
|
||||
echo An older fish installation using an incompatible filesystem hierarchy was detected;\
|
||||
echo You must uninstall this fish version before installing proceeding;\
|
||||
echo type \'make uninstall-legacy\' to uninstall these files,;\
|
||||
echo or type \'make force-install\' to force installation.;\
|
||||
echo The latter may result in a broken installation.;\
|
||||
echo;\
|
||||
false;\
|
||||
fi;
|
||||
.PHONY: check-uninstall
|
||||
|
||||
# Try to install after checking for incompatible installed versions
|
||||
install: all check-uninstall install-force
|
||||
.PHONY: install
|
||||
|
||||
# Force installation, even in presense of incompatible previous
|
||||
# version
|
||||
install-force: all install-translations
|
||||
$(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
|
||||
for i in $(PROGRAMS); do\
|
||||
$(INSTALL) -m 755 $$i $(DESTDIR)$(bindir) ; \
|
||||
done;
|
||||
$(INSTALL) -m 755 -d $(DESTDIR)$(sysconfdir)$(fishdir)
|
||||
$(INSTALL) -m 755 -d $(DESTDIR)$(sysconfdir)$(fishdir)/completions
|
||||
$(INSTALL) -m 644 init/fish $(DESTDIR)$(sysconfdir)$(fishfile)
|
||||
for i in init/fish_interactive.fish init/fish_function.fish init/fish_complete.fish ; do \
|
||||
$(INSTALL) -m 644 $$i $(DESTDIR)$(sysconfdir)$(fishdir); \
|
||||
$(INSTALL) -m 755 -d $(DESTDIR)$(sysconfdir)/fish.d
|
||||
$(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish
|
||||
$(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/completions
|
||||
$(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/functions
|
||||
$(INSTALL) -m 644 etc/fish $(DESTDIR)$(sysconfdir)/fish
|
||||
$(INSTALL) -m 644 share/fish $(DESTDIR)$(datadir)/fish
|
||||
for i in $(ETC_DIR_INSTALL); do \
|
||||
$(INSTALL) -m 644 $$i $(DESTDIR)$(sysconfdir)/fish.d; \
|
||||
done;
|
||||
for i in $(COMPLETIONS_DIR_FILES); do \
|
||||
$(INSTALL) -m 644 $$i $(DESTDIR)$(sysconfdir)$(fishdir)/completions/; \
|
||||
$(INSTALL) -m 644 $$i $(DESTDIR)$(datadir)/fish/completions/; \
|
||||
done;
|
||||
$(INSTALL) -m 644 init/fish_inputrc $(DESTDIR)$(sysconfdir)$(fishinputfile);
|
||||
for i in $(FUNCTIONS_DIR_FILES); do \
|
||||
$(INSTALL) -m 644 $$i $(DESTDIR)$(datadir)/fish/functions/; \
|
||||
done;
|
||||
$(INSTALL) -m 644 etc/fish_inputrc $(DESTDIR)$(sysconfdir)/fish_inputrc;
|
||||
$(INSTALL) -m 755 -d $(DESTDIR)$(docdir)
|
||||
for i in user_doc/html/* ChangeLog; do \
|
||||
$(INSTALL) -m 644 $$i $(DESTDIR)$(docdir); \
|
||||
if test -f $$i; then \
|
||||
$(INSTALL) -m 644 $$i $(DESTDIR)$(docdir); \
|
||||
fi; \
|
||||
done;
|
||||
$(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
|
||||
for i in $(MANUALS); do \
|
||||
$(INSTALL) -m 644 $$i $(DESTDIR)$(mandir)/man1/; \
|
||||
done;
|
||||
@echo If you want to use fish as the default shell, remember to first
|
||||
@echo add the line \'$(DESTDIR)$(bindir)/fish\' to the file \'/etc/shells\'.
|
||||
@echo fish is now installed on your system.
|
||||
@echo To run fish, type \'fish\' in your terminal.
|
||||
@echo
|
||||
@echo To use fish as your login shell:
|
||||
@echo \* add the line \'$(DESTDIR)$(bindir)/fish\' to the file \'/etc/shells\'.
|
||||
@echo \* use the command \'chsh -s $(DESTDIR)$(bindir)/fish\'.
|
||||
@echo
|
||||
@echo Have fun!
|
||||
.PHONY: force-install
|
||||
|
||||
uninstall:
|
||||
|
||||
# Uninstall this fish version
|
||||
|
||||
uninstall: uninstall-translations
|
||||
for i in $(PROGRAMS); do \
|
||||
rm -f $(DESTDIR)$(bindir)/$$i; \
|
||||
done;
|
||||
rm -f $(DESTDIR)$(bindir)/xsel
|
||||
rm -f $(DESTDIR)$(sysconfdir)$(fishfile)
|
||||
rm -f $(DESTDIR)$(sysconfdir)$(fishinputfile)
|
||||
rm -r $(DESTDIR)$(sysconfdir)$(fishdir)
|
||||
rm -r $(DESTDIR)$(docdir)
|
||||
for i in fish.1* @XSEL_MAN@ mimedb.1* set_color.1* tokenize.1* count.1*; do \
|
||||
rm $(DESTDIR)$(mandir)/man1/$$i; \
|
||||
rm -f $(DESTDIR)$(sysconfdir)/fish
|
||||
rm -f $(DESTDIR)$(sysconfdir)/fish_inputrc
|
||||
if test -d $(DESTDIR)$(datadir)/fish; then \
|
||||
rm -r $(DESTDIR)$(datadir)/fish; \
|
||||
fi
|
||||
if test -d $(DESTDIR)$(docdir); then \
|
||||
rm -r $(DESTDIR)$(docdir);\
|
||||
fi
|
||||
for i in fish.1 @XSEL_MAN@ mimedb.1 fishd.1 set_color.1 count.1; do \
|
||||
rm -f $(DESTDIR)$(mandir)/man1/$$i*; \
|
||||
done;
|
||||
.PHONY: uninstall
|
||||
|
||||
# Uninstall older fish release. This is not the default uninstall
|
||||
# since there is a slight chance that it removes a file put in place by
|
||||
# the sysadmin.
|
||||
|
||||
uninstall-legacy: uninstall
|
||||
rm -f $(DESTDIR)$(sysconfdir)/fish.d/fish_interactive.fish
|
||||
rm -f $(DESTDIR)$(sysconfdir)/fish.d/fish_complete.fish
|
||||
rm -f $(DESTDIR)$(sysconfdir)/fish.d/fish_function.fish
|
||||
if test -d $(DESTDIR)$(sysconfdir)/fish.d/completions; then \
|
||||
for i in $(COMPLETIONS_DIR_FILES); do \
|
||||
basename=`basename $$i`; \
|
||||
if test -f $(DESTDIR)$(sysconfdir)/fish.d/completions/$$basename; then \
|
||||
rm $(DESTDIR)$(sysconfdir)/fish.d/completions/$$basename; \
|
||||
fi; \
|
||||
done; \
|
||||
fi;
|
||||
rmdir $(DESTDIR)$(sysconfdir)/fish.d/completions; true
|
||||
rmdir $(DESTDIR)$(sysconfdir)/fish.d; true
|
||||
|
||||
install-translations: $(TRANSLATIONS)
|
||||
if test $(HAVE_GETTEXT) = 1; then \
|
||||
for i in $(TRANSLATIONS); do \
|
||||
$(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/locale/`basename $$i .gmo`/LC_MESSAGES; \
|
||||
$(INSTALL) -m 644 $$i $(DESTDIR)$(datadir)/locale/`basename $$i .gmo`/LC_MESSAGES/fish.mo; \
|
||||
echo $(DESTDIR)$(datadir)/locale/`basename $$i .gmo`/LC_MESSAGES/fish.mo;\
|
||||
done; \
|
||||
fi;
|
||||
.PHONY: install-translations
|
||||
|
||||
uninstall-translations:
|
||||
if test $(HAVE_GETTEXT) = 1; then \
|
||||
for i in $(TRANSLATIONS_SRC); do \
|
||||
rm -f $(DESTDIR)$(datadir)/locale/*/LC_MESSAGES/fish.mo; \
|
||||
done; \
|
||||
fi
|
||||
.PHONY: uninstall-translations
|
||||
|
||||
#
|
||||
# The build rules for all the commands
|
||||
#
|
||||
|
||||
# The fish shell
|
||||
fish: $(FISH_OBJS)
|
||||
$(CC) $(FISH_OBJS) $(LDFLAGS) -o $@
|
||||
|
||||
fish_pager: $(FISH_PAGER_OBJS)
|
||||
$(CC) $(FISH_PAGER_OBJS) $(LDFLAGS) -o $@
|
||||
|
||||
fishd: $(FISHD_OBJS)
|
||||
fishd: $(FISHD_OBJS)
|
||||
$(CC) $(FISHD_OBJS) $(LDFLAGS) -o $@
|
||||
|
||||
fish_tests: $(FISH_TESTS_OBJS)
|
||||
@@ -325,18 +489,20 @@ mimedb: $(MIME_OBJS) util.o common.o doc_src/mimedb.c
|
||||
set_color: set_color.o doc_src/set_color.c
|
||||
$(CC) set_color.o doc_src/set_color.c $(LDFLAGS) -o $@
|
||||
|
||||
tokenize: tokenize.o doc_src/tokenize.c
|
||||
$(CC) tokenize.o doc_src/tokenize.c $(LDFLAGS) -o $@
|
||||
|
||||
# Test program for the tokenizer library
|
||||
tokenizer_test: tokenizer.c tokenizer.h util.o wutil.o common.o
|
||||
$(CC) ${CFLAGS} tokenizer.c util.o wutil.o common.o -D TOKENIZER_TEST $(LDFLAGS) -o $@
|
||||
|
||||
# Neat little program to show output from terminal
|
||||
key_reader: key_reader.o input_common.o common.o env_universal.o env_universal_common.o util.o wutil.o
|
||||
$(CC) key_reader.o input_common.o common.o env_universal.o env_universal_common.o util.o wutil.o $(LDFLAGS) -o $@
|
||||
|
||||
#
|
||||
# Update dependencies
|
||||
#
|
||||
depend:
|
||||
makedepend -fMakefile.in -Y *.c
|
||||
.PHONY: depend
|
||||
|
||||
# Copy all the source files into a new directory and use tar to create
|
||||
# an archive from it. Simplest way I could think of to make an archive
|
||||
@@ -344,18 +510,24 @@ depend:
|
||||
#
|
||||
# Uses install instead of mkdir so build won't fail if the directory
|
||||
# exists
|
||||
fish-@PACKAGE_VERSION@.tar: $(DOC_SRC_DIR_FILES) $(MAIN_DIR_FILES) $(INIT_DIR_FILES) $(TEST_DIR_FILES) $(COMPLETIONS_DIR_FILES) ChangeLog
|
||||
fish-@PACKAGE_VERSION@.tar: $(DOC_SRC_DIR_FILES) $(MAIN_DIR_FILES) $(ETC_DIR_FILES) $(TEST_DIR_FILES) $(SHARE_DIR_FILES) $(FUNCTIONS_DIR_FILES) $(COMPLETIONS_DIR_FILES) ChangeLog
|
||||
rm -rf fish-@PACKAGE_VERSION@
|
||||
$(INSTALL) -d fish-@PACKAGE_VERSION@
|
||||
$(INSTALL) -d fish-@PACKAGE_VERSION@/doc_src
|
||||
$(INSTALL) -d fish-@PACKAGE_VERSION@/init
|
||||
$(INSTALL) -d fish-@PACKAGE_VERSION@/init/completions
|
||||
$(INSTALL) -d fish-@PACKAGE_VERSION@/etc
|
||||
$(INSTALL) -d fish-@PACKAGE_VERSION@/share
|
||||
$(INSTALL) -d fish-@PACKAGE_VERSION@/share/completions
|
||||
$(INSTALL) -d fish-@PACKAGE_VERSION@/share/functions
|
||||
$(INSTALL) -d fish-@PACKAGE_VERSION@/tests
|
||||
$(INSTALL) -d fish-@PACKAGE_VERSION@/po
|
||||
cp -f $(DOC_SRC_DIR_FILES) fish-@PACKAGE_VERSION@/doc_src
|
||||
cp -f $(MAIN_DIR_FILES) fish-@PACKAGE_VERSION@/
|
||||
cp -f $(INIT_DIR_FILES) fish-@PACKAGE_VERSION@/init/
|
||||
cp -f $(COMPLETIONS_DIR_FILES) fish-@PACKAGE_VERSION@/init/completions/
|
||||
cp -f $(ETC_DIR_FILES) fish-@PACKAGE_VERSION@/etc/
|
||||
cp -f $(SHARE_DIR_FILES) fish-@PACKAGE_VERSION@/share/
|
||||
cp -f $(COMPLETIONS_DIR_FILES) fish-@PACKAGE_VERSION@/share/completions/
|
||||
cp -f $(FUNCTIONS_DIR_FILES) fish-@PACKAGE_VERSION@/share/functions/
|
||||
cp -f $(TESTS_DIR_FILES) fish-@PACKAGE_VERSION@/tests/
|
||||
cp -f $(TRANSLATIONS_SRC) fish-@PACKAGE_VERSION@/po/
|
||||
tar -c fish-@PACKAGE_VERSION@ >fish-@PACKAGE_VERSION@.tar
|
||||
rm -rf fish-@PACKAGE_VERSION@
|
||||
|
||||
@@ -373,11 +545,23 @@ rpm: fish-@PACKAGE_VERSION@.tar.bz2
|
||||
rpmbuild -ba --clean /usr/src/redhat/SPECS/fish.spec
|
||||
mv /usr/src/redhat/RPMS/*/fish*@PACKAGE_VERSION@*.rpm .
|
||||
mv /usr/src/redhat/SRPMS/fish*@PACKAGE_VERSION@*.src.rpm .
|
||||
.PHONY: rpm
|
||||
|
||||
#
|
||||
# Cleanup targets
|
||||
#
|
||||
|
||||
distclean: clean
|
||||
rm -f fish.spec doc_src/fish.1 doc_src/Doxyfile
|
||||
rm -f etc/fish etc/fish_interactive.fish share/fish
|
||||
rm -f config.status config.log config.h Makefile
|
||||
.PHONY: distclean
|
||||
|
||||
clean:
|
||||
rm -f *.o doc.h doc_src/*.doxygen doc_src/*.c builtin_help.c
|
||||
rm -f config.status config.log config.h Makefile
|
||||
rm -f tokenizer_test fish key_reader set_color tokenize gen_hdr2 mimedb
|
||||
rm -f tests/tmp.err tests/tmp.out tests/tmp.status tests/foo.txt
|
||||
rm -f tokenizer_test fish key_reader set_color gen_hdr2 mimedb
|
||||
rm -f fishd fish_pager count
|
||||
rm -f fish-@PACKAGE_VERSION@.tar
|
||||
rm -f fish-@PACKAGE_VERSION@.tar.gz
|
||||
rm -f fish-@PACKAGE_VERSION@.tar.bz2
|
||||
@@ -386,70 +570,109 @@ clean:
|
||||
rm -rf doc_src/builtin_doc
|
||||
rm -rf fish-@PACKAGE_VERSION@
|
||||
rm -rf xsel-0.9.6/
|
||||
rm -f $(TRANSLATIONS)
|
||||
.PHONY: clean
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
builtin.o: config.h util.h wutil.h builtin.h function.h complete.h proc.h
|
||||
builtin.o: parser.h reader.h env.h expand.h common.h wgetopt.h sanity.h
|
||||
builtin.o: io.h parser.h event.h reader.h env.h common.h wgetopt.h sanity.h
|
||||
builtin.o: tokenizer.h builtin_help.h wildcard.h input_common.h input.h
|
||||
builtin.o: intern.h
|
||||
builtin_commandline.o: config.h util.h builtin.h common.h wgetopt.h reader.h
|
||||
builtin_commandline.o: proc.h parser.h tokenizer.h input_common.h input.h
|
||||
builtin.o: intern.h signal.h translate.h halloc.h halloc_util.h parse_util.h
|
||||
builtin.o: expand.h
|
||||
builtin_commandline.o: signal.h config.h util.h wutil.h builtin.h common.h
|
||||
builtin_commandline.o: wgetopt.h reader.h proc.h io.h parser.h event.h
|
||||
builtin_commandline.o: tokenizer.h input_common.h input.h translate.h
|
||||
builtin_commandline.o: parse_util.h
|
||||
builtin_complete.o: signal.h config.h util.h wutil.h builtin.h common.h
|
||||
builtin_complete.o: complete.h wgetopt.h parser.h proc.h io.h event.h
|
||||
builtin_complete.o: reader.h translate.h
|
||||
builtin_help.o: config.h util.h common.h builtin_help.h
|
||||
builtin_set.o: config.h util.h builtin.h env.h expand.h common.h wgetopt.h
|
||||
builtin_set.o: proc.h parser.h
|
||||
common.o: config.h util.h wutil.h common.h expand.h proc.h wildcard.h
|
||||
common.o: parser.h
|
||||
complete.o: config.h util.h tokenizer.h wildcard.h proc.h parser.h function.h
|
||||
complete.o: complete.h builtin.h env.h exec.h expand.h common.h reader.h
|
||||
complete.o: history.h intern.h wutil.h
|
||||
env.o: config.h util.h wutil.h proc.h common.h env.h sanity.h expand.h
|
||||
env.o: history.h reader.h parser.h env_universal.h env_universal_common.h
|
||||
env_universal.o: util.h common.h wutil.h env_universal_common.h
|
||||
env_universal.o: env_universal.h
|
||||
env_universal_common.o: util.h common.h wutil.h env_universal_common.h
|
||||
exec.o: config.h util.h common.h wutil.h proc.h exec.h parser.h builtin.h
|
||||
exec.o: function.h env.h wildcard.h sanity.h expand.h env_universal.h
|
||||
exec.o: env_universal_common.h
|
||||
expand.o: config.h util.h common.h wutil.h env.h proc.h parser.h expand.h
|
||||
expand.o: wildcard.h exec.h tokenizer.h complete.h
|
||||
fishd.o: util.h common.h wutil.h env_universal_common.h
|
||||
fish_pager.o: config.h util.h wutil.h common.h complete.h output.h
|
||||
fish_pager.o: input_common.h env_universal.h env_universal_common.h
|
||||
fish_tests.o: config.h util.h common.h proc.h reader.h builtin.h function.h
|
||||
fish_tests.o: complete.h wutil.h env.h expand.h parser.h tokenizer.h
|
||||
function.o: config.h util.h function.h proc.h parser.h common.h intern.h
|
||||
highlight.o: config.h util.h wutil.h highlight.h tokenizer.h proc.h parser.h
|
||||
highlight.o: builtin.h function.h env.h expand.h sanity.h common.h complete.h
|
||||
highlight.o: output.h
|
||||
builtin_set.o: signal.h config.h util.h wutil.h builtin.h env.h expand.h
|
||||
builtin_set.o: common.h wgetopt.h proc.h io.h parser.h event.h translate.h
|
||||
builtin_ulimit.o: config.h util.h builtin.h common.h wgetopt.h translate.h
|
||||
common.o: config.h util.h wutil.h common.h expand.h proc.h io.h wildcard.h
|
||||
common.o: parser.h event.h
|
||||
complete.o: signal.h config.h util.h tokenizer.h wildcard.h proc.h io.h
|
||||
complete.o: parser.h event.h function.h complete.h builtin.h env.h exec.h
|
||||
complete.o: expand.h common.h reader.h history.h intern.h translate.h
|
||||
complete.o: parse_util.h halloc_util.h wutil.h
|
||||
env.o: config.h signal.h util.h wutil.h proc.h io.h common.h env.h sanity.h
|
||||
env.o: expand.h history.h reader.h parser.h event.h env_universal.h
|
||||
env.o: env_universal_common.h input_common.h translate.h complete.h
|
||||
env_universal.o: config.h signal.h util.h common.h wutil.h
|
||||
env_universal.o: env_universal_common.h env_universal.h
|
||||
env_universal_common.o: config.h signal.h util.h common.h wutil.h
|
||||
env_universal_common.o: env_universal_common.h
|
||||
event.o: signal.h config.h util.h wutil.h function.h proc.h io.h parser.h
|
||||
event.o: event.h common.h translate.h halloc_util.h
|
||||
exec.o: signal.h config.h util.h common.h wutil.h proc.h io.h exec.h parser.h
|
||||
exec.o: event.h builtin.h function.h env.h wildcard.h sanity.h expand.h
|
||||
exec.o: env_universal.h env_universal_common.h translate.h halloc.h
|
||||
exec.o: halloc_util.h parse_util.h
|
||||
expand.o: signal.h config.h util.h common.h wutil.h env.h proc.h io.h
|
||||
expand.o: parser.h event.h expand.h wildcard.h exec.h tokenizer.h complete.h
|
||||
expand.o: translate.h parse_util.h halloc_util.h
|
||||
fishd.o: config.h signal.h util.h common.h wutil.h env_universal_common.h
|
||||
fish_pager.o: config.h signal.h util.h wutil.h common.h complete.h output.h
|
||||
fish_pager.o: input_common.h env_universal.h env_universal_common.h halloc.h
|
||||
fish_pager.o: halloc_util.h
|
||||
fish_tests.o: config.h signal.h util.h common.h proc.h io.h reader.h
|
||||
fish_tests.o: builtin.h function.h complete.h wutil.h env.h expand.h parser.h
|
||||
fish_tests.o: event.h tokenizer.h output.h exec.h halloc_util.h
|
||||
function.o: signal.h config.h wutil.h util.h function.h proc.h io.h parser.h
|
||||
function.o: event.h common.h intern.h reader.h parse_util.h env.h expand.h
|
||||
halloc.o: config.h util.h common.h halloc.h
|
||||
halloc_util.o: config.h util.h common.h halloc.h
|
||||
highlight.o: signal.h config.h util.h wutil.h highlight.h tokenizer.h proc.h
|
||||
highlight.o: io.h parser.h event.h parse_util.h builtin.h function.h env.h
|
||||
highlight.o: expand.h sanity.h common.h complete.h output.h
|
||||
history.o: config.h util.h wutil.h history.h common.h reader.h env.h sanity.h
|
||||
input.o: config.h util.h wutil.h reader.h proc.h common.h sanity.h
|
||||
input.o: input_common.h input.h parser.h env.h expand.h
|
||||
history.o: signal.h
|
||||
input.o: config.h signal.h util.h wutil.h reader.h proc.h io.h common.h
|
||||
input.o: sanity.h input_common.h input.h parser.h event.h env.h expand.h
|
||||
input.o: translate.h output.h
|
||||
input_common.o: config.h util.h common.h wutil.h input_common.h
|
||||
input_common.o: env_universal.h env_universal_common.h
|
||||
intern.o: config.h util.h common.h intern.h
|
||||
kill.o: config.h util.h wutil.h kill.h proc.h sanity.h common.h env.h
|
||||
kill.o: expand.h exec.h parser.h
|
||||
main.o: config.h util.h common.h reader.h builtin.h function.h complete.h
|
||||
main.o: wutil.h env.h sanity.h proc.h parser.h expand.h intern.h
|
||||
intern.o: config.h util.h wutil.h common.h intern.h
|
||||
io.o: config.h util.h wutil.h exec.h proc.h io.h common.h translate.h
|
||||
io.o: halloc.h
|
||||
key_reader.o: input_common.h
|
||||
kill.o: signal.h config.h util.h wutil.h kill.h proc.h io.h sanity.h common.h
|
||||
kill.o: env.h exec.h parser.h event.h
|
||||
main.o: config.h signal.h util.h common.h reader.h builtin.h function.h
|
||||
main.o: complete.h wutil.h env.h sanity.h proc.h io.h parser.h event.h
|
||||
main.o: expand.h intern.h exec.h output.h translate.h halloc_util.h
|
||||
mimedb.o: config.h xdgmime.h util.h
|
||||
output.o: config.h util.h wutil.h expand.h common.h output.h highlight.h
|
||||
parser.o: config.h util.h common.h wutil.h proc.h parser.h tokenizer.h exec.h
|
||||
parser.o: wildcard.h function.h builtin.h builtin_help.h env.h expand.h
|
||||
parser.o: reader.h sanity.h env_universal.h env_universal_common.h
|
||||
proc.o: config.h util.h wutil.h proc.h common.h reader.h sanity.h env.h
|
||||
reader.o: config.h util.h wutil.h highlight.h reader.h proc.h parser.h
|
||||
reader.o: complete.h history.h common.h sanity.h env.h exec.h expand.h
|
||||
reader.o: tokenizer.h kill.h input_common.h input.h function.h output.h
|
||||
sanity.o: config.h util.h common.h sanity.h proc.h history.h reader.h kill.h
|
||||
sanity.o: wutil.h
|
||||
output.o: config.h signal.h util.h wutil.h expand.h common.h output.h
|
||||
output.o: halloc_util.h highlight.h
|
||||
parser.o: signal.h config.h util.h common.h wutil.h proc.h io.h parser.h
|
||||
parser.o: event.h tokenizer.h exec.h wildcard.h function.h builtin.h
|
||||
parser.o: builtin_help.h env.h expand.h reader.h sanity.h env_universal.h
|
||||
parser.o: env_universal_common.h translate.h intern.h parse_util.h halloc.h
|
||||
parser.o: halloc_util.h
|
||||
parse_util.o: config.h util.h wutil.h common.h tokenizer.h parse_util.h
|
||||
parse_util.o: expand.h intern.h exec.h proc.h io.h env.h halloc_util.h
|
||||
proc.o: config.h signal.h util.h wutil.h proc.h io.h common.h reader.h
|
||||
proc.o: sanity.h env.h parser.h event.h translate.h halloc.h halloc_util.h
|
||||
proc.o: output.h
|
||||
reader.o: config.h signal.h util.h wutil.h highlight.h reader.h proc.h io.h
|
||||
reader.o: parser.h event.h complete.h history.h common.h sanity.h env.h
|
||||
reader.o: exec.h expand.h tokenizer.h kill.h input_common.h input.h
|
||||
reader.o: function.h output.h translate.h parse_util.h
|
||||
refcount.o: config.h util.h wutil.h common.h refcount.h
|
||||
sanity.o: signal.h config.h util.h common.h sanity.h proc.h io.h history.h
|
||||
sanity.o: reader.h kill.h wutil.h translate.h
|
||||
set_color.o: config.h
|
||||
tokenize.o: config.h
|
||||
signal.o: config.h signal.h common.h util.h wutil.h event.h reader.h proc.h
|
||||
signal.o: io.h translate.h
|
||||
tokenizer.o: config.h util.h wutil.h tokenizer.h common.h wildcard.h
|
||||
tokenizer.o: translate.h
|
||||
translate.o: config.h common.h util.h halloc_util.h
|
||||
util.o: config.h util.h common.h wutil.h
|
||||
wgetopt.o: config.h wgetopt.h wutil.h
|
||||
wgetopt.o: config.h wgetopt.h wutil.h translate.h
|
||||
wildcard.o: config.h util.h wutil.h complete.h common.h wildcard.h reader.h
|
||||
wildcard.o: expand.h
|
||||
wildcard.o: expand.h translate.h
|
||||
wutil.o: config.h util.h common.h wutil.h
|
||||
xdgmimealias.o: xdgmimealias.h xdgmime.h xdgmimeint.h
|
||||
xdgmime.o: xdgmime.h xdgmimeint.h xdgmimeglob.h xdgmimemagic.h xdgmimealias.h
|
||||
|
||||
64
builtin.h
64
builtin.h
@@ -17,11 +17,45 @@ enum
|
||||
}
|
||||
;
|
||||
|
||||
#define BUILTIN_ERR_MISSING L": Expected argument"
|
||||
#define BUILTIN_ERR_COMBO L": Invalid combination of options"
|
||||
#define BUILTIN_ERR_GLOCAL L": Variable can only be one of universal, global and local"
|
||||
#define BUILTIN_ERR_EXPUNEXP L": Variable can't be both exported and unexported"
|
||||
#define BUILTIN_ERR_UNKNOWN L": Unknown option"
|
||||
/**
|
||||
Error message on missing argument
|
||||
*/
|
||||
#define BUILTIN_ERR_MISSING _( L"%ls: Expected argument\n" )
|
||||
|
||||
/**
|
||||
Error message on invalid combination of options
|
||||
*/
|
||||
#define BUILTIN_ERR_COMBO _( L"%ls: Invalid combination of options\n" )
|
||||
|
||||
/**
|
||||
Error message on invalid combination of options
|
||||
*/
|
||||
#define BUILTIN_ERR_COMBO2 _( L"%ls: Invalid combination of options,\n%ls\n" )
|
||||
|
||||
/**
|
||||
Error message on multiple scope levels for variables
|
||||
*/
|
||||
#define BUILTIN_ERR_GLOCAL _( L"%ls: Variable scope can only be one of universal, global and local\n%ls\n" )
|
||||
|
||||
/**
|
||||
Error message for specifying both export and unexport to set/read
|
||||
*/
|
||||
#define BUILTIN_ERR_EXPUNEXP _( L"%ls: Variable can't be both exported and unexported\n%ls\n" )
|
||||
|
||||
/**
|
||||
Error message for unknown switch
|
||||
*/
|
||||
#define BUILTIN_ERR_UNKNOWN _( L"%ls: Unknown option '%ls'\n" )
|
||||
|
||||
/**
|
||||
Error message for invalid character in variable name
|
||||
*/
|
||||
#define BUILTIN_ERR_VARCHAR _( L"%ls: Invalid character '%lc' in variable name. Only alphanumerical characters and underscores are valid in a variable name.\n" )
|
||||
|
||||
/**
|
||||
Error message for invalid (empty) variable name
|
||||
*/
|
||||
#define BUILTIN_ERR_VARNAME_ZERO _( L"%ls: Variable name can not be the empty string\n" )
|
||||
|
||||
/**
|
||||
Stringbuffer used to represent standard output
|
||||
@@ -103,10 +137,30 @@ int builtin_count_args( wchar_t **argv );
|
||||
void builtin_print_help( wchar_t *cmd, string_buffer_t *b );
|
||||
|
||||
|
||||
/**
|
||||
The set builtin, used for setting variables. Defined in builtin_set.c.
|
||||
*/
|
||||
int builtin_set(wchar_t **argv);
|
||||
|
||||
/**
|
||||
The commandline builtin, used for setting and getting the contents of the commandline. Defined in builtin_commandline.c.
|
||||
*/
|
||||
int builtin_commandline(wchar_t **argv);
|
||||
|
||||
/**
|
||||
The ulimit builtin, used for setting resource limits. Defined in builtin_ulimit.c.
|
||||
*/
|
||||
int builtin_ulimit(wchar_t **argv);
|
||||
|
||||
/**
|
||||
The complete builtin. Used for specifying programmable
|
||||
tab-completions. Calls the functions in complete.c for any heavy
|
||||
lifting.
|
||||
*/
|
||||
int builtin_complete(wchar_t **argv);
|
||||
|
||||
const wchar_t *builtin_complete_get_temporary_buffer();
|
||||
|
||||
/**
|
||||
This function works like wperror, but it prints its result into
|
||||
the sb_err string_buffer_t instead of to stderr. Used by the builtin
|
||||
|
||||
@@ -13,6 +13,7 @@ Functions used for implementing the commandline builtin.
|
||||
|
||||
#include "config.h"
|
||||
#include "util.h"
|
||||
#include "wutil.h"
|
||||
#include "builtin.h"
|
||||
#include "common.h"
|
||||
#include "wgetopt.h"
|
||||
@@ -22,16 +23,18 @@ Functions used for implementing the commandline builtin.
|
||||
#include "tokenizer.h"
|
||||
#include "input_common.h"
|
||||
#include "input.h"
|
||||
#include "translate.h"
|
||||
#include "parse_util.h"
|
||||
|
||||
/**
|
||||
Which part of the comandbuffer are we operating on
|
||||
*/
|
||||
enum
|
||||
{
|
||||
STRING_MODE=1, // Operate on entire buffer
|
||||
JOB_MODE, // Operate on job under cursor
|
||||
PROCESS_MODE, // Operate on process under cursor
|
||||
TOKEN_MODE // Operate on token under cursor
|
||||
STRING_MODE=1, /**< Operate on entire buffer */
|
||||
JOB_MODE, /**< Operate on job under cursor */
|
||||
PROCESS_MODE, /**< Operate on process under cursor */
|
||||
TOKEN_MODE /**< Operate on token under cursor */
|
||||
}
|
||||
;
|
||||
|
||||
@@ -40,28 +43,52 @@ enum
|
||||
*/
|
||||
enum
|
||||
{
|
||||
REPLACE_MODE=1, // Replace current text
|
||||
INSERT_MODE, // Insert at cursor position
|
||||
APPEND_MODE // Insert at end of current token/command/buffer
|
||||
REPLACE_MODE=1, /**< Replace current text */
|
||||
INSERT_MODE, /**< Insert at cursor position */
|
||||
APPEND_MODE /**< Insert at end of current token/command/buffer */
|
||||
}
|
||||
;
|
||||
|
||||
/**
|
||||
Returns the current commandline buffer.
|
||||
*/
|
||||
static const wchar_t *get_buffer()
|
||||
{
|
||||
const wchar_t *buff = builtin_complete_get_temporary_buffer();
|
||||
if( !buff )
|
||||
buff = reader_get_buffer();
|
||||
return buff;
|
||||
}
|
||||
|
||||
static void replace_part( wchar_t *begin,
|
||||
wchar_t *end,
|
||||
static int get_cursor_pos()
|
||||
{
|
||||
const wchar_t *buff = builtin_complete_get_temporary_buffer();
|
||||
if( buff )
|
||||
return wcslen( buff );
|
||||
else
|
||||
return reader_get_cursor_pos();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Replace/append/insert the selection with/at/after the specified string.
|
||||
|
||||
\param begin beginning of selection
|
||||
\param end end of selection
|
||||
\param insert the string to insert
|
||||
\param append_mode can be one of REPLACE_MODE, INSERT_MODE or APPEND_MODE, affects the way the test update is performed
|
||||
*/
|
||||
static void replace_part( const wchar_t *begin,
|
||||
const wchar_t *end,
|
||||
wchar_t *insert,
|
||||
int append_mode )
|
||||
{
|
||||
wchar_t *buff = reader_get_buffer();
|
||||
const wchar_t *buff = get_buffer();
|
||||
string_buffer_t out;
|
||||
int out_pos=reader_get_cursor_pos();
|
||||
int out_pos=get_cursor_pos();
|
||||
|
||||
sb_init( &out );
|
||||
|
||||
// wchar_t *tmp = wcsndup( begin, end-begin );
|
||||
|
||||
// fwprintf( stderr, L"Commandline '%ls', current command '%ls'\n", reader_get_buffer(), tmp );
|
||||
|
||||
sb_append_substring( &out, buff, begin-buff );
|
||||
|
||||
switch( append_mode)
|
||||
@@ -82,7 +109,7 @@ static void replace_part( wchar_t *begin,
|
||||
}
|
||||
case INSERT_MODE:
|
||||
{
|
||||
int cursor = reader_get_cursor_pos() -(begin-buff);
|
||||
int cursor = get_cursor_pos() -(begin-buff);
|
||||
sb_append_substring( &out, begin, cursor );
|
||||
sb_append( &out, insert );
|
||||
sb_append_substring( &out, begin+cursor, end-begin-cursor );
|
||||
@@ -95,17 +122,25 @@ static void replace_part( wchar_t *begin,
|
||||
sb_destroy( &out );
|
||||
}
|
||||
|
||||
void write_part( wchar_t *begin,
|
||||
wchar_t *end,
|
||||
int cut_at_cursor,
|
||||
int tokenize )
|
||||
/**
|
||||
Output the specified selection.
|
||||
|
||||
\param begin start of selection
|
||||
\param end end of selection
|
||||
\param cut_at_cursor whether printing should stop at the surrent cursor position
|
||||
\param tokenize whether the string should be tokenized, printing one string token on every line and skipping non-string tokens
|
||||
*/
|
||||
static void write_part( const wchar_t *begin,
|
||||
const wchar_t *end,
|
||||
int cut_at_cursor,
|
||||
int tokenize )
|
||||
{
|
||||
tokenizer tok;
|
||||
string_buffer_t out;
|
||||
wchar_t *buff;
|
||||
int pos;
|
||||
|
||||
pos = reader_get_cursor_pos()-(begin-reader_get_buffer());
|
||||
pos = get_cursor_pos()-(begin-get_buffer());
|
||||
|
||||
if( tokenize )
|
||||
{
|
||||
@@ -170,7 +205,7 @@ int builtin_commandline( wchar_t **argv )
|
||||
|
||||
int tokenize = 0;
|
||||
|
||||
if( !reader_get_buffer() )
|
||||
if( !get_buffer() )
|
||||
{
|
||||
sb_append2( sb_err,
|
||||
argv[0],
|
||||
@@ -237,7 +272,7 @@ int builtin_commandline( wchar_t **argv )
|
||||
|
||||
int opt = wgetopt_long( argc,
|
||||
argv,
|
||||
L"aijpctwfo",
|
||||
L"aijpctwfor",
|
||||
long_options,
|
||||
&opt_index );
|
||||
if( opt == -1 )
|
||||
@@ -248,13 +283,10 @@ int builtin_commandline( wchar_t **argv )
|
||||
case 0:
|
||||
if(long_options[opt_index].flag != 0)
|
||||
break;
|
||||
sb_append2( sb_err,
|
||||
argv[0],
|
||||
BUILTIN_ERR_UNKNOWN,
|
||||
L" ",
|
||||
long_options[opt_index].name,
|
||||
L"\n",
|
||||
(void *)0 );
|
||||
sb_printf( sb_err,
|
||||
BUILTIN_ERR_UNKNOWN,
|
||||
argv[0],
|
||||
long_options[opt_index].name );
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
|
||||
return 1;
|
||||
@@ -266,7 +298,11 @@ int builtin_commandline( wchar_t **argv )
|
||||
case L'i':
|
||||
append_mode = INSERT_MODE;
|
||||
break;
|
||||
|
||||
|
||||
case L'r':
|
||||
append_mode = REPLACE_MODE;
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
cut_at_cursor=1;
|
||||
break;
|
||||
@@ -306,10 +342,11 @@ int builtin_commandline( wchar_t **argv )
|
||||
*/
|
||||
if( buffer_part || cut_at_cursor || append_mode || tokenize )
|
||||
{
|
||||
sb_printf(sb_err,
|
||||
BUILTIN_ERR_COMBO,
|
||||
argv[0] );
|
||||
|
||||
sb_append2(sb_err,
|
||||
argv[0],
|
||||
BUILTIN_ERR_COMBO,
|
||||
L"\n",
|
||||
parser_current_line(),
|
||||
L"\n",
|
||||
(void *)0);
|
||||
@@ -319,10 +356,11 @@ int builtin_commandline( wchar_t **argv )
|
||||
|
||||
if( argc == woptind )
|
||||
{
|
||||
sb_printf( sb_err,
|
||||
BUILTIN_ERR_MISSING,
|
||||
argv[0] );
|
||||
|
||||
sb_append2( sb_err,
|
||||
argv[0],
|
||||
BUILTIN_ERR_MISSING,
|
||||
L"\n",
|
||||
parser_current_line(),
|
||||
L"\n",
|
||||
(void *)0 );
|
||||
@@ -378,22 +416,23 @@ int builtin_commandline( wchar_t **argv )
|
||||
if( (tokenize || cut_at_cursor) && (argc-woptind) )
|
||||
{
|
||||
|
||||
sb_append2( sb_err,
|
||||
argv[0],
|
||||
BUILTIN_ERR_COMBO,
|
||||
L",\n --cut-at-cursor and --tokenize can not be used when setting the commandline",
|
||||
(void *)0 );
|
||||
sb_printf( sb_err,
|
||||
BUILTIN_ERR_COMBO2,
|
||||
argv[0],
|
||||
L"--cut-at-cursor and --tokenize can not be used when setting the commandline" );
|
||||
|
||||
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
return 1;
|
||||
}
|
||||
|
||||
if( append_mode && !(argc-woptind) )
|
||||
{
|
||||
sb_append2( sb_err,
|
||||
sb_printf( sb_err,
|
||||
BUILTIN_ERR_COMBO2,
|
||||
argv[0],
|
||||
BUILTIN_ERR_COMBO,
|
||||
L",\n insertion mode switches can not be used when not in insertion mode",
|
||||
(void *)0 );
|
||||
L"insertion mode switches can not be used when not in insertion mode" );
|
||||
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
return 1;
|
||||
}
|
||||
@@ -411,32 +450,42 @@ int builtin_commandline( wchar_t **argv )
|
||||
buffer_part = STRING_MODE;
|
||||
}
|
||||
|
||||
wchar_t *begin, *end;
|
||||
const wchar_t *begin, *end;
|
||||
|
||||
switch( buffer_part )
|
||||
{
|
||||
case STRING_MODE:
|
||||
{
|
||||
begin = reader_get_buffer();
|
||||
begin = get_buffer();
|
||||
end = begin+wcslen(begin);
|
||||
break;
|
||||
}
|
||||
|
||||
case PROCESS_MODE:
|
||||
{
|
||||
reader_current_process_extent( &begin, &end );
|
||||
parse_util_process_extent( get_buffer(),
|
||||
get_cursor_pos(),
|
||||
&begin,
|
||||
&end );
|
||||
break;
|
||||
}
|
||||
|
||||
case JOB_MODE:
|
||||
{
|
||||
reader_current_job_extent( &begin, &end );
|
||||
parse_util_job_extent( get_buffer(),
|
||||
get_cursor_pos(),
|
||||
&begin,
|
||||
&end );
|
||||
break;
|
||||
}
|
||||
|
||||
case TOKEN_MODE:
|
||||
{
|
||||
reader_current_token_extent( &begin, &end, 0, 0 );
|
||||
parse_util_token_extent( get_buffer(),
|
||||
get_cursor_pos(),
|
||||
&begin,
|
||||
&end,
|
||||
0, 0 );
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
532
builtin_complete.c
Normal file
532
builtin_complete.c
Normal file
@@ -0,0 +1,532 @@
|
||||
/** \file builtin_complete.c Functions defining the complete builtin
|
||||
|
||||
Functions used for implementing the complete builtin.
|
||||
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
#include <wctype.h>
|
||||
#include <sys/types.h>
|
||||
#include <termios.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "util.h"
|
||||
#include "wutil.h"
|
||||
#include "builtin.h"
|
||||
#include "common.h"
|
||||
#include "complete.h"
|
||||
#include "wgetopt.h"
|
||||
#include "parser.h"
|
||||
#include "reader.h"
|
||||
#include "translate.h"
|
||||
|
||||
const static wchar_t *temporary_buffer;
|
||||
|
||||
/*
|
||||
builtin_complete_* are a set of rather silly looping functions that
|
||||
make sure that all the proper combinations of complete_add or
|
||||
complete_remove get called.
|
||||
*/
|
||||
|
||||
static void builtin_complete_add2( const wchar_t *cmd,
|
||||
int cmd_type,
|
||||
const wchar_t *short_opt,
|
||||
array_list_t *gnu_opt,
|
||||
array_list_t *old_opt,
|
||||
int result_mode,
|
||||
int authorative,
|
||||
const wchar_t *condition,
|
||||
const wchar_t *comp,
|
||||
const wchar_t *desc )
|
||||
{
|
||||
int i;
|
||||
const wchar_t *s;
|
||||
|
||||
for( s=short_opt; *s; s++ )
|
||||
{
|
||||
complete_add( cmd,
|
||||
cmd_type,
|
||||
*s,
|
||||
0,
|
||||
0,
|
||||
result_mode,
|
||||
authorative,
|
||||
condition,
|
||||
comp,
|
||||
desc );
|
||||
}
|
||||
|
||||
for( i=0; i<al_get_count( gnu_opt ); i++ )
|
||||
{
|
||||
complete_add( cmd,
|
||||
cmd_type,
|
||||
0,
|
||||
(wchar_t *)al_get(gnu_opt, i ),
|
||||
0,
|
||||
result_mode,
|
||||
authorative,
|
||||
condition,
|
||||
comp,
|
||||
desc );
|
||||
}
|
||||
|
||||
for( i=0; i<al_get_count( old_opt ); i++ )
|
||||
{
|
||||
complete_add( cmd,
|
||||
cmd_type,
|
||||
0,
|
||||
(wchar_t *)al_get(old_opt, i ),
|
||||
1,
|
||||
result_mode,
|
||||
authorative,
|
||||
condition,
|
||||
comp,
|
||||
desc );
|
||||
}
|
||||
|
||||
if( al_get_count( old_opt )+al_get_count( gnu_opt )+wcslen(short_opt) == 0 )
|
||||
{
|
||||
complete_add( cmd,
|
||||
cmd_type,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
result_mode,
|
||||
authorative,
|
||||
condition,
|
||||
comp,
|
||||
desc );
|
||||
}
|
||||
}
|
||||
|
||||
static void builtin_complete_add( array_list_t *cmd,
|
||||
array_list_t *path,
|
||||
const wchar_t *short_opt,
|
||||
array_list_t *gnu_opt,
|
||||
array_list_t *old_opt,
|
||||
int result_mode,
|
||||
int authorative,
|
||||
const wchar_t *condition,
|
||||
const wchar_t *comp,
|
||||
const wchar_t *desc )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i=0; i<al_get_count( cmd ); i++ )
|
||||
{
|
||||
builtin_complete_add2( al_get( cmd, i ),
|
||||
COMMAND,
|
||||
short_opt,
|
||||
gnu_opt,
|
||||
old_opt,
|
||||
result_mode,
|
||||
authorative,
|
||||
condition,
|
||||
comp,
|
||||
desc );
|
||||
}
|
||||
|
||||
for( i=0; i<al_get_count( path ); i++ )
|
||||
{
|
||||
builtin_complete_add2( al_get( path, i ),
|
||||
PATH,
|
||||
short_opt,
|
||||
gnu_opt,
|
||||
old_opt,
|
||||
result_mode,
|
||||
authorative,
|
||||
condition,
|
||||
comp,
|
||||
desc );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void builtin_complete_remove3( wchar_t *cmd,
|
||||
int cmd_type,
|
||||
wchar_t short_opt,
|
||||
array_list_t *long_opt )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i=0; i<al_get_count( long_opt ); i++ )
|
||||
{
|
||||
complete_remove( cmd,
|
||||
cmd_type,
|
||||
short_opt,
|
||||
(wchar_t *)al_get( long_opt, i ) );
|
||||
}
|
||||
}
|
||||
|
||||
static void builtin_complete_remove2( wchar_t *cmd,
|
||||
int cmd_type,
|
||||
const wchar_t *short_opt,
|
||||
array_list_t *gnu_opt,
|
||||
array_list_t *old_opt )
|
||||
{
|
||||
const wchar_t *s = (wchar_t *)short_opt;
|
||||
if( *s )
|
||||
{
|
||||
for( ; *s; s++ )
|
||||
{
|
||||
if( al_get_count( old_opt) + al_get_count( gnu_opt ) == 0 )
|
||||
{
|
||||
complete_remove(cmd,
|
||||
cmd_type,
|
||||
*s,
|
||||
0 );
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
builtin_complete_remove3( cmd,
|
||||
cmd_type,
|
||||
*s,
|
||||
gnu_opt );
|
||||
builtin_complete_remove3( cmd,
|
||||
cmd_type,
|
||||
*s,
|
||||
old_opt );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
builtin_complete_remove3( cmd,
|
||||
cmd_type,
|
||||
0,
|
||||
gnu_opt );
|
||||
builtin_complete_remove3( cmd,
|
||||
cmd_type,
|
||||
0,
|
||||
old_opt );
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
static void builtin_complete_remove( array_list_t *cmd,
|
||||
array_list_t *path,
|
||||
const wchar_t *short_opt,
|
||||
array_list_t *gnu_opt,
|
||||
array_list_t *old_opt )
|
||||
{
|
||||
|
||||
int i;
|
||||
|
||||
for( i=0; i<al_get_count( cmd ); i++ )
|
||||
{
|
||||
builtin_complete_remove2( (wchar_t *)al_get( cmd, i ),
|
||||
COMMAND,
|
||||
short_opt,
|
||||
gnu_opt,
|
||||
old_opt );
|
||||
}
|
||||
|
||||
for( i=0; i<al_get_count( path ); i++ )
|
||||
{
|
||||
builtin_complete_remove2( (wchar_t *)al_get( path, i ),
|
||||
PATH,
|
||||
short_opt,
|
||||
gnu_opt,
|
||||
old_opt );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
const wchar_t *builtin_complete_get_temporary_buffer()
|
||||
{
|
||||
return temporary_buffer;
|
||||
}
|
||||
|
||||
int builtin_complete( wchar_t **argv )
|
||||
{
|
||||
int res=0;
|
||||
int argc=0;
|
||||
int result_mode=SHARED;
|
||||
int remove = 0;
|
||||
int authorative = 1;
|
||||
|
||||
string_buffer_t short_opt;
|
||||
array_list_t gnu_opt, old_opt;
|
||||
wchar_t *comp=L"", *desc=L"", *condition=L"";
|
||||
|
||||
wchar_t *do_complete = 0;
|
||||
|
||||
array_list_t cmd;
|
||||
array_list_t path;
|
||||
|
||||
static int recursion_level=0;
|
||||
|
||||
if( !is_interactive_session )
|
||||
{
|
||||
debug( 1, _(L"%ls: Command only available in interactive sessions"), argv[0] );
|
||||
}
|
||||
|
||||
al_init( &cmd );
|
||||
al_init( &path );
|
||||
sb_init( &short_opt );
|
||||
al_init( &gnu_opt );
|
||||
al_init( &old_opt );
|
||||
|
||||
argc = builtin_count_args( argv );
|
||||
|
||||
woptind=0;
|
||||
|
||||
while( res == 0 )
|
||||
{
|
||||
const static struct woption
|
||||
long_options[] =
|
||||
{
|
||||
{
|
||||
L"exclusive", no_argument, 0, 'x'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"no-files", no_argument, 0, 'f'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"require-parameter", no_argument, 0, 'r'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"path", required_argument, 0, 'p'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"command", required_argument, 0, 'c'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"short-option", required_argument, 0, 's'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"long-option", required_argument, 0, 'l'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"old-option", required_argument, 0, 'o'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"description", required_argument, 0, 'd'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"arguments", required_argument, 0, 'a'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"erase", no_argument, 0, 'e'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"unauthorative", no_argument, 0, 'u'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"condition", required_argument, 0, 'n'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"do-complete", required_argument, 0, 'C'
|
||||
}
|
||||
,
|
||||
{
|
||||
0, 0, 0, 0
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
int opt_index = 0;
|
||||
|
||||
int opt = wgetopt_long( argc,
|
||||
argv,
|
||||
L"a:c:p:s:l:o:d:frxeun:C:",
|
||||
long_options,
|
||||
&opt_index );
|
||||
if( opt == -1 )
|
||||
break;
|
||||
|
||||
switch( opt )
|
||||
{
|
||||
case 0:
|
||||
if(long_options[opt_index].flag != 0)
|
||||
break;
|
||||
sb_printf( sb_err,
|
||||
BUILTIN_ERR_UNKNOWN,
|
||||
argv[0],
|
||||
long_options[opt_index].name );
|
||||
sb_append( sb_err,
|
||||
parser_current_line() );
|
||||
|
||||
// builtin_print_help( argv[0], sb_err );
|
||||
|
||||
|
||||
res = 1;
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
result_mode |= EXCLUSIVE;
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
result_mode |= NO_FILES;
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
result_mode |= NO_COMMON;
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
al_push( &cmd, unescape( woptarg, 1));
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
al_push( &cmd, unescape( woptarg, 1) );
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
desc = woptarg;
|
||||
break;
|
||||
|
||||
case 'u':
|
||||
authorative=0;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
sb_append( &short_opt, woptarg );
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
al_push( &gnu_opt, woptarg );
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
al_push( &old_opt, woptarg );
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
comp = woptarg;
|
||||
break;
|
||||
|
||||
case 'e':
|
||||
remove = 1;
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
condition = woptarg;
|
||||
break;
|
||||
|
||||
case 'C':
|
||||
do_complete = woptarg?woptarg:reader_get_buffer();
|
||||
break;
|
||||
|
||||
case '?':
|
||||
sb_append( sb_err,
|
||||
parser_current_line() );
|
||||
// builtin_print_help( argv[0], sb_err );
|
||||
|
||||
res = 1;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if( !res )
|
||||
{
|
||||
if( do_complete )
|
||||
{
|
||||
array_list_t comp;
|
||||
int i;
|
||||
|
||||
const wchar_t *prev_temporary_buffer = temporary_buffer;
|
||||
temporary_buffer = do_complete;
|
||||
|
||||
if( recursion_level < 1 )
|
||||
{
|
||||
recursion_level++;
|
||||
|
||||
al_init( &comp );
|
||||
|
||||
complete( do_complete, &comp );
|
||||
|
||||
for( i=0; i<al_get_count( &comp ); i++ )
|
||||
{
|
||||
wchar_t *next = (wchar_t *)al_get( &comp, i );
|
||||
wchar_t *sep = wcschr( next, COMPLETE_SEP );
|
||||
if( sep )
|
||||
*sep = L'\t';
|
||||
sb_printf( sb_out, L"%ls\n", next );
|
||||
}
|
||||
|
||||
al_foreach( &comp, (void (*)(const void *))&free );
|
||||
al_destroy( &comp );
|
||||
recursion_level--;
|
||||
}
|
||||
|
||||
temporary_buffer = prev_temporary_buffer;
|
||||
|
||||
}
|
||||
else if( woptind != argc )
|
||||
{
|
||||
sb_printf( sb_err,
|
||||
_( L"%ls: Too many arguments\n" ),
|
||||
argv[0] );
|
||||
sb_append( sb_err,
|
||||
parser_current_line() );
|
||||
// builtin_print_help( argv[0], sb_err );
|
||||
|
||||
res = 1;
|
||||
}
|
||||
else if( (al_get_count( &cmd) == 0 ) && (al_get_count( &path) == 0 ) )
|
||||
{
|
||||
/* No arguments specified, meaning we print the definitions of
|
||||
* all specified completions to stdout.*/
|
||||
complete_print( sb_out );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( remove )
|
||||
{
|
||||
builtin_complete_remove( &cmd,
|
||||
&path,
|
||||
(wchar_t *)short_opt.buff,
|
||||
&gnu_opt,
|
||||
&old_opt );
|
||||
}
|
||||
else
|
||||
{
|
||||
builtin_complete_add( &cmd,
|
||||
&path,
|
||||
(wchar_t *)short_opt.buff,
|
||||
&gnu_opt,
|
||||
&old_opt,
|
||||
result_mode,
|
||||
authorative,
|
||||
condition,
|
||||
comp,
|
||||
desc );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
al_foreach( &cmd, (void (*)(const void *))&free );
|
||||
al_foreach( &path, (void (*)(const void *))&free );
|
||||
|
||||
al_destroy( &cmd );
|
||||
al_destroy( &path );
|
||||
sb_destroy( &short_opt );
|
||||
al_destroy( &gnu_opt );
|
||||
al_destroy( &old_opt );
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <stdio.h>
|
||||
#include <strings.h>
|
||||
#include <wchar.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "util.h"
|
||||
|
||||
@@ -13,6 +13,7 @@ Functions used for implementing the set builtin.
|
||||
|
||||
#include "config.h"
|
||||
#include "util.h"
|
||||
#include "wutil.h"
|
||||
#include "builtin.h"
|
||||
#include "env.h"
|
||||
#include "expand.h"
|
||||
@@ -20,6 +21,7 @@ Functions used for implementing the set builtin.
|
||||
#include "wgetopt.h"
|
||||
#include "proc.h"
|
||||
#include "parser.h"
|
||||
#include "translate.h"
|
||||
|
||||
/**
|
||||
Extract the name from a destination argument of the form name[index1 index2...]
|
||||
@@ -40,10 +42,8 @@ static int parse_fill_name( string_buffer_t *name,
|
||||
|
||||
if (*src != L'[' && *src != L'\0')
|
||||
{
|
||||
|
||||
sb_append(sb_err, L"set: Invalid character in variable name: ");
|
||||
sb_append_char(sb_err, *src);
|
||||
sb_append2(sb_err, L"\n", parser_current_line(), L"\n", (void *)0 );
|
||||
sb_printf( sb_err, BUILTIN_ERR_VARCHAR, L"set", *src );
|
||||
sb_append2(sb_err, parser_current_line(), L"\n", (void *)0 );
|
||||
// builtin_print_help( L"set", sb_err );
|
||||
|
||||
return -1;
|
||||
@@ -83,7 +83,7 @@ static int parse_fill_indexes( array_list_t *indexes,
|
||||
return -1;
|
||||
}
|
||||
|
||||
while (iswblank(*src))
|
||||
while (iswspace(*src))
|
||||
{
|
||||
src++;
|
||||
}
|
||||
@@ -94,9 +94,7 @@ static int parse_fill_indexes( array_list_t *indexes,
|
||||
long l_ind = wcstol(src, &end, 10);
|
||||
if (end == src)
|
||||
{
|
||||
wchar_t sbuf[256];
|
||||
swprintf(sbuf, 255, L"Invalid index starting at %ls\n", src);
|
||||
sb_append(sb_err, sbuf);
|
||||
sb_printf(sb_err, _(L"%ls: Invalid index starting at '%ls'\n"), L"set", src);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -105,7 +103,7 @@ static int parse_fill_indexes( array_list_t *indexes,
|
||||
al_push(indexes, ind);
|
||||
src = end;
|
||||
count++;
|
||||
while (iswblank(*src)) src++;
|
||||
while (iswspace(*src)) src++;
|
||||
}
|
||||
|
||||
return count;
|
||||
@@ -292,7 +290,7 @@ int builtin_set( wchar_t **argv )
|
||||
}
|
||||
;
|
||||
|
||||
wchar_t short_options[] = L"xglenuUq";
|
||||
wchar_t short_options[] = L"+xglenuUq";
|
||||
|
||||
int argc = builtin_count_args(argv);
|
||||
|
||||
@@ -364,13 +362,11 @@ int builtin_set( wchar_t **argv )
|
||||
|
||||
if( query && (erase || list || global || local || universal || export || unexport ) )
|
||||
{
|
||||
sb_append2(sb_err,
|
||||
sb_printf(sb_err,
|
||||
BUILTIN_ERR_COMBO2,
|
||||
argv[0],
|
||||
BUILTIN_ERR_COMBO,
|
||||
L"\n",
|
||||
parser_current_line(),
|
||||
L"\n",
|
||||
(void *)0);
|
||||
parser_current_line() );
|
||||
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
return 1;
|
||||
}
|
||||
@@ -379,13 +375,11 @@ int builtin_set( wchar_t **argv )
|
||||
/* Check operation and modifiers sanity */
|
||||
if( erase && list )
|
||||
{
|
||||
sb_append2(sb_err,
|
||||
sb_printf(sb_err,
|
||||
BUILTIN_ERR_COMBO2,
|
||||
argv[0],
|
||||
BUILTIN_ERR_COMBO,
|
||||
L"\n",
|
||||
parser_current_line(),
|
||||
L"\n",
|
||||
(void *)0);
|
||||
parser_current_line() );
|
||||
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
return 1;
|
||||
}
|
||||
@@ -393,9 +387,8 @@ int builtin_set( wchar_t **argv )
|
||||
if( local + global + universal > 1 )
|
||||
{
|
||||
sb_printf( sb_err,
|
||||
L"%ls%ls\n%ls\n",
|
||||
argv[0],
|
||||
BUILTIN_ERR_GLOCAL,
|
||||
argv[0],
|
||||
parser_current_line() );
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
return 1;
|
||||
@@ -403,13 +396,10 @@ int builtin_set( wchar_t **argv )
|
||||
|
||||
if( export && unexport )
|
||||
{
|
||||
sb_append2(sb_err,
|
||||
argv[0],
|
||||
sb_printf( sb_err,
|
||||
BUILTIN_ERR_EXPUNEXP,
|
||||
L"\n",
|
||||
parser_current_line(),
|
||||
L"\n",
|
||||
(void *)0);
|
||||
argv[0],
|
||||
parser_current_line() );
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
return 1;
|
||||
}
|
||||
@@ -435,6 +425,13 @@ int builtin_set( wchar_t **argv )
|
||||
{
|
||||
dest = wcsdup(argv[woptind++]);
|
||||
//fwprintf(stderr, L"Dest: %ls\n", dest);
|
||||
|
||||
if( !wcslen( dest ) )
|
||||
{
|
||||
free( dest );
|
||||
sb_printf( sb_err, BUILTIN_ERR_VARNAME_ZERO, argv[0] );
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Parse values */
|
||||
@@ -488,12 +485,11 @@ int builtin_set( wchar_t **argv )
|
||||
/* No arguments -- display name & value for all variables in scope */
|
||||
if( erase )
|
||||
{
|
||||
sb_append2( sb_err,
|
||||
argv[0],
|
||||
L": Erase needs a variable name\n",
|
||||
parser_current_line(),
|
||||
L"\n",
|
||||
(void *)0 );
|
||||
sb_printf( sb_err,
|
||||
_(L"%ls: Erase needs a variable name\n%ls\n"),
|
||||
argv[0],
|
||||
parser_current_line() );
|
||||
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
retcode = 1;
|
||||
}
|
||||
@@ -513,9 +509,6 @@ int builtin_set( wchar_t **argv )
|
||||
!erase &&
|
||||
!list )
|
||||
{
|
||||
/*
|
||||
Only update the variable scope
|
||||
*/
|
||||
env_set( name, 0, scope );
|
||||
finished = 1;
|
||||
}
|
||||
@@ -526,12 +519,11 @@ int builtin_set( wchar_t **argv )
|
||||
/* There are some arguments, we have at least a variable name */
|
||||
if( erase && al_get_count(&values) != 0 )
|
||||
{
|
||||
sb_append2( sb_err,
|
||||
argv[0],
|
||||
L": Values cannot be specfied with erase\n",
|
||||
parser_current_line(),
|
||||
L"\n",
|
||||
(void *)0 );
|
||||
sb_printf( sb_err,
|
||||
_(L"%ls: Values cannot be specfied with erase\n%ls\n"),
|
||||
argv[0],
|
||||
parser_current_line() );
|
||||
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
retcode = 1;
|
||||
}
|
||||
|
||||
129
builtin_ulimit.c
129
builtin_ulimit.c
@@ -1,6 +1,6 @@
|
||||
/** \file builtin_commandline.c Functions defining the commandline builtin
|
||||
/** \file builtin_ulimit.c Functions defining the ulimit builtin
|
||||
|
||||
Functions used for implementing the commandline builtin.
|
||||
Functions used for implementing the ulimit builtin.
|
||||
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
@@ -17,77 +17,111 @@ Functions used for implementing the commandline builtin.
|
||||
#include "builtin.h"
|
||||
#include "common.h"
|
||||
#include "wgetopt.h"
|
||||
#include "translate.h"
|
||||
|
||||
/**
|
||||
Struct describing a resource limit
|
||||
*/
|
||||
struct resource_t
|
||||
{
|
||||
/**
|
||||
Resource id
|
||||
*/
|
||||
int resource;
|
||||
/**
|
||||
Description of resource
|
||||
*/
|
||||
const wchar_t *desc;
|
||||
/**
|
||||
Switch used on commandline to specify resource
|
||||
*/
|
||||
wchar_t switch_char;
|
||||
/**
|
||||
The implicit multiplier used when setting getting values
|
||||
*/
|
||||
int multiplier;
|
||||
}
|
||||
;
|
||||
|
||||
/**
|
||||
Array of resource_t structs, describing all known resource types.
|
||||
*/
|
||||
const static struct resource_t resource_arr[] =
|
||||
{
|
||||
{
|
||||
RLIMIT_CORE, L"Maximum size of core files created", L'c'
|
||||
RLIMIT_CORE, L"Maximum size of core files created", L'c', 1024
|
||||
}
|
||||
,
|
||||
{
|
||||
RLIMIT_DATA, L"Maximum size of a process’s data segment", L'd'
|
||||
RLIMIT_DATA, L"Maximum size of a process’s data segment", L'd', 1024
|
||||
}
|
||||
,
|
||||
{
|
||||
RLIMIT_FSIZE, L"Maximum size of files created by the shell", L'f'
|
||||
RLIMIT_FSIZE, L"Maximum size of files created by the shell", L'f', 1024
|
||||
}
|
||||
,
|
||||
#if HAVE_RLIMIT_MEMLOCK
|
||||
{
|
||||
RLIMIT_MEMLOCK, L"Maximum size that may be locked into memory", L'l', 1024
|
||||
}
|
||||
,
|
||||
#endif
|
||||
#if HAVE_RLIMIT_RSS
|
||||
{
|
||||
RLIMIT_RSS, L"Maximum resident set size", L'm', 1024
|
||||
}
|
||||
,
|
||||
#endif
|
||||
{
|
||||
RLIMIT_NOFILE, L"Maximum number of open file descriptors", L'n', 1
|
||||
}
|
||||
,
|
||||
{
|
||||
RLIMIT_MEMLOCK, L"Maximum size that may be locked into memory", L'l'
|
||||
RLIMIT_STACK, L"Maximum stack size", L's', 1024
|
||||
}
|
||||
,
|
||||
{
|
||||
RLIMIT_RSS, L"Maximum resident set size", L'm'
|
||||
RLIMIT_CPU, L"Maximum amount of cpu time in seconds", L't', 1
|
||||
}
|
||||
,
|
||||
#if HAVE_RLIMIT_NPROC
|
||||
{
|
||||
RLIMIT_NOFILE, L"Maximum number of open file descriptors", L'n'
|
||||
}
|
||||
,
|
||||
{
|
||||
RLIMIT_STACK, L"Maximum stack size", L's'
|
||||
}
|
||||
,
|
||||
{
|
||||
RLIMIT_CPU, L"Maximum amount of cpu time in seconds", L't'
|
||||
}
|
||||
,
|
||||
{
|
||||
RLIMIT_NPROC, L"Maximum number of processes available to a single user", L'u'
|
||||
RLIMIT_NPROC, L"Maximum number of processes available to a single user", L'u', 1
|
||||
}
|
||||
,
|
||||
#endif
|
||||
#if HAVE_RLIMIT_AS
|
||||
{
|
||||
RLIMIT_AS, L"Maximum amount of virtual memory available to the shell", L'v'
|
||||
RLIMIT_AS, L"Maximum amount of virtual memory available to the shell", L'v', 1024
|
||||
}
|
||||
,
|
||||
#endif
|
||||
{
|
||||
0, 0
|
||||
0, 0, 0, 0
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
/**
|
||||
Get the implicit multiplication factor for the specified resource limit
|
||||
*/
|
||||
static int get_multiplier( int what )
|
||||
{
|
||||
if( ( what == RLIMIT_NPROC ) ||
|
||||
( what == RLIMIT_NOFILE ) ||
|
||||
( what == RLIMIT_CPU ) )
|
||||
int i;
|
||||
|
||||
for( i=0; resource_arr[i].desc; i++ )
|
||||
{
|
||||
return 1;
|
||||
if( resource_arr[i].resource == what )
|
||||
{
|
||||
return resource_arr[i].multiplier;
|
||||
}
|
||||
}
|
||||
return 1024;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Return the value for the specified resource limit
|
||||
*/
|
||||
static rlim_t get( int resource, int hard )
|
||||
{
|
||||
struct rlimit ls;
|
||||
@@ -97,6 +131,9 @@ static rlim_t get( int resource, int hard )
|
||||
return hard ? ls.rlim_max:ls.rlim_cur;
|
||||
}
|
||||
|
||||
/**
|
||||
Print the value of the specified resource limit
|
||||
*/
|
||||
static void print( int resource, int hard )
|
||||
{
|
||||
rlim_t l = get( resource, hard );
|
||||
@@ -108,7 +145,9 @@ static void print( int resource, int hard )
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Print values of all resource limits
|
||||
*/
|
||||
static void print_all( int hard )
|
||||
{
|
||||
int i;
|
||||
@@ -142,6 +181,9 @@ static void print_all( int hard )
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Returns the description for the specified resource limit
|
||||
*/
|
||||
static const wchar_t *get_desc( int what )
|
||||
{
|
||||
int i;
|
||||
@@ -156,7 +198,9 @@ static const wchar_t *get_desc( int what )
|
||||
return L"Not a resource";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Set the new value of the specified resource limit
|
||||
*/
|
||||
static int set( int resource, int hard, int soft, rlim_t value )
|
||||
{
|
||||
struct rlimit ls;
|
||||
@@ -194,6 +238,9 @@ static int set( int resource, int hard, int soft, rlim_t value )
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
Set all resource limits
|
||||
*/
|
||||
static int set_all( int hard, int soft, rlim_t value )
|
||||
{
|
||||
int i;
|
||||
@@ -298,13 +345,10 @@ int builtin_ulimit( wchar_t ** argv )
|
||||
case 0:
|
||||
if(long_options[opt_index].flag != 0)
|
||||
break;
|
||||
sb_append2( sb_err,
|
||||
argv[0],
|
||||
BUILTIN_ERR_UNKNOWN,
|
||||
L" ",
|
||||
long_options[opt_index].name,
|
||||
L"\n",
|
||||
(void *)0 );
|
||||
sb_printf( sb_err,
|
||||
BUILTIN_ERR_UNKNOWN,
|
||||
argv[0],
|
||||
long_options[opt_index].name );
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
|
||||
return 1;
|
||||
@@ -332,14 +376,17 @@ int builtin_ulimit( wchar_t ** argv )
|
||||
case L'f':
|
||||
what=RLIMIT_FSIZE;
|
||||
break;
|
||||
|
||||
#if HAVE_RLIMIT_MEMLOCK
|
||||
case L'l':
|
||||
what=RLIMIT_MEMLOCK;
|
||||
break;
|
||||
|
||||
#endif
|
||||
|
||||
#if HAVE_RLIMIT_RSS
|
||||
case L'm':
|
||||
what=RLIMIT_RSS;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case L'n':
|
||||
what=RLIMIT_NOFILE;
|
||||
@@ -352,10 +399,12 @@ int builtin_ulimit( wchar_t ** argv )
|
||||
case L't':
|
||||
what=RLIMIT_CPU;
|
||||
break;
|
||||
|
||||
|
||||
#if HAVE_RLIMIT_NPROC
|
||||
case L'u':
|
||||
what=RLIMIT_NPROC;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if HAVE_RLIMIT_AS
|
||||
case L'v':
|
||||
|
||||
184
common.h
184
common.h
@@ -3,15 +3,23 @@
|
||||
*/
|
||||
|
||||
#ifndef FISH_COMMON_H
|
||||
/**
|
||||
Header guard
|
||||
*/
|
||||
#define FISH_COMMON_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
#include <termios.h>
|
||||
|
||||
#include "util.h"
|
||||
|
||||
/**
|
||||
Under curses, tputs expects an int (*func)(char) as its last parameter, but in ncurses, tputs expects a int (*func)(int) as its last parameter. tputs_arg_t is defined to always be what tputs expects. Hopefully.
|
||||
Under curses, tputs expects an int (*func)(char) as its last
|
||||
parameter, but in ncurses, tputs expects a int (*func)(int) as its
|
||||
last parameter. tputs_arg_t is defined to always be what tputs
|
||||
expects. Hopefully.
|
||||
*/
|
||||
|
||||
#ifdef NCURSES_VERSION
|
||||
@@ -21,7 +29,7 @@ typedef char tputs_arg_t;
|
||||
#endif
|
||||
|
||||
/**
|
||||
Maximum number of bytes in a utf-8 character
|
||||
Maximum number of bytes used by a single utf-8 character
|
||||
*/
|
||||
#define MAX_UTF8_BYTES 6
|
||||
|
||||
@@ -36,11 +44,19 @@ typedef char tputs_arg_t;
|
||||
*/
|
||||
#define FISH_COLOR_RESET -2
|
||||
|
||||
/** Save the shell mode on startup so we can restore them on exit */
|
||||
/**
|
||||
This is in the unicode private use area.
|
||||
*/
|
||||
#define ENCODE_DIRECT_BASE 0xf100
|
||||
|
||||
/**
|
||||
Save the shell mode on startup so we can restore them on exit
|
||||
*/
|
||||
extern struct termios shell_modes;
|
||||
|
||||
/**
|
||||
The character to use where the text has been truncated. Is an ellipsis on unicode system and a $ on other systems.
|
||||
The character to use where the text has been truncated. Is an
|
||||
ellipsis on unicode system and a $ on other systems.
|
||||
*/
|
||||
extern wchar_t ellipsis_char;
|
||||
|
||||
@@ -64,8 +80,13 @@ extern char *profile;
|
||||
debug function.
|
||||
*/
|
||||
extern wchar_t *program_name;
|
||||
|
||||
/**
|
||||
Take an array_list_t containing wide strings and converts them to a wchar_t **.
|
||||
Take an array_list_t containing wide strings and converts them to a
|
||||
single null-terminated wchar_t **. The array is allocated using
|
||||
halloc, and uses the \c context parameter as context. If \c context
|
||||
is not noll, all elements of the \c array_list_t are also
|
||||
registered to \c context using \c halloc_register().
|
||||
*/
|
||||
wchar_t **list_to_char_arr( array_list_t *l );
|
||||
|
||||
@@ -83,22 +104,29 @@ wchar_t **list_to_char_arr( array_list_t *l );
|
||||
int fgetws2( wchar_t **buff, int *len, FILE *f );
|
||||
|
||||
/**
|
||||
Sorts a list of wide strings according to the wcsfilecmp-function from the util library
|
||||
Sorts a list of wide strings according to the wcsfilecmp-function
|
||||
from the util library
|
||||
*/
|
||||
void sort_list( array_list_t *comp );
|
||||
|
||||
/**
|
||||
Returns a newly allocated wide character string equivalent of the specified multibyte character string
|
||||
Returns a newly allocated wide character string equivalent of the
|
||||
specified multibyte character string
|
||||
*/
|
||||
wchar_t *str2wcs( const char *in );
|
||||
wchar_t *str2wcs_internal( const char *in, wchar_t *out );
|
||||
|
||||
/**
|
||||
Returns a newly allocated multibyte character string equivalent of the specified wide character string
|
||||
Returns a newly allocated multibyte character string equivalent of
|
||||
the specified wide character string
|
||||
*/
|
||||
char *wcs2str( const wchar_t *in );
|
||||
|
||||
char *wcs2str_internal( const wchar_t *in, char *out );
|
||||
|
||||
/**
|
||||
Returns a newly allocated wide character string array equivalent of the specified multibyte character string array
|
||||
Returns a newly allocated wide character string array equivalent of
|
||||
the specified multibyte character string array
|
||||
*/
|
||||
char **wcsv2strv( const wchar_t **in );
|
||||
|
||||
@@ -108,61 +136,40 @@ char **wcsv2strv( const wchar_t **in );
|
||||
wchar_t **strv2wcsv( const char **in );
|
||||
|
||||
/**
|
||||
Returns a newly allocated concatenation of the specified wide character strings
|
||||
Returns a newly allocated concatenation of the specified wide
|
||||
character strings
|
||||
*/
|
||||
wchar_t *wcsdupcat( const wchar_t *a, const wchar_t *b );
|
||||
|
||||
/**
|
||||
Returns a newly allocated concatenation of the specified wide character strings. The last argument must be a null pointer.
|
||||
Returns a newly allocated concatenation of the specified wide
|
||||
character strings. The last argument must be a null pointer.
|
||||
*/
|
||||
wchar_t *wcsdupcat2( const wchar_t *a, ... );
|
||||
|
||||
/**
|
||||
Returns a newly allocated wide character string wich is a copy of the string in, but of length c or shorter. The returned string is always null terminated, and the null is not included in the string length.
|
||||
*/
|
||||
wchar_t *wcsndup( const wchar_t *in, int c );
|
||||
|
||||
/**
|
||||
Converts from wide char to digit in the specified base. If d is not
|
||||
a valid digit in the specified base, return -1.
|
||||
*/
|
||||
long convert_digit( wchar_t d, int base );
|
||||
Appends src to string dst of size siz (unlike wcsncat, siz is the
|
||||
full size of dst, not space left). At most siz-1 characters will be
|
||||
copied. Always NUL terminates (unless siz <= wcslen(dst)). Returns
|
||||
wcslen(src) + MIN(siz, wcslen(initial dst)). If retval >= siz,
|
||||
truncation occurred.
|
||||
|
||||
This is the OpenBSD strlcat function, modified for wide characters,
|
||||
and renamed to reflect this change.
|
||||
|
||||
*/
|
||||
size_t wcslcat( wchar_t *dst, const wchar_t *src, size_t siz );
|
||||
|
||||
/**
|
||||
Convert a wide character string to a number in the specified
|
||||
base. This functions is the wide character string equivalent of
|
||||
strtol. For bases of 10 or lower, 0..9 are used to represent
|
||||
numbers. For bases below 36, a-z and A-Z are used to represent
|
||||
numbers higher than 9. Higher bases than 36 are not supported.
|
||||
Copy src to string dst of size siz. At most siz-1 characters will
|
||||
be copied. Always NUL terminates (unless siz == 0). Returns
|
||||
wcslen(src); if retval >= siz, truncation occurred.
|
||||
|
||||
This is the OpenBSD strlcpy function, modified for wide characters,
|
||||
and renamed to reflect this change.
|
||||
*/
|
||||
long wcstol(const wchar_t *nptr,
|
||||
wchar_t **endptr,
|
||||
int base);
|
||||
|
||||
size_t
|
||||
wcslcat(wchar_t *dst, const wchar_t *src, size_t siz);
|
||||
|
||||
size_t
|
||||
wcslcpy(wchar_t *dst, const wchar_t *src, size_t siz);
|
||||
|
||||
/**
|
||||
Create a dublicate string. Wide string version of strdup.
|
||||
*/
|
||||
wchar_t *wcsdup(const wchar_t *in);
|
||||
|
||||
/**
|
||||
Case insensitive string compare function. Wide string version of
|
||||
strcasecmp.
|
||||
|
||||
This implementation of wcscasecmp does not take into account
|
||||
esoteric locales where uppercase and lowercase do not cleanly
|
||||
transform between each other. Hopefully this should be fine since
|
||||
fish only uses this function with one of the strings supplied by
|
||||
fish and guaranteed to be a sane, english word.
|
||||
*/
|
||||
int wcscasecmp( const wchar_t *a, const wchar_t *b );
|
||||
int wcsncasecmp( const wchar_t *a, const wchar_t *b, int count );
|
||||
size_t wcslcpy( wchar_t *dst, const wchar_t *src, size_t siz );
|
||||
|
||||
/**
|
||||
Test if the given string is a valid variable name
|
||||
@@ -170,13 +177,6 @@ int wcsncasecmp( const wchar_t *a, const wchar_t *b, int count );
|
||||
|
||||
int wcsvarname( wchar_t *str );
|
||||
|
||||
/**
|
||||
The prototype for this function is missing in some libc
|
||||
implementations. Fish has a fallback implementation in case the
|
||||
implementation is missing altogether.
|
||||
*/
|
||||
int wcwidth( wchar_t c );
|
||||
|
||||
|
||||
/**
|
||||
A wcswidth workalike. Fish uses this since the regular wcswidth seems flaky.
|
||||
@@ -184,9 +184,13 @@ int wcwidth( wchar_t c );
|
||||
int my_wcswidth( const wchar_t *c );
|
||||
|
||||
/**
|
||||
This functions returns the end of a quoted substring. It can handle nested single and double quotes.
|
||||
This functions returns the end of the quoted substring beginning at
|
||||
\c in. The type of quoting character is detemrined by examining \c
|
||||
in. Returns 0 on error.
|
||||
|
||||
\param in the position of the opening quote
|
||||
*/
|
||||
wchar_t *quote_end( const wchar_t *in );
|
||||
const wchar_t *quote_end( const wchar_t *in );
|
||||
|
||||
/**
|
||||
A call to this function will reset the error counter. Some
|
||||
@@ -199,9 +203,12 @@ wchar_t *quote_end( const wchar_t *in );
|
||||
void error_reset();
|
||||
|
||||
/**
|
||||
Set the locale, also change the ellipsis character
|
||||
This function behaves exactly like a wide character equivalent of
|
||||
the C function setlocale, except that it will also try to detect if
|
||||
the user is using a Unicode character set, and if so, use the
|
||||
unicode ellipsis character as ellipsis, instead of '$'.
|
||||
*/
|
||||
void fish_setlocale(int category, const wchar_t *locale);
|
||||
const wchar_t *wsetlocale( int category, const wchar_t *locale );
|
||||
|
||||
/**
|
||||
Checks if \c needle is included in the list of strings specified
|
||||
@@ -217,16 +224,17 @@ int contains_str( const wchar_t *needle, ... );
|
||||
int read_blocked(int fd, void *buf, size_t count);
|
||||
|
||||
/**
|
||||
This is for writing process notification messages. Has to write to
|
||||
stdout, so clr_eol and such functions will work correctly. Not an
|
||||
issue since this function is only used in interactive mode anyway.
|
||||
Exit program at once, leaving an error message about running out of memory
|
||||
*/
|
||||
int writeb( tputs_arg_t b );
|
||||
|
||||
void die_mem();
|
||||
|
||||
/**
|
||||
Clean up
|
||||
Create global_context using halloc
|
||||
*/
|
||||
void common_init();
|
||||
|
||||
/**
|
||||
Free global_context using halloc_free
|
||||
*/
|
||||
void common_destroy();
|
||||
|
||||
@@ -236,7 +244,7 @@ void common_destroy();
|
||||
program_name, followed by a colon and a whitespace.
|
||||
|
||||
\param level the priority of the message. Lower number means higher priority. Messages with a priority_number higher than \c debug_level will be ignored..
|
||||
\param the message format string.
|
||||
\param msg the message format string.
|
||||
|
||||
Example:
|
||||
|
||||
@@ -244,7 +252,7 @@ void common_destroy();
|
||||
|
||||
will print the string 'fish: Pi = 3.141', given that debug_level is 1 or higher, and that program_name is 'fish'.
|
||||
*/
|
||||
void debug( int level, wchar_t *msg, ... );
|
||||
void debug( int level, const wchar_t *msg, ... );
|
||||
|
||||
/**
|
||||
Replace special characters with backslash escape sequences. Newline is
|
||||
@@ -255,14 +263,31 @@ void debug( int level, wchar_t *msg, ... );
|
||||
\return The escaped string, or 0 if there is not enough memory
|
||||
*/
|
||||
|
||||
wchar_t *escape( const wchar_t *in,
|
||||
int escape_all );
|
||||
wchar_t *escape( const wchar_t *in, int escape_all );
|
||||
|
||||
wchar_t *unescape( const wchar_t * in, int escape_special );
|
||||
/**
|
||||
Expand backslashed escapes and substitute them with their unescaped
|
||||
counterparts. Also optionally change the wildcards, the tilde
|
||||
character and a few more into constants which are defined in a
|
||||
private use area of Unicode. This assumes wchar_t is a unicode
|
||||
character set.
|
||||
|
||||
void block();
|
||||
void unblock();
|
||||
The result must be free()d. The original string is not modified. If
|
||||
an invalid sequence is specified, 0 is returned.
|
||||
|
||||
*/
|
||||
wchar_t *unescape( const wchar_t * in,
|
||||
int escape_special );
|
||||
|
||||
/**
|
||||
Attempt to acquire a lock based on a lockfile, waiting LOCKPOLLINTERVAL
|
||||
milliseconds between polls and timing out after timeout seconds,
|
||||
thereafter forcibly attempting to obtain the lock if force is non-zero.
|
||||
Returns 1 on success, 0 on failure.
|
||||
To release the lock the lockfile must be unlinked.
|
||||
A unique temporary file named by appending characters to the lockfile name
|
||||
is used; any pre-existing file of the same name is subject to deletion.
|
||||
*/
|
||||
int acquire_lock_file( const char *lockfile, const int timeout, int force );
|
||||
|
||||
/**
|
||||
@@ -282,12 +307,19 @@ int common_get_width();
|
||||
*/
|
||||
int common_get_height();
|
||||
|
||||
/*
|
||||
/**
|
||||
Handle a window change event by looking up the new window size and
|
||||
saving it in an internal variable used by common_get_wisth and
|
||||
common_get_height().
|
||||
*/
|
||||
void common_handle_winch( int signal );
|
||||
|
||||
/**
|
||||
Write paragraph of output to screen. Ignore newlines in message and
|
||||
perform internal line-breaking.
|
||||
*/
|
||||
void write_screen( const wchar_t *msg );
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
1117
complete.c
1117
complete.c
File diff suppressed because it is too large
Load Diff
@@ -5,6 +5,9 @@
|
||||
*/
|
||||
|
||||
#ifndef FISH_COMPLETE_H
|
||||
/**
|
||||
Header guard
|
||||
*/
|
||||
#define FISH_COMPLETE_H
|
||||
|
||||
#include <wchar.h>
|
||||
@@ -30,6 +33,8 @@
|
||||
/** Separateor between completion and description*/
|
||||
#define COMPLETE_SEP_STR L"\004"
|
||||
|
||||
#define COMPLETE_ITEM_SEP L'\uf500'
|
||||
|
||||
/**
|
||||
Character that separates the completion and description on programmable completions
|
||||
*/
|
||||
@@ -159,6 +164,6 @@ int complete_is_valid_argument( const wchar_t *str,
|
||||
\param cmd the command for which to load command-specific completions
|
||||
\param reload should the commands completions be reloaded, even if they where previously loaded. (This is set to true on actual completions, so that changed completion are updated in running shells)
|
||||
*/
|
||||
void complete_load( wchar_t *cmd, int reload );
|
||||
void complete_load( const wchar_t *cmd, int reload );
|
||||
|
||||
#endif
|
||||
|
||||
97
config.h.in
97
config.h.in
@@ -1,97 +0,0 @@
|
||||
/* config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* CPU type */
|
||||
#undef CPU
|
||||
|
||||
/* Documentation directory */
|
||||
#undef DOCDIR
|
||||
|
||||
/* Define to 1 if you have the `futimes' function. */
|
||||
#undef HAVE_FUTIMES
|
||||
|
||||
/* Define to 1 if you have the <getopt.h> header file. */
|
||||
#undef HAVE_GETOPT_H
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the `rt' library (-lrt). */
|
||||
#undef HAVE_LIBRT
|
||||
|
||||
/* Define to 1 if you have the `socket' library (-lsocket). */
|
||||
#undef HAVE_LIBSOCKET
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define to 1 if you have the <ncurses.h> header file. */
|
||||
#undef HAVE_NCURSES_H
|
||||
|
||||
/* Define to 1 if HAVE_RLIMIT_AS is defined in <sys/resource.h>. */
|
||||
#undef HAVE_RLIMIT_AS
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#undef HAVE_STDINT_H
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#undef HAVE_STRINGS_H
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#undef HAVE_STRING_H
|
||||
|
||||
/* Define to 1 if you have the <sys/resource.h> header file. */
|
||||
#undef HAVE_SYS_RESOURCE_H
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
/* Define to 1 if you have the <termio.h> header file. */
|
||||
#undef HAVE_TERMIO_H
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define to 1 if you have the `wcswidth' function. */
|
||||
#undef HAVE_WCSWIDTH
|
||||
|
||||
/* Define to 1 if you have the `wcwidth' function. */
|
||||
#undef HAVE_WCWIDTH
|
||||
|
||||
/* Define to 1 if you have the `wprintf' function. */
|
||||
#undef HAVE_WPRINTF
|
||||
|
||||
/* Define to 1 if you have the file `AC_File'. */
|
||||
#undef HAVE__PROC_SELF_STAT
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#undef PACKAGE_BUGREPORT
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#undef PACKAGE_NAME
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#undef PACKAGE_STRING
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#undef PACKAGE_TARNAME
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
/* Installation directory */
|
||||
#undef PREFIX
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* System configuration directory */
|
||||
#undef SYSCONFDIR
|
||||
|
||||
/* Evil kludge to get Power based machines to work */
|
||||
#undef TPUTS_KLUDGE
|
||||
210
configure.ac
210
configure.ac
@@ -1,22 +1,71 @@
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
AC_INIT(fish,1.16.0,axel@liljencrantz.se)
|
||||
AC_INIT(fish,1.21.0,fish-users@lists.sf.net)
|
||||
|
||||
AC_CANONICAL_TARGET
|
||||
for i in /usr/pkg /sw /opt /opt/local; do
|
||||
|
||||
if test $target_cpu = powerpc; then
|
||||
AC_DEFINE([TPUTS_KLUDGE],[1],[Evil kludge to get Power based machines to work])
|
||||
AC_MSG_CHECKING([for $i/include include directory])
|
||||
if test -d $i/include; then
|
||||
AC_MSG_RESULT(yes)
|
||||
CPPFLAGS="$CPPFLAGS -I$i/include/"
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([for $i/lib library directory])
|
||||
if test -d $i/lib; then
|
||||
AC_MSG_RESULT(yes)
|
||||
LDFLAGS="$LDFLAGS -L$i/lib/ -R$i/lib/"
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([for $i/bin command directory])
|
||||
if test -d $i/bin; then
|
||||
AC_MSG_RESULT(yes)
|
||||
optbindirs="$optbindirs $i/bin"
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
AC_SUBST( optbindirs, $optbindirs )
|
||||
|
||||
# If needed, run autoheader automatically
|
||||
AC_MSG_CHECKING([if autoheader needs to be run])
|
||||
if test ! -f ./config.h.in -o config.h.in -ot configure.ac; then
|
||||
AC_MSG_RESULT([yes])
|
||||
if which autoheader >/dev/null; then
|
||||
AC_MSG_NOTICE([running autoheader])
|
||||
autoheader
|
||||
else
|
||||
AC_MSG_ERROR( [cannot find the autoheader program in your path.
|
||||
This program is needed because the configure.ac file has been modified.
|
||||
Please install it and try again.])
|
||||
fi
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
|
||||
AC_DEFINE_UNQUOTED([CPU],[L"$target_cpu"],[CPU type])
|
||||
|
||||
# Tell autoconf to create config.h header
|
||||
AC_CONFIG_HEADERS(config.h)
|
||||
|
||||
# Checks for programs.
|
||||
# Set up various programs needed for install
|
||||
AC_PROG_CC
|
||||
AC_PROG_CPP
|
||||
AC_PROG_INSTALL
|
||||
#AC_ISC_POSIX
|
||||
#AC_PROG_MAKE_SET
|
||||
|
||||
# Check for doxygen, which is needed to build
|
||||
AC_CHECK_PROG( has_doxygen, [doxygen], "true")
|
||||
|
||||
if ! test $has_doxygen = "true"; then
|
||||
AC_MSG_ERROR( [cannot find the Doxygen program in your path.
|
||||
This program is needed to build fish.
|
||||
Please install it and try again.])
|
||||
fi
|
||||
|
||||
# Check for seq program. If missing, install fallback shellscript implementation
|
||||
AC_CHECK_PROG( SEQ_FALLBACK, seq, [ ], [seq])
|
||||
|
||||
# Optionally drop xsel
|
||||
AC_ARG_WITH( xsel,
|
||||
@@ -35,25 +84,26 @@ else
|
||||
AC_SUBST( XSEL_MAN_PATH,[ ])
|
||||
fi
|
||||
|
||||
# Test cpu for special handling of ppc
|
||||
AC_CANONICAL_TARGET
|
||||
|
||||
if test $target_cpu = powerpc; then
|
||||
AC_DEFINE([TPUTS_KLUDGE],[1],[Evil kludge to get Power based machines to work])
|
||||
fi
|
||||
|
||||
AC_DEFINE_UNQUOTED([CPU],[L"$target_cpu"],[CPU type])
|
||||
|
||||
|
||||
# Set up installation directories
|
||||
if [[ "$prefix" = NONE ]]; then
|
||||
AC_DEFINE_UNQUOTED( [PREFIX], L"/usr/local", [Installation directory])
|
||||
AC_DEFINE_UNQUOTED( [PREFIX], L"/usr/local", [Installation directory])
|
||||
AC_SUBST( PREFIX, /usr/local)
|
||||
AC_SUBST(sysconfdir,[/etc])
|
||||
export prefix=/usr/local
|
||||
else
|
||||
AC_DEFINE_UNQUOTED( [PREFIX], L"$prefix", [Installation directory])
|
||||
AC_SUBST( PREFIX, [$prefix])
|
||||
AC_SUBST(sysconfdir,[/etc])
|
||||
fi
|
||||
|
||||
if echo $prefix | grep \^$HOME >/dev/null; then
|
||||
AC_SUBST(sysconfdir,[$HOME/etc])
|
||||
AC_MSG_NOTICE(["Install in $HOME"])
|
||||
fi
|
||||
AC_SUBST(fishdir,[/fish.d])
|
||||
AC_SUBST(fishfile,[/fish])
|
||||
AC_SUBST(fishinputfile,[/fish_inputrc])
|
||||
|
||||
AC_ARG_VAR( [docdir], [Documentation direcotry] )
|
||||
|
||||
if test -z $docdir; then
|
||||
@@ -61,18 +111,18 @@ if test -z $docdir; then
|
||||
fi
|
||||
|
||||
AC_DEFINE_UNQUOTED( DOCDIR, [L"$(eval echo $docdir)"], [Documentation directory] )
|
||||
AC_DEFINE_UNQUOTED( SYSCONFDIR, [L"$sysconfdir"], [System configuration directory] )
|
||||
AC_DEFINE_UNQUOTED( SYSCONFDIR, [L"$(eval echo $sysconfdir)"], [System configuration directory] )
|
||||
AC_DEFINE_UNQUOTED( DATADIR, [L"$(eval echo $datadir)"], [System configuration directory] )
|
||||
AC_SUBST( SYSCONFDIR, ["$(eval echo $sysconfdir)"] )
|
||||
AC_SUBST( DATADIR, ["$(eval echo $datadir)"] )
|
||||
|
||||
# Set up locale directory
|
||||
AC_DEFINE_UNQUOTED( [LOCALEDIR], "$(eval echo $datadir)/locale", [Locale directory])
|
||||
AC_SUBST( [LOCALEDIR], [$datadir/locale])
|
||||
|
||||
# See if Linux procfs is present
|
||||
AC_CHECK_FILES([/proc/self/stat])
|
||||
|
||||
# See if NetBSD pkgsrc is installed
|
||||
AC_CHECK_FILE([/usr/pkg/lib],[AC_SUBST(LIBDIR,[-L/usr/pkg/lib\ -R/usr/pkg/lib])])
|
||||
AC_CHECK_FILE([/usr/pkg/include],[AC_SUBST(INCLUDEDIR,[-I/usr/pkg/include])])
|
||||
|
||||
AC_CHECK_FUNCS( [wprintf futimes wcwidth wcswidth] )
|
||||
AC_CHECK_HEADERS([getopt.h termio.h sys/resource.h])
|
||||
|
||||
# Check for RLIMIT_AS in sys/resource.h.
|
||||
AC_MSG_CHECKING([for RLIMIT_AS in sys/resource.h])
|
||||
AC_TRY_COMPILE([#include <sys/resource.h>],
|
||||
@@ -85,16 +135,106 @@ else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
# Check for RLIMIT_MEMLOCK in sys/resource.h.
|
||||
AC_MSG_CHECKING([for RLIMIT_MEMLOCK in sys/resource.h])
|
||||
AC_TRY_COMPILE([#include <sys/resource.h>],
|
||||
[int tmp; tmp=RLIMIT_MEMLOCK;], have_rlimit_as=yes, have_rlimit_as=no)
|
||||
if test "$have_rlimit_as" = yes; then
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE([HAVE_RLIMIT_MEMLOCK], [1],
|
||||
[Define to 1 if HAVE_RLIMIT_MEMLOCK is defined in <sys/resource.h>.])
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
# Check for RLIMIT_RSS in sys/resource.h.
|
||||
AC_MSG_CHECKING([for RLIMIT_RSS in sys/resource.h])
|
||||
AC_TRY_COMPILE([#include <sys/resource.h>],
|
||||
[int tmp; tmp=RLIMIT_RSS;], have_rlimit_as=yes, have_rlimit_as=no)
|
||||
if test "$have_rlimit_as" = yes; then
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE([HAVE_RLIMIT_RSS], [1],
|
||||
[Define to 1 if HAVE_RLIMIT_RSS is defined in <sys/resource.h>.])
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
|
||||
# Check for RLIMIT_NPROC in sys/resource.h.
|
||||
AC_MSG_CHECKING([for RLIMIT_NPROC in sys/resource.h])
|
||||
AC_TRY_COMPILE([#include <sys/resource.h>],
|
||||
[int tmp; tmp=RLIMIT_NPROC;], have_rlimit_as=yes, have_rlimit_as=no)
|
||||
if test "$have_rlimit_as" = yes; then
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE([HAVE_RLIMIT_NPROC], [1],
|
||||
[Define to 1 if HAVE_RLIMIT_NPROC is defined in <sys/resource.h>.])
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
# Check if realpath accepts null for its second argument
|
||||
AC_MSG_CHECKING([if realpath accepts null for its second argument])
|
||||
AC_RUN_IFELSE(
|
||||
[AC_LANG_PROGRAM([#include <limits.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>],
|
||||
[int status; char *res; res = realpath( "somefile", 0 ); status = !(res != 0 || errno == ENOENT); exit( status );])],
|
||||
[have_realpath_null=yes],
|
||||
[have_realpath_null=no] )
|
||||
|
||||
if test "$have_realpath_null" = yes; then
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE([HAVE_REALPATH_NULL], [1],
|
||||
[Define to 1 if realpath accepts null for its second argument.])
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
|
||||
# Check for libraries
|
||||
AC_CHECK_LIB(socket, connect)
|
||||
AC_CHECK_LIB(rt, nanosleep)
|
||||
AC_CHECK_LIB(intl, gettext)
|
||||
|
||||
# Check for various header files
|
||||
AC_CHECK_HEADERS([getopt.h termio.h sys/resource.h term.h ncurses/term.h libintl.h ncurses.h curses.h])
|
||||
|
||||
AC_CHECK_HEADER([regex.h],
|
||||
[AC_DEFINE([HAVE_REGEX_H], [1], [Define to 1 if you have the <regex.h> header file.])],
|
||||
[AC_MSG_ERROR([Could not find the header regex.h, needed to build fish])])
|
||||
|
||||
|
||||
# Check for various functions, and insert results into config.h
|
||||
AC_CHECK_FUNCS( wcsdup wcsndup wcslen wcscasecmp wcsncasecmp gettext fwprintf )
|
||||
AC_CHECK_FUNCS( futimes wcwidth wcswidth getopt_long wcstok fputwc fgetwc )
|
||||
AC_CHECK_FUNCS( wcstol dcgettext )
|
||||
|
||||
AC_DEFINE([HAVE_TRANSLATE_H], [1],
|
||||
[Define to 1 if the wgettext function should be used for translating strings.])
|
||||
|
||||
# Check again for gettext library, and insert results into the Makefile
|
||||
AC_CHECK_FUNC(gettext, AC_SUBST(HAVE_GETTEXT,1), AC_SUBST(HAVE_GETTEXT,0) )
|
||||
|
||||
# Check for _nl_msg_cat_cntr symbol
|
||||
AC_MSG_CHECKING([for _nl_msg_cat_cntr symbol])
|
||||
AC_TRY_LINK([#if HAVE_LIBINTL_H]
|
||||
[#include <libintl.h>]
|
||||
[#endif],
|
||||
[extern int _nl_msg_cat_cntr;]
|
||||
[int tmp = _nl_msg_cat_cntr; exit(tmp);], have__nl_msg_cat_cntr=yes, have__nl_msg_cat_cntr=no)
|
||||
if test "$have__nl_msg_cat_cntr" = yes; then
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE([HAVE__NL_MSG_CAT_CNTR], [1],
|
||||
[Define to 1 if the _nl_msg_cat_cntr symbol is exported.])
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
# Check if we have ncurses, and use it rather than curses if possible.
|
||||
AC_CHECK_HEADERS([ncurses.h],[AC_SUBST(CURSESLIB,[ncurses]) AC_DEFINE(HAVE_NCURSES_H)],[AC_SUBST(CURSESLIB,[curses])])
|
||||
AC_SEARCH_LIBS( setupterm, [ncurses curses], [ AC_MSG_NOTICE([Found curses implementation])], [AC_MSG_ERROR([Could not find a curses implementation, needed to build fish])] )
|
||||
|
||||
#Force use of ncurses if it is avialable via NetBSD pkgsrc. This is an
|
||||
#ugly kludge to force NetBSD to use ncurses, since NetBSDs own version
|
||||
#does not properly support terminfo.
|
||||
AC_CHECK_FILE([/usr/pkg/include/ncurses.h],[AC_SUBST(CURSESLIB,[ncurses]) AC_DEFINE(HAVE_NCURSES_H)])
|
||||
|
||||
AC_CONFIG_FILES([Makefile fish.spec doc_src/fish.1 doc_src/Doxyfile init/fish])
|
||||
AC_CONFIG_FILES([Makefile fish.spec doc_src/fish.1 doc_src/Doxyfile etc/fish etc/fish_interactive.fish seq])
|
||||
AC_OUTPUT
|
||||
|
||||
echo "Now run 'make' and 'make install' to built and install fish."
|
||||
echo "Good luck!"
|
||||
|
||||
@@ -2,22 +2,16 @@
|
||||
\section and and - Conditionally execute a command
|
||||
|
||||
\subsection and-synopsis Synopsis
|
||||
<tt>and COMMAND1; COMMAND2</tt>
|
||||
<tt>COMMAND1; and COMMAND2</tt>
|
||||
|
||||
\subsection and-description Description
|
||||
|
||||
The \c and builtin is used to execute one command, and if it returns
|
||||
zero status, also execute a second command.
|
||||
The \c and builtin is used to execute a command if the current exit status (as set by the last previous command) is zero
|
||||
|
||||
\subsection and-example Example
|
||||
|
||||
The following code runs the \c make command to build a program, and if it suceeds, it runs <tt>make install</tt>, which installs the program.
|
||||
The following code runs the \c make command to build a program, and if it succeeds, it runs <tt>make install</tt>, which installs the program.
|
||||
<pre>
|
||||
and make; make install
|
||||
make; and make install
|
||||
</pre>
|
||||
|
||||
\c or and \c and can be nested, as in this example, that attempts to build and install a program, and removed the files created by the build process on failiure
|
||||
|
||||
<pre>
|
||||
or and make; make install; make clean
|
||||
</pre>
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
\subsection begin-description Description
|
||||
|
||||
The \c begin builtin is used to create a new block of code. The block
|
||||
is unconditionally erxecuted. Begin is equivalent to <tt>if
|
||||
is unconditionally executed. Begin is equivalent to <tt>if
|
||||
true</tt>. The begin command is used to group any number of commands
|
||||
into a block. The reason for this is usually either to introduce a new
|
||||
variable scope or to redirect the input ot output of this set of
|
||||
variable scope or to redirect the input to output of this set of
|
||||
commands as a group.
|
||||
|
||||
\subsection begin-example Example
|
||||
|
||||
19
doc_src/block.txt
Normal file
19
doc_src/block.txt
Normal file
@@ -0,0 +1,19 @@
|
||||
|
||||
\section block block - Temporarily block delivery of events
|
||||
|
||||
\subsection block-synopsis Synopsis
|
||||
<tt>block [OPTIONS...]</tt>
|
||||
|
||||
\subsection block-description Description
|
||||
|
||||
- <tt>-l</tt> or <tt>--local</tt> Release the block at the end of the currently innermost block scope
|
||||
- <tt>-g</tt> or <tt>--global</tt> Never automatically release the lock
|
||||
- <tt>-e</tt> or <tt>--erase</tt> Release global block
|
||||
|
||||
\subsection block-example Example
|
||||
|
||||
<pre>block -g
|
||||
\#Do something that should not be interrupted
|
||||
block -e
|
||||
</pre>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
The \c break builtin is used to halt a currently running loop, such as a <a href="#for">for</a> loop or a <a href="#while">while</a> loop. It is usually added inside of a conditional block such as an <a href="#if">if</a> statement or a <a href="#switch">switch</a> statement.
|
||||
|
||||
\subsection break-example Example
|
||||
The following code searches all .c files for smurfs, and halts at the first occurance.
|
||||
The following code searches all .c files for smurfs, and halts at the first occurrence.
|
||||
<p>
|
||||
<tt>for i in *.c;
|
||||
<br> if grep smurf $i;
|
||||
|
||||
@@ -23,7 +23,7 @@ switch $animal
|
||||
echo evil
|
||||
case wolf dog human moose dolphin whale
|
||||
echo mammal
|
||||
case duck goose albatros
|
||||
case duck goose albatross
|
||||
echo bird
|
||||
case shark trout stingray
|
||||
echo fish
|
||||
|
||||
@@ -3,10 +3,9 @@
|
||||
\subsection cd-synopsis Synopsis
|
||||
<tt>cd [DIRECTORY]</tt>
|
||||
|
||||
\subsection cd-description Description
|
||||
Changes the current directory. If <tt>DIRECTORY</tt> is supplied it
|
||||
will become the new directory. If \c DIRECTORY is a relative path, the
|
||||
CDPATH environment variable will be separated using the : as
|
||||
separator, and the resulting list will be searched for a suitable new
|
||||
current directory. If CDPATH is not set, it is assumed to be '.'. If
|
||||
\c DIRECTORY is not specified, \$HOME will be the new directory.
|
||||
\subsection cd-description Description Changes the current
|
||||
directory. If <tt>DIRECTORY</tt> is supplied it will become the new
|
||||
directory. If \c DIRECTORY is a relative path, the paths found in the
|
||||
CDPATH environment variable array will be tried as prefixes for the
|
||||
specified path. If CDPATH is not set, it is assumed to be '.'. If \c
|
||||
DIRECTORY is not specified, \$HOME will be the new directory.
|
||||
|
||||
@@ -25,14 +25,14 @@ or updated
|
||||
- \c -b or \c --current-buffer select the entire buffer (default)
|
||||
- \c -j or \c --current-job select the current job
|
||||
- \c -p or \c --current-process select the current process
|
||||
- \c -t or \c --current_token select the current token.
|
||||
- \c -t or \c --current_token select the current token.
|
||||
|
||||
The following switch changes the way \c commandline prints the current
|
||||
commandline
|
||||
|
||||
- \c -c or \c --cut-at-cursor only print selection up until the
|
||||
current cursor position
|
||||
- \c o or \c --tokenize tokenize the selection and print one string-type token per line
|
||||
- \c -o or \c --tokenize tokenize the selection and print one string-type token per line
|
||||
|
||||
Other switches
|
||||
|
||||
@@ -43,6 +43,10 @@ Other switches
|
||||
that they will be returned to the reader before any additional
|
||||
actual keypresses are read.
|
||||
|
||||
If commandline is called during a call to complete a given string
|
||||
using <code>complete -C STRING</code>, commandline will consider the
|
||||
specified string to be the current contents of the commandline.
|
||||
|
||||
\subsection commandline-example Example
|
||||
|
||||
<tt>commandline -j $history[3]</tt>
|
||||
|
||||
@@ -1,18 +1,24 @@
|
||||
\section complete complete - edit command specific tab-completions.
|
||||
\section complete complete - edit command specific tab-completions.
|
||||
|
||||
\subsection complete-synopsis Synopsis
|
||||
<tt>complete (-c|--command|-p|--path) COMMAND [(-s|--short-option) SHORT_OPTION] [(-l|--long-option|-o|--old-option) LONG_OPTION [(-a||--arguments) OPTION_ARGUMENTS] [(-d|--description) DESCRIPTION] </tt>
|
||||
|
||||
\subsection complete-description Description
|
||||
|
||||
For an introduction to how to specify completions, see the section <a
|
||||
href='index.html#completions-own'>Writing your own completions</a> of
|
||||
the fish manual.
|
||||
|
||||
- <tt>COMMAND</tt> is the name of the command for which to add a completion
|
||||
- <tt>SHORT_OPTION</tt> is a one character option for the command
|
||||
- <tt>LONG_OPTION</tt> is a multi character option for the command
|
||||
- <tt>OPTION_ARGUMENTS</tt> is parameter containing a space-separated list of possible option-arguments, which may contain subshells
|
||||
- <tt>DESCRIPTION</tt> is a description of what the option and/or option arguments do
|
||||
- <tt>-C STRING</tt> or <tt>--do-complete=STRING</tt> makes complete try to find all possible completions for the specified string
|
||||
- <tt>-e</tt> or <tt>--erase</tt> implies that the specified completion should be deleted
|
||||
- <tt>-f</tt> or <tt>--no-files</tt> specifies that the option specified by this completion may not be followed by a filename
|
||||
- <tt>-n</tt> or <tt>--condition</tt> specides a shell command that must return 0 if the completion is to be used. This makes it possible to specify completions that should only be used in some cases.
|
||||
- <tt>-o</tt> or <tt>--old-option</tt> implies that the command uses old long style options with only one dash
|
||||
- <tt>-n</tt> or <tt>--condition</tt> specifies a shell command that must return 0 if the completion is to be used. This makes it possible to specify completions that should only be used in some cases.
|
||||
- <tt>-o</tt> or <tt>--old-option</tt> implies that the command uses old long style options with only one dash
|
||||
- <tt>-p</tt> or <tt>--path</tt> implies that the string COMMAND is the full path of the command
|
||||
- <tt>-r</tt> or <tt>--require-parameter</tt> specifies that the option specified by this completion always must have an option argument, i.e. may not be followed by another option
|
||||
- <tt>-u</tt> or <tt>--unauthorative</tt> implies that there may be more options than the ones specified, and that fish should not assume that options not listed are spelling errors
|
||||
@@ -25,13 +31,14 @@ that do not begin with a hyphen. Fish recognizes three styles of
|
||||
options, the same styles as the GNU version of the getopt
|
||||
library. These styles are:
|
||||
|
||||
- Short options, like '-a'. Short options are a single character long, are preceeded by a single hyphen and may ge grouped together (like '-la', which is equivalent to '-l -a'). Option arguments may be specified in the following parameter ('-w 32') or by appending the option with the value ('-w32').
|
||||
- Old style long options, like '-Wall'. Old style long options are more than one character long, are preceeded by a single hyphen and may not be grouped together. Option arguments are specified in the following parameter ('-ao null').
|
||||
- GNU style long options, like '--colors'. GNU style long options are more than one character long, are preceeded by two hyphens, and may not be grouped together. Option arguments may be specified in the following parameter ('--quoting-style shell') or by appending the option with a '=' and the value ('--quoting-style=shell'). GNU style long options may be abbrevated so long as the abbrevation is unique ('--h' is equivalent to '--help' if help is the only long option beginning with an 'h').
|
||||
- Short options, like '-a'. Short options are a single character long, are preceded by a single hyphen and may be grouped together (like '-la', which is equivalent to '-l -a'). Option arguments may be specified in the following parameter ('-w 32') or by appending the option with the value ('-w32').
|
||||
- Old style long options, like '-Wall'. Old style long options can be more than one character long, are preceded by a single hyphen and may not be grouped together. Option arguments are specified in the following parameter ('-ao null').
|
||||
- GNU style long options, like '--colors'. GNU style long options can be more than one character long, are preceded by two hyphens, and may not be grouped together. Option arguments may be specified in the following parameter ('--quoting-style shell') or by appending the option with a '=' and the value ('--quoting-style=shell'). GNU style long options may be abbreviated so long as the abbreviation is unique ('--h' is equivalent to '--help' if help is the only long option beginning with an 'h').
|
||||
|
||||
\c complete only allows one of old style long options and GNU style
|
||||
long options to be used on a specific command, but short options can
|
||||
always be specified.
|
||||
The options for specifying command name, command path, or command
|
||||
switches may all be used multiple times to specify multiple commands
|
||||
which have the same completion or multiple switches accepted by a
|
||||
command.
|
||||
|
||||
When erasing completions, it is possible to either erase all
|
||||
completions for a specific command by specifying <tt>complete -e -c
|
||||
@@ -61,7 +68,9 @@ are valid, like the \c nodeps switch.
|
||||
|
||||
This can be written as:
|
||||
|
||||
<tt>complete -c rpm -n "__fish_contains_opt -s e erase" -l nodeps -d 'Dont check dependencies'</tt>
|
||||
<tt>complete -c rpm -n "__fish_contains_opt -s e erase" -l nodeps -d
|
||||
"Don't check dependencies"</tt>
|
||||
|
||||
where \c __fish_contains_opt is a function that checks the commandline buffer for the presense of a specified set of options.
|
||||
where \c __fish_contains_opt is a function that checks the commandline
|
||||
buffer for the presence of a specified set of options.
|
||||
|
||||
|
||||
24
doc_src/contains.txt
Normal file
24
doc_src/contains.txt
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
\section contains contains - Test if a word is present in a list
|
||||
|
||||
\subsection contains-synopsis Synopsis
|
||||
<code>contains [OPTIONS] KEY [VALUES...]</code>
|
||||
|
||||
\subsection contains-description Description
|
||||
|
||||
- \c -h or \c --help display this message
|
||||
|
||||
Test if the set VALUES contains the string KEY. Return status is 0 if
|
||||
yes, 1 otherwise
|
||||
|
||||
|
||||
\subsection contains-example Example
|
||||
<pre>
|
||||
for i in ~/bin /usr/local/bin
|
||||
if not contains \$i \$PATH
|
||||
set PATH \$PATH i
|
||||
end
|
||||
end
|
||||
</pre>
|
||||
|
||||
The above code tests if ~/bin and /usr/local/bin are in the path and if they are not, they are added.
|
||||
@@ -16,7 +16,7 @@ the user does not have to worry about an array containing elements
|
||||
such as dashes. \c fish performs a special check when invoking the
|
||||
count program, and if the user uses a help option, this help page is
|
||||
displayed, but if a help option is contained inside of a variable or
|
||||
is the result of expantion, it will be passed on to the count program.
|
||||
is the result of expansion, it will be passed on to the count program.
|
||||
|
||||
\subsection count-example Example
|
||||
|
||||
|
||||
1649
doc_src/doc.hdr
1649
doc_src/doc.hdr
File diff suppressed because it is too large
Load Diff
@@ -7,8 +7,8 @@
|
||||
\subsection exec-description Description
|
||||
|
||||
The \c exec builtin is used to replace the currently running shells
|
||||
process image with a new command. On sucessfull completion, exec never
|
||||
returns. exec can not be used inside a pipeline.
|
||||
process image with a new command. On successful completion, exec never
|
||||
returns. exec can not be used inside a pipeline.
|
||||
|
||||
\subsection exec-example Example
|
||||
|
||||
|
||||
9
doc_src/fish_pager.txt
Normal file
9
doc_src/fish_pager.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
\section fish_pager fish_pager - Internal command used by fish
|
||||
|
||||
\subsection fish_pager-description Description
|
||||
|
||||
This command is used internally by fish to display a list of
|
||||
completions. It should not be used by other commands, as it's
|
||||
interface is liable to change in the future.
|
||||
|
||||
@@ -2,50 +2,24 @@
|
||||
\section fishd fishd - Universal variable daemon
|
||||
|
||||
\subsection fishd-synopsis Synopsis
|
||||
<tt>fishd [SECTION]</tt>
|
||||
<tt>fishd [(-h|--help|-v|--version)]</tt>
|
||||
|
||||
\subsection fishd-description Description
|
||||
|
||||
The \c fishd daemon is used to load, save and distribute universal
|
||||
variable information. fish automtically connects to fishd via a socket
|
||||
variable information. fish automatically connects to fishd via a socket
|
||||
on startup. If no instance of fishd is running, fish spawns a new
|
||||
fishd instance. fishd will create a socket in /tmp, and wait for
|
||||
incoming connections from universal variable clents, such as fish,
|
||||
incoming connections from universal variable clients, such as fish,
|
||||
When no clients are connected, fishd will automatically shut down.
|
||||
|
||||
\subsection fishd-commands Commands
|
||||
|
||||
Fishd works by sending and recieving sommands. Each command is ended
|
||||
with a newline. These are the commands supported by fishd:
|
||||
|
||||
<pre>set KEY:VALUE
|
||||
set_export KEY:VALUE
|
||||
</pre>
|
||||
|
||||
These commands update the value of a variable. The only difference
|
||||
between the two is that <tt>set_export</tt>-variables should be
|
||||
exported to children of the process using them. The variable value may
|
||||
be escaped using C-style backslash escapes. In fact, this is required
|
||||
for newline characters, which would otherwise be interpreted as end of
|
||||
command.
|
||||
|
||||
<pre>erase KEY
|
||||
</pre>
|
||||
|
||||
Erase the variable with the specified name.
|
||||
|
||||
<pre>barrier
|
||||
barrier_reply
|
||||
</pre>
|
||||
|
||||
A \c barrier command will result in a barrier_reply beeing added to
|
||||
the end of the senders queue of unsent messages. These commands are
|
||||
used to synchronize clients, since once the reply for a barrier
|
||||
message returns, the sender can know that any updates available at the
|
||||
time the original barrier request was sent have been recieved.
|
||||
- <tt>-h</tt> or <tt>--help</tt> displays this help message and then exits
|
||||
- <tt>-v</tt> or <tt>--version</tt> displays the current fish version and then exits
|
||||
|
||||
\subsection fishd-files Files
|
||||
|
||||
~/.fishd.HOSTNAME permenent storage location for universal variale
|
||||
~/.fishd.HOSTNAME permanent storage location for universal variable
|
||||
data. The data is stored as a set of \c set and \c set_export commands
|
||||
such as would be parsed by fishd.
|
||||
such as would be parsed by fishd. If an instance of fishd is running
|
||||
(which is generally the case), manual modifications to ~/.fishd.HOSTNAME
|
||||
will be lost.
|
||||
|
||||
@@ -5,22 +5,22 @@
|
||||
|
||||
\subsection function-description Description
|
||||
|
||||
- \c -b or \c --key-binding specifies that the function is a key biding. Key binding functions work exactly like regular functions except that they can not be tab-completed, and may contain the '-' character.
|
||||
- \c -b or \c --key-binding specifies that the function is a key biding. Key binding functions work exactly like regular functions except that they can not be tab-completed, and may contain the '-' character.
|
||||
- <tt>-d DESCRIPTION</tt> or \c --description=DESCRIPTION is a description of what the function does, suitable as a completion description
|
||||
- <tt>-j PID</tt> or <tt> --on-job-exit PID</tt> tells fish to run this function when the job with group id PID exits
|
||||
- <tt>-p PID</tt> or <tt> --on-process-exit PID</tt> tells fish to run this function when the fish child process with process id PID exits
|
||||
- <tt>-s</tt> or <tt>--on-signal SIGSPEC</tt> tells fish to run this function when the signal SIGSPEC is delivered. SIGSPEC can be a singal number, or the signal name, such as SIGHUP (or just HUP)
|
||||
- <tt>-s</tt> or <tt>--on-signal SIGSPEC</tt> tells fish to run this function when the signal SIGSPEC is delivered. SIGSPEC can be a signal number, or the signal name, such as SIGHUP (or just HUP)
|
||||
- <tt>-v</tt> or <tt>--on-variable VARIABLE_NAME</tt> tells fish to run this function when the variable VARIABLE_NAME changes value
|
||||
|
||||
This builtin command is used to create a new function. A Function is a
|
||||
list of commands that will be executed when the name of the function
|
||||
is entered. The function
|
||||
is entered. The function
|
||||
|
||||
<pre>
|
||||
function hi
|
||||
echo hello
|
||||
end
|
||||
</pre>
|
||||
</pre>
|
||||
|
||||
will write <tt>hello</tt> whenever the user enters \c hi.
|
||||
|
||||
@@ -29,7 +29,7 @@ are inserted into the environment variable <a href="index.html#variables-arrays"
|
||||
|
||||
\subsection function-example Example
|
||||
|
||||
<pre>function ll
|
||||
<pre>function ll
|
||||
ls -l $argv
|
||||
end
|
||||
</pre>
|
||||
@@ -39,18 +39,18 @@ will run the \c ls command, using the \c -l option, while passing on any additio
|
||||
<pre>
|
||||
function mkdir -d "Create a directory and set CWD"
|
||||
mkdir $argv
|
||||
if test $status = 0
|
||||
if test $status = 0
|
||||
switch $argv[(count $argv)]
|
||||
case '-*'
|
||||
|
||||
|
||||
case '*'
|
||||
cd $argv[(count $argv)]
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
</pre>
|
||||
</pre>
|
||||
|
||||
will run the mkdir command, and if it is succesfull, change the
|
||||
will run the mkdir command, and if it is successful, change the
|
||||
current working directory to the one just created.
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
\section help help - Display fish documantation
|
||||
\section help help - Display fish documentation
|
||||
|
||||
\subsection help-synopsis Synopsis
|
||||
<tt>help [SECTION]</tt>
|
||||
|
||||
@@ -1,13 +1,20 @@
|
||||
\section jobs jobs - print currently running jobs
|
||||
|
||||
\subsection jobs-synopsis
|
||||
<tt>jobs</tt>
|
||||
<tt>jobs [OPTIONS] [PID]</tt>
|
||||
|
||||
\subsection jobs-description Description
|
||||
The <tt>jobs</tt> builtin causes fish to print a list of the currently
|
||||
running jobs and their status.
|
||||
running jobs and their status.
|
||||
|
||||
On systems that supports this feature, jobs will also print the CPU
|
||||
usage of each job since the last command was executed. The CPU usage
|
||||
is expressed as a percentage of full CPU activity. Note that on
|
||||
jobs accepts the following switches:
|
||||
|
||||
- <tt>-c</tt> or <tt>--command</tt> print the command name for each process in jobs
|
||||
- <tt>-g</tt> or <tt>--group</tt> only print the group id of each job
|
||||
- <tt>-l</tt> or <tt>--last</tt> only the last job to be started is printed
|
||||
- <tt>-p</tt> or <tt>--process</tt> print the process id for each process in all jobs
|
||||
|
||||
On systems that supports this feature, jobs will print the CPU usage
|
||||
of each job since the last command was executed. The CPU usage is
|
||||
expressed as a percentage of full CPU activity. Note that on
|
||||
multiprocessor systems, the total activity may be more than 100\%.
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
\section nextd nextd
|
||||
|
||||
\subsection nextd-synopsis Synopsis
|
||||
<tt>nextd [-l] [pos]</tt>
|
||||
<tt>nextd [-l | --list] [pos]</tt>
|
||||
|
||||
\subsection nextd-description Description
|
||||
<tt>nextd</tt> moves forwards <tt>pos</tt> positions in the history of visited directories;
|
||||
if the end of the history has been hit, a warning is printed. If the <tt>-l></tt> flag is
|
||||
specified, the current history is also displayed.
|
||||
\subsection nextd-description Description <tt>nextd</tt> moves
|
||||
forwards <tt>pos</tt> positions in the history of visited directories;
|
||||
if the end of the history has been hit, a warning is printed. If the
|
||||
<code>-l></code> or <code>--list</code> flag is specified, the current
|
||||
history is also displayed.
|
||||
|
||||
@@ -2,22 +2,16 @@
|
||||
\section or or - Conditionally execute a command
|
||||
|
||||
\subsection or-synopsis Synopsis
|
||||
<tt>or COMMAND1; COMMAND2</tt>
|
||||
<tt>COMMAND1; or COMMAND2</tt>
|
||||
|
||||
\subsection or-description Description
|
||||
|
||||
The \c or builtin is used to execute one command, and if it returns
|
||||
non-zero status, also execute a second command.
|
||||
The \c or builtin is used to execute a command if the current exit status (as set by the last previous command) is non-zero
|
||||
|
||||
\subsection or-example Example
|
||||
|
||||
The following code runs the \c make command to build a program, or if it fails, it runs <tt>make clean</tt>, which removes the files created by the build process
|
||||
<pre>
|
||||
or make; make clean
|
||||
make; or make clean
|
||||
</pre>
|
||||
|
||||
\c or and \c and can be nested, as in this example, that attempts to build and install a program, and removed the files created by the build process on failiure
|
||||
|
||||
<pre>
|
||||
or and make; make install; make clean
|
||||
</pre>
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
\section prevd prevd
|
||||
|
||||
\subsection prevd-synopsis Synopsis
|
||||
<tt>prevd [-l] [pos]</tt>
|
||||
<tt>prevd [-l | --list] [pos]</tt>
|
||||
|
||||
\subsection prevd-description Description
|
||||
<tt>prevd</tt> moves backwards <tt>pos</tt> positions in the history of visited directories;
|
||||
if the beginning of the history has been hit, a warning is printed. If the <tt>-l</tt> flag
|
||||
is specified, the current history is also displayed.
|
||||
\subsection prevd-description Description <tt>prevd</tt> moves
|
||||
backwards <tt>pos</tt> positions in the history of visited
|
||||
directories; if the beginning of the history has been hit, a warning
|
||||
is printed. If the <code>-l</code> or <code>--list</code> flag is
|
||||
specified, the current history is also displayed.
|
||||
|
||||
@@ -1,41 +1,47 @@
|
||||
\section set set - Handle environment variables.
|
||||
|
||||
\subsection set-synopsis Synopsis
|
||||
<tt>set [OPTIONS] VARIABLE_NAME [VALUES...]</tt>
|
||||
<code>set [OPTIONS] [VARIABLE_NAME [VALUES...]]</code>
|
||||
|
||||
The <tt>set</tt> builtin causes fish to assign the variable <tt>VARIABLE_NAME</tt> the values <tt>VALUES...</tt>.
|
||||
The <code>set</code> builtin causes fish to assign the variable <code>VARIABLE_NAME</code> the values <code>VALUES...</code>.
|
||||
|
||||
\subsection set-description Description
|
||||
- <tt>-e</tt> or <tt>--erase</tt> causes the specified environment variable to be erased
|
||||
- <tt>-g</tt> or <tt>--global</tt> causes the specified environment variable to be made global. If this option is not supplied, the specified variable will dissapear when the current block ends
|
||||
- <tt>-l</tt> or <tt>--local</tt> forces the specified environment variable to be made local to the current block, even if the variable already exists and is non-local
|
||||
- <tt>-n</tt> or <tt>--names</tt> List only the names of all defined variables
|
||||
- <tt>-q</tt> or <tt>--query</tt> test if the specified variable names are defined. Does not output anything, but the builtins exit status is the number of variables specified that were not defined.
|
||||
- <tt>-u</tt> or <tt>--unexport</tt> causes the specified environment not to be exported to child processes
|
||||
- <tt>-U</tt> or <tt>--universal</tt> causes the specified environment variable to be made universal. If this option is supplied, the variable will be shared between all the current users fish instances on the current computer, and will be preserved across restarts of the shell.
|
||||
- <tt>-x</tt> or <tt>--export</tt> causes the specified environment variable to be exported to child processes
|
||||
- <code>-e</code> or <code>--erase</code> causes the specified environment variable to be erased
|
||||
- <code>-g</code> or <code>--global</code> causes the specified environment variable to be made global. If this option is not supplied, the specified variable will disappear when the current block ends
|
||||
- <code>-l</code> or <code>--local</code> forces the specified environment variable to be made local to the current block, even if the variable already exists and is non-local
|
||||
- <code>-n</code> or <code>--names</code> List only the names of all defined variables
|
||||
- <code>-q</code> or <code>--query</code> test if the specified variable names are defined. Does not output anything, but the builtins exit status is the number of variables specified that were not defined.
|
||||
- <code>-u</code> or <code>--unexport</code> causes the specified environment not to be exported to child processes
|
||||
- <code>-U</code> or <code>--universal</code> causes the specified environment variable to be made universal. If this option is supplied, the variable will be shared between all the current users fish instances on the current computer, and will be preserved across restarts of the shell.
|
||||
- <code>-x</code> or <code>--export</code> causes the specified environment variable to be exported to child processes
|
||||
|
||||
If set is called with no arguments, the names and values of all
|
||||
environment variables are printed.
|
||||
|
||||
If set is called with only one argument, the scope of the variable
|
||||
with the given name will be changed as specified, but it's value will
|
||||
remain the same. If the variable did not previously exist, it's value
|
||||
will be an empty string.
|
||||
environment variables are printed. If some of the scope or export
|
||||
flags have been given, only the variables matching the specified scope
|
||||
are printed.
|
||||
|
||||
If the \c -e or \c --erase option is specified, the variable
|
||||
specified by the following arguments will be erased
|
||||
|
||||
If a variable is set to more than one value, the variable will be an
|
||||
array with the specified elements.
|
||||
array with the specified elements. If a variable is set to zero
|
||||
elements, it will become an array with zero elements.
|
||||
|
||||
If the variable name is one or more array elements, such as <tt>PATH[1
|
||||
3 7]</tt>, only those array elements specified will be changed.
|
||||
If the variable name is one or more array elements, such as
|
||||
<code>PATH[1 3 7]</code>, only those array elements specified will be
|
||||
changed.
|
||||
|
||||
The set command requires all switch arguments to come before any
|
||||
non-switch arguments. For example, <code>set flags -l</code> will have
|
||||
the effect of setting the value of the variable <code>flags</code> to
|
||||
'-l', not making the variable local.
|
||||
|
||||
\subsection set-example Example
|
||||
|
||||
<tt>set foo hi</tt> sets the value of the variable foo to be hi.
|
||||
<code>set -xg</code> will print all global, exported variables.
|
||||
|
||||
<tt>set -e smurf</tt> removes the variable \c smurf.
|
||||
<code>set foo hi</code> sets the value of the variable foo to be hi.
|
||||
|
||||
<tt>set PATH[4] ~/bin</tt> changes the fourth element of the \c PATH array to \c ~/bin
|
||||
<code>set -e smurf</code> removes the variable \c smurf.
|
||||
|
||||
<code>set PATH[4] ~/bin</code> changes the fourth element of the \c PATH array to \c ~/bin
|
||||
|
||||
@@ -10,11 +10,18 @@ Change the foreground and/or background color of the terminal.
|
||||
COLOR is one of black, red, green, brown, yellow, blue, magenta,
|
||||
purple, cyan, white and normal.
|
||||
|
||||
- \c -c, \c --print-colors Prints a list of all valid color names
|
||||
- \c -b, \c --background Set the background color
|
||||
- \c -o, \c --bold Set bold or extra bright mode
|
||||
- \c -h, \c --help Display help message and exit
|
||||
- \c -v, \c --version Display version and exit
|
||||
|
||||
|
||||
Calling <tt>set_color normal</tt> will set the terminal color to
|
||||
whatever is the default color of the terminal.
|
||||
|
||||
Some terminals use the --bold escape sequence to switch to a brighter
|
||||
color set. On such terminals, <code>set_color white</code> will result
|
||||
in a grey font color, while <code>set_color --bold white</code> will
|
||||
result in a white font color.
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<tt>status [OPTION]</tt>
|
||||
|
||||
\subsection status-description Description
|
||||
- <tt>-c</tt> or <tt>--is-command-substitution</tt> returns 0 if fish is currently executing a command usbstitution
|
||||
- <tt>-c</tt> or <tt>--is-command-substitution</tt> returns 0 if fish is currently executing a command substitution
|
||||
- <tt>-b</tt> or <tt>--is-block</tt> returns 0 if fish is currently executing a block of code
|
||||
- <tt>-i</tt> or <tt>--is-interactive</tt> returns 0 if fish is interactive, i.e.connected to a keyboard
|
||||
- <tt>-l</tt> or <tt>--is-login</tt> returns 0 if fish is a login shell, i.e. if fish should perform login tasks such as setting up the PATH.
|
||||
- <tt>-l</tt> or <tt>--is-login</tt> returns 0 if fish is a login shell, i.e. if fish should perform login tasks such as setting up the PATH.
|
||||
|
||||
@@ -12,7 +12,7 @@ wildcarded values.
|
||||
|
||||
\subsection switch-example Example
|
||||
|
||||
If the variable \$animal contins the name of an animal, the
|
||||
If the variable \$animal contains the name of an animal, the
|
||||
following code would attempt to classify it:
|
||||
|
||||
<p>
|
||||
@@ -22,7 +22,7 @@ switch $animal
|
||||
echo evil
|
||||
case wolf dog human moose dolphin whale
|
||||
echo mammal
|
||||
case duck goose albatros
|
||||
case duck goose albatross
|
||||
echo bird
|
||||
case shark trout stingray
|
||||
echo fish
|
||||
@@ -32,6 +32,6 @@ end
|
||||
<p>
|
||||
|
||||
If the above code was run with \$animal set to \c whale, the output
|
||||
would be \c mammal.
|
||||
would be \c mammal.
|
||||
|
||||
</p>
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
|
||||
\section tokenize tokenize - tokenize a string
|
||||
|
||||
\subsection tokenize-synopsis Synopsis
|
||||
<tt>tokenize [STRING...]</tt>
|
||||
|
||||
\subsection tokenize-description Description
|
||||
- STRING is the string or list of strings to tokenize. Each token will be printed on a line by itself
|
||||
- \c -e, \c --with-empty allow empty tokens
|
||||
- \c -n, \c --no-empty ignore empty tokens (Default)
|
||||
- <tt>-d DELIMITER</tt>, <tt>--delimiter=DELIMITER</tt> is the list of characters that will be used as delimiters. If unspecified, the IFS environment variable will be used as the delimiter string,
|
||||
- \c -h, \c --help Display help message and exit
|
||||
- \c -v, \c --version Display version and exit
|
||||
|
||||
37
doc_src/trap.txt
Normal file
37
doc_src/trap.txt
Normal file
@@ -0,0 +1,37 @@
|
||||
|
||||
\section trap trap - perform an action when the shell receives a signal
|
||||
|
||||
\subsection trap-synopsis Synopsis
|
||||
<tt>trap [OPTIONS] [[ARG] SIGSPEC ... ]</tt>
|
||||
|
||||
\subsection trap-description Description
|
||||
|
||||
Trap is a shellscript wrapper around the fish event delivery
|
||||
framework. IT is defined for backwards compatibility reasons. For
|
||||
other uses, it is recommended to define a <a
|
||||
href='index.html#event'>event handler</a>.
|
||||
|
||||
- ARG is the command to be executed on signal delivery
|
||||
- SIGSPEC is the name of the signal to trap
|
||||
- \c -h or \c --help Display help and exit
|
||||
- \c -l or \c --list-signals print a list of signal names
|
||||
- \c -p or \c --print print all defined signal handlers
|
||||
|
||||
If ARG and SIGSPEC are both specified, ARG is the command to be
|
||||
executed when the signal specified by SIGSPEC is delivered.
|
||||
|
||||
If ARG is absent (and there is a single SIGSPEC) or -, each specified
|
||||
signal is reset to its original disposition (the value it had upon
|
||||
entrance to the shell). If ARG is the null string the signal
|
||||
specified by each SIGSPEC is ignored by the shell and by the commands
|
||||
it invokes.
|
||||
|
||||
If ARG is not present and -p has been supplied, then the trap commands
|
||||
associated with each SIGSPEC are displayed. If no arguments are
|
||||
supplied or if only -p is given, trap prints the list of commands
|
||||
associated with each signal.
|
||||
|
||||
Signal names are case insensitive and the SIG prefix is optional.
|
||||
|
||||
The return status is 1 if any SIGSPEC is invalid; otherwise trap
|
||||
returns 0.
|
||||
@@ -6,11 +6,11 @@
|
||||
|
||||
\subsection type-description Description
|
||||
|
||||
With no options, indicate how each name would be interpreted if used as a command name.
|
||||
With no options, indicate how each name would be interpreted if used as a command name.
|
||||
|
||||
- \c -h or \c --help print this message
|
||||
- \c -a or \c --all print all of possible definitions of the specified names
|
||||
- \c -f or \c --no-functions supresses function and builtin lookup
|
||||
- \c -f or \c --no-functions suppresses function and builtin lookup
|
||||
- \c -t or \c --type print a string which is one of alias, keyword, function, builtin, or file if name is an alias, shell reserved word, function, builtin, or disk file, respectively
|
||||
- \c -p or \c --path either return the name of the disk file that would be executed if name were specified as a command name, or nothing if 'type -t name' would not return 'file'
|
||||
- \c -P or \c --force-path either return the name of the disk file that would be executed if name were specified as a command name, or nothing no file with the specified name could be found in the PATH
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
\section ulimit ulimit - Set or get the shells resurce usage limits
|
||||
\section ulimit ulimit - Set or get the shells resource usage limits
|
||||
|
||||
\subsection ulimit-synopsis Synopsis
|
||||
<tt>ulimit [OPTIONS] [LIMIT]</tt>
|
||||
@@ -38,7 +38,7 @@ except for -t, which is in seconds and -n and -u, which are unscaled
|
||||
values. The return status is 0 unless an invalid option or argument is
|
||||
supplied, or an error occurs while setting a new limit.
|
||||
|
||||
The fish implementation of ulimit should behave identically to the implementation in bash, except for these differences:
|
||||
The fish implementation of ulimit should behave identically to the implementation in bash, except for these differences:
|
||||
|
||||
- Fish ulimit supports GNU-style long options for all switches
|
||||
- Fish ulimit does not support the -p option for getting the pipe size. The bash implementation consists of a compile-time check that empirically guesses this number by writing to a pipe and waiting for SIGPIPE.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
\section umask umask - Set or get the shells resurce usage limits
|
||||
\section umask umask - Set or get the shells resource usage limits
|
||||
|
||||
\subsection umask-synopsis Synopsis
|
||||
<code>umask [OPTIONS] [MASK]</code>
|
||||
@@ -10,9 +10,30 @@ With no argument, the current file-creation mask is printed, if an
|
||||
argument is specified, it is the new file creation mask. The mask may
|
||||
be specified as an octal number, in which case it is interpreted as
|
||||
the rights that should be masked away, i.e. it is the inverse of the
|
||||
file permissions any new files will have. If a synbolic mask is
|
||||
specified, the actual file permission bits, and not the inverse, are
|
||||
specified.
|
||||
file permissions any new files will have.
|
||||
|
||||
If a symbolic mask is specified, the actual file permission bits, and
|
||||
not the inverse, should be specified. A symbolic mask is a comma
|
||||
separated list of rights. Each right consists of three parts:
|
||||
|
||||
- The first part specifies to whom this set of right applies, and can
|
||||
be one of \c u, \c g, \c o or \c a, where \c u specifies the user who
|
||||
owns the file, \c g specifies the group owner of the file, \c o
|
||||
specific other users rights and \c a specifies all three should be
|
||||
changed.
|
||||
- The second part of a right specifies the mode, and can be one of \c
|
||||
=, \c + or \c -, where \c = specifies that the rights should be set to
|
||||
the new value, \c + specifies that the specified right should be added
|
||||
to those previously specified and \c - specifies that the specified
|
||||
rights should be removed from those previously specified.
|
||||
- The third part of a right specifies what rights should be changed
|
||||
and can be any combination of \c r, \c w and \c x, representing
|
||||
read, write and execute rights.
|
||||
|
||||
If the first and second parts are skipped, they are assumed to be \c a
|
||||
and \c =, respectively. As an example, <code>r,u+w</code> means all
|
||||
users should have read access and the file owner should also have
|
||||
write access.
|
||||
|
||||
- <code>-h</code> or <code>--help</code> print this message
|
||||
- <code>-S</code> or <code>--symbolic</code> prints the file-creation mask in symbolic form instead of octal form. Use <code>man chmod</code> for more information.
|
||||
|
||||
15
doc_src/vared.txt
Normal file
15
doc_src/vared.txt
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
\section vared vared - Interactively edit the value of an environment variable
|
||||
|
||||
\subsection vared-synopsis Synopsis
|
||||
<tt>vared VARIABLE_NAME</tt>
|
||||
|
||||
\subsection vared-description Description
|
||||
|
||||
vared is used to interactively edit the value of an environment
|
||||
variable. Array variables as a whole can not be edited using vared,
|
||||
but individual array elements can.
|
||||
|
||||
\subsection vared-example Example
|
||||
|
||||
<code>vared PATH[3]</code> edits the third element of the PATH array
|
||||
427
env.c
427
env.c
@@ -25,7 +25,12 @@
|
||||
#include <termio.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_TERM_H
|
||||
#include <term.h>
|
||||
#elif HAVE_NCURSES_TERM_H
|
||||
#include <ncurses/term.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include "util.h"
|
||||
@@ -41,12 +46,17 @@
|
||||
#include "env_universal.h"
|
||||
#include "input_common.h"
|
||||
#include "event.h"
|
||||
#include "translate.h"
|
||||
#include "complete.h"
|
||||
|
||||
/**
|
||||
Command used to start fishd
|
||||
*/
|
||||
#define FISHD_CMD L"if which fishd >/dev/null; fishd ^/tmp/fish.%s.log; end"
|
||||
#define FISHD_CMD L"if which fishd >/dev/null; fishd ^/tmp/fishd.%s.log; end"
|
||||
|
||||
/**
|
||||
Value denoting a null string
|
||||
*/
|
||||
#define ENV_NULL L"\x1d"
|
||||
|
||||
/**
|
||||
@@ -116,6 +126,11 @@ static hash_table_t *global;
|
||||
*/
|
||||
static hash_table_t env_read_only;
|
||||
|
||||
/**
|
||||
Table of variables whose value is dynamically calculated, such as umask, status, etc
|
||||
*/
|
||||
static hash_table_t env_electric;
|
||||
|
||||
/**
|
||||
Exported variable array used by execv
|
||||
*/
|
||||
@@ -133,19 +148,6 @@ static buffer_t export_buffer;
|
||||
*/
|
||||
static int has_changed = 1;
|
||||
|
||||
/**
|
||||
Free hash key and hash value
|
||||
*/
|
||||
static void clear_hash_entry( const void *key, const void *data )
|
||||
{
|
||||
var_entry_t *entry = (var_entry_t *)data;
|
||||
if( entry->export )
|
||||
has_changed = 1;
|
||||
|
||||
free( (void *)key );
|
||||
free( (void *)data );
|
||||
}
|
||||
|
||||
/**
|
||||
This stringbuffer is used to store the value of dynamically
|
||||
generated variables, such as history.
|
||||
@@ -163,6 +165,36 @@ static int get_names_show_exported;
|
||||
*/
|
||||
static int get_names_show_unexported;
|
||||
|
||||
/**
|
||||
List of all locale variable names
|
||||
*/
|
||||
static const wchar_t *locale_variable[] =
|
||||
{
|
||||
L"LANG",
|
||||
L"LC_ALL",
|
||||
L"LC_COLLATE",
|
||||
L"LC_CTYPE",
|
||||
L"LC_MESSAGES",
|
||||
L"LC_MONETARY",
|
||||
L"LC_NUMERIC",
|
||||
L"LC_TIME",
|
||||
(void *)0
|
||||
}
|
||||
;
|
||||
|
||||
/**
|
||||
Free hash key and hash value
|
||||
*/
|
||||
static void clear_hash_entry( const void *key, const void *data )
|
||||
{
|
||||
var_entry_t *entry = (var_entry_t *)data;
|
||||
if( entry->export )
|
||||
has_changed = 1;
|
||||
|
||||
free( (void *)key );
|
||||
free( (void *)data );
|
||||
}
|
||||
|
||||
/**
|
||||
When fishd isn't started, this function is provided to
|
||||
env_universal as a callback, it tries to start up fishd. It's
|
||||
@@ -174,7 +206,7 @@ static void start_fishd()
|
||||
{
|
||||
string_buffer_t cmd;
|
||||
struct passwd *pw;
|
||||
|
||||
|
||||
sb_init( &cmd );
|
||||
pw = getpwuid(getuid());
|
||||
|
||||
@@ -182,7 +214,7 @@ static void start_fishd()
|
||||
|
||||
if( !pw )
|
||||
{
|
||||
debug( 0, L"Could not get user information" );
|
||||
debug( 0, _( L"Could not get user information" ) );
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -194,12 +226,114 @@ static void start_fishd()
|
||||
sb_destroy( &cmd );
|
||||
}
|
||||
|
||||
/**
|
||||
Return the current umask value.
|
||||
*/
|
||||
static mode_t get_umask()
|
||||
{
|
||||
mode_t res;
|
||||
res = umask( 0 );
|
||||
umask( res );
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
Checks if the specified variable is a locale variable
|
||||
*/
|
||||
static int is_locale( const wchar_t *key )
|
||||
{
|
||||
int i;
|
||||
for( i=0; locale_variable[i]; i++ )
|
||||
if( wcscmp(locale_variable[i], key ) == 0 )
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
Properly sets all locale information
|
||||
*/
|
||||
static void handle_locale()
|
||||
{
|
||||
const wchar_t *lc_all = env_get( L"LC_ALL" );
|
||||
const wchar_t *lang;
|
||||
int i;
|
||||
wchar_t *old = wcsdup(wsetlocale( LC_MESSAGES, (void *)0 ));
|
||||
|
||||
/*
|
||||
Array of locale constants corresponding to the local variable names defined in locale_variable
|
||||
*/
|
||||
static const int cat[] =
|
||||
{
|
||||
0,
|
||||
LC_ALL,
|
||||
LC_COLLATE,
|
||||
LC_CTYPE,
|
||||
LC_MESSAGES,
|
||||
LC_MONETARY,
|
||||
LC_NUMERIC,
|
||||
LC_TIME
|
||||
}
|
||||
;
|
||||
|
||||
if( lc_all )
|
||||
{
|
||||
wsetlocale( LC_ALL, lc_all );
|
||||
}
|
||||
else
|
||||
{
|
||||
lang = env_get( L"LANG" );
|
||||
if( lang )
|
||||
{
|
||||
wsetlocale( LC_ALL, lang );
|
||||
}
|
||||
|
||||
for( i=2; locale_variable[i]; i++ )
|
||||
{
|
||||
const wchar_t *val = env_get( locale_variable[i] );
|
||||
if( val )
|
||||
wsetlocale( cat[i], val );
|
||||
}
|
||||
}
|
||||
|
||||
if( wcscmp( wsetlocale( LC_MESSAGES, (void *)0 ), old ) != 0 )
|
||||
{
|
||||
|
||||
/* Try to make change known to gettext. */
|
||||
#ifdef HAVE__NL_MSG_CAT_CNTR
|
||||
{
|
||||
extern int _nl_msg_cat_cntr;
|
||||
++_nl_msg_cat_cntr;
|
||||
}
|
||||
#elif HAVE_DCGETTEXT
|
||||
dcgettext("fish","Changing language to English",LC_MESSAGES);
|
||||
#endif
|
||||
|
||||
if( is_interactive )
|
||||
{
|
||||
complete_destroy();
|
||||
complete_init();
|
||||
|
||||
debug( 0, _(L"Changing language to English") );
|
||||
}
|
||||
}
|
||||
free( old );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Universal variable callback function. This function makes sure the
|
||||
proper events are triggered when an event occurs.
|
||||
*/
|
||||
static void universal_callback( int type,
|
||||
const wchar_t *name,
|
||||
const wchar_t *val )
|
||||
{
|
||||
wchar_t *str=0;
|
||||
|
||||
if( is_locale( name ) )
|
||||
handle_locale();
|
||||
|
||||
switch( type )
|
||||
{
|
||||
case SET:
|
||||
@@ -213,7 +347,6 @@ static void universal_callback( int type,
|
||||
|
||||
if( str )
|
||||
{
|
||||
array_list_t arg;
|
||||
event_t ev;
|
||||
|
||||
has_changed=1;
|
||||
@@ -222,29 +355,108 @@ static void universal_callback( int type,
|
||||
ev.param1.variable=name;
|
||||
ev.function_name=0;
|
||||
|
||||
al_init( &arg );
|
||||
al_push( &arg, L"VARIABLE" );
|
||||
al_push( &arg, str );
|
||||
al_push( &arg, name );
|
||||
event_fire( &ev, &arg );
|
||||
al_destroy( &arg );
|
||||
al_init( &ev.arguments );
|
||||
al_push( &ev.arguments, L"VARIABLE" );
|
||||
al_push( &ev.arguments, str );
|
||||
al_push( &ev.arguments, name );
|
||||
event_fire( &ev );
|
||||
al_destroy( &ev.arguments );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Make sure the PATH variable contains the essaential directories
|
||||
*/
|
||||
static void setup_path()
|
||||
{
|
||||
wchar_t *path;
|
||||
|
||||
int i, j;
|
||||
array_list_t l;
|
||||
|
||||
const wchar_t *path_el[] =
|
||||
{
|
||||
L"/bin",
|
||||
L"/usr/bin",
|
||||
PREFIX L"/bin",
|
||||
0
|
||||
}
|
||||
;
|
||||
|
||||
path = env_get( L"PATH" );
|
||||
if( !path )
|
||||
{
|
||||
env_set( L"PATH", 0, ENV_EXPORT | ENV_GLOBAL );
|
||||
path=0;
|
||||
}
|
||||
|
||||
al_init( &l );
|
||||
|
||||
if( path )
|
||||
expand_variable_array( path, &l );
|
||||
|
||||
for( j=0; path_el[j]; j++ )
|
||||
{
|
||||
int has_el=0;
|
||||
|
||||
for( i=0; i<al_get_count( &l); i++ )
|
||||
{
|
||||
wchar_t * el = (wchar_t *)al_get( &l, i );
|
||||
size_t len = wcslen( el );
|
||||
while( (len > 0) && (el[len-1]==L'/') )
|
||||
len--;
|
||||
if( (wcslen( path_el[j] ) == len) && (wcsncmp( el, path_el[j], len)==0) )
|
||||
{
|
||||
has_el = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if( !has_el )
|
||||
{
|
||||
string_buffer_t b;
|
||||
|
||||
debug( 3, L"directory %ls was missing", path_el[j] );
|
||||
|
||||
sb_init( &b );
|
||||
if( path )
|
||||
{
|
||||
sb_append( &b, path );
|
||||
}
|
||||
|
||||
sb_append2( &b,
|
||||
ARRAY_SEP_STR,
|
||||
path_el[j],
|
||||
(void *)0 );
|
||||
|
||||
env_set( L"PATH", (wchar_t *)b.buff, ENV_GLOBAL | ENV_EXPORT );
|
||||
|
||||
sb_destroy( &b );
|
||||
|
||||
al_foreach( &l, (void (*)(const void *))&free );
|
||||
path = env_get( L"PATH" );
|
||||
al_truncate( &l, 0 );
|
||||
expand_variable_array( path, &l );
|
||||
}
|
||||
}
|
||||
|
||||
al_foreach( &l, (void (*)(const void *))&free );
|
||||
al_destroy( &l );
|
||||
}
|
||||
|
||||
void env_init()
|
||||
{
|
||||
char **p;
|
||||
struct passwd *pw;
|
||||
wchar_t *uname;
|
||||
|
||||
sb_init( &dyn_var );
|
||||
|
||||
b_init( &export_buffer );
|
||||
|
||||
|
||||
/*
|
||||
These variables can not be altered directly by the user
|
||||
*/
|
||||
hash_init( &env_read_only, &hash_wcs_func, &hash_wcs_cmp );
|
||||
|
||||
|
||||
hash_put( &env_read_only, L"status", L"" );
|
||||
hash_put( &env_read_only, L"history", L"" );
|
||||
hash_put( &env_read_only, L"_", L"" );
|
||||
@@ -253,11 +465,22 @@ void env_init()
|
||||
hash_put( &env_read_only, L"PWD", L"" );
|
||||
|
||||
/*
|
||||
HOME should be writeable by root, since this is often a
|
||||
Names of all dynamically calculated variables
|
||||
*/
|
||||
hash_init( &env_electric, &hash_wcs_func, &hash_wcs_cmp );
|
||||
hash_put( &env_electric, L"history", L"" );
|
||||
hash_put( &env_electric, L"status", L"" );
|
||||
hash_put( &env_electric, L"umask", L"" );
|
||||
|
||||
/*
|
||||
HOME and USER should be writeable by root, since this can be a
|
||||
convenient way to install software.
|
||||
*/
|
||||
if( getuid() != 0 )
|
||||
{
|
||||
hash_put( &env_read_only, L"HOME", L"" );
|
||||
hash_put( &env_read_only, L"USER", L"" );
|
||||
}
|
||||
|
||||
top = malloc( sizeof(env_node_t) );
|
||||
top->next = 0;
|
||||
@@ -267,6 +490,11 @@ void env_init()
|
||||
global_env = top;
|
||||
global = &top->env;
|
||||
|
||||
/*
|
||||
Now the environemnt variable handling is set up, the next step
|
||||
is to insert valid data
|
||||
*/
|
||||
|
||||
/*
|
||||
Import environment variables
|
||||
*/
|
||||
@@ -276,12 +504,13 @@ void env_init()
|
||||
wchar_t *pos;
|
||||
|
||||
key = str2wcs(*p);
|
||||
|
||||
|
||||
if( !key )
|
||||
continue;
|
||||
|
||||
val = wcschr( key, L'=' );
|
||||
|
||||
|
||||
if( val == 0 )
|
||||
env_set( key, L"", ENV_EXPORT );
|
||||
else
|
||||
@@ -296,13 +525,29 @@ void env_init()
|
||||
*pos = ARRAY_SEP;
|
||||
pos++;
|
||||
}
|
||||
|
||||
|
||||
env_set( key, val, ENV_EXPORT | ENV_GLOBAL );
|
||||
}
|
||||
free(key);
|
||||
}
|
||||
}
|
||||
|
||||
env_universal_init( env_get( L"FISHD_SOKET_DIR"),
|
||||
/*
|
||||
Set up the PATH variable
|
||||
*/
|
||||
setup_path();
|
||||
|
||||
/*
|
||||
Set up the USER variable
|
||||
*/
|
||||
pw = getpwuid( getuid() );
|
||||
if( pw )
|
||||
{
|
||||
uname = str2wcs( pw->pw_name );
|
||||
env_set( L"USER", uname, ENV_GLOBAL | ENV_EXPORT );
|
||||
free( uname );
|
||||
}
|
||||
|
||||
env_universal_init( env_get( L"FISHD_SOCKET_DIR"),
|
||||
env_get( L"USER" ),
|
||||
&start_fishd,
|
||||
&universal_callback );
|
||||
@@ -321,6 +566,8 @@ void env_destroy()
|
||||
env_pop();
|
||||
|
||||
hash_destroy( &env_read_only );
|
||||
|
||||
hash_destroy( &env_electric );
|
||||
|
||||
hash_foreach( global, &clear_hash_entry );
|
||||
hash_destroy( global );
|
||||
@@ -357,7 +604,7 @@ static env_node_t *env_get_node( const wchar_t *key )
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void env_set( const wchar_t *key,
|
||||
const wchar_t *val,
|
||||
int var_mode )
|
||||
@@ -371,42 +618,42 @@ void env_set( const wchar_t *key,
|
||||
int done=0;
|
||||
|
||||
event_t ev;
|
||||
array_list_t ev_list;
|
||||
int is_universal = 0;
|
||||
|
||||
|
||||
if( (var_mode & ENV_USER ) &&
|
||||
hash_get( &env_read_only, key ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( wcscmp(key, L"LANG" )==0 )
|
||||
{
|
||||
fish_setlocale(LC_ALL,val);
|
||||
}
|
||||
|
||||
if( wcscmp( key, L"umask" ) == 0)
|
||||
{
|
||||
wchar_t *end;
|
||||
int mask;
|
||||
|
||||
|
||||
/*
|
||||
Set the new umask
|
||||
*/
|
||||
if( val && wcslen(val) )
|
||||
{
|
||||
errno=0;
|
||||
mask = wcstol( val, &end, 8 );
|
||||
|
||||
if( !errno && !*end )
|
||||
if( !errno && (!*end) && (mask <= 0777) && (mask >= 0) )
|
||||
{
|
||||
umask( mask );
|
||||
}
|
||||
}
|
||||
/*
|
||||
Do not actually create a umask variable, on env_get, it will be calculated dynamically
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Zero element arrays are internaly not coded as null but as this placeholder string
|
||||
*/
|
||||
if( !val && ( var_mode & ENV_USER ) )
|
||||
if( !val )
|
||||
{
|
||||
val = ENV_NULL;
|
||||
}
|
||||
@@ -467,8 +714,11 @@ void env_set( const wchar_t *key,
|
||||
else
|
||||
{
|
||||
if( !proc_had_barrier)
|
||||
{
|
||||
proc_had_barrier=1;
|
||||
env_universal_barrier();
|
||||
|
||||
}
|
||||
|
||||
if( env_universal_get( key ) )
|
||||
{
|
||||
int export = 0;
|
||||
@@ -490,7 +740,8 @@ void env_set( const wchar_t *key,
|
||||
else
|
||||
{
|
||||
/*
|
||||
New variable with unspecified scope. The default scope is the innermost scope that is shadowing
|
||||
New variable with unspecified scope. The default
|
||||
scope is the innermost scope that is shadowing
|
||||
*/
|
||||
node = top;
|
||||
while( node->next && !node->new_scope )
|
||||
@@ -541,18 +792,24 @@ void env_set( const wchar_t *key,
|
||||
ev.param1.variable = key;
|
||||
ev.function_name = 0;
|
||||
|
||||
al_init( &ev_list );
|
||||
al_push( &ev_list, L"VARIABLE" );
|
||||
al_push( &ev_list, key );
|
||||
al_init( &ev.arguments );
|
||||
al_push( &ev.arguments, L"VARIABLE" );
|
||||
al_push( &ev.arguments, key );
|
||||
|
||||
// debug( 1, L"env_set: fire events on variable %ls", key );
|
||||
event_fire( &ev, &ev_list );
|
||||
event_fire( &ev );
|
||||
// debug( 1, L"env_set: return from event firing" );
|
||||
al_destroy( &ev_list );
|
||||
al_destroy( &ev.arguments );
|
||||
}
|
||||
|
||||
|
||||
if( is_locale( key ) )
|
||||
{
|
||||
handle_locale();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Attempt to remove/free the specified key/value pair from the
|
||||
specified hash table.
|
||||
@@ -600,6 +857,10 @@ void env_remove( const wchar_t *key, int var_mode )
|
||||
{
|
||||
env_universal_remove( key );
|
||||
}
|
||||
|
||||
if( is_locale( key ) )
|
||||
handle_locale();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -628,7 +889,7 @@ wchar_t *env_get( const wchar_t *key )
|
||||
wchar_t *next = history_get( i-add_current );
|
||||
if( !next )
|
||||
{
|
||||
debug( 1, L"No history at idx %d\n", i );
|
||||
debug( 1, _( L"No history item at index %d\n" ), i );
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -656,6 +917,12 @@ wchar_t *env_get( const wchar_t *key )
|
||||
sb_printf( &dyn_var, L"%d", proc_get_last_status() );
|
||||
return (wchar_t *)dyn_var.buff;
|
||||
}
|
||||
else if( wcscmp( key, L"umask" )==0 )
|
||||
{
|
||||
sb_clear( &dyn_var );
|
||||
sb_printf( &dyn_var, L"0%0.3o", get_umask() );
|
||||
return (wchar_t *)dyn_var.buff;
|
||||
}
|
||||
|
||||
while( env != 0 )
|
||||
{
|
||||
@@ -677,7 +944,11 @@ wchar_t *env_get( const wchar_t *key )
|
||||
env = env->next;
|
||||
}
|
||||
if( !proc_had_barrier)
|
||||
{
|
||||
proc_had_barrier=1;
|
||||
env_universal_barrier();
|
||||
}
|
||||
|
||||
item = env_universal_get( key );
|
||||
|
||||
if( !item || (wcscmp( item, ENV_NULL )==0))
|
||||
@@ -694,7 +965,7 @@ int env_exist( const wchar_t *key )
|
||||
env_node_t *env = top;
|
||||
wchar_t *item;
|
||||
|
||||
if( hash_get( &env_read_only, key ) )
|
||||
if( hash_get( &env_read_only, key ) || hash_get( &env_electric, key ) )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@@ -714,12 +985,19 @@ int env_exist( const wchar_t *key )
|
||||
env = env->next;
|
||||
}
|
||||
if( !proc_had_barrier)
|
||||
{
|
||||
proc_had_barrier=1;
|
||||
env_universal_barrier();
|
||||
}
|
||||
|
||||
item = env_universal_get( key );
|
||||
|
||||
return item != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
Returns true if the specified scope or any non-shadowed non-global subscopes contain an exported variable.
|
||||
*/
|
||||
static int local_scope_exports( env_node_t *n )
|
||||
{
|
||||
|
||||
@@ -755,8 +1033,20 @@ void env_pop()
|
||||
{
|
||||
if( &top->env != global )
|
||||
{
|
||||
int i;
|
||||
int locale_changed = 0;
|
||||
|
||||
env_node_t *killme = top;
|
||||
|
||||
for( i=0; locale_variable[i]; i++ )
|
||||
{
|
||||
if( hash_get( &killme->env, locale_variable[i] ) )
|
||||
{
|
||||
locale_changed = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( killme->new_scope )
|
||||
{
|
||||
has_changed |= killme->export || local_scope_exports( killme->next );
|
||||
@@ -766,12 +1056,15 @@ void env_pop()
|
||||
hash_foreach( &killme->env, &clear_hash_entry );
|
||||
hash_destroy( &killme->env );
|
||||
free( killme );
|
||||
|
||||
if( locale_changed )
|
||||
handle_locale();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
debug( 0,
|
||||
L"Tried to pop empty environment stack." );
|
||||
_( L"Tried to pop empty environment stack." ) );
|
||||
sanity_lose();
|
||||
}
|
||||
}
|
||||
@@ -788,9 +1081,14 @@ static void add_key_to_hash( const void *key,
|
||||
var_entry_t *e = (var_entry_t *)data;
|
||||
if( ( e->export && get_names_show_exported) ||
|
||||
( !e->export && get_names_show_unexported) )
|
||||
{
|
||||
hash_put( (hash_table_t *)aux, key, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Add key to hashtable
|
||||
*/
|
||||
static void add_to_hash( const void *k, void *aux )
|
||||
{
|
||||
hash_put( (hash_table_t *)aux,
|
||||
@@ -798,6 +1096,16 @@ static void add_to_hash( const void *k, void *aux )
|
||||
0 );
|
||||
}
|
||||
|
||||
/**
|
||||
Add key to list
|
||||
*/
|
||||
static void add_key_to_list( const void * key,
|
||||
const void * val,
|
||||
void *aux )
|
||||
{
|
||||
al_push( (array_list_t *)aux, key );
|
||||
}
|
||||
|
||||
|
||||
void env_get_names( array_list_t *l, int flags )
|
||||
{
|
||||
@@ -844,11 +1152,9 @@ void env_get_names( array_list_t *l, int flags )
|
||||
hash_foreach2( &global_env->env,
|
||||
add_key_to_hash,
|
||||
&names );
|
||||
|
||||
if( get_names_show_unexported )
|
||||
{
|
||||
al_push( l, L"history" );
|
||||
al_push( l, L"status" );
|
||||
}
|
||||
hash_foreach2( &env_electric, &add_key_to_list, l );
|
||||
|
||||
if( get_names_show_exported )
|
||||
{
|
||||
@@ -934,8 +1240,11 @@ static void export_func2( const void *k, const void *v, void *aux )
|
||||
char **env_export_arr( int recalc)
|
||||
{
|
||||
if( recalc && !proc_had_barrier)
|
||||
{
|
||||
proc_had_barrier=1;
|
||||
env_universal_barrier();
|
||||
|
||||
}
|
||||
|
||||
if( has_changed )
|
||||
{
|
||||
array_list_t uni;
|
||||
|
||||
@@ -11,12 +11,19 @@
|
||||
#include <pwd.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#if HAVE_NCURSES_H
|
||||
#include <ncurses.h>
|
||||
#else
|
||||
#include <curses.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_TERM_H
|
||||
#include <term.h>
|
||||
#elif HAVE_NCURSES_TERM_H
|
||||
#include <ncurses/term.h>
|
||||
#endif
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#include "util.h"
|
||||
@@ -112,24 +119,21 @@ static int get_socket( int fork_ok )
|
||||
local.sun_family = AF_UNIX;
|
||||
strcpy(local.sun_path, name );
|
||||
free( name );
|
||||
len = strlen(local.sun_path) + sizeof(local.sun_family);
|
||||
len = sizeof(local);
|
||||
|
||||
if( connect( s, (struct sockaddr *)&local, len) == -1 )
|
||||
{
|
||||
close( s );
|
||||
if( fork_ok )
|
||||
if( fork_ok && start_fishd )
|
||||
{
|
||||
debug( 2, L"Could not connect to socket %d, starting fishd", s );
|
||||
|
||||
if( start_fishd )
|
||||
{
|
||||
start_fishd();
|
||||
}
|
||||
|
||||
start_fishd();
|
||||
|
||||
return get_socket( 0 );
|
||||
}
|
||||
|
||||
debug( 3, L"Could not connect to socket %d, already tried forking, giving up", s );
|
||||
debug( 2, L"Could not connect to socket %d, already tried manual restart (or no command supplied), giving up", s );
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -174,7 +178,7 @@ static void check_connection()
|
||||
|
||||
if( env_universal_server.killme )
|
||||
{
|
||||
debug( 2, L"Lost connection to universal variable server." );
|
||||
debug( 3, L"Lost connection to universal variable server." );
|
||||
close( env_universal_server.fd );
|
||||
env_universal_server.fd = -1;
|
||||
env_universal_server.killme=0;
|
||||
@@ -193,7 +197,7 @@ static void reconnect()
|
||||
if( get_socket_count >= RECONNECT_COUNT )
|
||||
return;
|
||||
|
||||
debug( 2, L"Get new fishd connection" );
|
||||
debug( 3, L"Get new fishd connection" );
|
||||
|
||||
init = 0;
|
||||
env_universal_server.fd = get_socket(1);
|
||||
@@ -210,7 +214,7 @@ void env_universal_init( wchar_t * p,
|
||||
void (*sf)(),
|
||||
void (*cb)( int type, const wchar_t *name, const wchar_t *val ))
|
||||
{
|
||||
debug( 2, L"env_universal_init()" );
|
||||
debug( 3, L"env_universal_init()" );
|
||||
path=p;
|
||||
user=u;
|
||||
start_fishd=sf;
|
||||
@@ -229,7 +233,7 @@ void env_universal_init( wchar_t * p,
|
||||
{
|
||||
env_universal_barrier();
|
||||
}
|
||||
debug( 2, L"end env_universal_init()" );
|
||||
debug( 3, L"end env_universal_init()" );
|
||||
}
|
||||
|
||||
void env_universal_destroy()
|
||||
@@ -262,6 +266,8 @@ int env_universal_read_all()
|
||||
if( !init)
|
||||
return 0;
|
||||
|
||||
debug( 3, L"env_universal_read_all()" );
|
||||
|
||||
if( env_universal_server.fd == -1 )
|
||||
{
|
||||
reconnect();
|
||||
@@ -290,11 +296,13 @@ wchar_t *env_universal_get( const wchar_t *name )
|
||||
if( !name )
|
||||
return 0;
|
||||
|
||||
debug( 3, L"env_universal_get( \"%ls\" )", name );
|
||||
return env_universal_common_get( name );
|
||||
}
|
||||
|
||||
int env_universal_get_export( const wchar_t *name )
|
||||
{
|
||||
debug( 3, L"env_universal_get_export()" );
|
||||
return env_universal_common_get_export( name );
|
||||
}
|
||||
|
||||
@@ -305,7 +313,7 @@ void env_universal_barrier()
|
||||
|
||||
if( !init || ( env_universal_server.fd == -1 ))
|
||||
return;
|
||||
|
||||
|
||||
barrier_reply = 0;
|
||||
|
||||
/*
|
||||
@@ -330,6 +338,7 @@ void env_universal_barrier()
|
||||
if( env_universal_server.fd == -1 )
|
||||
{
|
||||
reconnect();
|
||||
debug( 2, L"barrier interrupted, exiting" );
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -347,6 +356,7 @@ void env_universal_barrier()
|
||||
if( env_universal_server.fd == -1 )
|
||||
{
|
||||
reconnect();
|
||||
debug( 2, L"barrier interrupted, exiting (2)" );
|
||||
return;
|
||||
}
|
||||
FD_ZERO( &fds );
|
||||
@@ -365,7 +375,7 @@ void env_universal_set( const wchar_t *name, const wchar_t *value, int export )
|
||||
if( !init )
|
||||
return;
|
||||
|
||||
debug( 3, L"env_universal_set( %ls, %ls )", name, value );
|
||||
debug( 3, L"env_universal_set( \"%ls\", \"%ls\" )", name, value );
|
||||
|
||||
msg = create_message( export?SET_EXPORT:SET,
|
||||
name,
|
||||
@@ -388,8 +398,8 @@ void env_universal_remove( const wchar_t *name )
|
||||
if( !init )
|
||||
return;
|
||||
|
||||
debug( 2,
|
||||
L"env_universal_remove( %ls )",
|
||||
debug( 3,
|
||||
L"env_universal_remove( \"%ls\" )",
|
||||
name );
|
||||
|
||||
msg= create_message( ERASE, name, 0);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/** \file env_universl.h
|
||||
/** \file env_universal.h
|
||||
Universal variable client library
|
||||
*/
|
||||
|
||||
@@ -18,7 +18,7 @@ extern connection_t env_universal_server;
|
||||
Initialize the envuni library
|
||||
*/
|
||||
void env_universal_init();
|
||||
/*
|
||||
/**
|
||||
Free memory used by envuni
|
||||
*/
|
||||
void env_universal_destroy();
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
client library and by the daemon.
|
||||
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
@@ -65,12 +67,12 @@
|
||||
should be exported. Obviously, it needs to be allocated large
|
||||
enough to fit the value string.
|
||||
*/
|
||||
typedef struct var_entry
|
||||
typedef struct var_uni_entry
|
||||
{
|
||||
int export; /**< Whether the variable should be exported */
|
||||
wchar_t val[0]; /**< The value of the variable */
|
||||
}
|
||||
var_entry_t;
|
||||
var_uni_entry_t;
|
||||
|
||||
|
||||
static void parse_message( wchar_t *msg,
|
||||
@@ -81,6 +83,9 @@ static void parse_message( wchar_t *msg,
|
||||
*/
|
||||
hash_table_t env_universal_var;
|
||||
|
||||
/**
|
||||
Callback function, should be called on all events
|
||||
*/
|
||||
void (*callback)( int type,
|
||||
const wchar_t *key,
|
||||
const wchar_t *val );
|
||||
@@ -100,11 +105,14 @@ static int get_names_show_unexported;
|
||||
|
||||
void env_universal_common_init( void (*cb)(int type, const wchar_t *key, const wchar_t *val ) )
|
||||
{
|
||||
debug( 2, L"Init env_universal_common" );
|
||||
debug( 3, L"Init env_universal_common" );
|
||||
callback = cb;
|
||||
hash_init( &env_universal_var, &hash_wcs_func, &hash_wcs_cmp );
|
||||
}
|
||||
|
||||
/**
|
||||
Free both key and data
|
||||
*/
|
||||
static void erase( const void *key,
|
||||
const void *data )
|
||||
{
|
||||
@@ -180,12 +188,15 @@ void read_message( connection_t *src )
|
||||
}
|
||||
else
|
||||
{
|
||||
sb_printf( &src->input, L"%lc", res );
|
||||
sb_append_char( &src->input, res );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Remove variable with specified name
|
||||
*/
|
||||
static void remove_entry( wchar_t *name )
|
||||
{
|
||||
void *k, *v;
|
||||
@@ -197,6 +208,9 @@ static void remove_entry( wchar_t *name )
|
||||
free( v );
|
||||
}
|
||||
|
||||
/**
|
||||
Test if the message msg contains the command cmd
|
||||
*/
|
||||
static int match( const wchar_t *msg, const wchar_t *cmd )
|
||||
{
|
||||
size_t len = wcslen( cmd );
|
||||
@@ -209,11 +223,13 @@ static int match( const wchar_t *msg, const wchar_t *cmd )
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Parse message msg
|
||||
*/
|
||||
static void parse_message( wchar_t *msg,
|
||||
connection_t *src )
|
||||
{
|
||||
debug( 2, L"parse_message( %ls );", msg );
|
||||
debug( 3, L"parse_message( %ls );", msg );
|
||||
|
||||
if( msg[0] == L'#' )
|
||||
return;
|
||||
@@ -239,8 +255,8 @@ static void parse_message( wchar_t *msg,
|
||||
|
||||
val = unescape( val, 0 );
|
||||
|
||||
var_entry_t *entry =
|
||||
malloc( sizeof(var_entry_t) + sizeof(wchar_t)*(wcslen(val)+1) );
|
||||
var_uni_entry_t *entry =
|
||||
malloc( sizeof(var_uni_entry_t) + sizeof(wchar_t)*(wcslen(val)+1) );
|
||||
if( !entry )
|
||||
die_mem();
|
||||
entry->export=export;
|
||||
@@ -307,8 +323,13 @@ static void parse_message( wchar_t *msg,
|
||||
}
|
||||
}
|
||||
|
||||
int try_send( message_t *msg,
|
||||
int fd )
|
||||
/**
|
||||
Attempt to send the specified message to the specified file descriptor
|
||||
|
||||
\return 1 on sucess, 0 if the message could not be sent without blocking and -1 on error
|
||||
*/
|
||||
static int try_send( message_t *msg,
|
||||
int fd )
|
||||
{
|
||||
|
||||
debug( 3,
|
||||
@@ -478,7 +499,7 @@ static void add_key_to_hash( const void *key,
|
||||
const void *data,
|
||||
void *aux )
|
||||
{
|
||||
var_entry_t *e = (var_entry_t *)data;
|
||||
var_uni_entry_t *e = (var_uni_entry_t *)data;
|
||||
if( ( e->export && get_names_show_exported) ||
|
||||
( !e->export && get_names_show_unexported) )
|
||||
al_push( (array_list_t *)aux, key );
|
||||
@@ -498,7 +519,7 @@ void env_universal_common_get_names( array_list_t *l,
|
||||
|
||||
wchar_t *env_universal_common_get( const wchar_t *name )
|
||||
{
|
||||
var_entry_t *e = (var_entry_t *)hash_get( &env_universal_var, name );
|
||||
var_uni_entry_t *e = (var_uni_entry_t *)hash_get( &env_universal_var, name );
|
||||
if( e )
|
||||
return e->val;
|
||||
return 0;
|
||||
@@ -506,18 +527,28 @@ wchar_t *env_universal_common_get( const wchar_t *name )
|
||||
|
||||
int env_universal_common_get_export( const wchar_t *name )
|
||||
{
|
||||
var_entry_t *e = (var_entry_t *)hash_get( &env_universal_var, name );
|
||||
var_uni_entry_t *e = (var_uni_entry_t *)hash_get( &env_universal_var, name );
|
||||
if( e )
|
||||
return e->export;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
Adds a variable creation message about the specified variable to
|
||||
the specified queue. The function signature is non-obvious since
|
||||
this function is used together with hash_foreach2, which requires
|
||||
the specified function signature.
|
||||
|
||||
\param k the variable name
|
||||
\param v the variable value
|
||||
\param q the queue to add the message to
|
||||
*/
|
||||
static void enqueue( const void *k,
|
||||
const void *v,
|
||||
void *q)
|
||||
{
|
||||
const wchar_t *key = (const wchar_t *)k;
|
||||
const var_entry_t *val = (const var_entry_t *)v;
|
||||
const var_uni_entry_t *val = (const var_uni_entry_t *)v;
|
||||
dyn_queue_t *queue = (dyn_queue_t *)q;
|
||||
|
||||
message_t *msg = create_message( val->export?SET_EXPORT:SET, key, val->val );
|
||||
|
||||
@@ -88,7 +88,13 @@ typedef struct connection
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/**
|
||||
Number of queues that contain this message. Once this reaches zero, the message should be deleted
|
||||
*/
|
||||
int count;
|
||||
/**
|
||||
Message body. The message must be allocated using enough memory to actually contain the message.
|
||||
*/
|
||||
char body[0];
|
||||
}
|
||||
message_t;
|
||||
@@ -136,6 +142,9 @@ wchar_t *env_universal_common_get( const wchar_t *name );
|
||||
*/
|
||||
int env_universal_common_get_export( const wchar_t *name );
|
||||
|
||||
/**
|
||||
Add messages about all existing variables to the specified connection
|
||||
*/
|
||||
void enqueue_all( connection_t *c );
|
||||
|
||||
|
||||
|
||||
70
etc/fish.in
Normal file
70
etc/fish.in
Normal file
@@ -0,0 +1,70 @@
|
||||
#
|
||||
# Init file for fish
|
||||
#
|
||||
# @configure_input@
|
||||
|
||||
#
|
||||
# Set default search paths
|
||||
#
|
||||
|
||||
set -g fish_function_path ~/.fish.d/functions @SYSCONFDIR@/fish.d/functions @DATADIR@/functions
|
||||
set -g fish_complete_path ~/.fish.d/completions @SYSCONFDIR@/fish.d/completions @DATADIR@/completions
|
||||
|
||||
#
|
||||
# Set default field separators
|
||||
#
|
||||
|
||||
set -g IFS \ \t\n
|
||||
|
||||
#
|
||||
# Add a few common directories to path, if they exists. Note that pure
|
||||
# console programs like makedep sometimes live in /usr/X11R6/bin, so we
|
||||
# want this even for text-only terminals.
|
||||
#
|
||||
|
||||
set -l path_list /bin /usr/bin /usr/X11R6/bin @PREFIX@/bin @optbindirs@
|
||||
|
||||
# Root should also have the sbin directories in the path
|
||||
if test "$USER" = root
|
||||
set path_list $path_list /sbin /usr/sbin /usr/local/sbin
|
||||
end
|
||||
|
||||
for i in $path_list
|
||||
if not expr "$PATH" : .\*$i.\* >/dev/null
|
||||
if test -d $i
|
||||
set PATH $PATH $i
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
#
|
||||
# Put linux console in unicode mode. Should this be done in any other
|
||||
# situation as well?
|
||||
#
|
||||
|
||||
if expr "$LANG" : ".*[Uu][Tt][Ff]" >/dev/null
|
||||
if test linux = "$TERM"
|
||||
unicode_start ^/dev/null
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
#
|
||||
# There are variables that contain colons that are not arrays. This
|
||||
# reverts them back to regular strings.
|
||||
#
|
||||
|
||||
for i in DISPLAY
|
||||
if set -q $i
|
||||
set -- $i (printf ":%s" $$i|cut -c 2-)
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
# Load additional initialization files
|
||||
#
|
||||
|
||||
for i in fish.d/*.fish
|
||||
. $i
|
||||
end
|
||||
@@ -19,7 +19,7 @@ $if fish
|
||||
"\M-d": if test -z (commandline); dirh; else; commandline -f kill-word; end
|
||||
"\C-d": delete-or-exit
|
||||
# This will make sure the output of the current command is paged using the less pager when you press Meta-p
|
||||
"\M-p": if commandline -j|grep -v "less *$" >/dev/null; commandline -aj "|less;"; end
|
||||
"\M-p": if commandline -j|grep -v 'less *$' >/dev/null; commandline -aj "|less;"; end
|
||||
$endif
|
||||
|
||||
# Include user-specific inputrc file after including fish-specific
|
||||
@@ -1,6 +1,7 @@
|
||||
#
|
||||
# Initializations that should only be performed when in interactive mode
|
||||
#
|
||||
# @configure_input@
|
||||
|
||||
if not status --is-interactive
|
||||
exit
|
||||
@@ -10,26 +11,15 @@ end
|
||||
# Print a greeting
|
||||
#
|
||||
|
||||
printf 'Welcome to fish, the friendly interactive shell\nType '
|
||||
set_color green
|
||||
printf 'help '
|
||||
set_color normal
|
||||
printf 'for instructions on how to use fish\n'
|
||||
printf (_ 'Welcome to fish, the friendly interactive shell\n')
|
||||
printf (_ 'Type %shelp%s for instructions on how to use fish\n') (set_color green) (set_color normal)
|
||||
|
||||
#
|
||||
# Set exit message
|
||||
#
|
||||
|
||||
function fish_on_exit -d "Commands to execute when fish exits"
|
||||
echo Good bye
|
||||
end
|
||||
|
||||
# Set the default prompt command. Make sure that every terminal escape
|
||||
# string has a newline before and after, so that fish will know how
|
||||
# long it is.
|
||||
|
||||
function fish_prompt -d "Write out the prompt"
|
||||
printf '%s@%s \n%s\n%s\n%s\n> ' (whoami) (hostname|cut -d . -f 1) (set_color $fish_color_cwd) (prompt_pwd) (set_color normal)
|
||||
function fish_on_exit -d (_ "Commands to execute when fish exits") --on-process %self
|
||||
printf (_ "Good bye\n")
|
||||
end
|
||||
|
||||
#
|
||||
@@ -39,9 +29,11 @@ end
|
||||
# other than fish, which may use a different file. The new value should
|
||||
# be exported, since the fish inputrc file plays nice with other files
|
||||
# by including them when found.
|
||||
# Give priority to the default file installed with fish in
|
||||
# @SYSCONFDIR@/fish_inputrc.
|
||||
#
|
||||
|
||||
for i in ~/.fish_inputrc ~/etc/fish_inputrc /etc/fish_inputrc ~/.inputrc /etc/inputrc
|
||||
for i in ~/.fish_inputrc @SYSCONFDIR@/fish_inputrc ~/.inputrc /etc/inputrc
|
||||
if test -f $i
|
||||
set -xg INPUTRC $i
|
||||
break
|
||||
@@ -53,9 +45,9 @@ end
|
||||
# Set various color values
|
||||
#
|
||||
|
||||
function set_default -d "Set an universal variable, unless it has already been set"
|
||||
if not set -q $argv[1]
|
||||
set -U -- $argv
|
||||
function set_default -d "Set an exported universal variable, unless it has already been set"
|
||||
if not set -q $argv[1]
|
||||
set -Ux -- $argv
|
||||
end
|
||||
end
|
||||
|
||||
@@ -95,25 +87,11 @@ set_default fish_color_history_current cyan
|
||||
# Setup the CDPATH variable
|
||||
#
|
||||
|
||||
set_exported_default CDPATH . ~
|
||||
set_default CDPATH . ~
|
||||
|
||||
#
|
||||
# Match colors for grep, if supported
|
||||
# Remove temporary functions
|
||||
#
|
||||
|
||||
if grep --color=auto --help 1>/dev/null 2>/dev/null
|
||||
set_exported_default GREP_COLOR '97;45'
|
||||
set_exported_default GREP_OPTIONS '--color=auto'
|
||||
end
|
||||
|
||||
#
|
||||
# Color definitions for ls, if supported
|
||||
#
|
||||
|
||||
if command ls --color=auto --help 1>/dev/null 2>/dev/null
|
||||
set_exported_default LS_COLORS $LS_COLORS '*.jar=01;31' '*.doc=35' '*.pdf=35' '*.ps=35' '*.xls=35' '*.swf=35' '*~=37'
|
||||
end
|
||||
|
||||
|
||||
functions -e set_default
|
||||
functions -e set_exported_default
|
||||
functions -e set_default
|
||||
240
event.c
240
event.c
@@ -1,6 +1,6 @@
|
||||
/** \file function.c
|
||||
/** \file event.c
|
||||
|
||||
Functions for storing and retrieving function information.
|
||||
Functions for handling event triggers
|
||||
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
@@ -13,12 +13,15 @@
|
||||
|
||||
#include "config.h"
|
||||
#include "util.h"
|
||||
#include "wutil.h"
|
||||
#include "function.h"
|
||||
#include "proc.h"
|
||||
#include "parser.h"
|
||||
#include "common.h"
|
||||
#include "event.h"
|
||||
#include "signal.h"
|
||||
#include "translate.h"
|
||||
#include "halloc_util.h"
|
||||
|
||||
/**
|
||||
Number of signals that can be queued before an overflow occurs
|
||||
@@ -31,13 +34,22 @@
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/**
|
||||
Number of delivered signals
|
||||
*/
|
||||
int count;
|
||||
/**
|
||||
Whether signals have been skipped
|
||||
*/
|
||||
int overflow;
|
||||
/**
|
||||
Array of signal events
|
||||
*/
|
||||
int signal[SIG_UNHANDLED_MAX];
|
||||
}
|
||||
signal_list_t;
|
||||
|
||||
/*
|
||||
/**
|
||||
The signal event list. Actually two separate lists. One which is
|
||||
active, which is the one that new events is written to. The inactive
|
||||
one contains the events that are currently beeing performed.
|
||||
@@ -58,10 +70,20 @@ static array_list_t *events;
|
||||
*/
|
||||
static array_list_t *killme;
|
||||
|
||||
/**
|
||||
List of events that have been sent but have not yet been delivered because they are blocked.
|
||||
*/
|
||||
static array_list_t *blocked;
|
||||
|
||||
/**
|
||||
String buffer used for formating event descriptions in event_get_desc()
|
||||
*/
|
||||
static string_buffer_t *get_desc_buff=0;
|
||||
|
||||
/**
|
||||
Tests if one event instance matches the definition of a event
|
||||
class. If the class defines a function name, that will also be a
|
||||
match criterion.
|
||||
class. If both the class and the instance name a function,
|
||||
they must name the same function.
|
||||
|
||||
*/
|
||||
static int event_match( event_t *class, event_t *instance )
|
||||
@@ -111,7 +133,7 @@ static int event_match( event_t *class, event_t *instance )
|
||||
Create an identical copy of an event. Use deep copying, i.e. make
|
||||
duplicates of any strings used as well.
|
||||
*/
|
||||
static event_t *event_copy( event_t *event )
|
||||
static event_t *event_copy( event_t *event, int copy_arguments )
|
||||
{
|
||||
event_t *e = malloc( sizeof( event_t ) );
|
||||
if( !e )
|
||||
@@ -124,15 +146,114 @@ static event_t *event_copy( event_t *event )
|
||||
if( e->type == EVENT_VARIABLE )
|
||||
e->param1.variable = wcsdup( e->param1.variable );
|
||||
|
||||
al_init( &e->arguments );
|
||||
if( copy_arguments )
|
||||
{
|
||||
int i;
|
||||
for( i=0; i<al_get_count( &event->arguments ); i++ )
|
||||
{
|
||||
al_push( &e->arguments, wcsdup( (wchar_t *)al_get( &event->arguments, i ) ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
/**
|
||||
Test if specified event is blocked
|
||||
*/
|
||||
static int event_is_blocked( event_t *e )
|
||||
{
|
||||
block_t *block;
|
||||
event_block_t *eb;
|
||||
|
||||
for( block = current_block; block; block = block->outer )
|
||||
{
|
||||
for( eb = block->first_event_block; eb; eb=eb->next )
|
||||
{
|
||||
if( eb->type & (1<<EVENT_ANY ) )
|
||||
return 1;
|
||||
if( eb->type & (1<<e->type) )
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
for( eb = global_event_block; eb; eb=eb->next )
|
||||
{
|
||||
if( eb->type & (1<<EVENT_ANY ) )
|
||||
return 1;
|
||||
if( eb->type & (1<<e->type) )
|
||||
return 1;
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const wchar_t *event_get_desc( event_t *e )
|
||||
{
|
||||
if( !get_desc_buff )
|
||||
{
|
||||
get_desc_buff=sb_halloc( global_context );
|
||||
}
|
||||
else
|
||||
{
|
||||
sb_clear( get_desc_buff );
|
||||
}
|
||||
|
||||
switch( e->type )
|
||||
{
|
||||
|
||||
case EVENT_SIGNAL:
|
||||
sb_printf( get_desc_buff, _(L"signal handler for %ls (%ls)"), sig2wcs(e->param1.signal ), signal_get_desc( e->param1.signal ) );
|
||||
break;
|
||||
|
||||
case EVENT_VARIABLE:
|
||||
sb_printf( get_desc_buff, _(L"handler for variable '%ls'"), e->param1.variable );
|
||||
break;
|
||||
|
||||
case EVENT_EXIT:
|
||||
if( e->param1.pid > 0 )
|
||||
{
|
||||
sb_printf( get_desc_buff, _(L"exit handler for process %d"), e->param1.pid );
|
||||
}
|
||||
else
|
||||
{
|
||||
job_t *j = job_get_from_pid( -e->param1.pid );
|
||||
if( j )
|
||||
sb_printf( get_desc_buff, _(L"exit handler for job %d, '%ls'"), j->job_id, j->command );
|
||||
else
|
||||
sb_printf( get_desc_buff, _(L"exit handler for job with process group %d"), -e->param1.pid );
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case EVENT_JOB_ID:
|
||||
{
|
||||
job_t *j = job_get( e->param1.job_id );
|
||||
if( j )
|
||||
sb_printf( get_desc_buff, _(L"exit handler for job %d, '%ls'"), j->job_id, j->command );
|
||||
else
|
||||
sb_printf( get_desc_buff, _(L"exit handler for job with job id %d"), j->job_id );
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return (const wchar_t *)get_desc_buff->buff;
|
||||
}
|
||||
|
||||
|
||||
void event_add_handler( event_t *event )
|
||||
{
|
||||
event_t *e = event_copy( event );
|
||||
event_t *e;
|
||||
|
||||
e = event_copy( event, 0 );
|
||||
|
||||
if( !events )
|
||||
events = al_new();
|
||||
events = al_new();
|
||||
|
||||
if( e->type == EVENT_SIGNAL )
|
||||
{
|
||||
@@ -259,7 +380,7 @@ static int event_is_killed( event_t *e )
|
||||
matches' path. This means that nothing is allocated/initialized
|
||||
unless that is needed.
|
||||
*/
|
||||
static void event_fire_internal( event_t *event, array_list_t *arguments )
|
||||
static void event_fire_internal( event_t *event )
|
||||
{
|
||||
int i, j;
|
||||
string_buffer_t *b=0;
|
||||
@@ -325,9 +446,9 @@ static void event_fire_internal( event_t *event, array_list_t *arguments )
|
||||
|
||||
sb_append( b, criterion->function_name );
|
||||
|
||||
for( j=0; j<al_get_count(arguments); j++ )
|
||||
for( j=0; j<al_get_count(&event->arguments); j++ )
|
||||
{
|
||||
wchar_t *arg_esc = escape( (wchar_t *)al_get( arguments, j), 0 );
|
||||
wchar_t *arg_esc = escape( (wchar_t *)al_get( &event->arguments, j), 1 );
|
||||
sb_append( b, L" " );
|
||||
sb_append( b, arg_esc );
|
||||
free( arg_esc );
|
||||
@@ -335,13 +456,16 @@ static void event_fire_internal( event_t *event, array_list_t *arguments )
|
||||
|
||||
// debug( 1, L"Event handler fires command '%ls'", (wchar_t *)b->buff );
|
||||
|
||||
is_subshell=1;
|
||||
is_interactive=1;
|
||||
|
||||
/*
|
||||
Event handlers are not part of the main flow of code, so
|
||||
they are marked as non-interactive and as a subshell
|
||||
*/
|
||||
proc_push_interactive(0);
|
||||
parser_push_block( EVENT );
|
||||
current_block->param1.event = event;
|
||||
eval( (wchar_t *)b->buff, 0, TOP );
|
||||
is_subshell=0;
|
||||
is_interactive=1;
|
||||
|
||||
parser_pop_block();
|
||||
proc_pop_interactive();
|
||||
}
|
||||
|
||||
if( b )
|
||||
@@ -366,15 +490,40 @@ static void event_fire_internal( event_t *event, array_list_t *arguments )
|
||||
/**
|
||||
Handle all pending signal events
|
||||
*/
|
||||
static void event_fire_signal_events()
|
||||
static void event_fire_delayed()
|
||||
{
|
||||
|
||||
int i;
|
||||
|
||||
if( blocked && is_event==1)
|
||||
{
|
||||
array_list_t *new_blocked = 0;
|
||||
|
||||
for( i=0; i<al_get_count( blocked ); i++ )
|
||||
{
|
||||
event_t *e = (event_t *)al_get( blocked, i );
|
||||
if( event_is_blocked( e ) )
|
||||
{
|
||||
if( !new_blocked )
|
||||
new_blocked = al_new();
|
||||
al_push( new_blocked, e );
|
||||
}
|
||||
else
|
||||
{
|
||||
event_fire_internal( e );
|
||||
event_free( e );
|
||||
}
|
||||
}
|
||||
al_destroy( blocked );
|
||||
free( blocked );
|
||||
blocked = new_blocked;
|
||||
}
|
||||
|
||||
while( sig_list[active_list].count > 0 )
|
||||
{
|
||||
int i;
|
||||
signal_list_t *lst;
|
||||
event_t e;
|
||||
array_list_t a;
|
||||
al_init( &a );
|
||||
al_init( &e.arguments );
|
||||
|
||||
/*
|
||||
Switch signal lists
|
||||
@@ -393,7 +542,7 @@ static void event_fire_signal_events()
|
||||
|
||||
if( lst->overflow )
|
||||
{
|
||||
debug( 0, L"Signal list overflow. Signals have been ignored" );
|
||||
debug( 0, _( L"Signal list overflow. Signals have been ignored." ) );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -402,19 +551,27 @@ static void event_fire_signal_events()
|
||||
for( i=0; i<lst->count; i++ )
|
||||
{
|
||||
e.param1.signal = lst->signal[i];
|
||||
al_set( &a, 0, sig2wcs( e.param1.signal ) );
|
||||
event_fire_internal( &e, &a );
|
||||
al_set( &e.arguments, 0, sig2wcs( e.param1.signal ) );
|
||||
if( event_is_blocked( &e ) )
|
||||
{
|
||||
if( !blocked )
|
||||
blocked = al_new();
|
||||
al_push( blocked, event_copy(&e, 1) );
|
||||
}
|
||||
else
|
||||
{
|
||||
event_fire_internal( &e );
|
||||
}
|
||||
}
|
||||
|
||||
al_destroy( &a );
|
||||
al_destroy( &e.arguments );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void event_fire( event_t *event, array_list_t *arguments )
|
||||
void event_fire( event_t *event )
|
||||
{
|
||||
//int is_event_old = is_event;
|
||||
is_event++;
|
||||
|
||||
if( event && (event->type == EVENT_SIGNAL) )
|
||||
@@ -429,17 +586,29 @@ void event_fire( event_t *event, array_list_t *arguments )
|
||||
sig_list[active_list].signal[sig_list[active_list].count++]=event->param1.signal;
|
||||
else
|
||||
sig_list[active_list].overflow=1;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
event_fire_signal_events();
|
||||
|
||||
event_fire_delayed();
|
||||
|
||||
if( event )
|
||||
event_fire_internal( event, arguments );
|
||||
{
|
||||
if( event_is_blocked( event ) )
|
||||
{
|
||||
if( !blocked )
|
||||
blocked = al_new();
|
||||
|
||||
al_push( blocked, event_copy(event, 1) );
|
||||
}
|
||||
else
|
||||
{
|
||||
event_fire_internal( event );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
is_event--;// = is_event_old;
|
||||
is_event--;
|
||||
}
|
||||
|
||||
|
||||
@@ -450,6 +619,7 @@ void event_init()
|
||||
|
||||
void event_destroy()
|
||||
{
|
||||
|
||||
if( events )
|
||||
{
|
||||
al_foreach( events, (void (*)(const void *))&event_free );
|
||||
@@ -457,6 +627,7 @@ void event_destroy()
|
||||
free( events );
|
||||
events=0;
|
||||
}
|
||||
|
||||
if( killme )
|
||||
{
|
||||
al_foreach( killme, (void (*)(const void *))&event_free );
|
||||
@@ -468,9 +639,14 @@ void event_destroy()
|
||||
|
||||
void event_free( event_t *e )
|
||||
{
|
||||
/*
|
||||
When apropriate, we clear the argument vector
|
||||
*/
|
||||
al_foreach( &e->arguments, (void (*)(const void *))&free );
|
||||
al_destroy( &e->arguments );
|
||||
|
||||
free( (void *)e->function_name );
|
||||
if( e->type == EVENT_VARIABLE )
|
||||
free( (void *)e->param1.variable );
|
||||
free( e );
|
||||
}
|
||||
|
||||
|
||||
36
event.h
36
event.h
@@ -1,6 +1,6 @@
|
||||
/** \file event.h
|
||||
|
||||
Event handling library
|
||||
Functions for handling event triggers
|
||||
|
||||
*/
|
||||
#ifndef FISH_EVENT_H
|
||||
@@ -17,6 +17,9 @@ Event handling library
|
||||
*/
|
||||
#define EVENT_ANY_PID 0
|
||||
|
||||
/**
|
||||
Enumeration of event types
|
||||
*/
|
||||
enum
|
||||
{
|
||||
EVENT_ANY, /**< Matches any event type (Not always any event, as the function name may limit the choice as well */
|
||||
@@ -40,18 +43,24 @@ typedef struct
|
||||
Type of event
|
||||
*/
|
||||
int type;
|
||||
|
||||
/**
|
||||
The type-specific parameter
|
||||
*/
|
||||
union
|
||||
{
|
||||
/**
|
||||
Signal number for signal-type events.Use EVENT_ANY_SIGNAL to match any signal
|
||||
Signal number for signal-type events.Use EVENT_ANY_SIGNAL
|
||||
to match any signal
|
||||
*/
|
||||
int signal;
|
||||
/**
|
||||
Variable name for variable-type events.
|
||||
Variable name for variable-type events.
|
||||
*/
|
||||
const wchar_t *variable;
|
||||
/**
|
||||
Process id for process-type events. Use EVENT_ANY_PID to match any pid.
|
||||
Process id for process-type events. Use EVENT_ANY_PID to
|
||||
match any pid.
|
||||
*/
|
||||
pid_t pid;
|
||||
/**
|
||||
@@ -61,7 +70,17 @@ typedef struct
|
||||
|
||||
} param1;
|
||||
|
||||
/**
|
||||
The name of the event handler function
|
||||
*/
|
||||
const wchar_t *function_name;
|
||||
|
||||
/**
|
||||
The argument list. Only used when sending a new event using
|
||||
event_fire. In all other situations, the value of this variable
|
||||
is ignored.
|
||||
*/
|
||||
array_list_t arguments;
|
||||
}
|
||||
event_t;
|
||||
|
||||
@@ -93,9 +112,8 @@ int event_get( event_t *criterion, array_list_t *out );
|
||||
dispatched.
|
||||
|
||||
\param event the specific event whose handlers should fire
|
||||
\param arguments the argument string to send to the event handler function
|
||||
*/
|
||||
void event_fire( event_t *event, array_list_t *arguments );
|
||||
void event_fire( event_t *event );
|
||||
|
||||
/**
|
||||
Initialize the event-handling library
|
||||
@@ -112,4 +130,10 @@ void event_destroy();
|
||||
*/
|
||||
void event_free( event_t *e );
|
||||
|
||||
/**
|
||||
Returns a string describing the specified event. The string should
|
||||
not be freed.
|
||||
*/
|
||||
const wchar_t *event_get_desc( event_t *e );
|
||||
|
||||
#endif
|
||||
|
||||
524
exec.c
524
exec.c
@@ -36,11 +36,15 @@
|
||||
#include "expand.h"
|
||||
#include "signal.h"
|
||||
#include "env_universal.h"
|
||||
#include "translate.h"
|
||||
#include "halloc.h"
|
||||
#include "halloc_util.h"
|
||||
#include "parse_util.h"
|
||||
|
||||
/**
|
||||
Prototype for the getpgid library function. The prototype for this
|
||||
function seems to be missing in glibc, at least I've not found any
|
||||
combination of #includes, macros and compiler switches that will
|
||||
combination of includes, macros and compiler switches that will
|
||||
include it.
|
||||
*/
|
||||
pid_t getpgid( pid_t pid );
|
||||
@@ -48,15 +52,15 @@ pid_t getpgid( pid_t pid );
|
||||
/**
|
||||
file descriptor redirection error message
|
||||
*/
|
||||
#define FD_ERROR L"An error occurred while redirecting file descriptor %d"
|
||||
#define FD_ERROR _( L"An error occurred while redirecting file descriptor %d" )
|
||||
/**
|
||||
file redirection error message
|
||||
*/
|
||||
#define FILE_ERROR L"An error occurred while redirecting file '%ls'"
|
||||
#define FILE_ERROR _( L"An error occurred while redirecting file '%ls'" )
|
||||
/**
|
||||
fork error message
|
||||
*/
|
||||
#define FORK_ERROR L"Could not create child process - exiting"
|
||||
#define FORK_ERROR _( L"Could not create child process - exiting" )
|
||||
|
||||
|
||||
/**
|
||||
@@ -66,6 +70,8 @@ pid_t getpgid( pid_t pid );
|
||||
*/
|
||||
static array_list_t *open_fds=0;
|
||||
|
||||
static int set_child_group( job_t *j, process_t *p, int print_errors );
|
||||
|
||||
|
||||
void exec_close( int fd )
|
||||
{
|
||||
@@ -103,7 +109,7 @@ void exec_close( int fd )
|
||||
int exec_pipe( int fd[2])
|
||||
{
|
||||
int res;
|
||||
|
||||
|
||||
while( ( res=pipe( fd ) ) )
|
||||
{
|
||||
if( errno != EINTR )
|
||||
@@ -111,23 +117,18 @@ int exec_pipe( int fd[2])
|
||||
wperror(L"pipe");
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
debug( 4, L"Created pipe using fds %d and %d", fd[0], fd[1]);
|
||||
|
||||
if( open_fds == 0 )
|
||||
{
|
||||
open_fds = malloc( sizeof( array_list_t ) );
|
||||
if(!open_fds )
|
||||
die_mem();
|
||||
al_init( open_fds );
|
||||
open_fds = al_new();
|
||||
}
|
||||
|
||||
if( res != -1 )
|
||||
{
|
||||
debug( 4, L"Created pipe using fds %d and %d", fd[0], fd[1]);
|
||||
|
||||
al_push( open_fds, (void *)(long)fd[0] );
|
||||
al_push( open_fds, (void *)(long)fd[1] );
|
||||
}
|
||||
al_push( open_fds, (void *)(long)fd[0] );
|
||||
al_push( open_fds, (void *)(long)fd[1] );
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -183,7 +184,6 @@ static void close_unused_internal_pipes( io_data_t *io )
|
||||
|
||||
void exec_init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void exec_destroy()
|
||||
@@ -241,14 +241,14 @@ void free_fd( io_data_t *io, int fd )
|
||||
redirections described by \c io.
|
||||
|
||||
\param io the list of IO redirections for the child
|
||||
\param exit_on_error whether to call exit() on errors
|
||||
|
||||
\return 0 on sucess, -1 on failiure
|
||||
*/
|
||||
static void handle_child_io( io_data_t *io )
|
||||
static int handle_child_io( io_data_t *io, int exit_on_error )
|
||||
{
|
||||
|
||||
close_unused_internal_pipes( io );
|
||||
|
||||
if( env_universal_server.fd >= 0 )
|
||||
exec_close( env_universal_server.fd );
|
||||
|
||||
for( ; io; io=io->next )
|
||||
{
|
||||
@@ -262,22 +262,18 @@ static void handle_child_io( io_data_t *io )
|
||||
if( io->fd > 2 )
|
||||
{
|
||||
/*
|
||||
Make sure the fd used by this redirection is not used by i.e. a pipe.
|
||||
Make sure the fd used by this redirection is not used by e.g. a pipe.
|
||||
*/
|
||||
free_fd( io, io->fd );
|
||||
}
|
||||
|
||||
/*
|
||||
We don't mind if this fails, it is just a speculative close
|
||||
to make sure no unexpected untracked fd causes us to fail
|
||||
*/
|
||||
close(io->fd);
|
||||
|
||||
switch( io->io_mode )
|
||||
{
|
||||
case IO_CLOSE:
|
||||
close(io->fd);
|
||||
break;
|
||||
case IO_FILE:
|
||||
{
|
||||
if( (tmp=wopen( io->param1.filename,
|
||||
io->param2.flags, 0777 ) )==-1 )
|
||||
{
|
||||
@@ -286,55 +282,81 @@ static void handle_child_io( io_data_t *io )
|
||||
io->param1.filename );
|
||||
|
||||
wperror( L"open" );
|
||||
exit(1);
|
||||
if( exit_on_error )
|
||||
{
|
||||
exit(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if( tmp != io->fd)
|
||||
{
|
||||
close(io->fd);
|
||||
|
||||
if(dup2( tmp, io->fd ) == -1 )
|
||||
{
|
||||
debug( 1,
|
||||
FD_ERROR,
|
||||
io->fd );
|
||||
wperror( L"dup2" );
|
||||
exit(1);
|
||||
if( exit_on_error )
|
||||
{
|
||||
exit(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
exec_close( tmp );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case IO_FD:
|
||||
/* debug( 3, L"Redirect fd %d in process %ls (%d) from fd %d",
|
||||
io->fd,
|
||||
p->actual_cmd,
|
||||
p->pid,
|
||||
io->old_fd );
|
||||
*/
|
||||
{
|
||||
close(io->fd);
|
||||
|
||||
if( dup2( io->param1.old_fd, io->fd ) == -1 )
|
||||
{
|
||||
debug( 1,
|
||||
FD_ERROR,
|
||||
io->fd );
|
||||
wperror( L"dup2" );
|
||||
exit(1);
|
||||
if( exit_on_error )
|
||||
{
|
||||
exit(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case IO_BUFFER:
|
||||
case IO_PIPE:
|
||||
{
|
||||
|
||||
/* debug( 3, L"Pipe fd %d in process %ls (%d) (Through fd %d)",
|
||||
io->fd,
|
||||
p->actual_cmd,
|
||||
p->pid,
|
||||
io->pipe_fd[io->fd] );
|
||||
*/
|
||||
int fd_to_dup = io->fd;
|
||||
|
||||
close(io->fd);
|
||||
|
||||
if( dup2( io->param1.pipe_fd[fd_to_dup?1:0], io->fd ) == -1 )
|
||||
{
|
||||
debug( 1, PIPE_ERROR );
|
||||
wperror( L"dup2" );
|
||||
exit(1);
|
||||
if( exit_on_error )
|
||||
{
|
||||
exit(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if( fd_to_dup != 0 )
|
||||
@@ -343,28 +365,21 @@ static void handle_child_io( io_data_t *io )
|
||||
exec_close( io->param1.pipe_fd[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
exec_close( io->param1.pipe_fd[0] );
|
||||
}
|
||||
|
||||
/*
|
||||
if( close( io[i].pipe_fd[ io->fd ] ) == -1 )
|
||||
{
|
||||
wperror( L"close" );
|
||||
exit(1);
|
||||
}
|
||||
*/
|
||||
/* if( close( io[i].pipe_fd[1] ) == -1 )
|
||||
{
|
||||
wperror( L"close" );
|
||||
exit(1);
|
||||
}
|
||||
*/
|
||||
|
||||
/* fprintf( stderr, "fd %d points to fd %d\n", i, io[i].fd[i>0?1:0] );*/
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if( env_universal_server.fd >= 0 )
|
||||
exec_close( env_universal_server.fd );
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -373,42 +388,37 @@ static void handle_child_io( io_data_t *io )
|
||||
process is put in the jobs group, all signal handlers are reset,
|
||||
SIGCHLD is unblocked (the exec call blocks blocks SIGCHLD), and all
|
||||
IO redirections and other file descriptor actions are performed.
|
||||
*/
|
||||
static void setup_child_process( job_t *j )
|
||||
{
|
||||
if( is_interactive && !is_subshell && !is_block)
|
||||
{
|
||||
pid_t pid;
|
||||
/*
|
||||
Put the process into the process group and give the process
|
||||
group the terminal, if appropriate. This has to be done
|
||||
both by the shell and in the individual child processes
|
||||
because of potential race conditions.
|
||||
*/
|
||||
pid = getpid ();
|
||||
if (j->pgid == 0)
|
||||
j->pgid = pid;
|
||||
|
||||
/* Wait till shell puts os in our own group */
|
||||
while( getpgrp() != j->pgid )
|
||||
sleep(0);
|
||||
|
||||
/* Wait till shell gives us stdin */
|
||||
if ( j->fg )
|
||||
{
|
||||
while( tcgetpgrp( 0 ) != j->pgid )
|
||||
sleep(0);
|
||||
}
|
||||
\param j the job to set up the IO for
|
||||
\param p the child process to set up
|
||||
|
||||
\return 0 on sucess, -1 on failiure
|
||||
*/
|
||||
static int setup_child_process( job_t *j, process_t *p )
|
||||
{
|
||||
int res=0;
|
||||
|
||||
if( p )
|
||||
{
|
||||
res = set_child_group( j, p, 1 );
|
||||
}
|
||||
|
||||
if( !res )
|
||||
{
|
||||
res = handle_child_io( j->io, (p!=0) );
|
||||
}
|
||||
|
||||
/* Set the handling for job control signals back to the default. */
|
||||
signal_reset_handlers();
|
||||
|
||||
handle_child_io( j->io );
|
||||
|
||||
if( !res )
|
||||
{
|
||||
signal_reset_handlers();
|
||||
}
|
||||
|
||||
/* Remove all signal blocks */
|
||||
signal_unblock();
|
||||
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -420,10 +430,11 @@ static void setup_child_process( job_t *j )
|
||||
*/
|
||||
static void launch_process( process_t *p )
|
||||
{
|
||||
// debug( 1, L"exec '%ls'", p->argv[0] );
|
||||
|
||||
execve (wcs2str(p->actual_cmd), wcsv2strv( (const wchar_t **) p->argv), env_export_arr( 0 ) );
|
||||
debug( 0,
|
||||
L"Failed to execute process %ls",
|
||||
_( L"Failed to execute process '%ls'" ),
|
||||
p->actual_cmd );
|
||||
wperror( L"execve" );
|
||||
exit(1);
|
||||
@@ -440,11 +451,33 @@ static int has_fd( io_data_t *d, int fd )
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Free a transmogrified io chain. Only the chain itself and resources
|
||||
used by a transmogrified IO_FILE redirection are freed, since the
|
||||
original chain may still be needed.
|
||||
*/
|
||||
static void io_untransmogrify( io_data_t * in, io_data_t *out )
|
||||
{
|
||||
if( !out )
|
||||
return;
|
||||
io_untransmogrify( in->next, out->next );
|
||||
switch( in->io_mode )
|
||||
{
|
||||
case IO_FILE:
|
||||
exec_close( out->param1.old_fd );
|
||||
break;
|
||||
}
|
||||
free(out);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Make a copy of the specified io redirection chain, but change file
|
||||
redirection into fd redirection. This makes the redirection chain
|
||||
suitable for use as block-level io, since the file won't be
|
||||
repeatedly reopened for every command in the block.
|
||||
|
||||
\return the transmogrified chain on sucess, or 0 on failiure
|
||||
*/
|
||||
static io_data_t *io_transmogrify( io_data_t * in )
|
||||
{
|
||||
@@ -460,7 +493,8 @@ static io_data_t *io_transmogrify( io_data_t * in )
|
||||
out->fd = in->fd;
|
||||
out->io_mode = IO_FD;
|
||||
out->param2.close_old = 1;
|
||||
|
||||
out->next=0;
|
||||
|
||||
switch( in->io_mode )
|
||||
{
|
||||
/*
|
||||
@@ -489,7 +523,8 @@ static io_data_t *io_transmogrify( io_data_t * in )
|
||||
in->param1.filename );
|
||||
|
||||
wperror( L"open" );
|
||||
exit(1);
|
||||
free( out );
|
||||
return 0;
|
||||
}
|
||||
|
||||
out->param1.old_fd = fd;
|
||||
@@ -497,31 +532,19 @@ static io_data_t *io_transmogrify( io_data_t * in )
|
||||
}
|
||||
}
|
||||
|
||||
out->next = io_transmogrify( in->next );
|
||||
if( in->next)
|
||||
{
|
||||
out->next = io_transmogrify( in->next );
|
||||
if( !out->next )
|
||||
{
|
||||
io_untransmogrify( in, out );
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
Free a transmogrified io chain. Only the chain itself and resources
|
||||
used by a transmogrified IO_FILE redirection are freed, since the
|
||||
original chain may still be needed.
|
||||
*/
|
||||
static void io_untransmogrify( io_data_t * in, io_data_t *out )
|
||||
{
|
||||
if( !in )
|
||||
return;
|
||||
io_untransmogrify( in->next, out->next );
|
||||
switch( in->io_mode )
|
||||
{
|
||||
case IO_FILE:
|
||||
exec_close( out->param1.old_fd );
|
||||
break;
|
||||
}
|
||||
free(out);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Morph an io redirection chain into redirections suitable for
|
||||
passing to eval, call eval, and clean up morphed redirections.
|
||||
@@ -531,43 +554,51 @@ static void io_untransmogrify( io_data_t * in, io_data_t *out )
|
||||
\param io the io redirections to be performed on this block
|
||||
*/
|
||||
|
||||
static int internal_exec_helper( const wchar_t *def,
|
||||
static void internal_exec_helper( const wchar_t *def,
|
||||
int block_type,
|
||||
io_data_t *io )
|
||||
{
|
||||
int res=0;
|
||||
io_data_t *io_internal = io_transmogrify( io );
|
||||
int is_block_old=is_block;
|
||||
is_block=1;
|
||||
|
||||
signal_unblock();
|
||||
/*
|
||||
Did the transmogrification fail - if so, set error status and return
|
||||
*/
|
||||
if( io && !io_internal )
|
||||
{
|
||||
proc_set_last_status( 1 );
|
||||
return;
|
||||
}
|
||||
|
||||
signal_unblock();
|
||||
|
||||
eval( def, io_internal, block_type );
|
||||
|
||||
|
||||
signal_block();
|
||||
|
||||
/*
|
||||
io_data_t *buff = io_get( io, 1 );
|
||||
if( buff && buff->io_mode == IO_BUFFER )
|
||||
fwprintf( stderr, L"block %ls produced %d bytes of output\n",
|
||||
def,
|
||||
buff->out_buffer->used );
|
||||
*/
|
||||
|
||||
io_untransmogrify( io, io_internal );
|
||||
job_reap( 0 );
|
||||
is_block=is_block_old;
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
This function should be called by the parent process right after
|
||||
fork() has been called. If job control is enabled, the child is put
|
||||
in the jobs group.
|
||||
This function should be called by both the parent process and the
|
||||
child right after fork() has been called. If job control is
|
||||
enabled, the child is put in the jobs group, and if the child is
|
||||
also in the foreground, it is also given control of the
|
||||
terminal. When called in the parent process, this function may
|
||||
fail, since the child might have already finished and called
|
||||
exit. The parent process may safely ignore the exit status of this
|
||||
call.
|
||||
|
||||
Returns 0 on sucess, -1 on failiure.
|
||||
*/
|
||||
static int handle_new_child( job_t *j, process_t *p )
|
||||
static int set_child_group( job_t *j, process_t *p, int print_errors )
|
||||
{
|
||||
int res = 0;
|
||||
|
||||
if(is_interactive && !is_subshell && !is_block)
|
||||
if( j->job_control )
|
||||
{
|
||||
int new_pgid=0;
|
||||
|
||||
@@ -579,46 +610,36 @@ static int handle_new_child( job_t *j, process_t *p )
|
||||
|
||||
if( setpgid (p->pid, j->pgid) )
|
||||
{
|
||||
if( getpgid( p->pid) != j->pgid )
|
||||
if( getpgid( p->pid) != j->pgid && print_errors )
|
||||
{
|
||||
debug( 1,
|
||||
L"Could not send process %d from group %d to group %d",
|
||||
_( L"Could not send process %d from group %d to group %d" ),
|
||||
p->pid,
|
||||
getpgid( p->pid),
|
||||
j->pgid );
|
||||
wperror( L"setpgid" );
|
||||
res = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if( j->fg )
|
||||
{
|
||||
if( tcsetpgrp (0, j->pgid) )
|
||||
{
|
||||
debug( 1, L"Could not send job %d ('%ls')to foreground",
|
||||
j->job_id,
|
||||
j->command );
|
||||
wperror( L"tcsetpgrp" );
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if( j->fg && new_pgid)
|
||||
{
|
||||
if( tcsetpgrp (0, j->pgid) )
|
||||
{
|
||||
debug( 1, L"Could not send job %d ('%ls')to foreground",
|
||||
j->job_id,
|
||||
j->command );
|
||||
wperror( L"tcsetpgrp" );
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
j->pgid = getpid();
|
||||
}
|
||||
return 0;
|
||||
|
||||
if( j->terminal && j->fg )
|
||||
{
|
||||
if( tcsetpgrp (0, j->pgid) && print_errors )
|
||||
{
|
||||
debug( 1, _( L"Could not send job %d ('%ls') to foreground" ),
|
||||
j->job_id,
|
||||
j->command );
|
||||
wperror( L"tcsetpgrp" );
|
||||
res = -1;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -644,7 +665,7 @@ void exec( job_t *j )
|
||||
int exec_error=0;
|
||||
|
||||
|
||||
debug( 4, L"Exec job %ls with id %d", j->command, j->job_id );
|
||||
debug( 4, L"Exec job '%ls' with id %d", j->command, j->job_id );
|
||||
|
||||
if( j->first_process->type==INTERNAL_EXEC )
|
||||
{
|
||||
@@ -654,15 +675,24 @@ void exec( job_t *j )
|
||||
signal_block();
|
||||
|
||||
/*
|
||||
setup_child_process make sure signals are propelry set up
|
||||
setup_child_process make sure signals are properly set
|
||||
up. It will also call signal_unblock
|
||||
*/
|
||||
setup_child_process( j );
|
||||
launch_process( j->first_process );
|
||||
/*
|
||||
launch_process _never_ returns...
|
||||
*/
|
||||
}
|
||||
|
||||
if( !setup_child_process( j, 0 ) )
|
||||
{
|
||||
/*
|
||||
launch_process never returns
|
||||
*/
|
||||
launch_process( j->first_process );
|
||||
}
|
||||
else
|
||||
{
|
||||
j->constructed=1;
|
||||
j->first_process->completed=1;
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pipe_read.fd=0;
|
||||
pipe_write.fd=1;
|
||||
@@ -672,16 +702,16 @@ void exec( job_t *j )
|
||||
pipe_write.io_mode=IO_PIPE;
|
||||
pipe_read.next=0;
|
||||
pipe_write.next=0;
|
||||
pipe_write.param1.pipe_fd[0]=pipe_write.param1.pipe_fd[1]=0;
|
||||
pipe_write.param1.pipe_fd[0]=pipe_write.param1.pipe_fd[1]=-1;
|
||||
|
||||
//fwprintf( stderr, L"Run command %ls\n", j->command );
|
||||
|
||||
if( block_io )
|
||||
{
|
||||
if( j->io )
|
||||
j->io = io_add( io_duplicate(block_io), j->io );
|
||||
j->io = io_add( io_duplicate( j, block_io), j->io );
|
||||
else
|
||||
j->io=io_duplicate(block_io);
|
||||
j->io=io_duplicate( j, block_io);
|
||||
}
|
||||
|
||||
j->io = io_add( j->io, &pipe_write );
|
||||
@@ -696,7 +726,7 @@ void exec( job_t *j )
|
||||
The loop also has to handle pipelining between the jobs.
|
||||
*/
|
||||
|
||||
for (p = j->first_process; p; p = p->next)
|
||||
for( p=j->first_process; p; p = p->next )
|
||||
{
|
||||
mypipe[1]=-1;
|
||||
skip_fork=0;
|
||||
@@ -722,9 +752,11 @@ void exec( job_t *j )
|
||||
j->io = io_add( j->io, &pipe_read );
|
||||
}
|
||||
|
||||
if (p->next)
|
||||
if( p->next )
|
||||
{
|
||||
if (exec_pipe( mypipe ) == -1)
|
||||
// debug( 1, L"%ls|%ls" , p->argv[0], p->next->argv[0]);
|
||||
|
||||
if( exec_pipe( mypipe ) == -1 )
|
||||
{
|
||||
debug( 1, PIPE_ERROR );
|
||||
wperror (L"pipe");
|
||||
@@ -758,33 +790,22 @@ void exec( job_t *j )
|
||||
{
|
||||
case INTERNAL_FUNCTION:
|
||||
{
|
||||
wchar_t **arg;
|
||||
int i;
|
||||
string_buffer_t sb;
|
||||
|
||||
const wchar_t * def = function_get_definition( p->argv[0] );
|
||||
// fwprintf( stderr, L"run function %ls\n", argv[0] );
|
||||
|
||||
wchar_t * def = halloc_register( j, wcsdup( function_get_definition( p->argv[0] )));
|
||||
//fwprintf( stderr, L"run function %ls\n", argv[0] );
|
||||
if( def == 0 )
|
||||
{
|
||||
debug( 0, L"Unknown function %ls", p->argv[0] );
|
||||
debug( 0, _( L"Unknown function '%ls'" ), p->argv[0] );
|
||||
break;
|
||||
}
|
||||
|
||||
parser_push_block( FUNCTION_CALL );
|
||||
|
||||
if( builtin_count_args(p->argv)>1 )
|
||||
{
|
||||
sb_init( &sb );
|
||||
|
||||
for( i=1,arg = p->argv+1; *arg; i++, arg++ )
|
||||
{
|
||||
if( i != 1 )
|
||||
sb_append( &sb, ARRAY_SEP_STR );
|
||||
sb_append( &sb, *arg );
|
||||
}
|
||||
|
||||
env_set( L"argv", (wchar_t *)sb.buff, ENV_LOCAL );
|
||||
sb_destroy( &sb );
|
||||
}
|
||||
current_block->param2.function_call_process = p;
|
||||
current_block->param1.function_name = halloc_register( current_block, wcsdup( p->argv[0] ) );
|
||||
|
||||
parse_util_set_argv( p->argv+1 );
|
||||
|
||||
parser_forbid_function( p->argv[0] );
|
||||
|
||||
if( p->next )
|
||||
@@ -874,7 +895,7 @@ void exec( job_t *j )
|
||||
{
|
||||
builtin_stdin=-1;
|
||||
debug( 1,
|
||||
L"Unknown input redirection type %d",
|
||||
_( L"Unknown input redirection type %d" ),
|
||||
in->io_mode);
|
||||
break;
|
||||
}
|
||||
@@ -941,15 +962,23 @@ void exec( job_t *j )
|
||||
case INTERNAL_FUNCTION:
|
||||
{
|
||||
int status = proc_get_last_status();
|
||||
|
||||
|
||||
/*
|
||||
Handle output from a block or function. This usually
|
||||
means do nothing, but in the case of pipes, we have
|
||||
to buffer such io, since otherwisethe internal pipe
|
||||
to buffer such io, since otherwise the internal pipe
|
||||
buffer might overflow.
|
||||
*/
|
||||
if( !io_buffer)
|
||||
if( !io_buffer )
|
||||
{
|
||||
/*
|
||||
No buffer, so we exit directly. This means we
|
||||
have to manually set the exit status.
|
||||
*/
|
||||
if( p->next == 0 )
|
||||
{
|
||||
proc_set_last_status( j->negate?(status?0:1):status);
|
||||
}
|
||||
p->completed = 1;
|
||||
break;
|
||||
}
|
||||
@@ -960,22 +989,21 @@ void exec( job_t *j )
|
||||
|
||||
if( io_buffer->param2.out_buffer->used != 0 )
|
||||
{
|
||||
|
||||
|
||||
pid = fork ();
|
||||
if (pid == 0)
|
||||
pid = fork();
|
||||
|
||||
if( pid == 0 )
|
||||
{
|
||||
/*
|
||||
This is the child process. Write out the contents of the pipeline.
|
||||
*/
|
||||
p->pid = getpid();
|
||||
setup_child_process( j );
|
||||
setup_child_process( j, p );
|
||||
write( io_buffer->fd,
|
||||
io_buffer->param2.out_buffer->buff,
|
||||
io_buffer->param2.out_buffer->used );
|
||||
exit( status );
|
||||
}
|
||||
else if (pid < 0)
|
||||
else if( pid < 0 )
|
||||
{
|
||||
/* The fork failed. */
|
||||
debug( 0, FORK_ERROR );
|
||||
@@ -990,12 +1018,19 @@ void exec( job_t *j )
|
||||
it control over the terminal.
|
||||
*/
|
||||
p->pid = pid;
|
||||
if( handle_new_child( j, p ) )
|
||||
exit(1);
|
||||
|
||||
set_child_group( j, p, 0 );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if( p->next == 0 )
|
||||
{
|
||||
proc_set_last_status( j->negate?(status?0:1):status);
|
||||
}
|
||||
p->completed = 1;
|
||||
}
|
||||
|
||||
io_buffer_destroy( io_buffer );
|
||||
|
||||
@@ -1024,7 +1059,7 @@ void exec( job_t *j )
|
||||
|
||||
io_data_t *io = io_get( j->io, 1 );
|
||||
int buffer_stdout = io && io->io_mode == IO_BUFFER;
|
||||
|
||||
|
||||
if( ( !sb_err->used ) &&
|
||||
( !p->next ) &&
|
||||
( sb_out->used ) &&
|
||||
@@ -1044,22 +1079,20 @@ void exec( job_t *j )
|
||||
{
|
||||
debug( 3, L"Set status of %ls to %d using short circut", j->command, p->status );
|
||||
|
||||
proc_set_last_status( p->status );
|
||||
proc_set_last_status( j->negate?(p->status?0:1):p->status );
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
pid = fork ();
|
||||
if (pid == 0)
|
||||
pid = fork();
|
||||
if( pid == 0 )
|
||||
{
|
||||
/*
|
||||
This is the child process.
|
||||
*/
|
||||
p->pid = getpid();
|
||||
setup_child_process( j );
|
||||
setup_child_process( j, p );
|
||||
if( sb_out->used )
|
||||
fwprintf( stdout, L"%ls", sb_out->buff );
|
||||
if( sb_err->used )
|
||||
@@ -1068,7 +1101,7 @@ void exec( job_t *j )
|
||||
exit( p->status );
|
||||
|
||||
}
|
||||
else if (pid < 0)
|
||||
else if( pid < 0 )
|
||||
{
|
||||
/* The fork failed. */
|
||||
debug( 0, FORK_ERROR );
|
||||
@@ -1084,9 +1117,8 @@ void exec( job_t *j )
|
||||
*/
|
||||
p->pid = pid;
|
||||
|
||||
if( handle_new_child( j, p ) )
|
||||
exit( 1 );
|
||||
|
||||
set_child_group( j, p, 0 );
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -1094,29 +1126,26 @@ void exec( job_t *j )
|
||||
|
||||
case EXTERNAL:
|
||||
{
|
||||
|
||||
// fwprintf( stderr,
|
||||
// L"fork on %ls\n", j->command );
|
||||
pid = fork ();
|
||||
if (pid == 0)
|
||||
pid = fork();
|
||||
if( pid == 0 )
|
||||
{
|
||||
/*
|
||||
This is the child process.
|
||||
*/
|
||||
p->pid = getpid();
|
||||
setup_child_process( j );
|
||||
setup_child_process( j, p );
|
||||
launch_process( p );
|
||||
|
||||
/*
|
||||
launch_process _never_ returns...
|
||||
*/
|
||||
}
|
||||
else if (pid < 0)
|
||||
else if( pid < 0 )
|
||||
{
|
||||
/* The fork failed. */
|
||||
debug( 0, FORK_ERROR );
|
||||
wperror (L"fork");
|
||||
exit (1);
|
||||
wperror( L"fork" );
|
||||
exit( 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1127,22 +1156,17 @@ void exec( job_t *j )
|
||||
*/
|
||||
p->pid = pid;
|
||||
|
||||
if( handle_new_child( j, p ) )
|
||||
exit( 1 );
|
||||
|
||||
|
||||
set_child_group( j, p, 0 );
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(p->type == INTERNAL_BUILTIN)
|
||||
builtin_pop_io();
|
||||
|
||||
|
||||
|
||||
if( p->type == INTERNAL_BUILTIN )
|
||||
builtin_pop_io();
|
||||
|
||||
/*
|
||||
Close the pipe the current process uses to read from the previous process_t
|
||||
*/
|
||||
@@ -1201,7 +1225,7 @@ int exec_subshell( const wchar_t *cmd,
|
||||
if( !cmd )
|
||||
{
|
||||
debug( 1,
|
||||
L"Sent null command to subshell. This is a fish bug. If it can be reproduced, please send a bug report to %ls",
|
||||
_( L"Sent null command to subshell. This is a fish bug. If it can be reproduced, please send a bug report to %s." ),
|
||||
PACKAGE_BUGREPORT );
|
||||
return 0;
|
||||
}
|
||||
@@ -1223,7 +1247,7 @@ int exec_subshell( const wchar_t *cmd,
|
||||
b_append( io_buffer->param2.out_buffer, &z, 1 );
|
||||
|
||||
begin=end=io_buffer->param2.out_buffer->buff;
|
||||
|
||||
|
||||
if( l )
|
||||
{
|
||||
while( 1 )
|
||||
@@ -1236,18 +1260,31 @@ int exec_subshell( const wchar_t *cmd,
|
||||
{
|
||||
wchar_t *el = str2wcs( begin );
|
||||
if( el )
|
||||
{
|
||||
al_push( l, el );
|
||||
}
|
||||
else
|
||||
{
|
||||
debug( 2, L"Got null string on line %d of file %s", __LINE__, __FILE__ );
|
||||
}
|
||||
}
|
||||
io_buffer_destroy( io_buffer );
|
||||
|
||||
|
||||
return status;
|
||||
|
||||
case '\n':
|
||||
{
|
||||
wchar_t *el;
|
||||
*end=0;
|
||||
el = str2wcs( begin );
|
||||
al_push( l, el );
|
||||
el = str2wcs( begin );
|
||||
if( el )
|
||||
{
|
||||
al_push( l, el );
|
||||
}
|
||||
else
|
||||
{
|
||||
debug( 2, L"Got null string on line %d of file %s", __LINE__, __FILE__ );
|
||||
}
|
||||
begin = end+1;
|
||||
break;
|
||||
}
|
||||
@@ -1257,5 +1294,6 @@ int exec_subshell( const wchar_t *cmd,
|
||||
}
|
||||
|
||||
io_buffer_destroy( io_buffer );
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
7
exec.h
7
exec.h
@@ -3,6 +3,9 @@
|
||||
*/
|
||||
|
||||
#ifndef FISH_EXEC_H
|
||||
/**
|
||||
Header guard
|
||||
*/
|
||||
#define FISH_EXEC_H
|
||||
|
||||
#include <wchar.h>
|
||||
@@ -13,14 +16,14 @@
|
||||
/**
|
||||
pipe redirection error message
|
||||
*/
|
||||
#define PIPE_ERROR L"An error occurred while setting up pipe"
|
||||
#define PIPE_ERROR _(L"An error occurred while setting up pipe")
|
||||
|
||||
/**
|
||||
Initialize the exec library
|
||||
*/
|
||||
void exec_init();
|
||||
|
||||
/*
|
||||
/**
|
||||
Destroy dynamically allocated data and other resources used by the
|
||||
exec library
|
||||
*/
|
||||
|
||||
112
expand.h
112
expand.h
@@ -1,15 +1,18 @@
|
||||
/**\file expand.h
|
||||
|
||||
Prototypes for string expantion functions. These functions perform
|
||||
several kinds of parameter expantion. There are a lot of issues
|
||||
Prototypes for string expansion functions. These functions perform
|
||||
several kinds of parameter expansion. There are a lot of issues
|
||||
with regards to memory allocation. Overall, these functions would
|
||||
benefit from using a more clever memory allocation scheme, perhaps
|
||||
an evil combination of talloc, string buffers and reference
|
||||
counting.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#ifndef FISH_EXPAND_H
|
||||
/**
|
||||
Header guard
|
||||
*/
|
||||
#define FISH_EXPAND_H
|
||||
|
||||
#include <wchar.h>
|
||||
@@ -17,17 +20,17 @@
|
||||
#include "util.h"
|
||||
|
||||
/**
|
||||
Flag specifying that subshell expantion should be skipped
|
||||
Flag specifying that subshell expansion should be skipped
|
||||
*/
|
||||
#define EXPAND_SKIP_SUBSHELL 1
|
||||
|
||||
/**
|
||||
Flag specifying that variable expantion should be skipped
|
||||
Flag specifying that variable expansion should be skipped
|
||||
*/
|
||||
#define EXPAND_SKIP_VARIABLES 2
|
||||
|
||||
/**
|
||||
Flag specifying that wildcard expantion should be skipped
|
||||
Flag specifying that wildcard expansion should be skipped
|
||||
*/
|
||||
#define EXPAND_SKIP_WILDCARDS 4
|
||||
|
||||
@@ -51,7 +54,7 @@
|
||||
|
||||
#define DIRECTORIES_ONLY 32
|
||||
|
||||
/*
|
||||
/**
|
||||
Use unencoded private-use keycodes for internal characters
|
||||
*/
|
||||
#define EXPAND_RESERVED 0xf000
|
||||
@@ -61,20 +64,45 @@ enum
|
||||
/** Character represeting a home directory */
|
||||
HOME_DIRECTORY = EXPAND_RESERVED,
|
||||
|
||||
/** Character represeting process expantion */
|
||||
/** Character represeting process expansion */
|
||||
PROCESS_EXPAND,
|
||||
|
||||
/** Character representing variable expantion */
|
||||
/** Character representing variable expansion */
|
||||
VARIABLE_EXPAND,
|
||||
|
||||
/** Character representing the start of a bracket expantion */
|
||||
/** Character rpresenting variable expansion into a single element*/
|
||||
VARIABLE_EXPAND_SINGLE,
|
||||
|
||||
/** Character representing the start of a bracket expansion */
|
||||
BRACKET_BEGIN,
|
||||
|
||||
/** Character representing the end of a bracket expantion */
|
||||
/** Character representing the end of a bracket expansion */
|
||||
BRACKET_END,
|
||||
|
||||
/** Character representing separation between two bracket elements */
|
||||
BRACKET_SEP,
|
||||
/**
|
||||
Separate subtokens in a token with this character.
|
||||
*/
|
||||
INTERNAL_SEPARATOR,
|
||||
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
/**
|
||||
These are the possible return values for expand_string
|
||||
*/
|
||||
enum
|
||||
{
|
||||
/** Error */
|
||||
EXPAND_ERROR,
|
||||
/** Ok */
|
||||
EXPAND_OK,
|
||||
/** Ok, a wildcard in the string matched no files */
|
||||
EXPAND_WILDCARD_NO_MATCH,
|
||||
/* Ok, a wildcard in the string matched a file */
|
||||
EXPAND_WILDCARD_MATCH
|
||||
}
|
||||
;
|
||||
|
||||
@@ -84,18 +112,13 @@ enum
|
||||
/** String containing the character for separating two array elements */
|
||||
#define ARRAY_SEP_STR L"\x1e"
|
||||
|
||||
/**
|
||||
Separate subtokens in a token with this character.
|
||||
*/
|
||||
#define INTERNAL_SEPARATOR 0xfffffff0
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Perform various forms of expansion on in, such as tilde expansion
|
||||
(~USER becomes the users home directory), variable expansion
|
||||
($VAR_NAME becomes the value of the environment variable VAR_NAME),
|
||||
subshell expantion and wildcard expansion. The results are inserted
|
||||
subshell expansion and wildcard expansion. The results are inserted
|
||||
into the list out.
|
||||
|
||||
If the parameter does not need expansion, it is copied into the list
|
||||
@@ -103,10 +126,11 @@ enum
|
||||
newly allocated strings are inserted into the list out.
|
||||
|
||||
\param in The parameter to expand
|
||||
\param flag Specifies if any expantion pass should be skipped. Legal values are any combination of EXPAND_SKIP_SUBSHELL EXPAND_SKIP_VARIABLES and EXPAND_SKIP_WILDCARDS
|
||||
\param flag Specifies if any expansion pass should be skipped. Legal values are any combination of EXPAND_SKIP_SUBSHELL EXPAND_SKIP_VARIABLES and EXPAND_SKIP_WILDCARDS
|
||||
\param out The list to which the result will be appended.
|
||||
\return One of EXPAND_OK, EXPAND_ERROR, EXPAND_WILDCARD_MATCH and EXPAND_WILDCARD_NO_MATCH
|
||||
*/
|
||||
int expand_string( wchar_t *in, array_list_t *out, int flag );
|
||||
int expand_string( void *context, wchar_t *in, array_list_t *out, int flag );
|
||||
|
||||
/**
|
||||
expand_one is identical to expand_string, except it will fail if in
|
||||
@@ -114,66 +138,24 @@ int expand_string( wchar_t *in, array_list_t *out, int flag );
|
||||
names.
|
||||
|
||||
\param in The parameter to expand
|
||||
\param flag Specifies if any expantion pass should be skipped. Legal values are any combination of EXPAND_SKIP_SUBSHELL EXPAND_SKIP_VARIABLES and EXPAND_SKIP_WILDCARDS
|
||||
\param flag Specifies if any expansion pass should be skipped. Legal values are any combination of EXPAND_SKIP_SUBSHELL EXPAND_SKIP_VARIABLES and EXPAND_SKIP_WILDCARDS
|
||||
\return The expanded parameter, or 0 on failiure
|
||||
*/
|
||||
wchar_t *expand_one( wchar_t *in, int flag );
|
||||
|
||||
/**
|
||||
Expand backslashed escapes and substitute them with their unescaped
|
||||
counterparts. Also optionally change the wildcards, the tilde
|
||||
character and a few more into constants which are defined to be
|
||||
outside of the valid character space, but still inside the valid
|
||||
space for a wchar_t. This assumes that a wchar_t is at least 32
|
||||
bits long AND that the characterset is UCS4 or some other 31-bit
|
||||
character set.
|
||||
|
||||
The result must be free()d. The original string is not modified. If
|
||||
an invalid sequence is specified, 0 is returned.
|
||||
|
||||
*/
|
||||
wchar_t *expand_unescape( const wchar_t * in, int escape_special );
|
||||
|
||||
/**
|
||||
Replace special characters with escape sequences. Newline is
|
||||
replaced with \n, etc.
|
||||
|
||||
The result must be free()d. The original string is not modified.
|
||||
|
||||
\param in The string to be escaped
|
||||
\param escape_all Whether all characters wich hold special meaning in fish (Pipe, semicolon, etc,) should be escaped, or only unprintable characters
|
||||
\return The escaped string
|
||||
*/
|
||||
wchar_t *expand_escape( const wchar_t *in, int escape_all );
|
||||
wchar_t *expand_one( void *context, wchar_t *in, int flag );
|
||||
|
||||
/**
|
||||
Convert the variable value to a human readable form, i.e. escape things, handle arrays, etc. Suitable for pretty-printing.
|
||||
*/
|
||||
wchar_t *expand_escape_variable( const wchar_t *in );
|
||||
|
||||
|
||||
/**
|
||||
Perform tilde expantion and nothing else on the specified string.
|
||||
Perform tilde expansion and nothing else on the specified string.
|
||||
|
||||
If tilde expantion is needed, the original string is freed and a
|
||||
If tilde expansion is needed, the original string is freed and a
|
||||
new string, allocated using malloc, is returned.
|
||||
*/
|
||||
wchar_t *expand_tilde(wchar_t *in);
|
||||
|
||||
/**
|
||||
Locate the last subshell in the specified string.
|
||||
|
||||
\param in the string to search for subshells
|
||||
\param begin the starting paranthesis of the subshell
|
||||
\param end the ending paranthesis of the subshell
|
||||
\param flags set this variable to ACCEPT_INCOMPLETE if in tab_completion mode
|
||||
\return -1 on syntax error, 0 if no subshells exist and 1 on sucess
|
||||
*/
|
||||
int expand_locate_subshell( wchar_t *in,
|
||||
wchar_t **begin,
|
||||
wchar_t **end,
|
||||
int flags );
|
||||
|
||||
|
||||
/**
|
||||
Tokenize the specified string into the specified array_list_t.
|
||||
|
||||
52
fish.spec.in
52
fish.spec.in
@@ -13,62 +13,104 @@ Source0: http://roo.no-ip.org/%{name}/files/%{version}/%{name}-%{
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
BuildRequires: doxygen ncurses-devel xorg-x11-devel
|
||||
|
||||
|
||||
|
||||
|
||||
%description
|
||||
fish is a shell geared towards interactive use. It's features are
|
||||
focused on user friendlieness and discoverability. The language syntax
|
||||
is simple but incompatible with other shell languages.
|
||||
|
||||
|
||||
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
|
||||
%build
|
||||
|
||||
|
||||
|
||||
%build
|
||||
%configure docdir=%_datadir/doc/%{name}-%{version}
|
||||
make %{?_smp_mflags}
|
||||
|
||||
|
||||
|
||||
|
||||
%install
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
make install DESTDIR="$RPM_BUILD_ROOT"
|
||||
|
||||
|
||||
|
||||
|
||||
%clean
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
|
||||
|
||||
|
||||
%post
|
||||
if ! grep %_bindir/fish %_sysconfdir/shells >/dev/null; then
|
||||
echo %_bindir/fish >>%_sysconfdir/shells
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
%postun
|
||||
if [ "$1" = 0 ]; then
|
||||
grep -v %_bindir/fish %_sysconfdir/shells >%_sysconfdir/fish.tmp
|
||||
mv %_sysconfdir/fish.tmp %_sysconfdir/shells
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
%files
|
||||
%defattr(-,root,root,-)
|
||||
|
||||
%doc %_datadir/doc/%{name}-%{version}
|
||||
|
||||
%_mandir/man1/fish.1*
|
||||
%_mandir/man1/xsel.1x*
|
||||
%_mandir/man1/mimedb.1*
|
||||
%_mandir/man1/set_color.1*
|
||||
%_mandir/man1/tokenize.1*
|
||||
%_mandir/man1/count.1*
|
||||
%_mandir/man1/fishd.1*
|
||||
%_mandir/man1/fish_pager.1*
|
||||
|
||||
%attr(0755,root,root) %_bindir/fish
|
||||
%attr(0755,root,root) %_bindir/fishd
|
||||
%attr(0755,root,root) %_bindir/fish_pager
|
||||
%attr(0755,root,root) %_bindir/xsel
|
||||
%attr(0755,root,root) %_bindir/set_color
|
||||
%attr(0755,root,root) %_bindir/tokenize
|
||||
%attr(0755,root,root) %_bindir/mimedb
|
||||
%attr(0755,root,root) %_bindir/count
|
||||
|
||||
%config %_sysconfdir/fish
|
||||
%config %_sysconfdir/fish_inputrc
|
||||
%dir %_sysconfdir/fish.d
|
||||
%config %_sysconfdir/fish.d/fish_*.fish
|
||||
%dir %_sysconfdir/fish.d/completions
|
||||
%config %_sysconfdir/fish.d/completions/*.fish
|
||||
|
||||
%dir %_datadir/fish
|
||||
%_datadir/fish/fish
|
||||
|
||||
%dir %_datadir/fish/completions
|
||||
%_datadir/fish/completions/*.fish
|
||||
|
||||
%dir %_datadir/fish/functions
|
||||
%_datadir/fish/functions/*.fish
|
||||
|
||||
%_datadir/locale/*/LC_MESSAGES/fish.mo
|
||||
|
||||
|
||||
|
||||
|
||||
%changelog
|
||||
* Tue Nov 29 2005 Axel Liljencrantz <axel@liljencrantz.se> 1.17.0-0
|
||||
- 1.17.0
|
||||
|
||||
* Sat Sep 24 2005 Axel Liljencrantz <axel@liljencrantz.se> 1.14.0-0
|
||||
- 1.14.0
|
||||
|
||||
|
||||
634
fish_pager.c
634
fish_pager.c
@@ -27,7 +27,12 @@
|
||||
#include <termio.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_TERM_H
|
||||
#include <term.h>
|
||||
#elif HAVE_NCURSES_TERM_H
|
||||
#include <ncurses/term.h>
|
||||
#endif
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#include "util.h"
|
||||
@@ -37,6 +42,8 @@
|
||||
#include "output.h"
|
||||
#include "input_common.h"
|
||||
#include "env_universal.h"
|
||||
#include "halloc.h"
|
||||
#include "halloc_util.h"
|
||||
|
||||
enum
|
||||
{
|
||||
@@ -69,6 +76,7 @@ static struct termios pager_modes;
|
||||
|
||||
static int is_ca_mode = 0;
|
||||
|
||||
static buffer_t *pager_buffer;
|
||||
|
||||
/**
|
||||
The environment variables used to specify the color of different
|
||||
@@ -86,8 +94,18 @@ static wchar_t *hightlight_var[] =
|
||||
static string_buffer_t out_buff;
|
||||
static FILE *out_file;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
array_list_t *comp;
|
||||
wchar_t *desc;
|
||||
int comp_width;
|
||||
int desc_width;
|
||||
int pref_width;
|
||||
int min_width;
|
||||
}
|
||||
comp_t;
|
||||
|
||||
int get_color( int highlight )
|
||||
static int get_color( int highlight )
|
||||
{
|
||||
if( highlight < 0 )
|
||||
return FISH_COLOR_NORMAL;
|
||||
@@ -96,9 +114,6 @@ int get_color( int highlight )
|
||||
|
||||
wchar_t *val = env_universal_get( hightlight_var[highlight]);
|
||||
|
||||
if( val == 0 )
|
||||
return FISH_COLOR_NORMAL;
|
||||
|
||||
if( val == 0 )
|
||||
{
|
||||
return FISH_COLOR_NORMAL;
|
||||
@@ -107,7 +122,20 @@ int get_color( int highlight )
|
||||
return output_color_code( val );
|
||||
}
|
||||
|
||||
int try_sequence( char *seq )
|
||||
static void recalc_width( array_list_t *l, const wchar_t *prefix )
|
||||
{
|
||||
int i;
|
||||
for( i=0; i<al_get_count( l ); i++ )
|
||||
{
|
||||
comp_t *c = (comp_t *)al_get( l, i );
|
||||
|
||||
c->min_width = mini( c->desc_width, maxi(0,termsize.ws_col/3 - 2)) +
|
||||
mini( c->desc_width, maxi(0,termsize.ws_col/5 - 4)) +4;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static int try_sequence( char *seq )
|
||||
{
|
||||
int j, k;
|
||||
wint_t c=0;
|
||||
@@ -190,6 +218,110 @@ static wint_t readch()
|
||||
}
|
||||
|
||||
|
||||
static int pager_buffered_writer( char c)
|
||||
{
|
||||
b_append( pager_buffer, &c, 1 );
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void pager_flush()
|
||||
{
|
||||
write( 1, pager_buffer->buff, pager_buffer->used );
|
||||
pager_buffer->used = 0;
|
||||
}
|
||||
|
||||
|
||||
static int print_max( const wchar_t *str, int max, int has_more )
|
||||
{
|
||||
int i;
|
||||
int written = 0;
|
||||
for( i=0; str[i]; i++ )
|
||||
{
|
||||
if( written + wcwidth(str[i]) > max )
|
||||
break;
|
||||
if( ( written + wcwidth(str[i]) == max) && (has_more || str[i+1]) )
|
||||
{
|
||||
writech( ellipsis_char );
|
||||
written += wcwidth(ellipsis_char );
|
||||
break;
|
||||
}
|
||||
|
||||
writech( str[i] );
|
||||
written+= wcwidth( str[i] );
|
||||
}
|
||||
return written;
|
||||
}
|
||||
|
||||
static void completion_print_item( const wchar_t *prefix, comp_t *c, int width )
|
||||
{
|
||||
int comp_width=0, desc_width=0;
|
||||
int i;
|
||||
int written=0;
|
||||
|
||||
if( c->pref_width <= width )
|
||||
{
|
||||
/*
|
||||
The entry fits, we give it as much space as it wants
|
||||
*/
|
||||
comp_width = c->comp_width;
|
||||
desc_width = c->desc_width;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
The completion and description won't fit on the
|
||||
allocated space. Give a maximum of 2/3 of the
|
||||
space to the completion, and whatever is left to
|
||||
the description.
|
||||
*/
|
||||
int desc_all = c->desc_width?c->desc_width+4:0;
|
||||
|
||||
comp_width = maxi( mini( c->comp_width,
|
||||
2*(width-4)/3 ),
|
||||
width - desc_all );
|
||||
if( c->desc_width )
|
||||
desc_width = width-comp_width-4;
|
||||
else
|
||||
c->desc_width=0;
|
||||
|
||||
}
|
||||
|
||||
for( i=0; i<al_get_count( c->comp ); i++ )
|
||||
{
|
||||
const wchar_t *comp = (const wchar_t *)al_get( c->comp, i );
|
||||
if( i != 0 )
|
||||
written += print_max( L" ", comp_width - written, 2 );
|
||||
set_color( get_color(HIGHLIGHT_PAGER_PREFIX),FISH_COLOR_NORMAL );
|
||||
written += print_max( prefix, comp_width - written, comp[0]?1:0 );
|
||||
set_color( get_color(HIGHLIGHT_PAGER_COMPLETION),FISH_COLOR_IGNORE );
|
||||
written += print_max( comp, comp_width - written, i!=(al_get_count(c->comp)-1) );
|
||||
}
|
||||
|
||||
|
||||
if( desc_width )
|
||||
{
|
||||
while( written < (width-desc_width-2))
|
||||
{
|
||||
written++;
|
||||
writech( L' ');
|
||||
}
|
||||
written += print_max( L"(", 1, 0 );
|
||||
set_color( get_color( HIGHLIGHT_PAGER_DESCRIPTION ),
|
||||
FISH_COLOR_IGNORE );
|
||||
written += print_max( c->desc, desc_width, 0 );
|
||||
written += print_max( L")", 1, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
while( written < width )
|
||||
{
|
||||
written++;
|
||||
writech( L' ');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
Print the specified part of the completion list, using the
|
||||
specified column offsets and quoting style.
|
||||
@@ -214,271 +346,29 @@ static void completion_print( int cols,
|
||||
|
||||
int rows = (al_get_count( l )-1)/cols+1;
|
||||
int i, j;
|
||||
int prefix_width= my_wcswidth(prefix);
|
||||
|
||||
for( i = row_start; i<row_stop; i++ )
|
||||
{
|
||||
for( j = 0; j < cols; j++ )
|
||||
{
|
||||
wchar_t *el, *el_end;
|
||||
comp_t *el;
|
||||
|
||||
int is_last = (j==(cols-1));
|
||||
|
||||
if( al_get_count( l ) <= j*rows + i )
|
||||
continue;
|
||||
|
||||
el = (wchar_t *)al_get( l, j*rows + i );
|
||||
el_end= wcschr( el, COMPLETE_SEP );
|
||||
|
||||
set_color( get_color(HIGHLIGHT_PAGER_PREFIX),FISH_COLOR_NORMAL );
|
||||
|
||||
writestr( prefix );
|
||||
|
||||
set_color( get_color(HIGHLIGHT_PAGER_COMPLETION),FISH_COLOR_IGNORE );
|
||||
|
||||
if( el_end == 0 )
|
||||
{
|
||||
/* We do not have a description for this completion */
|
||||
int written = 0;
|
||||
int max_written = width[j] - prefix_width - (j==cols-1?0:2);
|
||||
|
||||
if( is_quoted )
|
||||
{
|
||||
for( i=0; i<max_written; i++ )
|
||||
{
|
||||
if( !el[i] )
|
||||
break;
|
||||
writech( el[i] );
|
||||
written+= wcwidth( el[i] );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
written = write_escaped_str( el, max_written );
|
||||
}
|
||||
|
||||
set_color( get_color( HIGHLIGHT_PAGER_DESCRIPTION ),
|
||||
FISH_COLOR_IGNORE );
|
||||
|
||||
writespace( width[j]-
|
||||
written-
|
||||
prefix_width );
|
||||
}
|
||||
else
|
||||
{
|
||||
int whole_desc_width = my_wcswidth(el_end+1);
|
||||
int whole_comp_width;
|
||||
|
||||
/*
|
||||
Temporarily drop the description so that wcswidth et
|
||||
al only calculate the width of the completion.
|
||||
*/
|
||||
*el_end = L'\0';
|
||||
|
||||
/*
|
||||
Calculate preferred completion width
|
||||
*/
|
||||
if( is_quoted )
|
||||
{
|
||||
whole_comp_width = my_wcswidth(el);
|
||||
}
|
||||
else
|
||||
{
|
||||
wchar_t *tmp = escape( el, 1 );
|
||||
whole_comp_width = my_wcswidth( tmp );
|
||||
free(tmp);
|
||||
}
|
||||
|
||||
/*
|
||||
Calculate how wide this entry 'wants' to be
|
||||
*/
|
||||
int pref_width = whole_desc_width + 4 + prefix_width + 2 -
|
||||
(j==cols-1?2:0) + whole_comp_width;
|
||||
|
||||
int comp_width, desc_width;
|
||||
|
||||
if( pref_width <= width[j] )
|
||||
{
|
||||
/*
|
||||
The entry fits, we give it as much space as it wants
|
||||
*/
|
||||
comp_width = whole_comp_width;
|
||||
desc_width = whole_desc_width;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
The completion and description won't fit on the
|
||||
allocated space. Give a maximum of 2/3 of the
|
||||
space to the completion, and whatever is left to
|
||||
the description.
|
||||
*/
|
||||
int sum = width[j] - prefix_width - 4 - 2 + (j==cols-1?2:0);
|
||||
|
||||
comp_width = maxi( mini( whole_comp_width,
|
||||
2*sum/3 ),
|
||||
sum - whole_desc_width );
|
||||
desc_width = sum-comp_width;
|
||||
}
|
||||
|
||||
/* First we must print the completion. */
|
||||
if( is_quoted )
|
||||
{
|
||||
writestr_ellipsis( el, comp_width);
|
||||
}
|
||||
else
|
||||
{
|
||||
write_escaped_str( el, comp_width );
|
||||
}
|
||||
|
||||
/* Put the description back */
|
||||
*el_end = COMPLETE_SEP;
|
||||
|
||||
/* And print it */
|
||||
set_color( get_color(HIGHLIGHT_PAGER_DESCRIPTION),
|
||||
FISH_COLOR_IGNORE );
|
||||
writespace( maxi( 2,
|
||||
width[j]
|
||||
- comp_width
|
||||
- desc_width
|
||||
- 4
|
||||
- prefix_width
|
||||
+ (j==cols-1?2:0) ) );
|
||||
/* Print description */
|
||||
writestr(L"(");
|
||||
writestr_ellipsis( el_end+1, desc_width);
|
||||
writestr(L")");
|
||||
|
||||
if( j != cols-1)
|
||||
writestr( L" " );
|
||||
|
||||
}
|
||||
el = (comp_t *)al_get( l, j*rows + i );
|
||||
|
||||
completion_print_item( prefix, el, width[j] - (is_last?0:2) );
|
||||
|
||||
if( !is_last)
|
||||
writestr( L" " );
|
||||
}
|
||||
writech( L'\n' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Calculates how long the specified string would be when printed on the command line.
|
||||
|
||||
\param str The string to be printed.
|
||||
\param is_quoted Whether the string would be printed quoted or unquoted
|
||||
\param pref_width the preferred width for this item
|
||||
\param min_width the minimum width for this item
|
||||
*/
|
||||
static void printed_length( wchar_t *str,
|
||||
int is_quoted,
|
||||
int *pref_width,
|
||||
int *min_width )
|
||||
{
|
||||
if( is_quoted )
|
||||
{
|
||||
wchar_t *sep = wcschr(str,COMPLETE_SEP);
|
||||
if( sep )
|
||||
{
|
||||
*sep=0;
|
||||
int cw = my_wcswidth( str );
|
||||
int dw = my_wcswidth(sep+1);
|
||||
|
||||
if( termsize.ws_col > 80 )
|
||||
dw = mini( dw, termsize.ws_col/3 );
|
||||
|
||||
|
||||
*pref_width = cw+dw+4;
|
||||
|
||||
if( dw > termsize.ws_col/3 )
|
||||
{
|
||||
dw = termsize.ws_col/3;
|
||||
}
|
||||
|
||||
*min_width=cw+dw+4;
|
||||
|
||||
*sep= COMPLETE_SEP;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
*pref_width=*min_width= my_wcswidth( str );
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
int comp_len=0, desc_len=0;
|
||||
int has_description = 0;
|
||||
while( *str != 0 )
|
||||
{
|
||||
switch( *str )
|
||||
{
|
||||
case L'\n':
|
||||
case L'\b':
|
||||
case L'\r':
|
||||
case L'\e':
|
||||
case L'\t':
|
||||
case L'\\':
|
||||
case L'&':
|
||||
case L'$':
|
||||
case L' ':
|
||||
case L'#':
|
||||
case L'^':
|
||||
case L'<':
|
||||
case L'>':
|
||||
case L'@':
|
||||
case L'(':
|
||||
case L')':
|
||||
case L'{':
|
||||
case L'}':
|
||||
case L'?':
|
||||
case L'*':
|
||||
case L'|':
|
||||
case L';':
|
||||
case L':':
|
||||
if( has_description )
|
||||
desc_len++;
|
||||
else
|
||||
comp_len+=2;
|
||||
break;
|
||||
|
||||
case COMPLETE_SEP:
|
||||
has_description = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
if( has_description )
|
||||
desc_len+= wcwidth(*str);
|
||||
else
|
||||
comp_len+= wcwidth(*str);
|
||||
break;
|
||||
}
|
||||
str++;
|
||||
}
|
||||
if( has_description )
|
||||
{
|
||||
/*
|
||||
Mangle long descriptions to make formating look nicer
|
||||
*/
|
||||
debug( 3, L"Desc, width = %d %d\n", comp_len, desc_len );
|
||||
// if( termsize.ws_col > 80 )
|
||||
// desc_len = mini( desc_len, termsize.ws_col/3 );
|
||||
|
||||
*pref_width = comp_len+ desc_len+4;;
|
||||
|
||||
comp_len = mini( comp_len, maxi(0,termsize.ws_col/3 - 2));
|
||||
desc_len = mini( desc_len, maxi(0,termsize.ws_col/5 - 4));
|
||||
|
||||
*min_width = comp_len+ desc_len+4;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
debug( 3, L"No desc, width = %d\n", comp_len );
|
||||
|
||||
*pref_width=*min_width= comp_len;
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Try to print the list of completions l with the prefix prefix using
|
||||
@@ -526,8 +416,6 @@ static int completion_try_print( int cols,
|
||||
|
||||
int pref_tot_width=0;
|
||||
int min_tot_width = 0;
|
||||
int prefix_width = my_wcswidth( prefix );
|
||||
|
||||
int res=0;
|
||||
/*
|
||||
Skip completions on tiny terminals
|
||||
@@ -535,25 +423,24 @@ static int completion_try_print( int cols,
|
||||
|
||||
if( termsize.ws_col < 16 )
|
||||
return 1;
|
||||
|
||||
|
||||
memset( pref_width, 0, sizeof(pref_width) );
|
||||
memset( min_width, 0, sizeof(min_width) );
|
||||
|
||||
/* Calculated how wide the list would be */
|
||||
|
||||
/* Calculate how wide the list would be */
|
||||
for( j = 0; j < cols; j++ )
|
||||
{
|
||||
for( i = 0; i<rows; i++ )
|
||||
{
|
||||
int pref,min;
|
||||
wchar_t *el;
|
||||
comp_t *c;
|
||||
if( al_get_count( l ) <= j*rows + i )
|
||||
continue;
|
||||
|
||||
el = (wchar_t *)al_get( l, j*rows + i );
|
||||
printed_length( el, is_quoted, &pref, &min );
|
||||
|
||||
pref += prefix_width;
|
||||
min += prefix_width;
|
||||
c = (comp_t *)al_get( l, j*rows + i );
|
||||
pref = c->pref_width;
|
||||
min = c->min_width;
|
||||
|
||||
if( j != cols-1 )
|
||||
{
|
||||
pref += 2;
|
||||
@@ -635,6 +522,7 @@ static int completion_try_print( int cols,
|
||||
}
|
||||
|
||||
completion_print( cols, width, 0, rows, prefix, is_quoted, l);
|
||||
pager_flush();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -667,6 +555,7 @@ static int completion_try_print( int cols,
|
||||
percent );
|
||||
writestr(msg);
|
||||
set_color( FISH_COLOR_NORMAL, FISH_COLOR_NORMAL );
|
||||
pager_flush();
|
||||
int c = readch();
|
||||
|
||||
switch( c )
|
||||
@@ -728,7 +617,8 @@ static int completion_try_print( int cols,
|
||||
}
|
||||
else
|
||||
{
|
||||
writembs( flash_screen );
|
||||
if( flash_screen )
|
||||
writembs( flash_screen );
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -752,7 +642,8 @@ static int completion_try_print( int cols,
|
||||
}
|
||||
else
|
||||
{
|
||||
writembs( flash_screen );
|
||||
if( flash_screen )
|
||||
writembs( flash_screen );
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -780,7 +671,9 @@ static int completion_try_print( int cols,
|
||||
}
|
||||
|
||||
/**
|
||||
Substitute any series of tabs, newlines, etc. with a single space character in completion description
|
||||
Substitute any series of whitespace with a single space character
|
||||
inside completion descriptions. Remove all whitespace from
|
||||
beginning/end of completion descriptions.
|
||||
*/
|
||||
static void mangle_descriptions( array_list_t *l )
|
||||
{
|
||||
@@ -789,7 +682,7 @@ static void mangle_descriptions( array_list_t *l )
|
||||
{
|
||||
wchar_t *next = (wchar_t *)al_get(l, i);
|
||||
wchar_t *in, *out;
|
||||
skip=0;
|
||||
skip=1;
|
||||
|
||||
while( *next != COMPLETE_SEP && *next )
|
||||
next++;
|
||||
@@ -818,6 +711,125 @@ static void mangle_descriptions( array_list_t *l )
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Merge multiple completions with the same description to the same line
|
||||
*/
|
||||
static void join_completions( array_list_t *l )
|
||||
{
|
||||
int i, in, out;
|
||||
hash_table_t desc_table;
|
||||
|
||||
hash_init( &desc_table, &hash_wcs_func, &hash_wcs_cmp );
|
||||
|
||||
for( i=0; i<al_get_count(l); i++ )
|
||||
{
|
||||
wchar_t *item = (wchar_t *)al_get( l, i );
|
||||
wchar_t *desc = wcschr( item, COMPLETE_SEP );
|
||||
long prev_idx;
|
||||
|
||||
if( !desc )
|
||||
continue;
|
||||
desc++;
|
||||
prev_idx = ((long)hash_get( &desc_table, desc) )-1;
|
||||
if( prev_idx == -1 )
|
||||
{
|
||||
hash_put( &desc_table, halloc_wcsdup( global_context, desc), (void *)(i+1));
|
||||
}
|
||||
else
|
||||
{
|
||||
string_buffer_t foo;
|
||||
wchar_t *old = (wchar_t *)al_get( l, prev_idx );
|
||||
wchar_t *old_end = wcschr( old, COMPLETE_SEP );
|
||||
|
||||
if( old_end )
|
||||
{
|
||||
*old_end = 0;
|
||||
|
||||
sb_init( &foo );
|
||||
sb_append( &foo, old );
|
||||
sb_append_char( &foo, COMPLETE_ITEM_SEP );
|
||||
sb_append( &foo, item );
|
||||
|
||||
free( (void *)al_get( l, prev_idx ) );
|
||||
al_set( l, prev_idx, foo.buff );
|
||||
|
||||
free( (void *)al_get( l, i ) );
|
||||
al_set( l, i, 0 );
|
||||
}
|
||||
|
||||
// debug( 1, L"WOOT WOOT %ls är släkt med %ls", item, al_get( l, prev_idx ) );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
hash_destroy( &desc_table );
|
||||
|
||||
out=0;
|
||||
for( in=0; in < al_get_count(l); in++ )
|
||||
{
|
||||
const void * d = al_get( l, in );
|
||||
|
||||
if( d )
|
||||
{
|
||||
al_set( l, out++, d );
|
||||
}
|
||||
}
|
||||
al_truncate( l, out );
|
||||
}
|
||||
|
||||
/**
|
||||
Replace completion strings with a comp_t structure
|
||||
*/
|
||||
static void mangle_completions( array_list_t *l, const wchar_t *prefix )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i=0; i<al_get_count( l ); i++ )
|
||||
{
|
||||
wchar_t *next = (wchar_t *)al_get( l, i );
|
||||
wchar_t *start, *end;
|
||||
comp_t *comp = halloc( global_context, sizeof( comp_t ) );
|
||||
comp->comp = al_halloc( global_context );
|
||||
|
||||
for( start=end=next; 1; end++ )
|
||||
{
|
||||
wchar_t c = *end;
|
||||
|
||||
if( (c == COMPLETE_ITEM_SEP) || (c==COMPLETE_SEP) || !c)
|
||||
{
|
||||
*end = 0;
|
||||
wchar_t * str = escape( start, 1 );
|
||||
comp->comp_width += my_wcswidth( str );
|
||||
halloc_register( global_context, str );
|
||||
al_push( comp->comp, str );
|
||||
start = end+1;
|
||||
}
|
||||
|
||||
if( c == COMPLETE_SEP )
|
||||
{
|
||||
comp->desc = halloc_wcsdup( global_context, start );
|
||||
break;
|
||||
}
|
||||
|
||||
if( !c )
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
comp->comp_width += my_wcswidth(prefix)*al_get_count(comp->comp) + 2*(al_get_count(comp->comp)-1);
|
||||
comp->desc_width = comp->desc?my_wcswidth( comp->desc ):0;
|
||||
|
||||
comp->pref_width = comp->comp_width + comp->desc_width + (comp->desc_width?4:0);
|
||||
|
||||
free( next );
|
||||
al_set( l, i, comp );
|
||||
}
|
||||
|
||||
recalc_width( l, prefix );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Respond to a winch signal by checking the terminal size
|
||||
*/
|
||||
@@ -839,9 +851,12 @@ static void init()
|
||||
{
|
||||
struct sigaction act;
|
||||
program_name = L"fish_pager";
|
||||
fish_setlocale( LC_ALL, L"" );
|
||||
|
||||
|
||||
wsetlocale( LC_ALL, L"" );
|
||||
|
||||
/*
|
||||
Make fd 1 output to screen, and use some other fd for writing
|
||||
the resulting output back to the caller
|
||||
*/
|
||||
int out = dup( 1 );
|
||||
close(1);
|
||||
if( open( ttyname(0), O_WRONLY ) != 1 )
|
||||
@@ -853,11 +868,18 @@ static void init()
|
||||
}
|
||||
}
|
||||
out_file = fdopen( out, "w" );
|
||||
|
||||
/**
|
||||
Init the stringbuffer used to keep any output in
|
||||
*/
|
||||
sb_init( &out_buff );
|
||||
|
||||
output_init();
|
||||
halloc_util_init();
|
||||
env_universal_init( 0, 0, 0, 0);
|
||||
input_common_init( &interrupt_handler );
|
||||
output_set_writer( &pager_buffered_writer );
|
||||
pager_buffer = halloc( global_context, sizeof( buffer_t ) );
|
||||
halloc_register_function( global_context, (void (*)(void *))&b_destroy, pager_buffer );
|
||||
|
||||
sigemptyset( & act.sa_mask );
|
||||
act.sa_flags=0;
|
||||
@@ -870,33 +892,6 @@ static void init()
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Loop until we are in the foreground. */
|
||||
while (tcgetpgrp( 0 ) != getpid())
|
||||
{
|
||||
kill (- getpid(), SIGTTIN);
|
||||
}
|
||||
|
||||
/* Put ourselves in our own process group. */
|
||||
if( getpgrp() != getpid() )
|
||||
{
|
||||
if (setpgid (getpid(), getpid()) < 0)
|
||||
{
|
||||
debug( 1,
|
||||
L"Couldn't put the shell in its own process group");
|
||||
wperror( L"setpgid" );
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Grab control of the terminal. */
|
||||
if( tcsetpgrp (STDIN_FILENO, getpid()) )
|
||||
{
|
||||
debug( 1,
|
||||
L"Couldn't grab control of terminal" );
|
||||
wperror( L"tcsetpgrp" );
|
||||
exit(1);
|
||||
}
|
||||
|
||||
handle_winch( 0 ); /* Set handler for window change events */
|
||||
|
||||
tcgetattr(0,&pager_modes); /* get the current terminal modes */
|
||||
@@ -909,6 +904,9 @@ static void init()
|
||||
pager_modes.c_cc[VMIN]=1;
|
||||
pager_modes.c_cc[VTIME]=0;
|
||||
|
||||
/*
|
||||
|
||||
*/
|
||||
if( tcsetattr(0,TCSANOW,&pager_modes)) /* set the new modes */
|
||||
{
|
||||
wperror(L"tcsetattr");
|
||||
@@ -927,45 +925,51 @@ void destroy()
|
||||
{
|
||||
env_universal_destroy();
|
||||
input_common_destroy();
|
||||
output_destroy();
|
||||
halloc_util_destroy();
|
||||
del_curterm( cur_term );
|
||||
sb_destroy( &out_buff );
|
||||
fclose( out_file );
|
||||
|
||||
}
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
int i;
|
||||
int is_quoted=0;
|
||||
array_list_t comp;
|
||||
array_list_t *comp;
|
||||
wchar_t *prefix;
|
||||
|
||||
|
||||
init();
|
||||
|
||||
if( argc < 3 )
|
||||
{
|
||||
debug( 0, L"Insufficient arguments" );
|
||||
}
|
||||
else
|
||||
{
|
||||
comp = al_halloc( global_context );
|
||||
prefix = str2wcs( argv[2] );
|
||||
is_quoted = strcmp( "1", argv[1] )==0;
|
||||
|
||||
is_quoted = 0;
|
||||
|
||||
debug( 3, L"prefix is '%ls'", prefix );
|
||||
|
||||
al_init( &comp );
|
||||
|
||||
|
||||
for( i=3; i<argc; i++ )
|
||||
{
|
||||
al_push( &comp, str2wcs( argv[i] ) );
|
||||
wchar_t *wcs = str2wcs( argv[i] );
|
||||
if( wcs )
|
||||
{
|
||||
al_push( comp, wcs );
|
||||
}
|
||||
}
|
||||
|
||||
mangle_descriptions( comp );
|
||||
if( wcscmp( prefix, L"-" ) == 0 )
|
||||
join_completions( comp );
|
||||
mangle_completions( comp, prefix );
|
||||
|
||||
mangle_descriptions( &comp );
|
||||
|
||||
for( i = 6; i>0; i-- )
|
||||
{
|
||||
switch( completion_try_print( i, prefix, is_quoted, &comp ) )
|
||||
switch( completion_try_print( i, prefix, is_quoted, comp ) )
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
@@ -979,8 +983,6 @@ int main( int argc, char **argv )
|
||||
|
||||
}
|
||||
|
||||
al_foreach( &comp, (void(*)(const void *))&free );
|
||||
al_destroy( &comp );
|
||||
free(prefix );
|
||||
|
||||
fwprintf( out_file, L"%ls", (wchar_t *)out_buff.buff );
|
||||
|
||||
102
fish_tests.c
102
fish_tests.c
@@ -1,4 +1,4 @@
|
||||
/** \file main.c
|
||||
/** \file fish_tests.c
|
||||
Various bug and feature tests. Compiled and run by make test.
|
||||
*/
|
||||
|
||||
@@ -38,11 +38,24 @@
|
||||
#include "expand.h"
|
||||
#include "parser.h"
|
||||
#include "tokenizer.h"
|
||||
#include "output.h"
|
||||
#include "exec.h"
|
||||
#include "event.h"
|
||||
#include "halloc_util.h"
|
||||
|
||||
/**
|
||||
Number of laps to run performance testing loop
|
||||
*/
|
||||
#define LAPS 50
|
||||
|
||||
/**
|
||||
Number of encountered errors
|
||||
*/
|
||||
static int err_count=0;
|
||||
|
||||
/**
|
||||
Print formatted output
|
||||
*/
|
||||
static void say( wchar_t *blah, ... )
|
||||
{
|
||||
va_list va;
|
||||
@@ -52,6 +65,9 @@ static void say( wchar_t *blah, ... )
|
||||
wprintf( L"\n" );
|
||||
}
|
||||
|
||||
/**
|
||||
Print formatted error string
|
||||
*/
|
||||
static void err( wchar_t *blah, ... )
|
||||
{
|
||||
va_list va;
|
||||
@@ -64,16 +80,25 @@ static void err( wchar_t *blah, ... )
|
||||
wprintf( L"\n" );
|
||||
}
|
||||
|
||||
/**
|
||||
Print ok message
|
||||
*/
|
||||
static void ok()
|
||||
{
|
||||
wprintf( L"OK\n" );
|
||||
}
|
||||
|
||||
/**
|
||||
Compare two pointers
|
||||
*/
|
||||
static int pq_compare( void *e1, void *e2 )
|
||||
{
|
||||
return e1-e2;
|
||||
}
|
||||
|
||||
/**
|
||||
Test priority queue functionality
|
||||
*/
|
||||
static int pq_test( int elements )
|
||||
{
|
||||
int i;
|
||||
@@ -114,7 +139,9 @@ static int pq_test( int elements )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Test stack functionality
|
||||
*/
|
||||
static int stack_test( int elements )
|
||||
{
|
||||
int i;
|
||||
@@ -160,7 +187,9 @@ static int stack_test( int elements )
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Hash function for pointers
|
||||
*/
|
||||
static int hash_func( const void *data )
|
||||
{
|
||||
/* srand( (int)data );
|
||||
@@ -170,12 +199,18 @@ static int hash_func( const void *data )
|
||||
return 127*((foo^0xefc7e214)) ^(foo<<11);
|
||||
}
|
||||
|
||||
/**
|
||||
Pointer hash comparison function
|
||||
*/
|
||||
static int compare_func( const void *key1, const void *key2 )
|
||||
{
|
||||
return key1==key2;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Hashtable test
|
||||
*/
|
||||
static int hash_test( int elements )
|
||||
{
|
||||
int i;
|
||||
@@ -249,6 +284,9 @@ static int hash_test( int elements )
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
Arraylist test
|
||||
*/
|
||||
static int al_test( int sz)
|
||||
{
|
||||
int i;
|
||||
@@ -280,6 +318,9 @@ static int al_test( int sz)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Stringbuffer test
|
||||
*/
|
||||
static void sb_test()
|
||||
{
|
||||
string_buffer_t b;
|
||||
@@ -287,7 +328,7 @@ static void sb_test()
|
||||
|
||||
sb_init( &b );
|
||||
|
||||
if( res=sb_printf( &b, L"%ls%s", L"Testing ", "string_buffer_t " ) == -1 )
|
||||
if( (res=sb_printf( &b, L"%ls%s", L"Testing ", "string_buffer_t " )) == -1 )
|
||||
{
|
||||
err( L"Error %d while testing stringbuffers", res );
|
||||
}
|
||||
@@ -296,10 +337,27 @@ static void sb_test()
|
||||
{
|
||||
err( L"Error %d while testing stringbuffers", res );
|
||||
}
|
||||
|
||||
say( (wchar_t *)b.buff );
|
||||
|
||||
sb_clear( &b );
|
||||
|
||||
#define NUM_ANS L"-7 99999999 1234567 deadbeef DEADBEEFDEADBEEF"
|
||||
|
||||
sb_printf( &b, L"%d %u %o %x %llX", -7, 99999999, 01234567, 0xdeadbeef, 0xdeadbeefdeadbeefll );
|
||||
if( wcscmp( (wchar_t *)b.buff, NUM_ANS) != 0 )
|
||||
{
|
||||
err( L"numerical formating is broken, '%ls' != '%ls'", (wchar_t *)b.buff, NUM_ANS );
|
||||
}
|
||||
else
|
||||
say( L"numerical formating works" );
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Performs all tests of the util library
|
||||
*/
|
||||
static void test_util()
|
||||
{
|
||||
int i;
|
||||
@@ -346,8 +404,9 @@ static void test_util()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Test the tokenizer
|
||||
*/
|
||||
static void test_tok()
|
||||
{
|
||||
tokenizer t;
|
||||
@@ -412,6 +471,9 @@ static void test_tok()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
Test the parser
|
||||
*/
|
||||
static void test_parser()
|
||||
{
|
||||
say( L"Testing parser" );
|
||||
@@ -472,7 +534,7 @@ static void test_parser()
|
||||
}
|
||||
|
||||
/**
|
||||
Perform parameter expantion and test if the output equals the zero-terminated parameter list supplied.
|
||||
Perform parameter expansion and test if the output equals the zero-terminated parameter list supplied.
|
||||
|
||||
\param in the string to expand
|
||||
\param flags the flags to send to expand_string
|
||||
@@ -487,7 +549,7 @@ static int expand_test( const wchar_t *in, int flags, ... )
|
||||
wchar_t *arg;
|
||||
|
||||
al_init( &out );
|
||||
expand_string( wcsdup(in), &out, flags);
|
||||
expand_string( 0, wcsdup(in), &out, flags);
|
||||
|
||||
va_start( va, flags );
|
||||
|
||||
@@ -514,10 +576,12 @@ static int expand_test( const wchar_t *in, int flags, ... )
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Test globbing and other parameter expansion
|
||||
*/
|
||||
static void test_expand()
|
||||
{
|
||||
say( L"Testing parameter expantion" );
|
||||
say( L"Testing parameter expansion" );
|
||||
|
||||
if( !expand_test( L"foo", 0, L"foo", 0 ))
|
||||
{
|
||||
@@ -526,17 +590,19 @@ static void test_expand()
|
||||
|
||||
if( !expand_test( L"a{b,c,d}e", 0, L"abe", L"ace", L"ade", 0 ) )
|
||||
{
|
||||
err( L"Bracket expantion is broken" );
|
||||
err( L"Bracket expansion is broken" );
|
||||
}
|
||||
|
||||
if( !expand_test( L"a*", EXPAND_SKIP_WILDCARDS, L"a*", 0 ) )
|
||||
{
|
||||
err( L"Cannot skip wildcard expantion" );
|
||||
err( L"Cannot skip wildcard expansion" );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Test speed of completion calculations
|
||||
*/
|
||||
void perf_complete()
|
||||
{
|
||||
wchar_t c;
|
||||
@@ -607,7 +673,9 @@ void perf_complete()
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Main test
|
||||
*/
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
|
||||
@@ -617,7 +685,7 @@ int main( int argc, char **argv )
|
||||
say( L"Lines beginning with '(ignore):' are not errors, they are warning messages\ngenerated by the fish parser library when given broken input, and can be\nignored. All actual errors begin with 'Error:'." );
|
||||
|
||||
proc_init();
|
||||
output_init();
|
||||
halloc_util_init();
|
||||
event_init();
|
||||
exec_init();
|
||||
parser_init();
|
||||
@@ -649,7 +717,7 @@ int main( int argc, char **argv )
|
||||
wutil_destroy();
|
||||
exec_destroy();
|
||||
event_destroy();
|
||||
output_destroy();
|
||||
proc_destroy();
|
||||
halloc_util_destroy();
|
||||
|
||||
}
|
||||
|
||||
193
fishd.c
193
fishd.c
@@ -2,11 +2,45 @@
|
||||
|
||||
The universal variable server. fishd is automatically started by fish
|
||||
if a fishd server isn't already running. fishd reads any saved
|
||||
variables from ~/.fishd, and takes care of commonication between fish
|
||||
variables from ~/.fishd, and takes care of communication between fish
|
||||
instances. When no clients are running, fishd will automatically shut
|
||||
down and save.
|
||||
|
||||
\subsection fishd-commands Commands
|
||||
|
||||
Fishd works by sending and receiving commands. Each command is ended
|
||||
with a newline. These are the commands supported by fishd:
|
||||
|
||||
<pre>set KEY:VALUE
|
||||
set_export KEY:VALUE
|
||||
</pre>
|
||||
|
||||
These commands update the value of a variable. The only difference
|
||||
between the two is that <tt>set_export</tt>-variables should be
|
||||
exported to children of the process using them. The variable value may
|
||||
be escaped using C-style backslash escapes. In fact, this is required
|
||||
for newline characters, which would otherwise be interpreted as end of
|
||||
command.
|
||||
|
||||
<pre>erase KEY
|
||||
</pre>
|
||||
|
||||
Erase the variable with the specified name.
|
||||
|
||||
<pre>barrier
|
||||
barrier_reply
|
||||
</pre>
|
||||
|
||||
A \c barrier command will result in a barrier_reply being added to
|
||||
the end of the senders queue of unsent messages. These commands are
|
||||
used to synchronize clients, since once the reply for a barrier
|
||||
message returns, the sender can know that any updates available at the
|
||||
time the original barrier request was sent have been received.
|
||||
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
@@ -19,6 +53,10 @@ down and save.
|
||||
#include <pwd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifdef HAVE_GETOPT_H
|
||||
#include <getopt.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <locale.h>
|
||||
#include <signal.h>
|
||||
@@ -35,6 +73,15 @@ down and save.
|
||||
#define UNIX_PATH_MAX 100
|
||||
#endif
|
||||
|
||||
/**
|
||||
Fallback if MSG_DONTWAIT isn't defined. That's actually prerry bad,
|
||||
and may lead to strange fishd behaviour, but at least it should
|
||||
work most of the time.
|
||||
*/
|
||||
#ifndef MSG_DONTWAIT
|
||||
#define MSG_DONTWAIT 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
Small greeting to show that fishd is running
|
||||
*/
|
||||
@@ -70,6 +117,16 @@ static connection_t *conn;
|
||||
*/
|
||||
static int sock;
|
||||
|
||||
/**
|
||||
Set to one when fishd should save and exit
|
||||
*/
|
||||
static int quit=0;
|
||||
|
||||
/**
|
||||
Dynamically generated function, made from the documentation in doc_src.
|
||||
*/
|
||||
void print_help();
|
||||
|
||||
/**
|
||||
Constructs the fish socket filename
|
||||
*/
|
||||
@@ -110,6 +167,15 @@ static char *get_socket_filename()
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
Signal handler for the term signal.
|
||||
*/
|
||||
static void handle_term( int signal )
|
||||
{
|
||||
quit=1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Acquire the lock for the socket
|
||||
Returns the name of the lock file if successful or
|
||||
@@ -160,8 +226,8 @@ static int get_socket()
|
||||
|
||||
local.sun_family = AF_UNIX;
|
||||
strcpy( local.sun_path, sock_name );
|
||||
len = strlen( local.sun_path ) + sizeof( local.sun_family );
|
||||
|
||||
len = sizeof(local);
|
||||
|
||||
debug(1, L"Connect to socket at %s", sock_name);
|
||||
|
||||
if( ( s = socket( AF_UNIX, SOCK_STREAM, 0 ) ) == -1 )
|
||||
@@ -268,26 +334,37 @@ static void daemonize()
|
||||
|
||||
case 0:
|
||||
{
|
||||
/*
|
||||
Make fishd ignore the HUP signal.
|
||||
*/
|
||||
struct sigaction act;
|
||||
sigemptyset( & act.sa_mask );
|
||||
act.sa_flags=0;
|
||||
act.sa_handler=SIG_IGN;
|
||||
sigaction( SIGHUP, &act, 0);
|
||||
|
||||
/*
|
||||
Make fishd save and exit on the TERM signal.
|
||||
*/
|
||||
sigfillset( & act.sa_mask );
|
||||
act.sa_flags=0;
|
||||
act.sa_handler=&handle_term;
|
||||
sigaction( SIGTERM, &act, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
debug( 0, L"Parent calling exit" );
|
||||
debug( 0, L"Parent process exiting (This is normal)" );
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Put ourself in out own processing group
|
||||
*/
|
||||
setsid();
|
||||
|
||||
|
||||
/*
|
||||
Close stdin and stdout. We only use stderr, anyway.
|
||||
*/
|
||||
@@ -350,12 +427,17 @@ void load_or_save( int save)
|
||||
close( c.fd );
|
||||
}
|
||||
|
||||
/**
|
||||
Load variables from disk
|
||||
*/
|
||||
static void load()
|
||||
{
|
||||
load_or_save(0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Save variables to disk
|
||||
*/
|
||||
static void save()
|
||||
{
|
||||
load_or_save(1);
|
||||
@@ -366,28 +448,89 @@ static void save()
|
||||
*/
|
||||
static void init()
|
||||
{
|
||||
program_name=L"fishd";
|
||||
|
||||
sock = get_socket();
|
||||
daemonize();
|
||||
fish_setlocale( LC_ALL, L"" );
|
||||
env_universal_common_init( &broadcast );
|
||||
|
||||
load();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Main function for fishd
|
||||
*/
|
||||
int main( int argc, char ** argv )
|
||||
{
|
||||
int child_socket, t;
|
||||
int child_socket;
|
||||
struct sockaddr_un remote;
|
||||
socklen_t t;
|
||||
int max_fd;
|
||||
int update_count=0;
|
||||
|
||||
fd_set read_fd, write_fd;
|
||||
|
||||
init();
|
||||
program_name=L"fishd";
|
||||
wsetlocale( LC_ALL, L"" );
|
||||
|
||||
/*
|
||||
Parse options
|
||||
*/
|
||||
while( 1 )
|
||||
{
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
static struct option
|
||||
long_options[] =
|
||||
{
|
||||
{
|
||||
"help", no_argument, 0, 'h'
|
||||
}
|
||||
,
|
||||
{
|
||||
"version", no_argument, 0, 'v'
|
||||
}
|
||||
,
|
||||
{
|
||||
0, 0, 0, 0
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
int opt_index = 0;
|
||||
|
||||
int opt = getopt_long( argc,
|
||||
argv,
|
||||
"hv",
|
||||
long_options,
|
||||
&opt_index );
|
||||
|
||||
#else
|
||||
int opt = getopt( argc,
|
||||
argv,
|
||||
"hv" );
|
||||
#endif
|
||||
if( opt == -1 )
|
||||
break;
|
||||
|
||||
switch( opt )
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
print_help();
|
||||
exit(0);
|
||||
|
||||
case 'v':
|
||||
debug( 0, L"%ls, version %s\n", program_name, PACKAGE_VERSION );
|
||||
exit( 0 );
|
||||
|
||||
case '?':
|
||||
return 1;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
init();
|
||||
while(1)
|
||||
{
|
||||
connection_t *c;
|
||||
@@ -409,15 +552,27 @@ int main( int argc, char ** argv )
|
||||
FD_SET( c->fd, &write_fd );
|
||||
}
|
||||
}
|
||||
|
||||
res=select( max_fd, &read_fd, &write_fd, 0, 0 );
|
||||
|
||||
if( res==-1 )
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
wperror( L"select" );
|
||||
exit(1);
|
||||
res=select( max_fd, &read_fd, &write_fd, 0, 0 );
|
||||
|
||||
if( quit )
|
||||
{
|
||||
save();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if( res != -1 )
|
||||
break;
|
||||
|
||||
if( errno != EINTR )
|
||||
{
|
||||
wperror( L"select" );
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if( FD_ISSET( sock, &read_fd ) )
|
||||
{
|
||||
if( (child_socket =
|
||||
|
||||
158
function.c
158
function.c
@@ -9,6 +9,7 @@
|
||||
#include <signal.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "wutil.h"
|
||||
#include "util.h"
|
||||
#include "function.h"
|
||||
#include "proc.h"
|
||||
@@ -16,6 +17,10 @@
|
||||
#include "common.h"
|
||||
#include "intern.h"
|
||||
#include "event.h"
|
||||
#include "reader.h"
|
||||
#include "parse_util.h"
|
||||
#include "env.h"
|
||||
#include "expand.h"
|
||||
|
||||
|
||||
/**
|
||||
@@ -27,7 +32,10 @@ typedef struct
|
||||
wchar_t *cmd;
|
||||
/** Function description */
|
||||
wchar_t *desc;
|
||||
const wchar_t *definition_file;
|
||||
int definition_offset;
|
||||
int is_binding;
|
||||
int is_autoload;
|
||||
}
|
||||
function_data_t;
|
||||
|
||||
@@ -35,6 +43,79 @@ typedef struct
|
||||
Table containing all functions
|
||||
*/
|
||||
static hash_table_t function;
|
||||
static int is_autoload = 0;
|
||||
|
||||
/**
|
||||
Make sure that if the specified function is a dynamically loaded
|
||||
function, it has been fully loaded.
|
||||
*/
|
||||
static int load( const wchar_t *name )
|
||||
{
|
||||
int was_autoload = is_autoload;
|
||||
int res;
|
||||
function_data_t *data;
|
||||
data = (function_data_t *)hash_get( &function, name );
|
||||
if( data && !data->is_autoload )
|
||||
return 0;
|
||||
|
||||
is_autoload = 1;
|
||||
res = parse_util_load( name,
|
||||
L"fish_function_path",
|
||||
&function_remove,
|
||||
1 );
|
||||
is_autoload = was_autoload;
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
Insert a list of all dynamically loaded functions into the
|
||||
specified list.
|
||||
*/
|
||||
static void autoload_names( array_list_t *out, int get_hidden )
|
||||
{
|
||||
int i;
|
||||
|
||||
array_list_t path_list;
|
||||
const wchar_t *path_var = env_get( L"fish_function_path" );
|
||||
|
||||
if( ! path_var )
|
||||
return;
|
||||
|
||||
al_init( &path_list );
|
||||
|
||||
expand_variable_array( path_var, &path_list );
|
||||
for( i=0; i<al_get_count( &path_list ); i++ )
|
||||
{
|
||||
wchar_t *ndir = (wchar_t *)al_get( &path_list, i );
|
||||
DIR *dir = wopendir( ndir );
|
||||
if( !dir )
|
||||
continue;
|
||||
|
||||
struct wdirent *next;
|
||||
while( (next=wreaddir(dir))!=0 )
|
||||
{
|
||||
wchar_t *fn = next->d_name;
|
||||
wchar_t *suffix;
|
||||
if( !get_hidden && fn[0] == L'_' )
|
||||
continue;
|
||||
|
||||
suffix = wcsrchr( fn, L'.' );
|
||||
if( suffix && (wcscmp( suffix, L".fish" ) == 0 ) )
|
||||
{
|
||||
const wchar_t *dup;
|
||||
*suffix = 0;
|
||||
dup = intern( fn );
|
||||
if( !dup )
|
||||
die_mem();
|
||||
al_push( out, dup );
|
||||
}
|
||||
}
|
||||
closedir(dir);
|
||||
}
|
||||
al_foreach( &path_list, (void (*)(const void *))&free );
|
||||
al_destroy( &path_list );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Free all contents of an entry to the function hash table
|
||||
@@ -61,6 +142,7 @@ void function_destroy()
|
||||
hash_destroy( &function );
|
||||
}
|
||||
|
||||
|
||||
void function_add( const wchar_t *name,
|
||||
const wchar_t *val,
|
||||
const wchar_t *desc,
|
||||
@@ -68,16 +150,28 @@ void function_add( const wchar_t *name,
|
||||
int is_binding )
|
||||
{
|
||||
int i;
|
||||
wchar_t *cmd_end;
|
||||
function_data_t *d;
|
||||
|
||||
if( function_exists( name ) )
|
||||
function_remove( name );
|
||||
function_remove( name );
|
||||
|
||||
function_data_t *d = malloc( sizeof( function_data_t ) );
|
||||
d = malloc( sizeof( function_data_t ) );
|
||||
d->definition_offset = parse_util_lineno( parser_get_buffer(), current_block->tok_pos );
|
||||
d->cmd = wcsdup( val );
|
||||
|
||||
cmd_end = d->cmd + wcslen(d->cmd)-1;
|
||||
while( (cmd_end>d->cmd) && wcschr( L"\n\r\t ", *cmd_end ) )
|
||||
{
|
||||
*cmd_end-- = 0;
|
||||
}
|
||||
|
||||
d->desc = desc?wcsdup( desc ):0;
|
||||
d->is_binding = is_binding;
|
||||
d->definition_file = intern(reader_current_filename());
|
||||
d->is_autoload = is_autoload;
|
||||
|
||||
hash_put( &function, intern(name), d );
|
||||
|
||||
|
||||
for( i=0; i<al_get_count( events ); i++ )
|
||||
{
|
||||
event_add_handler( (event_t *)al_get( events, i ) );
|
||||
@@ -87,6 +181,10 @@ void function_add( const wchar_t *name,
|
||||
|
||||
int function_exists( const wchar_t *cmd )
|
||||
{
|
||||
if( parser_is_reserved(cmd) )
|
||||
return 0;
|
||||
|
||||
load( cmd );
|
||||
return (hash_get(&function, cmd) != 0 );
|
||||
}
|
||||
|
||||
@@ -94,27 +192,28 @@ void function_remove( const wchar_t *name )
|
||||
{
|
||||
void *key;
|
||||
function_data_t *d;
|
||||
|
||||
event_t ev;
|
||||
ev.type=EVENT_ANY;
|
||||
ev.function_name=name;
|
||||
event_remove( &ev );
|
||||
|
||||
hash_remove( &function,
|
||||
name,
|
||||
(const void **) &key,
|
||||
(const void **)&d );
|
||||
|
||||
if( !d )
|
||||
if( !key )
|
||||
return;
|
||||
|
||||
ev.type=EVENT_ANY;
|
||||
ev.function_name=name;
|
||||
event_remove( &ev );
|
||||
|
||||
clear_function_entry( key, d );
|
||||
}
|
||||
|
||||
const wchar_t *function_get_definition( const wchar_t *argv )
|
||||
{
|
||||
function_data_t *data =
|
||||
(function_data_t *)hash_get( &function, argv );
|
||||
function_data_t *data;
|
||||
load( argv );
|
||||
data = (function_data_t *)hash_get( &function, argv );
|
||||
if( data == 0 )
|
||||
return 0;
|
||||
return data->cmd;
|
||||
@@ -122,18 +221,20 @@ const wchar_t *function_get_definition( const wchar_t *argv )
|
||||
|
||||
const wchar_t *function_get_desc( const wchar_t *argv )
|
||||
{
|
||||
function_data_t *data =
|
||||
(function_data_t *)hash_get( &function, argv );
|
||||
function_data_t *data;
|
||||
load( argv );
|
||||
data = (function_data_t *)hash_get( &function, argv );
|
||||
if( data == 0 )
|
||||
return 0;
|
||||
|
||||
return data->desc?data->desc:data->cmd;
|
||||
return data->desc;
|
||||
}
|
||||
|
||||
void function_set_desc( const wchar_t *name, const wchar_t *desc )
|
||||
{
|
||||
function_data_t *data =
|
||||
(function_data_t *)hash_get( &function, name );
|
||||
function_data_t *data;
|
||||
load( name );
|
||||
data = (function_data_t *)hash_get( &function, name );
|
||||
if( data == 0 )
|
||||
return;
|
||||
|
||||
@@ -156,6 +257,8 @@ static void get_names_internal( const void *key,
|
||||
|
||||
void function_get_names( array_list_t *list, int get_hidden )
|
||||
{
|
||||
autoload_names( list, get_hidden );
|
||||
|
||||
if( get_hidden )
|
||||
hash_get_keys( &function, list );
|
||||
else
|
||||
@@ -163,3 +266,26 @@ void function_get_names( array_list_t *list, int get_hidden )
|
||||
|
||||
}
|
||||
|
||||
const wchar_t *function_get_definition_file( const wchar_t *argv )
|
||||
{
|
||||
function_data_t *data;
|
||||
load( argv );
|
||||
data = (function_data_t *)hash_get( &function, argv );
|
||||
if( data == 0 )
|
||||
return 0;
|
||||
|
||||
return data->definition_file;
|
||||
}
|
||||
|
||||
|
||||
int function_get_definition_offset( const wchar_t *argv )
|
||||
{
|
||||
function_data_t *data;
|
||||
load( argv );
|
||||
data = (function_data_t *)hash_get( &function, argv );
|
||||
if( data == 0 )
|
||||
return -1;
|
||||
|
||||
return data->definition_offset;
|
||||
}
|
||||
|
||||
|
||||
13
function.h
13
function.h
@@ -58,7 +58,7 @@ void function_set_desc( const wchar_t *name, const wchar_t *desc );
|
||||
/**
|
||||
Returns true if the function witrh the name name exists.
|
||||
*/
|
||||
int function_exists( const wchar_t *name);
|
||||
int function_exists( const wchar_t *name );
|
||||
|
||||
/**
|
||||
Insert all function names into l. These are not copies of the strings and should not be freed after use.
|
||||
@@ -69,4 +69,15 @@ int function_exists( const wchar_t *name);
|
||||
void function_get_names( array_list_t *list,
|
||||
int get_hidden );
|
||||
|
||||
/**
|
||||
Returns tha absolute path of the file where the specified function
|
||||
was defined. Returns 0 if the file was defined on the commandline.
|
||||
*/
|
||||
const wchar_t *function_get_definition_file( const wchar_t *name );
|
||||
|
||||
/**
|
||||
Returns the linenumber where the definition of the specified function started
|
||||
*/
|
||||
int function_get_definition_offset( const wchar_t *name );
|
||||
|
||||
#endif
|
||||
|
||||
170
halloc.c
Normal file
170
halloc.c
Normal file
@@ -0,0 +1,170 @@
|
||||
/** \file halloc.c
|
||||
|
||||
A hierarchical memory allocation system. Works just like talloc
|
||||
used in Samba, except that an arbitrary block allocated with
|
||||
malloc() can be registered to be freed by halloc_free.
|
||||
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "common.h"
|
||||
#include "halloc.h"
|
||||
|
||||
#define HALLOC_BLOCK_SIZE 128
|
||||
#define HALLOC_SCRAP_SIZE 16
|
||||
|
||||
#ifdef HALLOC_DEBUG
|
||||
static int child_count=0;
|
||||
static int child_size=0;
|
||||
static int alloc_count =0;
|
||||
static int alloc_spill = 0;
|
||||
static pid_t pid=0;
|
||||
static int parent_count=0;
|
||||
#endif
|
||||
|
||||
typedef struct halloc
|
||||
{
|
||||
array_list_t children;
|
||||
void *scratch;
|
||||
size_t scratch_free;
|
||||
long long data[0];
|
||||
}
|
||||
halloc_t;
|
||||
|
||||
static halloc_t *halloc_from_data( void *data )
|
||||
{
|
||||
return (halloc_t *)(data - sizeof( halloc_t ) );
|
||||
}
|
||||
|
||||
static void late_free( void *data)
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef HALLOC_DEBUG
|
||||
static void woot()
|
||||
{
|
||||
if( getpid() == pid )
|
||||
{
|
||||
debug( 1, L"%d parents, %d children with average child size of %.2f bytes caused %d allocs, average spill of %.2f bytes",
|
||||
parent_count, child_count, (double)child_size/child_count,
|
||||
parent_count+alloc_count, (double)alloc_spill/(parent_count+alloc_count) );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void *halloc( void *context, size_t size )
|
||||
{
|
||||
halloc_t *me, *parent;
|
||||
if( context )
|
||||
{
|
||||
void *res;
|
||||
|
||||
#ifdef HALLOC_DEBUG
|
||||
|
||||
if( !child_count )
|
||||
{
|
||||
pid = getpid();
|
||||
atexit( woot );
|
||||
}
|
||||
|
||||
child_count++;
|
||||
child_size += size;
|
||||
#endif
|
||||
parent = halloc_from_data( context );
|
||||
if( size <= parent->scratch_free )
|
||||
{
|
||||
res = parent->scratch;
|
||||
parent->scratch_free -= size;
|
||||
parent->scratch += size;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
#ifdef HALLOC_DEBUG
|
||||
alloc_count++;
|
||||
#endif
|
||||
|
||||
if( parent->scratch_free < HALLOC_SCRAP_SIZE )
|
||||
{
|
||||
#ifdef HALLOC_DEBUG
|
||||
alloc_spill += parent->scratch_free;
|
||||
#endif
|
||||
res = calloc( 1, size + HALLOC_BLOCK_SIZE );
|
||||
parent->scratch = res + size;
|
||||
parent->scratch_free = HALLOC_BLOCK_SIZE;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = calloc( 1, size );
|
||||
}
|
||||
al_push( &parent->children, &late_free );
|
||||
al_push( &parent->children, res );
|
||||
|
||||
}
|
||||
return res;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
me = (halloc_t *)calloc( 1, sizeof(halloc_t) + size + HALLOC_BLOCK_SIZE );
|
||||
|
||||
if( !me )
|
||||
return 0;
|
||||
#ifdef HALLOC_DEBUG
|
||||
parent_count++;
|
||||
#endif
|
||||
me->scratch = ((void *)me) + sizeof(halloc_t) + size;
|
||||
me->scratch_free = HALLOC_BLOCK_SIZE;
|
||||
|
||||
al_init( &me->children );
|
||||
return &me->data;
|
||||
}
|
||||
}
|
||||
|
||||
void halloc_register_function( void *context, void (*func)(void *), void *data )
|
||||
{
|
||||
halloc_t *me;
|
||||
if( !context )
|
||||
return;
|
||||
|
||||
me = halloc_from_data( context );
|
||||
al_push( &me->children, func );
|
||||
al_push( &me->children, data );
|
||||
}
|
||||
|
||||
void halloc_free( void *context )
|
||||
{
|
||||
halloc_t *me;
|
||||
int i;
|
||||
|
||||
if( !context )
|
||||
return;
|
||||
|
||||
|
||||
me = halloc_from_data( context );
|
||||
|
||||
#ifdef HALLOC_DEBUG
|
||||
alloc_spill += me->scratch_free;
|
||||
#endif
|
||||
for( i=0; i<al_get_count(&me->children); i+=2 )
|
||||
{
|
||||
void (*func)(void *) = (void (*)(void *))al_get( &me->children, i );
|
||||
void * data = (void *)al_get( &me->children, i+1 );
|
||||
if( func != &late_free )
|
||||
func( data );
|
||||
}
|
||||
for( i=0; i<al_get_count(&me->children); i+=2 )
|
||||
{
|
||||
void (*func)(void *) = (void (*)(void *))al_get( &me->children, i );
|
||||
void * data = (void *)al_get( &me->children, i+1 );
|
||||
if( func == &late_free )
|
||||
free( data );
|
||||
}
|
||||
al_destroy( &me->children );
|
||||
free(me);
|
||||
}
|
||||
48
halloc.h
Normal file
48
halloc.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/** \file halloc.h
|
||||
|
||||
A hierarchical memory allocation system. Works mostly like talloc
|
||||
used in Samba, except that an arbitrary block allocated with
|
||||
malloc() can be registered to be freed by halloc_free.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef FISH_HALLOC_H
|
||||
#define FISH_HALLOC_H
|
||||
|
||||
/**
|
||||
Allocate new memory using specified parent memory context. Context
|
||||
_must_ be either 0 or the result of a previous call to halloc.
|
||||
|
||||
If \c context is null, the resulting block is a root block, and
|
||||
must be freed with a call to halloc_free().
|
||||
|
||||
If \c context is not null, context must be a halloc root block. the
|
||||
resulting memory block is a child context, and must never be
|
||||
explicitly freed, it will be automatically freed whenever the
|
||||
parent context is freed. Child blocks can also never be used as the
|
||||
context in calls to halloc_register_function, halloc_free, etc.
|
||||
*/
|
||||
void *halloc( void *context, size_t size );
|
||||
|
||||
/**
|
||||
Make the specified function run whenever context is free'd, using data as argument.
|
||||
|
||||
\c context a halloc root block
|
||||
*/
|
||||
void halloc_register_function( void *context, void (*func)(void *), void *data );
|
||||
|
||||
/**
|
||||
Free memory context and all children contexts. Only root contexts
|
||||
may be freed explicitly.
|
||||
|
||||
All functions registered with halloc_register_function are run in
|
||||
the order they where added. Afterwards, all memory allocated using
|
||||
halloc itself is free'd.
|
||||
|
||||
\c context a halloc root block
|
||||
*/
|
||||
void halloc_free( void *context );
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
94
halloc_util.c
Normal file
94
halloc_util.c
Normal file
@@ -0,0 +1,94 @@
|
||||
/** \file halloc.c
|
||||
|
||||
A hierarchical memory allocation system. Works just like talloc
|
||||
used in Samba, except that an arbitrary block allocated with
|
||||
malloc() can be registered to be freed by halloc_free.
|
||||
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "common.h"
|
||||
#include "halloc.h"
|
||||
|
||||
void *global_context=0;
|
||||
|
||||
void halloc_util_init()
|
||||
{
|
||||
global_context = halloc( 0, 0 );
|
||||
}
|
||||
|
||||
void halloc_util_destroy()
|
||||
{
|
||||
halloc_free( global_context );
|
||||
}
|
||||
|
||||
array_list_t *al_halloc( void *context )
|
||||
{
|
||||
array_list_t *res = halloc( context, sizeof( array_list_t ) );
|
||||
if( !res )
|
||||
die_mem();
|
||||
al_init( res );
|
||||
halloc_register_function( context, (void (*)(void *)) &al_destroy, res );
|
||||
return res;
|
||||
}
|
||||
|
||||
string_buffer_t *sb_halloc( void *context )
|
||||
{
|
||||
string_buffer_t *res = halloc( context, sizeof( string_buffer_t ) );
|
||||
if( !res )
|
||||
die_mem();
|
||||
sb_init( res );
|
||||
halloc_register_function( context, (void (*)(void *)) &sb_destroy, res );
|
||||
return res;
|
||||
}
|
||||
|
||||
static void halloc_passthrough( void *f )
|
||||
{
|
||||
void (*func)() = (void (*)() )f;
|
||||
func();
|
||||
}
|
||||
|
||||
void halloc_register_function_void( void *context, void (*func)() )
|
||||
{
|
||||
halloc_register_function( context, &halloc_passthrough, (void *)func );
|
||||
}
|
||||
|
||||
void *halloc_register( void *context, void *data )
|
||||
{
|
||||
if( !data )
|
||||
return 0;
|
||||
|
||||
halloc_register_function( context, &free, data );
|
||||
return data;
|
||||
}
|
||||
|
||||
wchar_t *halloc_wcsdup( void *context, wchar_t *in )
|
||||
{
|
||||
size_t len=wcslen(in);
|
||||
wchar_t *out = halloc( context, sizeof( wchar_t)*(len+1));
|
||||
|
||||
if( out == 0 )
|
||||
{
|
||||
die_mem();
|
||||
}
|
||||
memcpy( out, in, sizeof( wchar_t)*(len+1));
|
||||
return out;
|
||||
}
|
||||
|
||||
wchar_t *halloc_wcsndup( void * context, const wchar_t *in, int c )
|
||||
{
|
||||
wchar_t *res = halloc( context, sizeof(wchar_t)*(c+1) );
|
||||
if( res == 0 )
|
||||
{
|
||||
die_mem();
|
||||
}
|
||||
wcslcpy( res, in, c+1 );
|
||||
res[c] = L'\0';
|
||||
return res;
|
||||
}
|
||||
66
halloc_util.h
Normal file
66
halloc_util.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
\file halloc_util.h
|
||||
|
||||
Various halloc-related utility functions.
|
||||
*/
|
||||
|
||||
#ifndef FISH_HALLOC_UTIL_H
|
||||
#define FISH_HALLOC_UTIL_H
|
||||
|
||||
/**
|
||||
This pointer is a valid halloc context that will be freed right
|
||||
before program shutdown. It may be used to allocate memory that
|
||||
should be freed when the program shuts down.
|
||||
*/
|
||||
extern void *global_context;
|
||||
|
||||
/**
|
||||
Create the global_context halloc object
|
||||
*/
|
||||
void halloc_util_init();
|
||||
|
||||
/**
|
||||
Free the global_context halloc object
|
||||
*/
|
||||
void halloc_util_destroy();
|
||||
|
||||
/**
|
||||
Allocate a array_list_t that will be automatically disposed of when
|
||||
the specified context is free'd
|
||||
*/
|
||||
array_list_t *al_halloc( void *context );
|
||||
|
||||
/**
|
||||
Allocate a string_buffer_t that will be automatically disposed of
|
||||
when the specified context is free'd
|
||||
*/
|
||||
string_buffer_t *sb_halloc( void *context );
|
||||
|
||||
/**
|
||||
Register the specified function to run when the specified context
|
||||
is free'd. This function is related to halloc_register_function,
|
||||
but the specified function dowes not take an argument.
|
||||
*/
|
||||
void halloc_register_function_void( void *context, void (*func)() );
|
||||
|
||||
/**
|
||||
Free the memory pointed to by \c data when the memory pointed to by
|
||||
\c context is free:d. Note that this will _not_ turn the specified
|
||||
memory area into a valid halloc context. Only memory areas created
|
||||
using a call to halloc( 0, size ) can be used as a context.
|
||||
*/
|
||||
void *halloc_register( void *context, void *data );
|
||||
|
||||
/**
|
||||
Make a copy of the specified string using memory allocated using
|
||||
halloc and the specified context
|
||||
*/
|
||||
wchar_t *halloc_wcsdup( void *context, wchar_t *str );
|
||||
|
||||
/**
|
||||
Make a copy of the specified substring using memory allocated using
|
||||
halloc and the specified context
|
||||
*/
|
||||
wchar_t *halloc_wcsndup( void * context, const wchar_t *in, int c );
|
||||
|
||||
#endif
|
||||
27
highlight.c
27
highlight.c
@@ -18,6 +18,7 @@
|
||||
#include "tokenizer.h"
|
||||
#include "proc.h"
|
||||
#include "parser.h"
|
||||
#include "parse_util.h"
|
||||
#include "builtin.h"
|
||||
#include "function.h"
|
||||
#include "env.h"
|
||||
@@ -129,10 +130,10 @@ void highlight_shell( wchar_t * buff,
|
||||
/*
|
||||
Command. First check that the command actually exists.
|
||||
*/
|
||||
wchar_t *cmd =
|
||||
(last_type == TOK_STRING) ?
|
||||
expand_one(wcsdup(tok_last( &tok )),EXPAND_SKIP_SUBSHELL | EXPAND_SKIP_VARIABLES) :
|
||||
wcsdup(tok_last( &tok ));
|
||||
wchar_t *cmd = expand_one( 0,
|
||||
wcsdup(tok_last( &tok )),
|
||||
EXPAND_SKIP_SUBSHELL | EXPAND_SKIP_VARIABLES);
|
||||
|
||||
if( cmd == 0 )
|
||||
{
|
||||
color[ tok_get_pos( &tok ) ] = HIGHLIGHT_ERROR;
|
||||
@@ -144,7 +145,6 @@ void highlight_shell( wchar_t * buff,
|
||||
int is_subcommand = 0;
|
||||
int mark = tok_get_pos( &tok );
|
||||
color[ tok_get_pos( &tok ) ] = HIGHLIGHT_COMMAND;
|
||||
|
||||
|
||||
if( parser_is_subcommand( cmd ) )
|
||||
{
|
||||
@@ -247,7 +247,7 @@ void highlight_shell( wchar_t * buff,
|
||||
{
|
||||
case TOK_STRING:
|
||||
{
|
||||
target = expand_one( wcsdup( tok_last( &tok ) ), EXPAND_SKIP_SUBSHELL);
|
||||
target = expand_one( 0, wcsdup( tok_last( &tok ) ), EXPAND_SKIP_SUBSHELL);
|
||||
/*
|
||||
Redirect filename may contain a subshell.
|
||||
If so, it will be ignored/not flagged.
|
||||
@@ -357,7 +357,7 @@ void highlight_shell( wchar_t * buff,
|
||||
/*
|
||||
Locate and syntax highlight subshells recursively
|
||||
*/
|
||||
|
||||
|
||||
wchar_t *buffcpy = wcsdup( buff );
|
||||
wchar_t *subpos=buffcpy;
|
||||
int done=0;
|
||||
@@ -365,11 +365,11 @@ void highlight_shell( wchar_t * buff,
|
||||
while( 1 )
|
||||
{
|
||||
wchar_t *begin, *end;
|
||||
|
||||
if( expand_locate_subshell( subpos,
|
||||
&begin,
|
||||
&end,
|
||||
1) <= 0)
|
||||
|
||||
if( parse_util_locate_cmdsubst( subpos,
|
||||
(const wchar_t **)&begin,
|
||||
(const wchar_t **)&end,
|
||||
1) <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -386,8 +386,9 @@ void highlight_shell( wchar_t * buff,
|
||||
break;
|
||||
|
||||
subpos = end+1;
|
||||
|
||||
}
|
||||
free( buffcpy );
|
||||
free( buffcpy);
|
||||
|
||||
|
||||
last_val=0;
|
||||
|
||||
67
history.c
67
history.c
@@ -19,6 +19,7 @@
|
||||
#include "reader.h"
|
||||
#include "env.h"
|
||||
#include "sanity.h"
|
||||
#include "signal.h"
|
||||
|
||||
/*
|
||||
The history is implemented using a linked list. Searches are done
|
||||
@@ -45,6 +46,8 @@ typedef struct
|
||||
The last item loaded from file
|
||||
*/
|
||||
ll_node_t *last_loaded;
|
||||
|
||||
int is_loaded;
|
||||
}
|
||||
history_data;
|
||||
|
||||
@@ -82,25 +85,31 @@ static wchar_t *mode_name;
|
||||
*/
|
||||
static hash_table_t history_table;
|
||||
|
||||
/**
|
||||
Flag, set to 1 once the history file has been loaded
|
||||
*/
|
||||
static int is_loaded;
|
||||
|
||||
/**
|
||||
Load history from ~/.fish_history
|
||||
Load history from file
|
||||
*/
|
||||
static void history_load( wchar_t *name )
|
||||
static void history_load()
|
||||
{
|
||||
wchar_t *fn;
|
||||
wchar_t *buff=0;
|
||||
int buff_len=0;
|
||||
FILE *in_stream;
|
||||
hash_table_t used;
|
||||
|
||||
block();
|
||||
|
||||
is_loaded = 1;
|
||||
|
||||
signal_block();
|
||||
hash_init2( &used,
|
||||
&hash_wcs_func,
|
||||
&hash_wcs_cmp,
|
||||
4096 );
|
||||
|
||||
fn = wcsdupcat2( env_get(L"HOME"), L"/.", name, L"_history", 0 );
|
||||
fn = wcsdupcat2( env_get(L"HOME"), L"/.", mode_name, L"_history", 0 );
|
||||
|
||||
in_stream = wfopen( fn, "r" );
|
||||
|
||||
@@ -111,12 +120,12 @@ static void history_load( wchar_t *name )
|
||||
int buff_read = fgetws2( &buff, &buff_len, in_stream );
|
||||
if( buff_read == -1 )
|
||||
{
|
||||
debug( 1, L"The following non-fatal error occurred while reading command history from \'%ls\':", name );
|
||||
debug( 1, L"The following non-fatal error occurred while reading command history from \'%ls\':", mode_name );
|
||||
wperror( L"fgetws2" );
|
||||
fclose( in_stream );
|
||||
free( fn );
|
||||
free( buff );
|
||||
unblock();
|
||||
signal_unblock();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -127,8 +136,8 @@ static void history_load( wchar_t *name )
|
||||
|
||||
Use a hashtable to check for duplicates instead.
|
||||
*/
|
||||
if( !hash_get( &used,
|
||||
buff ) )
|
||||
if( wcslen(buff) && !hash_get( &used,
|
||||
buff ) )
|
||||
{
|
||||
history_count++;
|
||||
|
||||
@@ -161,7 +170,7 @@ static void history_load( wchar_t *name )
|
||||
{
|
||||
if( errno != ENOENT )
|
||||
{
|
||||
debug( 1, L"The following non-fatal error occurred while reading command history from \'%ls\':", name );
|
||||
debug( 1, L"The following non-fatal error occurred while reading command history from \'%ls\':", mode_name );
|
||||
wperror( L"fopen" );
|
||||
}
|
||||
|
||||
@@ -173,7 +182,7 @@ static void history_load( wchar_t *name )
|
||||
free( buff );
|
||||
free( fn );
|
||||
last_loaded = history_last;
|
||||
unblock();
|
||||
signal_unblock();
|
||||
}
|
||||
|
||||
void history_init()
|
||||
@@ -198,6 +207,7 @@ static void history_to_hash()
|
||||
d->last=history_last;
|
||||
d->last_loaded=last_loaded;
|
||||
d->count=history_count;
|
||||
d->is_loaded = is_loaded;
|
||||
|
||||
hash_put( &history_table,
|
||||
mode_name,
|
||||
@@ -223,13 +233,14 @@ void history_set_mode( wchar_t *name )
|
||||
history_current = history_last = curr->last;
|
||||
last_loaded = curr->last_loaded;
|
||||
history_count = curr->count;
|
||||
is_loaded = curr->is_loaded;
|
||||
}
|
||||
else
|
||||
{
|
||||
history_count=0;
|
||||
history_last = history_current = last_loaded=0;
|
||||
mode_name = wcsdup( name );
|
||||
history_load( name );
|
||||
is_loaded = 0;
|
||||
}
|
||||
|
||||
past_end=1;
|
||||
@@ -259,6 +270,9 @@ static void history_save()
|
||||
/* First we save this sessions history in local variables */
|
||||
ll_node_t *real_pos = history_last, *real_first = last_loaded;
|
||||
|
||||
if( !is_loaded )
|
||||
return;
|
||||
|
||||
if( !real_first )
|
||||
{
|
||||
real_first = history_current;
|
||||
@@ -390,6 +404,9 @@ void history_destroy()
|
||||
*/
|
||||
static ll_node_t *history_find( ll_node_t *n, const wchar_t *s )
|
||||
{
|
||||
if( !is_loaded )
|
||||
history_load();
|
||||
|
||||
if( n == 0 )
|
||||
return 0;
|
||||
|
||||
@@ -406,6 +423,9 @@ void history_add( const wchar_t *str )
|
||||
{
|
||||
ll_node_t *old_node;
|
||||
|
||||
if( !is_loaded )
|
||||
history_load();
|
||||
|
||||
if( wcslen( str ) == 0 )
|
||||
return;
|
||||
|
||||
@@ -460,15 +480,15 @@ static int history_test( const wchar_t *needle, const wchar_t *haystack )
|
||||
|
||||
const wchar_t *history_prev_match( const wchar_t *str )
|
||||
{
|
||||
if( !is_loaded )
|
||||
history_load();
|
||||
|
||||
if( history_current == 0 )
|
||||
return str;
|
||||
|
||||
if( history_current->prev == 0 )
|
||||
{
|
||||
if( history_test( str, history_current->data ) )
|
||||
return (wchar_t *)history_current->data;
|
||||
else
|
||||
return str;
|
||||
return str;
|
||||
}
|
||||
if( past_end )
|
||||
past_end = 0;
|
||||
@@ -484,6 +504,9 @@ const wchar_t *history_prev_match( const wchar_t *str )
|
||||
|
||||
const wchar_t *history_next_match( const wchar_t *str)
|
||||
{
|
||||
if( !is_loaded )
|
||||
history_load();
|
||||
|
||||
if( history_current == 0 )
|
||||
return str;
|
||||
|
||||
@@ -510,15 +533,21 @@ void history_reset()
|
||||
*/
|
||||
void history_first()
|
||||
{
|
||||
while( history_current->prev )
|
||||
history_current = history_current->prev;
|
||||
if( is_loaded )
|
||||
while( history_current->prev )
|
||||
history_current = history_current->prev;
|
||||
|
||||
}
|
||||
|
||||
wchar_t *history_get( int idx )
|
||||
{
|
||||
ll_node_t *n=history_last;
|
||||
ll_node_t *n;
|
||||
int i;
|
||||
if( !is_loaded )
|
||||
history_load();
|
||||
|
||||
n = history_last;
|
||||
|
||||
if( idx<0)
|
||||
{
|
||||
debug( 1, L"Tried to access negative history index %d", idx );
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
#include <wchar.h>
|
||||
|
||||
/**
|
||||
Load history from file.
|
||||
Init history library. The history file won't actually be loaded
|
||||
until the first time a history search is performed.
|
||||
*/
|
||||
void history_init();
|
||||
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
#apm
|
||||
complete -f -c apm -s V -l version -d "print version"
|
||||
complete -f -c apm -s v -l verbose -d "print APM info"
|
||||
complete -f -c apm -s m -l minutes -d "print time remaining"
|
||||
complete -f -c apm -s M -l monitor -d "monitor status info"
|
||||
complete -f -c apm -s S -l standby -d "request APM standby mode"
|
||||
complete -f -c apm -s s -l suspend -d "request APM suspend mode"
|
||||
complete -f -c apm -s d -l debug -d "APM status debuggin info"
|
||||
@@ -1,20 +0,0 @@
|
||||
function __fish_complete_apropos
|
||||
if test (commandline -ct)
|
||||
set str (commandline -ct)
|
||||
apropos $str|sed -e 's/^\(.*'$str'\([^ ]*\).*\)$/'$str'\2\t\1/'
|
||||
end
|
||||
end
|
||||
|
||||
complete -xc apropos -a "(__fish_complete_apropos)" -d "Whatis entry"
|
||||
|
||||
complete -c apropos -s h -l help -d "apropos command help"
|
||||
complete -f -c apropos -s d -l debug -d "print debugging info"
|
||||
complete -f -c apropos -s v -l verbose -d "print verbose warning"
|
||||
complete -f -c apropos -s r -l regex -d "keyword as regex"
|
||||
complete -f -c apropos -s w -l wildcard -d "keyword as wildwards"
|
||||
complete -f -c apropos -s e -l exact -d "keyword as exactly match"
|
||||
complete -x -c apropos -s m -l system -d "search for other system"
|
||||
complete -x -c apropos -s M -l manpath -a "(echo $MANPATH)" -d "specify man path"
|
||||
complete -x -c apropos -s C -l config-file -d "specify a conf file"
|
||||
complete -f -c apropos -s V -l version -d "Display version"
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
|
||||
#apt-build
|
||||
complete -c apt-build -l help -d "apt-build command help"
|
||||
complete -f -c apt-build -a update -d "update list of packages"
|
||||
complete -f -c apt-build -a upgrade -d "upgrade packages"
|
||||
complete -f -c apt-bulid -a world -d "rebuild your system"
|
||||
complete -x -c apt-build -a install -d "build and install a new pkg"
|
||||
complete -x -c apt-build -a source -d "download and extract a src"
|
||||
complete -x -c apt-build -a info -d "info on a pkg"
|
||||
complete -x -c apt-build -a remove -d "remove packages"
|
||||
complete -x -c apt-build -a clean-build -d "erase built pkgs"
|
||||
complete -x -c apt-build -a build-source -d "build src without install"
|
||||
complete -x -c apt-build -a clean-sources -d "clean src dirs"
|
||||
complete -x -c apt-build -a update-source -d "update src and rebuild them"
|
||||
complete -x -c apt-build -a update-repository -d "update the repository"
|
||||
complete -f -c apt-build -l nowrapper -d "do not use gcc wrapper"
|
||||
complete -f -c apt-build -l remove-builddep -d "remove build-dep"
|
||||
complete -f -c apt-build -l no-source -d "do not download source"
|
||||
complete -f -c apt-build -l build-dir -d "specify build-dir"
|
||||
complete -f -c apt-build -l rebuild -d "rebuild a package"
|
||||
complete -f -c apt-build -l reinstall -d "rebuild and install an installed pkg"
|
||||
complete -r -f -c apt-build -l build-command -d "use <command> to build"
|
||||
complete -r -c apt-build -l patch -d "apply <file> patch"
|
||||
complete -c apt-build -s p -l patch-strip -d "prefix to strip on patch"
|
||||
complete -c apt-build -s y -l yes -d "assume yes"
|
||||
complete -c apt-build -l purge -d "use purge instead of remove"
|
||||
complete -c apt-build -l noupdate -d "do not run update"
|
||||
complete -r -c apt-build -l source-list -d "specify sources.list file"
|
||||
complete -f -c apt-build -s v -l version -d "show version"
|
||||
@@ -1,33 +0,0 @@
|
||||
#apt-cache
|
||||
complete -c apt-cache -s h -l help -d "apt-cache command help"
|
||||
complete -c apt-cache -a add -d "add index files Debug only"
|
||||
complete -f -c apt-cache -a gencaches -d "build apt cache"
|
||||
complete -x -c apt-cache -a showpkg -d "show package info"
|
||||
complete -f -c apt-cache -a stats -d "show cache statistics"
|
||||
complete -x -c apt-cache -a showsrc -d "show source package"
|
||||
complete -f -c apt-cache -a dump -d "show packages in cache"
|
||||
complete -f -c apt-cache -a dumpavail -d "print available list"
|
||||
complete -f -c apt-cache -a unmet -d "list unmet dep in cache"
|
||||
complete -x -c apt-cache -a show -d "display package record"
|
||||
complete -x -c apt-cache -a search -d "search pkgname by REGEX"
|
||||
complete -c apt-cache -l full -a search -d "search full package name"
|
||||
complete -x -c apt-cache -l names-only -a search -d "search pkgname only"
|
||||
complete -x -c apt-cache -a depends -d "list dep for the package"
|
||||
complete -x -c apt-cache -a rdepends -d "list reverse dep for the package"
|
||||
complete -x -c apt-cache -a pkgnames -d "print package name by prefix"
|
||||
complete -x -c apt-cache -a dotty -d "generate dotty output for packages"
|
||||
complete -x -c apt-cache -a policy -d "debug preferences file"
|
||||
complete -x -c apt-cache -a madison -d "mimic madison"
|
||||
complete -r -c apt-cache -s p -l pkg-cache -d "select file to store pkg cache"
|
||||
complete -r -c apt-cache -s s -l src-cache -d "select file to store src cache"
|
||||
complete -f -c apt-cache -s q -l quiet -d "quiet output"
|
||||
complete -f -c apt-cache -s i -l important -d "print important deps"
|
||||
complete -f -c apt-cache -s a -l all-versions -d "print full records"
|
||||
complete -f -c apt-cache -s g -l generate -d "auto-gen package cache"
|
||||
complete -f -c apt-cache -l all-names -d "print all names"
|
||||
complete -f -c apt-cache -l recurse -d "dep and rdep recursive"
|
||||
complete -f -c apt-cache -l installed -d "limit to installed"
|
||||
complete -f -c apt-cache -s v -l version -d "show version"
|
||||
complete -r -c apt-cache -s c -l config-file -d "specify config file"
|
||||
complete -x -c apt-cache -s o -l option -d "specify options"
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
#apt-cdrom
|
||||
complete -c apt-cdrom -s h -l help -d "apt-cdrom command help"
|
||||
complete -r -c apt-cdrom -a add -d "add new disc to source list"
|
||||
complete -x -c apt-cdrom -a ident -d "report identity of disc"
|
||||
complete -r -c apt-cdrom -s d -l cdrom -d "mount point"
|
||||
complete -f -c apt-cdrom -s r -l rename -d "rename a disc"
|
||||
complete -f -c apt-cdrom -s m -l no-mount -d "no mounting"
|
||||
complete -f -c apt-cdrom -s f -l fast -d "fast copy"
|
||||
complete -f -c apt-cdrom -s a -l thorough -d "thorough pkg scan"
|
||||
complete -f -c apt-cdrom -s n -l no-act -d "no changes"
|
||||
complete -f -c apt-cdrom -s v -l version -d "show version"
|
||||
complete -r -c apt-cdrom -s c -l config-file -d "specify config file"
|
||||
complete -x -c apt-cdrom -s o -l option -d "specify options"
|
||||
@@ -1,7 +0,0 @@
|
||||
#apt-config
|
||||
complete -c apt-config -s h -l help -d "apt-config command help"
|
||||
complete -c apt-config -a shell -d "access config file from shell"
|
||||
complete -f -c apt-config -a dump -d "dump contents of config file"
|
||||
complete -f -c apt-config -s v -l version -d "show version"
|
||||
complete -r -c apt-config -s c -l config-file -d "specify config file"
|
||||
complete -x -c apt-config -s o -l option -d "specify options"
|
||||
@@ -1,7 +0,0 @@
|
||||
|
||||
#apt-extracttemplates
|
||||
complete -c apt-extracttemplates -s h -l help -d "apt-extracttemplates command help"
|
||||
complete -r -c apt-extracttemplates -s t -d "set temp dir"
|
||||
complete -r -c apt-extracttemplates -s c -d "specifiy config file"
|
||||
complete -r -c apt-extracttemplates -s o -d "specify options"
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
#apt-file
|
||||
complete -c apt-file -s h -l help -d "apt-file command help"
|
||||
complete -x -c apt-file -a update -d "resync pkg contents from source"
|
||||
complete -r -c apt-file -a search -d "search pkg containing pattern"
|
||||
complete -r -c apt-file -a list -d "list contents of a pkg matching pattern"
|
||||
complete -x -c apt-file -a purge -d "remove all gz files from cache"
|
||||
complete -r -c apt-file -s c -l cache -d "set cache dir"
|
||||
complete -f -c apt-file -s v -l verbose -d "run in verbose"
|
||||
complete -c apt-file -s d -l cdrom-mount -d "use cdrom-mount-point"
|
||||
complete -f -c apt-file -s i -l ignore-case -d "do not expand pattern"
|
||||
complete -f -c apt-file -s x -l regexp -d "pattern is regexp"
|
||||
complete -f -c apt-file -s V -l version -d "show version"
|
||||
complete -f -c apt-file -s a -l architecture -d "set arch"
|
||||
complete -r -c apt-file -s s -l sources-list -a "(ls /etc/apt)" -d "set sources.list file"
|
||||
complete -f -c apt-file -s l -l package-only -d "only display pkg name"
|
||||
complete -f -c apt-file -s F -l fixed-string -d "do not expand pattern"
|
||||
complete -f -c apt-file -s y -l dummy -d "run in dummy mode"
|
||||
@@ -1,17 +0,0 @@
|
||||
#apt-ftparchive
|
||||
complete -c apt-ftparchive -s h -l help -d "apt-ftparchive command help"
|
||||
complete -f -c apt-ftparchive -a packages -d "generate pkg from source"
|
||||
complete -f -c apt-ftparchive -a sources -d "generate source index file"
|
||||
complete -f -c apt-ftparchive -a contents -d "generate contents file"
|
||||
complete -f -c apt-ftparchive -a release -d "generate release file"
|
||||
complete -f -c apt-ftparchive -a clean -d "remove records"
|
||||
complete -f -c apt-ftparchive -l md5 -d "generate MD5 sums"
|
||||
complete -f -c apt-ftparchive -s d -l db -d "use a binary db"
|
||||
complete -f -c apt-ftparchive -s q -l quiet -d "quiet mode"
|
||||
complete -f -c apt-ftparchive -l delink -d "perform delinking"
|
||||
complete -f -c apt-ftparchive -l contents -d "perform contents generation"
|
||||
complete -c apt-ftparchive -s s -l source-override -d "use source override"
|
||||
complete -f -c apt-ftparchive -l readonly -d "make caching db readonly"
|
||||
complete -f -c apt-ftparchive -s v -l version -d "show version"
|
||||
complete -r -c apt-ftparchive -s c -l config-file -d "use config file"
|
||||
complete -r -c apt-ftparchive -s o -l option -d "set config options"
|
||||
@@ -1,64 +0,0 @@
|
||||
#completion for apt-get
|
||||
|
||||
function __fish_apt_no_subcommand -d "test if apt has yet to be given the subcommand"
|
||||
for i in (commandline -opc)
|
||||
if contains -- $i update upgrade dselect-upgrade dist-upgrade install remove source build-dep check clean autoclean
|
||||
return 1
|
||||
end
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
function __fish_apt_use_package -d "Test if apt command should have packages as potential completion"
|
||||
for i in (commandline -opc)
|
||||
if contains -- $i contains install remove build-dep
|
||||
return 0
|
||||
end
|
||||
end
|
||||
return 1
|
||||
end
|
||||
|
||||
complete -c apt-get -n "__fish_apt_use_package" -a "(__fish_print_packages)" -d "Package"
|
||||
|
||||
complete -c apt-get -s h -l help -d "apt-get command help"
|
||||
complete -f -n "__fish_apt_no_subcommand" -c apt-get -a "update" -d "update sources"
|
||||
complete -f -n "__fish_apt_no_subcommand" -c apt-get -a "upgrade" -d "upgrade or install newest packages"
|
||||
complete -f -n "__fish_apt_no_subcommand" -c apt-get -a "dselect-upgrade" -d "use with dselect front-end"
|
||||
complete -f -n "__fish_apt_no_subcommand" -c apt-get -a "dist-upgrade" -d "distro upgrade"
|
||||
complete -f -n "__fish_apt_no_subcommand" -c apt-get -a "install" -d "install one or more packages"
|
||||
complete -f -n "__fish_apt_no_subcommand" -c apt-get -a "remove" -d "remove one or more packages"
|
||||
complete -f -n "__fish_apt_no_subcommand" -c apt-get -a "source" -d "fetch source packages"
|
||||
complete -f -n "__fish_apt_no_subcommand" -c apt-get -a "build-dep" -d "install/remove packages for dependencies"
|
||||
complete -f -n "__fish_apt_no_subcommand" -c apt-get -a "check" -d "update cache and check dep"
|
||||
complete -f -n "__fish_apt_no_subcommand" -c apt-get -a "clean" -d "clean local caches and packages"
|
||||
complete -f -n "__fish_apt_no_subcommand" -c apt-get -a "autoclean" -d "clean packages no longer be downloaded"
|
||||
complete -c apt-get -s d -l download-only -d "Download Only"
|
||||
complete -c apt-get -s f -l fix-broken -d "correct broken deps"
|
||||
complete -c apt-get -s m -l fix-missing -d "ignore missing packages"
|
||||
complete -c apt-get -l no-download -d "Disable downloading packages"
|
||||
complete -c apt-get -s q -l quiet -d "quiet output"
|
||||
complete -c apt-get -s s -l simulate -d "perform a siulation"
|
||||
complete -c apt-get -s y -l assume-yes -d "automatic yes to prompts"
|
||||
complete -c apt-get -s u -l show-upgraded -d "show upgraded packages"
|
||||
complete -c apt-get -s V -l verbose-versions -d "show full versions for packages"
|
||||
complete -c apt-get -s b -l compile -d "compile source packages"
|
||||
complete -c apt-get -s b -l build -d "compile source packages"
|
||||
complete -c apt-get -l ignore-hold -d "ignore package Holds"
|
||||
complete -c apt-get -l no-upgrade -d "Do not upgrade packages"
|
||||
complete -c apt-get -l force-yes -d "Force yes"
|
||||
complete -c apt-get -l print-uris -d "print the URIs"
|
||||
complete -c apt-get -l purge -d "use purge instead of remove"
|
||||
complete -c apt-get -l reinstall -d "reinstall packages"
|
||||
complete -c apt-get -l list-cleanup -d "erase obsolete files"
|
||||
complete -c apt-get -s t -l target-release -d "control default input to the policy engine"
|
||||
complete -c apt-get -l trivial-only -d "only perform operations that are trivial"
|
||||
complete -c apt-get -l no-remove -d "abort if any packages are to be removed"
|
||||
complete -c apt-get -l only-source -d "only accept source packages"
|
||||
complete -c apt-get -l diff-only -d "download only diff file"
|
||||
complete -c apt-get -l tar-only -d "download only tar file"
|
||||
complete -c apt-get -l arch-only -d "only process arch-dep build-deps"
|
||||
complete -c apt-get -l allow-unauthenticated -d "ignore non-authenticated packages"
|
||||
complete -c apt-get -s v -l version -d "show program version"
|
||||
complete -r -c apt-get -s c -l config-file -d "specify a config file"
|
||||
complete -r -c apt-get -s o -l option -d "set a config option"
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
#apt-key
|
||||
complete -r -c apt-key -a add -d "add a new key"
|
||||
complete -f -c apt-key -a del -d "remove a key"
|
||||
complete -f -c apt-key -a list -d "list trusted keys"
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
#apt-listbugs
|
||||
complete -c apt-listbugs -s h -l help -d "apt-listbugs command help"
|
||||
complete -f -c apt-listbugs -s s -l severity -a "critical grave" -d "set severity"
|
||||
complete -f -c apt-listbugs -s T -l tag -d "Targs you want to see"
|
||||
complete -f -c apt-listbugs -s S -l stats -d "outstanding 'pending upload' resolved done open" -d "status you want to see"
|
||||
complete -f -c apt-listbugs -s l -l showless -d "ignore bugs in your system"
|
||||
complete -f -c apt-listbugs -s g -l showgreater -d "ignore newer bugs than upgrade pkgs"
|
||||
complete -f -c apt-listbugs -s D -l show-downgrade -d "bugs for downgrade pkgs"
|
||||
complete -f -c apt-listbugs -s H -l hostname -a "osdn.debian.or.jp" -d "Bug Tracking system"
|
||||
complete -f -c apt-listbugs -s p -l port -d "specify port for web interface"
|
||||
complete -f -c apt-listbugs -s R -l release-critical -d "use daily bug report"
|
||||
complete -f -c apt-listbugs -s I -l index -d "use the raw index.db"
|
||||
complete -f -c apt-listbugs -s X -l indexdir -d "specify index dir"
|
||||
complete -f -c apt-listbugs -s P -l pin-priority -d "specify Pin-Priority value"
|
||||
complete -f -c apt-listbugs -l title -d "specify the title of rss"
|
||||
complete -f -c apt-listbugs -s f -l force-download -d "retrieve fresh bugs"
|
||||
complete -f -c apt-listbugs -s q -l quiet -d "do not display progress bar"
|
||||
complete -f -c apt-listbugs -s c -l cache-dir -a "/var/cache/apt-listbugs/" -d "specify local cache dir"
|
||||
complete -f -c apt-listbugs -s t -l timer -d "specify the expire cache timer"
|
||||
complete -c apt-listbugs -s C -l aptconf -d "specify apt config file"
|
||||
complete -f -c apt-listbugs -s y -l force-yes -d "assume all yes"
|
||||
complete -f -c apt-listbugs -s n -l force-no -d "assume all no"
|
||||
complete -c apt-listbugs -a list -d "list bugs from pkgs"
|
||||
complete -c apt-listbugs -a rss -d "list bugs in rss format"
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
#apt-listchanges
|
||||
complete -c apt-listchanges -l help -d "apt-listchanges command help"
|
||||
complete -c apt-listchanges -l apt -d "read filenames from pipe"
|
||||
complete -f -c apt-listchanges -s v -l verbose -d "verbose info"
|
||||
complete -f -c apt-listchanges -s f -l frontend -a "pager browser xterm-pager xterm-browser text mail none" -d "select fronend interface"
|
||||
complete -r -f -c apt-listchanges -l email-address -d "specify email address"
|
||||
complete -f -c apt-listchanges -s c -l confirm -d "ask confirmation"
|
||||
complete -f -c apt-listchanges -s a -l all -d "display all changelogs"
|
||||
complete -r -c apt-listchanges -l save_seen -d "avoid changelogs from db in named file"
|
||||
complete -r -f -c apt-listchanges -l which -a "news changelogs both" -d "select display"
|
||||
complete -f -c apt-listchanges -s h -l headers -d "insert header"
|
||||
complete -f -c apt-listchanges -l debug -d "display debug info"
|
||||
complete -r -c apt-listchanges -l profile -d "select an option profile"
|
||||
@@ -1,23 +0,0 @@
|
||||
#apt-move
|
||||
complete -c apt-move -a get -d "generate master file"
|
||||
complete -c apt-move -a getlocal -d "alias of get"
|
||||
complete -f -c apt-move -a move -d "move pkgs to local tree"
|
||||
complete -f -c apt-move -a delete -d "delete obsolete pkg files"
|
||||
complete -f -c apt-move -a packages -d "build new local files"
|
||||
complete -f -c apt-move -a fsck -d "rebuild index files"
|
||||
complete -f -c apt-move -a update -d "move pkgs from cache to local mirror"
|
||||
complete -f -c apt-move -a local -d "alias to move delete packages"
|
||||
complete -f -c apt-move -a localupdate -d "alias for update"
|
||||
complete -f -c apt-move -a mirror -d "download pkg missing from mirror"
|
||||
complete -f -c apt-move -a sync -d "sync pkgs installed"
|
||||
complete -f -c apt-move -a exclude -d 'test $LOCALDIR/.exclude file'
|
||||
complete -c apt-move -a movefile -d "move file from CLI"
|
||||
complete -f -c apt-move -a listbin -d "mirror|sync|repo"
|
||||
complete -f -c apt-move -a mirrorbin -d "fetch pkg from STDIN"
|
||||
complete -f -c apt-move -a mirrorsrc -d "fetch src pkg from STDIN"
|
||||
complete -f -c apt-move -s a -d "process all pkgs"
|
||||
complete -c apt-move -s c -d "use specific conffile"
|
||||
complete -f -c apt-move -s d -d "use specific dist"
|
||||
complete -f -c apt-move -s f -d "force deletion"
|
||||
complete -f -c apt-move -s q -d "suppresses normal output"
|
||||
complete -f -c apt-move -s t -d "test run"
|
||||
@@ -1,10 +0,0 @@
|
||||
#apt-proxy-import
|
||||
complete -c apt-proxy-import -s h -l help -d "apt-proxy-import command help"
|
||||
complete -f -c apt-proxy-import -s V -l version -d "print version"
|
||||
complete -f -c apt-proxy-import -s v -l verbose -d "verbose info"
|
||||
complete -f -c apt-proxy-import -s q -l quiet -d "no message to STDOUT"
|
||||
complete -f -c apt-proxy-import -s r -l recursive -d "recurse into subdir"
|
||||
complete -r -c apt-proxy-import -s i -l import-dir -a "(ls -Fp|grep /$)" -d "dir to import"
|
||||
complete -r -c apt-proxy-import -s u -l user -a "(__fish_complete_users)" -d "change to user"
|
||||
complete -r -c apt-proxy-import -s d -l debug -d "debug level[default 0]"
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
#apt-rdepends
|
||||
complete -c apt-rdepends -l help -d "apt-rdepends command help"
|
||||
complete -f -c apt-rdepends -s b -l build-depends -d "show bulid deps"
|
||||
complete -f -c apt-rdepends -s d -l dotty -d "generate a dotty graph"
|
||||
complete -f -c apt-rdepends -s p -l print-state -d "show state of deps"
|
||||
complete -f -c apt-rdepends -s r -l reverse -d "list pkgs depending on"
|
||||
complete -r -f -c apt-rdepends -s f -l follow -d "only follow DEPENDS recursively"
|
||||
complete -r -f -c apt-rdepends -s s -l show -d "only show DEPENDS"
|
||||
complete -r -f -c apt-rdepends -l state-follow -d "only follow STATES recursively"
|
||||
complete -r -f -c apt-rdepends -l state-show -d "only show STATES"
|
||||
complete -f -c apt-rdepends -l man -d "display man page"
|
||||
complete -f -c apt-rdepends -l version -d "print version"
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
#apt-setup
|
||||
complete -c apt-setup -a probe -d "probe a CD"
|
||||
complete -c apt-setup -s N -d "run in noninteractive mode"
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
#apt-show-source
|
||||
complete -c apt-show-source -s h -l help -d "apt-show-source command help"
|
||||
complete -r -c apt-show-source -l status-file -d "read pkg from FILE" -f
|
||||
complete -r -c apt-show-source -o stf -d "read pkg from FILE" -f
|
||||
complete -r -c apt-show-source -l list-dir -a "(ls -Fp .|grep /$) /var/lib/apt/lists" -d "specify APT list dir"
|
||||
complete -r -c apt-show-source -o ld -a "(ls -Fp .|grep /$) /var/lib/apt/lists" -d "specify APT list dir"
|
||||
complete -r -c apt-show-source -s p -l package -a "(apt-cache pkgnames)" -d "list PKG info"
|
||||
complete -f -c apt-show-source -l version-only -d "print version only"
|
||||
complete -f -c apt-show-source -s a -l all -d "print all src pkgs with version"
|
||||
complete -f -c apt-show-source -s v -l verbose -d "verbose message"
|
||||
@@ -1,14 +0,0 @@
|
||||
#apt-show-versions
|
||||
complete -c apt-show-source -s h -l help -d "apt-show-versions command help"
|
||||
complete -r -c apt-show-versions -s p -l packages -a "(apt-cache pkgnames)" -d "print PKG versions"
|
||||
complete -f -c apt-show-versions -s r -l regex -d "using regex"
|
||||
complete -f -c apt-show-versions -s u -l upgradeable -d "print only upgradeable pkgs"
|
||||
complete -f -c apt-show-versions -s a -l allversions -d "print all versions"
|
||||
complete -f -c apt-show-versions -s b -l brief -d "print pkg name/distro"
|
||||
complete -f -c apt-show-versions -s v -l verbose -d "print verbose info"
|
||||
complete -f -c apt-show-versions -s i -l initialize -d "init or update cache only"
|
||||
complete -r -c apt-show-versions -l status-file -d "read pkg from FILE"
|
||||
complete -r -c apt-show-versions -o stf -d "read pkg from FILE"
|
||||
complete -r -c apt-show-versions -l list-dir -a "(ls -Fp .|grep /$) /var/lib/apt/lists /var/state/apt/lists" -d "specify APT list dir"
|
||||
complete -r -c apt-show-versions -o ld -a "(ls -Fp .|grep /$) /var/lib/apt/lists /var/state/apt/lists" -d "specify APT list dir"
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
#apt-sortpkgs
|
||||
complete -c apt-sortpkgs -s h -l help -d "apt-sortpkgs command help"
|
||||
complete -f -c apt-sortpkgs -s s -l source -d "use source index field"
|
||||
complete -f -c apt-sortpkgs -s v -l version -d "show version"
|
||||
complete -r -c apt-sortpkgs -s c -l conf-file -d "specify conffile"
|
||||
complete -r -f -c apt-sortpkgs -s o -l option -d "set config options"
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
#apt-spy
|
||||
complete -c apt-spy -s h -d "apt-spy command help"
|
||||
complete -f -c apt-spy -s d -a "stable testing unstable" -d "Debian distribtion"
|
||||
complete -f -c apt-spy -s a -a "Africa Asia Europe North-America Oceania South-America" -d "servers in the areas"
|
||||
complete -c apt-spy -s c -d "conf file"
|
||||
complete -f -c apt-spy -s e -d "finish after number of servers"
|
||||
complete -c apt-spy -s f -d "file to grab servers"
|
||||
complete -c apt-spy -s i -d "file as input"
|
||||
complete -c apt-spy -s m -d "mirror-list file"
|
||||
complete -c apt-spy -s o -d "output sources.list file"
|
||||
complete -f -c apt-spy -s p -d "use proxy server"
|
||||
complete -f -c apt-spy -s s -d "comma separated country list"
|
||||
complete -f -c apt-spy -s t -d "how long in sec to download"
|
||||
complete -f -c apt-spy -s u -d "custom URL to get mirror list"
|
||||
complete -c apt-spy -s w -d "write top servers to file"
|
||||
complete -f -c apt-spy -s n -d "number of top servers"
|
||||
complete -f -c apt-spy -a "update" -d "update mirror list"
|
||||
complete -f -c apt-spy -s v -d "version number"
|
||||
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
#apt-src
|
||||
complete -c apt-src -s h -l help -d "apt-src command help"
|
||||
complete -f -c apt-src -a "update" -d "update list of src pkgs"
|
||||
complete -f -c apt-src -a "install" -d "install src pkgs"
|
||||
complete -f -c apt-src -a "upgrade" -d "upgrade src pkgs"
|
||||
complete -f -c apt-src -a "remove" -d "remove src pkgs"
|
||||
complete -f -c apt-src -a "build" -d "build src pkgs"
|
||||
complete -f -c apt-src -a "clean" -d "clean src pkgs"
|
||||
complete -f -c apt-src -a "import" -d "detect known src tree"
|
||||
complete -f -c apt-src -a "list" -d "list installed src pkg\(s\)"
|
||||
complete -f -c apt-src -a "location" -d "root src tree"
|
||||
complete -f -c apt-src -a "version" -d "version of src pkg"
|
||||
complete -f -c apt-src -a "name" -d "name of the src pkg"
|
||||
complete -f -c apt-src -s b -l build -d "build src pkgs"
|
||||
complete -f -c apt-src -s i -l installdebs -d "install after build"
|
||||
complete -f -c apt-src -s p -l patch -d "patch local changes"
|
||||
complete -r -c apt-src -s l -l location -d "specify a dir"
|
||||
complete -c apt-src -s c -l here -d "run on current dir"
|
||||
complete -f -c apt-src -l upstream-version -d "omit debian version"
|
||||
complete -f -c apt-src -s k -l keep-built -d "do not del built files"
|
||||
complete -f -c apt-src -s n -l no-delete-source -d "do not del source files"
|
||||
complete -f -c apt-src -l version -d "source tree version"
|
||||
complete -f -c apt-src -s q -l quiet -d "output to /dev/null"
|
||||
complete -f -c apt-src -s t -l trace -d "output trace"
|
||||
@@ -1,10 +0,0 @@
|
||||
#apt-zip-inst
|
||||
complete -c apt-zip-inst -s h -l help -d "apt-zip-inst command help"
|
||||
complete -f -c apt-zip-inst -s V -l version -d "show version"
|
||||
complete -c apt-zip-inst -s m -l medium -d "removable medium"
|
||||
complete -f -c apt-zip-inst -s a -l aptgetaction -a "dselect-upgrade upgrade dist-upgrade" -d "select an action"
|
||||
complete -c apt-zip-inst -s p -l packages -d "list of pkgs to install"
|
||||
complete -f -c apt-zip-inst -s f -l fix-broken -d "fix broken option"
|
||||
complete -c apt-zip-inst -l skip-mount -d "specify a non-mountpoint dir"
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
#apt-zip-list
|
||||
complete -c apt-zip-list -s h -l help -d "apt-zip-list command help"
|
||||
complete -f -c apt-zip-list -s V -l version -d "show version"
|
||||
complete -c apt-zip-list -s m -l medium -d "removable medium"
|
||||
complete -f -c apt-zip-list -s a -l aptgetaction -a "dselect-upgrade upgrade dist-upgrade" -d "select an action"
|
||||
complete -c apt-zip-list -s p -l packages -d "list of pkgs to install"
|
||||
complete -f -c apt-zip-list -s f -l fix-broken -d "fix broken option"
|
||||
complete -c apt-zip-list -l skip-mount -d "specify a non-mountpoint dir"
|
||||
complete -c apt-zip-list -s M -l method -d "select a method"
|
||||
complete -c apt-zip-list -s o -l options -a "tar restart" -d "specify options"
|
||||
complete -c apt-zip-list -s A -l accept -a "http ftp" -d "accept protocols"
|
||||
complete -c apt-zip-list -s R -l reject -a "http ftp" -d "reject protocols"
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
#completion for arp
|
||||
complete -c arp -s v -l verbose -d "verbose mode"
|
||||
complete -c arp -s n -l numeric -d "numerical address"
|
||||
complete -x -c arp -s H -l tw-type -a "ether arcnet pronet ax25 netrom" -d "class of hw type"
|
||||
complete -c arp -s a -l display -x -a "(__fish_print_hostnames)" -d "show arp entries"
|
||||
complete -x -c arp -s d -l delete -a "(__fish_print_hostnames)" -d "remove an entry for hostname"
|
||||
complete -c arp -s D -l use-device -d "use hardware address"
|
||||
complete -x -c arp -s i -l device -a "(__fish_print_interfaces)" -d "select interface"
|
||||
complete -x -c arp -s s -l set -d "Manually create ARP address" -a "(__fish_print_hostnames)"
|
||||
complete -f -c arp -s f -l file -d "taken addr from filename, default /etc/ethers"
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
#at
|
||||
complete -f -c at -s V -d "print version"
|
||||
complete -f -c at -s q -d "use specified queue"
|
||||
complete -f -c at -s m -d "send mail to user"
|
||||
complete -c at -s f -x -a "(__fish_complete_suffix (commandline -ct) '' 'At job')" -d "Read job from file"
|
||||
complete -f -c at -s l -d "alias for atq"
|
||||
complete -f -c at -s d -d "alias for atrm"
|
||||
complete -f -c at -s v -d "show the time"
|
||||
complete -f -c at -s c -d "cat the jobs listed"
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
#atd
|
||||
complete -f -c atd -s l -d "limiting load factor"
|
||||
complete -f -c atd -s b -d "minimum interval in seconds"
|
||||
complete -f -c atd -s d -d "Debug mode"
|
||||
complete -f -c atd -s s -d "process at queue only once"
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user