mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-09 08:51:14 -03:00
Compare commits
1069 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ab162c6c25 | ||
|
|
5ed912bebc | ||
|
|
ec43090c16 | ||
|
|
80759ee03f | ||
|
|
816f473ac9 | ||
|
|
d59d3b4463 | ||
|
|
8784b78d84 | ||
|
|
5005c67d76 | ||
|
|
63732a99e9 | ||
|
|
04b7da336d | ||
|
|
5f69f2bb0c | ||
|
|
fb62a35921 | ||
|
|
08787c7674 | ||
|
|
79de45eed5 | ||
|
|
9bc9e1c08d | ||
|
|
3acdeb87a4 | ||
|
|
9959e53985 | ||
|
|
4edb71325f | ||
|
|
310768e8d2 | ||
|
|
dc90e460fe | ||
|
|
d20c14b4bb | ||
|
|
981f5782d8 | ||
|
|
c2021b6225 | ||
|
|
9de4dbdd03 | ||
|
|
1a84a44cc2 | ||
|
|
80a9fc2fce | ||
|
|
8aac7e82c0 | ||
|
|
49e300d0ca | ||
|
|
136e99de62 | ||
|
|
c41986a63f | ||
|
|
bedf8ea55e | ||
|
|
d8f1c0abcd | ||
|
|
13a85ee3f1 | ||
|
|
fab18bae80 | ||
|
|
6e24b26e2c | ||
|
|
7fb44d4d5f | ||
|
|
44f85d04f9 | ||
|
|
bd71f0a096 | ||
|
|
f7b656017f | ||
|
|
7a8ca73376 | ||
|
|
9eb1826961 | ||
|
|
728a60bd67 | ||
|
|
0099c3c420 | ||
|
|
885d16fcd6 | ||
|
|
c4a8f4c890 | ||
|
|
c098cb5c87 | ||
|
|
63643ff17f | ||
|
|
f83575f084 | ||
|
|
a6c00ca0d2 | ||
|
|
c5eaefc8b5 | ||
|
|
f16bb285be | ||
|
|
09c348bef2 | ||
|
|
561ec7d5f5 | ||
|
|
e98a604a21 | ||
|
|
3341fc888c | ||
|
|
1faf7df371 | ||
|
|
3a128e1484 | ||
|
|
cdc52f7bde | ||
|
|
e0899addcb | ||
|
|
c627509e59 | ||
|
|
4502fc74c3 | ||
|
|
3b0ed061cd | ||
|
|
dfa73c7cc1 | ||
|
|
12be24ef47 | ||
|
|
c684b7c7c7 | ||
|
|
4f22082a5c | ||
|
|
e3c1363831 | ||
|
|
6d413c8dc3 | ||
|
|
32a49e45c8 | ||
|
|
b37d49a708 | ||
|
|
86b7023536 | ||
|
|
287ab597ca | ||
|
|
c313f21066 | ||
|
|
e2dca4273a | ||
|
|
5a7a8003a0 | ||
|
|
b83a7cb659 | ||
|
|
da81328d75 | ||
|
|
5ae4306418 | ||
|
|
ed36f30eae | ||
|
|
7b8ebdadd6 | ||
|
|
bb4e166b37 | ||
|
|
9dc1a7d5e9 | ||
|
|
79f59e2a2d | ||
|
|
8285242ff6 | ||
|
|
c0a54955e7 | ||
|
|
b2d4e85f17 | ||
|
|
a5868d67f5 | ||
|
|
45f1263112 | ||
|
|
4683f4c989 | ||
|
|
ae16397e1c | ||
|
|
2d05b1c1b4 | ||
|
|
ea998b03f2 | ||
|
|
52b2525b0e | ||
|
|
ff96668151 | ||
|
|
d7576a409a | ||
|
|
f6815629fc | ||
|
|
8b3bcd2c4c | ||
|
|
c7bc31fe50 | ||
|
|
bab168f1d1 | ||
|
|
2ab04f4043 | ||
|
|
b32bbb24b9 | ||
|
|
f86f80fcd6 | ||
|
|
d563e428e8 | ||
|
|
5473711a20 | ||
|
|
91009ac9aa | ||
|
|
49bff53370 | ||
|
|
afcab9f1b3 | ||
|
|
841fdf3a04 | ||
|
|
92446bda80 | ||
|
|
a620a1e5ed | ||
|
|
5a8df6cc85 | ||
|
|
b70b966f90 | ||
|
|
97f7c2093b | ||
|
|
8ece4f3ddc | ||
|
|
17a13a8eb7 | ||
|
|
afaf156a42 | ||
|
|
c4f3b5e9ef | ||
|
|
f5916358e5 | ||
|
|
e3e1b34fec | ||
|
|
18bb4ca826 | ||
|
|
007e4662e3 | ||
|
|
e11677ef66 | ||
|
|
194167da32 | ||
|
|
dafeac5c40 | ||
|
|
effea85984 | ||
|
|
0b34836c79 | ||
|
|
f85ce201ee | ||
|
|
80ac4ddc2b | ||
|
|
9a0f712e29 | ||
|
|
286e110fb1 | ||
|
|
988a7fddf3 | ||
|
|
a321505351 | ||
|
|
a074cd62bc | ||
|
|
7a8b468165 | ||
|
|
770fa771b6 | ||
|
|
414fa591b8 | ||
|
|
941b472b37 | ||
|
|
179f575593 | ||
|
|
6400b60bdd | ||
|
|
0e03e872be | ||
|
|
e51322ac81 | ||
|
|
1e739166b3 | ||
|
|
560e53fd5f | ||
|
|
184d58cd36 | ||
|
|
bcf3024cf0 | ||
|
|
9611a3b205 | ||
|
|
8ace1739f5 | ||
|
|
302516a747 | ||
|
|
ad5a6e0552 | ||
|
|
873fd83307 | ||
|
|
d1078f8582 | ||
|
|
0ea668b260 | ||
|
|
91c745e4b5 | ||
|
|
7d73349889 | ||
|
|
53a2c017fe | ||
|
|
80ff583400 | ||
|
|
0c7f74c78d | ||
|
|
13b1ea3f50 | ||
|
|
44ff9956b9 | ||
|
|
add1fa9208 | ||
|
|
8b2059c628 | ||
|
|
15724d0798 | ||
|
|
2839f5e567 | ||
|
|
67c820cee8 | ||
|
|
bce4c78d49 | ||
|
|
421ebcc2d7 | ||
|
|
92df4a6d91 | ||
|
|
22fe8e6a17 | ||
|
|
d0f1870735 | ||
|
|
b71f5d09b0 | ||
|
|
eb00ad77fb | ||
|
|
be886bc6df | ||
|
|
7a5823fd60 | ||
|
|
81d61c467b | ||
|
|
e91e3b6593 | ||
|
|
1db67a5105 | ||
|
|
810faacd72 | ||
|
|
6be3807cae | ||
|
|
4399503f4e | ||
|
|
06b5fdc6e8 | ||
|
|
4037219dc0 | ||
|
|
1612ec50fb | ||
|
|
3bb0163598 | ||
|
|
4d19aa7698 | ||
|
|
f72de8e141 | ||
|
|
02eb856e44 | ||
|
|
c550f4eb21 | ||
|
|
00c25436d7 | ||
|
|
6107d63995 | ||
|
|
eafa0a7169 | ||
|
|
45d2b89780 | ||
|
|
72d73b7fdd | ||
|
|
227a5da02c | ||
|
|
e356bdaa8e | ||
|
|
697d524687 | ||
|
|
73f0d0bb48 | ||
|
|
200ebe43dc | ||
|
|
ff2d354ef8 | ||
|
|
3bef568955 | ||
|
|
9a7be6db08 | ||
|
|
40e2025327 | ||
|
|
a819c863eb | ||
|
|
827c88e4a1 | ||
|
|
e2b7a078f4 | ||
|
|
6de0c4103b | ||
|
|
b6e8171f01 | ||
|
|
b1439075c6 | ||
|
|
7df536023b | ||
|
|
f5f15f9de2 | ||
|
|
0e0a61119f | ||
|
|
6f058c687d | ||
|
|
53ea5d60b7 | ||
|
|
9525f429c6 | ||
|
|
548e379d6a | ||
|
|
202d29de88 | ||
|
|
23152ae8a6 | ||
|
|
7310596dab | ||
|
|
4afe49d7c6 | ||
|
|
d7c3d2acbf | ||
|
|
f771fce892 | ||
|
|
6522000bf0 | ||
|
|
285abcc9bc | ||
|
|
b15e8123ca | ||
|
|
1c86395ed8 | ||
|
|
3c8d2a1126 | ||
|
|
ed8cd08984 | ||
|
|
69537430ea | ||
|
|
0a603a56c6 | ||
|
|
046dd82995 | ||
|
|
97c3e231f4 | ||
|
|
76b782d576 | ||
|
|
ed5c1db392 | ||
|
|
37f5db2bf9 | ||
|
|
8a97bffd02 | ||
|
|
2fd48bce11 | ||
|
|
d1a3e6abf5 | ||
|
|
1a29979bbd | ||
|
|
69814e5066 | ||
|
|
4dbac8f941 | ||
|
|
303473f20c | ||
|
|
480a29594e | ||
|
|
dfe3dc1429 | ||
|
|
2ea00ce444 | ||
|
|
ac13bdeaa7 | ||
|
|
22cb7dd2d7 | ||
|
|
20698cc813 | ||
|
|
1ebf571da5 | ||
|
|
7c822cbf30 | ||
|
|
90302d9232 | ||
|
|
bee6805ff9 | ||
|
|
65035c4dc7 | ||
|
|
2b0d64184a | ||
|
|
51d7159ba7 | ||
|
|
0a4819be27 | ||
|
|
72ad4e0d3b | ||
|
|
21de293a44 | ||
|
|
8b395d05ef | ||
|
|
8392902cec | ||
|
|
a5abdd2792 | ||
|
|
e784683b8a | ||
|
|
7fadf6c083 | ||
|
|
7ff76476ed | ||
|
|
cd9102214b | ||
|
|
8da54a1955 | ||
|
|
6899e4e734 | ||
|
|
486e0dbe84 | ||
|
|
441c109afb | ||
|
|
4b0810d7e9 | ||
|
|
51d58a6a7c | ||
|
|
7a884e11a6 | ||
|
|
c4acfdd87c | ||
|
|
41f8007a03 | ||
|
|
8207030b21 | ||
|
|
a2c70f495e | ||
|
|
b11f366bb0 | ||
|
|
0e1a3c7c4a | ||
|
|
d3a75a354a | ||
|
|
afc49dded2 | ||
|
|
49b232df84 | ||
|
|
248d11c462 | ||
|
|
6b1570b745 | ||
|
|
dc3634dc94 | ||
|
|
696b4df1c6 | ||
|
|
65f4d6e866 | ||
|
|
8833e8f4ea | ||
|
|
f29026b767 | ||
|
|
7ecf7c1fac | ||
|
|
4a2fa5ea34 | ||
|
|
03f6656af6 | ||
|
|
8e6dbe245c | ||
|
|
daf171aa86 | ||
|
|
d1bbb89389 | ||
|
|
bd0c1573df | ||
|
|
2700a9b697 | ||
|
|
474f6e90ff | ||
|
|
7cbc11f1c3 | ||
|
|
09f9d43be3 | ||
|
|
109e7455a8 | ||
|
|
9b95332aa9 | ||
|
|
cccd13db92 | ||
|
|
2c8a2c9f61 | ||
|
|
f05e1f6e48 | ||
|
|
f439c4a484 | ||
|
|
2fba53b113 | ||
|
|
8a2846ed44 | ||
|
|
91b63e4989 | ||
|
|
89d876d0f7 | ||
|
|
e79fdcb194 | ||
|
|
60f0533821 | ||
|
|
0768cf7e53 | ||
|
|
bdd83d338c | ||
|
|
db369a9ad7 | ||
|
|
aa895c6740 | ||
|
|
8e06805f2d | ||
|
|
00360d8fbc | ||
|
|
3b365d9f8d | ||
|
|
3835000e9d | ||
|
|
9bbe19bfb8 | ||
|
|
787e99d901 | ||
|
|
713748c782 | ||
|
|
c9eb74fa4b | ||
|
|
b2d940c25a | ||
|
|
2a7bc8c04b | ||
|
|
013d3dbb89 | ||
|
|
0aff94dd4c | ||
|
|
431850b4ec | ||
|
|
e280d10033 | ||
|
|
8c4708b51e | ||
|
|
4ba9ac28bb | ||
|
|
4664d65af7 | ||
|
|
1b7157a03f | ||
|
|
e1dd17a7dd | ||
|
|
5c8d9bd13c | ||
|
|
1c9a173b3d | ||
|
|
a0c40fcf8d | ||
|
|
f36811b7be | ||
|
|
40ed01f6f2 | ||
|
|
b2e2743195 | ||
|
|
1dc033f71c | ||
|
|
ba4166d17d | ||
|
|
46c6f7880b | ||
|
|
bef7fff383 | ||
|
|
0811613fe9 | ||
|
|
a09abea737 | ||
|
|
fd4e5e6777 | ||
|
|
57b3965518 | ||
|
|
3e843f8219 | ||
|
|
2343ce5a0c | ||
|
|
0122e35cb6 | ||
|
|
c96382152c | ||
|
|
af0bd61fb5 | ||
|
|
4a87c9895d | ||
|
|
036cc4e0fa | ||
|
|
9e304fa734 | ||
|
|
6d9631d0d0 | ||
|
|
bb04df2ac9 | ||
|
|
746a602515 | ||
|
|
a41fd8f759 | ||
|
|
ba9fbc67da | ||
|
|
ac40a3bcd0 | ||
|
|
942dcd7d54 | ||
|
|
9830bf985a | ||
|
|
7bb070d817 | ||
|
|
d56ab1d365 | ||
|
|
38175cdd30 | ||
|
|
436b1e10c6 | ||
|
|
e59cb1da5d | ||
|
|
e42198b7c8 | ||
|
|
2076944268 | ||
|
|
407c96e943 | ||
|
|
bf333f2a84 | ||
|
|
3ddd5e5981 | ||
|
|
b016438c08 | ||
|
|
7268a4a4e0 | ||
|
|
51c6c5ea49 | ||
|
|
5688035680 | ||
|
|
43b6b703ff | ||
|
|
e007a5c203 | ||
|
|
f836bd41c0 | ||
|
|
c9e98c2eef | ||
|
|
e94803152c | ||
|
|
07ff8a6c03 | ||
|
|
9f10dd377e | ||
|
|
6e0e7e0996 | ||
|
|
907b2f8462 | ||
|
|
d2869d5140 | ||
|
|
587e91d0c1 | ||
|
|
aad3249b79 | ||
|
|
081ab955af | ||
|
|
9a9d84c58a | ||
|
|
94d1322fc1 | ||
|
|
eed8b61a9e | ||
|
|
40558c2eb9 | ||
|
|
d677b468db | ||
|
|
4e38d3bc8c | ||
|
|
36ae253a29 | ||
|
|
f673b06dd2 | ||
|
|
e9e0643817 | ||
|
|
358f412abb | ||
|
|
a983798295 | ||
|
|
52a0149e4f | ||
|
|
8fdc46a105 | ||
|
|
63b02e308d | ||
|
|
7c97095bca | ||
|
|
b62beaf47d | ||
|
|
b2b1ec27d8 | ||
|
|
6aa682755d | ||
|
|
2bc49b3291 | ||
|
|
cea3dfd0cb | ||
|
|
d7d2c82a82 | ||
|
|
58aa1e75c1 | ||
|
|
0361423469 | ||
|
|
9aee2b7c9c | ||
|
|
2c95e087b2 | ||
|
|
5d5ee87a59 | ||
|
|
c60b62de73 | ||
|
|
2e5821c17d | ||
|
|
f46145a6b3 | ||
|
|
c61f6ceea6 | ||
|
|
d32751df13 | ||
|
|
038dcca143 | ||
|
|
d79e8c7f62 | ||
|
|
af8cb6fe87 | ||
|
|
5855f78010 | ||
|
|
f7118e769f | ||
|
|
93ae00e8e5 | ||
|
|
d7eb084b9d | ||
|
|
6e1548b821 | ||
|
|
5381c6cf93 | ||
|
|
20e5d298a0 | ||
|
|
39e9974e71 | ||
|
|
d2bd3e4919 | ||
|
|
04b142208d | ||
|
|
cf35a8e3a5 | ||
|
|
e7e3e8ee74 | ||
|
|
6fd69bdda8 | ||
|
|
a85f4cc1c4 | ||
|
|
07af5f4832 | ||
|
|
446272eee6 | ||
|
|
48ca253097 | ||
|
|
da2a757dff | ||
|
|
6fada015b6 | ||
|
|
a1a2773cbf | ||
|
|
67f216fa55 | ||
|
|
8986e05b94 | ||
|
|
7c016c56e3 | ||
|
|
0602044723 | ||
|
|
4ffd2afccd | ||
|
|
ec58ffa641 | ||
|
|
2c44ecb4a3 | ||
|
|
2eebb6e7ed | ||
|
|
1a3ab8a189 | ||
|
|
4722ddc373 | ||
|
|
25365dbc54 | ||
|
|
6a5f11879b | ||
|
|
b028e41f7f | ||
|
|
86593cd6a2 | ||
|
|
6cae5c8b0a | ||
|
|
29cd62ab6e | ||
|
|
4c7e06e752 | ||
|
|
433169dca4 | ||
|
|
d46dade284 | ||
|
|
79b466441b | ||
|
|
9f14d50974 | ||
|
|
990803009e | ||
|
|
6dfd629fc5 | ||
|
|
d97f8f3fde | ||
|
|
95ca3d1c69 | ||
|
|
c8b04f70cf | ||
|
|
bffff77d17 | ||
|
|
6bdb0cde8b | ||
|
|
42a260f1e6 | ||
|
|
148cb68700 | ||
|
|
18c185c256 | ||
|
|
b5b49e7a4d | ||
|
|
28ea5ce732 | ||
|
|
eccba7626d | ||
|
|
79d3207d51 | ||
|
|
d6bf879675 | ||
|
|
051f557e8f | ||
|
|
17171c3277 | ||
|
|
18a59291ed | ||
|
|
29e86254d0 | ||
|
|
b746a803a9 | ||
|
|
07e14ed7a8 | ||
|
|
df5cc6f858 | ||
|
|
409a407ca0 | ||
|
|
1c2cbb00bc | ||
|
|
bbf2a3836f | ||
|
|
1aa1ab540e | ||
|
|
27c9eb8758 | ||
|
|
e6b1035ddc | ||
|
|
9f6aba38d6 | ||
|
|
b52fe0feb6 | ||
|
|
db459f869a | ||
|
|
763a6b8351 | ||
|
|
4a06821d99 | ||
|
|
22f3dcfd35 | ||
|
|
dbb66e1895 | ||
|
|
5a7a264b96 | ||
|
|
3d601bd751 | ||
|
|
c9deea2237 | ||
|
|
32e54fd719 | ||
|
|
9ebdc16be6 | ||
|
|
92ecc01baa | ||
|
|
ff1c5e058f | ||
|
|
3d192a8e93 | ||
|
|
f5c6306bde | ||
|
|
524e0aa174 | ||
|
|
94abb30f94 | ||
|
|
af8e053896 | ||
|
|
633e2f498f | ||
|
|
4932538c74 | ||
|
|
786144ba86 | ||
|
|
e3dd94f272 | ||
|
|
b110a0ae21 | ||
|
|
48d9c38d1e | ||
|
|
51f8272ebd | ||
|
|
77f35c1b41 | ||
|
|
06668bfacb | ||
|
|
df59b8498f | ||
|
|
92fde30c0c | ||
|
|
d690a15b29 | ||
|
|
445f6539cf | ||
|
|
13a7269378 | ||
|
|
fd2644ce49 | ||
|
|
508de57459 | ||
|
|
de2405b35a | ||
|
|
a7f977836a | ||
|
|
f59e4a88c6 | ||
|
|
c755bd0358 | ||
|
|
536523ffd7 | ||
|
|
ca82fc2f03 | ||
|
|
d1411c42d6 | ||
|
|
9d770af5f4 | ||
|
|
d1ff6a323a | ||
|
|
112ea1759a | ||
|
|
76bafbef2a | ||
|
|
1947ec88f1 | ||
|
|
d0956f1e43 | ||
|
|
6996c7718e | ||
|
|
45d56d8e05 | ||
|
|
53295d38b7 | ||
|
|
bd9c843fd1 | ||
|
|
f812b9b26c | ||
|
|
52851a3ba4 | ||
|
|
b1bf115fa2 | ||
|
|
0f25ef365d | ||
|
|
55ea4b6fc0 | ||
|
|
5ef8cccf21 | ||
|
|
5613d96001 | ||
|
|
5d9ba8c1a2 | ||
|
|
0de232bf54 | ||
|
|
db5b887824 | ||
|
|
634bdb8b3b | ||
|
|
9c579a37bb | ||
|
|
1502acd83e | ||
|
|
ef3430f669 | ||
|
|
01af64cf1f | ||
|
|
349f52a1a5 | ||
|
|
850aa1963f | ||
|
|
185d0c3c1c | ||
|
|
3656443b1f | ||
|
|
6748b9699f | ||
|
|
dc91d7aec4 | ||
|
|
13a51ba4c2 | ||
|
|
749dad1309 | ||
|
|
7a07d7c188 | ||
|
|
53c95abfb2 | ||
|
|
7fd2ae4ffd | ||
|
|
717ac3f7fe | ||
|
|
50fa7234ea | ||
|
|
80b4055eab | ||
|
|
94b7c8d5e6 | ||
|
|
580ec26885 | ||
|
|
6ba5d80a20 | ||
|
|
d58b9de63b | ||
|
|
99a93b5add | ||
|
|
de50539c02 | ||
|
|
04cf08b93b | ||
|
|
2c5b52eb6c | ||
|
|
dd8150d98d | ||
|
|
99662d7711 | ||
|
|
5f3ad87a98 | ||
|
|
83d05f9170 | ||
|
|
0d56818664 | ||
|
|
5b0cd5a911 | ||
|
|
102b99a17b | ||
|
|
6222d00ffc | ||
|
|
73370f5f39 | ||
|
|
883ce6e440 | ||
|
|
f320f5f710 | ||
|
|
32b531667a | ||
|
|
c47dae77a4 | ||
|
|
53160d134e | ||
|
|
619defd748 | ||
|
|
40db2b3c2a | ||
|
|
b05ccee0f0 | ||
|
|
d722fa59ca | ||
|
|
60065614bd | ||
|
|
05b39a9bdb | ||
|
|
91ab644173 | ||
|
|
083fcd6491 | ||
|
|
7e9e7d77d1 | ||
|
|
66ee644130 | ||
|
|
c20b8982bc | ||
|
|
15bb8f712d | ||
|
|
d48e9ef8b1 | ||
|
|
acd28b5dc4 | ||
|
|
1fe4863039 | ||
|
|
d347da963b | ||
|
|
930bb9c6d1 | ||
|
|
676c3ed505 | ||
|
|
2d3588fa51 | ||
|
|
4835945c09 | ||
|
|
82bff9f407 | ||
|
|
3b6d8756ea | ||
|
|
d1bb30afae | ||
|
|
7a1d64637d | ||
|
|
5f85d27671 | ||
|
|
5d828b5fcf | ||
|
|
c2f6c6c1d2 | ||
|
|
7726cffdab | ||
|
|
3570013496 | ||
|
|
2401a163fe | ||
|
|
e8d802c5e1 | ||
|
|
dca4167de6 | ||
|
|
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 |
@@ -93,7 +93,7 @@ DISABLE_INDEX = YES
|
||||
ENUM_VALUES_PER_LINE = 4
|
||||
GENERATE_TREEVIEW = NO
|
||||
TREEVIEW_WIDTH = 250
|
||||
GENERATE_LATEX = YES
|
||||
GENERATE_LATEX = NO
|
||||
LATEX_OUTPUT = latex
|
||||
LATEX_CMD_NAME = latex
|
||||
MAKEINDEX_CMD_NAME = makeindex
|
||||
|
||||
59
INSTALL
59
INSTALL
@@ -2,44 +2,52 @@
|
||||
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 is developed using GCC, with the goal of using only C89 language
|
||||
features. Fish does, however use the *wprintf family of functions,
|
||||
which are new to the C99 standrard. It is not unlikely that any given
|
||||
release contains a few GCC:isms, but ICC 9.0.030 has been found to
|
||||
produce working binaries. GCC 2.95.* won't compile fish, but GCC 3.2.3
|
||||
is known to work. Patches to fix any remaining GNU:isms 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
|
||||
========================
|
||||
|
||||
% ./configure
|
||||
% make #Compile fish
|
||||
% make install #Install fish
|
||||
% echo /usr/local/bin/fish >>/etc/shells #Add fish to list of shells
|
||||
Always begin by uninstalling any previous fish versions. This is done
|
||||
by running the command 'make uninstall' in the source directory of
|
||||
your previous fish installation.
|
||||
|
||||
If you wish to use fish as your default shell, use the following
|
||||
command:
|
||||
Next, if you have downloaded a fresh copy of the darcs repository of
|
||||
fish, you need to run the 'autoconf' command.
|
||||
|
||||
Then, use 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
|
||||
|
||||
Finally, if you wish to use fish as your default shell, use the
|
||||
following command:
|
||||
|
||||
% chsh -s /usr/local/bin/fish
|
||||
|
||||
@@ -49,6 +57,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 to generate the configure script.
|
||||
|
||||
To install fish in your own home directory (typically as non-root),
|
||||
type:
|
||||
|
||||
@@ -57,6 +68,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.
|
||||
|
||||
1007
Makefile.in
1007
Makefile.in
File diff suppressed because it is too large
Load Diff
86
builtin.h
86
builtin.h
@@ -20,28 +20,71 @@ enum
|
||||
/**
|
||||
Error message on missing argument
|
||||
*/
|
||||
#define BUILTIN_ERR_MISSING L": Expected argument"
|
||||
#define BUILTIN_ERR_MISSING _( L"%ls: Expected argument\n" )
|
||||
|
||||
/**
|
||||
Error message on invalid combination of options
|
||||
*/
|
||||
#define BUILTIN_ERR_COMBO L": 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": Variable can only be one of universal, global and local"
|
||||
#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": Variable can't be both exported and unexported"
|
||||
#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": Unknown option"
|
||||
#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" )
|
||||
|
||||
/**
|
||||
Error message when second argument to for isn't 'in'
|
||||
*/
|
||||
#define BUILTIN_FOR_ERR_IN _( L"%ls: Second argument must be 'in'\n" )
|
||||
|
||||
/**
|
||||
Error message for insufficient number of arguments
|
||||
*/
|
||||
#define BUILTIN_FOR_ERR_COUNT _( L"%ls: Expected at least two arguments, got %d\n")
|
||||
|
||||
#define BUILTIN_FOR_ERR_NAME _( L"%ls: '%ls' is not a valid variable name\n" )
|
||||
|
||||
/**
|
||||
Error message when too many arguments are supplied to a builtin
|
||||
*/
|
||||
#define BUILTIN_ERR_TOO_MANY_ARGUMENTS _( L"%ls: Too many arguments\n" )
|
||||
|
||||
/**
|
||||
Error message when block types mismatch in the end builtin, e.g. 'begin; end for'
|
||||
*/
|
||||
#define BUILTIN_END_BLOCK_MISMATCH _( L"%ls: Block mismatch: '%ls' vs. '%ls'\n" )
|
||||
|
||||
/**
|
||||
Error message for unknown block type in the end builtin, e.g. 'begin; end beggin'
|
||||
*/
|
||||
#define BUILTIN_END_BLOCK_UNKNOWN _( L"%ls: Unknown block type '%ls'\n" )
|
||||
|
||||
#define BUILTIN_ERR_NOT_NUMBER _( L"%ls: Argument '%ls' is not a number\n" )
|
||||
/**
|
||||
Stringbuffer used to represent standard output
|
||||
*/
|
||||
@@ -111,37 +154,22 @@ void builtin_pop_io();
|
||||
*/
|
||||
const wchar_t *builtin_get_desc( const wchar_t *b );
|
||||
|
||||
/**
|
||||
Counts the number of non null pointers in the specified array
|
||||
*/
|
||||
int builtin_count_args( wchar_t **argv );
|
||||
|
||||
/**
|
||||
Print help for the specified builtin. If \c b is sb_err, also print the line information
|
||||
Slightly kludgy function used with 'complete -C' in order to make
|
||||
the commandline builtin operate on the string to complete instead
|
||||
of operating on whatever is to be completed.
|
||||
*/
|
||||
void builtin_print_help( wchar_t *cmd, string_buffer_t *b );
|
||||
const wchar_t *builtin_complete_get_temporary_buffer();
|
||||
|
||||
|
||||
/**
|
||||
The set builtin, used for setting variables. Defined in builtin_set.c.
|
||||
*/
|
||||
int builtin_set(wchar_t **argv);
|
||||
Return the help text for the specified builtin command. Use
|
||||
non-wide characters since wide characters have some issues with
|
||||
string formating escape sequences sometimes.
|
||||
|
||||
/**
|
||||
The commandline builtin, used for setting and getting the contents of the commandline. Defined in builtin_commandline.c.
|
||||
\param cmd The command for which to obtain help text
|
||||
*/
|
||||
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);
|
||||
|
||||
/**
|
||||
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
|
||||
commands.
|
||||
*/
|
||||
void builtin_wperror( const wchar_t *s);
|
||||
char *builtin_help_get( const wchar_t *cmd );
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
Functions used for implementing the commandline builtin.
|
||||
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
@@ -11,8 +13,10 @@ Functions used for implementing the commandline builtin.
|
||||
#include <termios.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "fallback.h"
|
||||
#include "util.h"
|
||||
|
||||
#include "wutil.h"
|
||||
#include "builtin.h"
|
||||
#include "common.h"
|
||||
#include "wgetopt.h"
|
||||
@@ -23,15 +27,17 @@ Functions used for implementing the commandline builtin.
|
||||
#include "input_common.h"
|
||||
#include "input.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,12 +46,31 @@ 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 */
|
||||
}
|
||||
;
|
||||
|
||||
static wchar_t *current_buffer=0;
|
||||
static int current_cursor_pos = -1;
|
||||
|
||||
/**
|
||||
Returns the current commandline buffer.
|
||||
*/
|
||||
static wchar_t *get_buffer()
|
||||
{
|
||||
return current_buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
Returns the position of the cursor
|
||||
*/
|
||||
static int get_cursor_pos()
|
||||
{
|
||||
return current_cursor_pos;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Replace/append/insert the selection with/at/after the specified string.
|
||||
@@ -55,21 +80,17 @@ enum
|
||||
\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( wchar_t *begin,
|
||||
wchar_t *end,
|
||||
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)
|
||||
@@ -90,7 +111,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 );
|
||||
@@ -111,8 +132,8 @@ static void replace_part( wchar_t *begin,
|
||||
\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( wchar_t *begin,
|
||||
wchar_t *end,
|
||||
static void write_part( const wchar_t *begin,
|
||||
const wchar_t *end,
|
||||
int cut_at_cursor,
|
||||
int tokenize )
|
||||
{
|
||||
@@ -121,7 +142,7 @@ static void write_part( wchar_t *begin,
|
||||
wchar_t *buff;
|
||||
int pos;
|
||||
|
||||
pos = reader_get_cursor_pos()-(begin-reader_get_buffer());
|
||||
pos = get_cursor_pos()-(begin-get_buffer());
|
||||
|
||||
if( tokenize )
|
||||
{
|
||||
@@ -173,7 +194,7 @@ static void write_part( wchar_t *begin,
|
||||
The commandline builtin. It is used for specifying a new value for
|
||||
the commandline.
|
||||
*/
|
||||
int builtin_commandline( wchar_t **argv )
|
||||
static int builtin_commandline( wchar_t **argv )
|
||||
{
|
||||
|
||||
int buffer_part=0;
|
||||
@@ -185,8 +206,22 @@ int builtin_commandline( wchar_t **argv )
|
||||
int function_mode = 0;
|
||||
|
||||
int tokenize = 0;
|
||||
|
||||
int cursor_mode = 0;
|
||||
wchar_t *begin, *end;
|
||||
|
||||
if( !reader_get_buffer() )
|
||||
current_buffer = (wchar_t *)builtin_complete_get_temporary_buffer();
|
||||
if( current_buffer )
|
||||
{
|
||||
current_cursor_pos = wcslen( current_buffer );
|
||||
}
|
||||
else
|
||||
{
|
||||
current_buffer = reader_get_buffer();
|
||||
current_cursor_pos = reader_get_cursor_pos();
|
||||
}
|
||||
|
||||
if( !get_buffer() )
|
||||
{
|
||||
sb_append2( sb_err,
|
||||
argv[0],
|
||||
@@ -243,6 +278,18 @@ int builtin_commandline( wchar_t **argv )
|
||||
L"tokenize", no_argument, 0, 'o'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"help", no_argument, 0, 'h'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"input", required_argument, 0, 'I'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"cursor", no_argument, 0, 'C'
|
||||
}
|
||||
,
|
||||
{
|
||||
0, 0, 0, 0
|
||||
}
|
||||
@@ -253,7 +300,7 @@ int builtin_commandline( wchar_t **argv )
|
||||
|
||||
int opt = wgetopt_long( argc,
|
||||
argv,
|
||||
L"aijpctwfo",
|
||||
L"aijpctwforhI:C",
|
||||
long_options,
|
||||
&opt_index );
|
||||
if( opt == -1 )
|
||||
@@ -264,13 +311,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;
|
||||
@@ -282,7 +326,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;
|
||||
@@ -307,6 +355,19 @@ int builtin_commandline( wchar_t **argv )
|
||||
tokenize=1;
|
||||
break;
|
||||
|
||||
case 'I':
|
||||
current_buffer = woptarg;
|
||||
current_cursor_pos = wcslen( woptarg );
|
||||
break;
|
||||
|
||||
case 'C':
|
||||
cursor_mode = 1;
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
builtin_print_help( argv[0], sb_out );
|
||||
return 0;
|
||||
|
||||
case L'?':
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
return 1;
|
||||
@@ -320,28 +381,23 @@ int builtin_commandline( wchar_t **argv )
|
||||
/*
|
||||
Check for invalid switch combinations
|
||||
*/
|
||||
if( buffer_part || cut_at_cursor || append_mode || tokenize )
|
||||
if( buffer_part || cut_at_cursor || append_mode || tokenize || cursor_mode )
|
||||
{
|
||||
sb_append2(sb_err,
|
||||
argv[0],
|
||||
BUILTIN_ERR_COMBO,
|
||||
L"\n",
|
||||
parser_current_line(),
|
||||
L"\n",
|
||||
(void *)0);
|
||||
sb_printf(sb_err,
|
||||
BUILTIN_ERR_COMBO,
|
||||
argv[0] );
|
||||
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
if( argc == woptind )
|
||||
{
|
||||
sb_append2( sb_err,
|
||||
argv[0],
|
||||
BUILTIN_ERR_MISSING,
|
||||
L"\n",
|
||||
parser_current_line(),
|
||||
L"\n",
|
||||
(void *)0 );
|
||||
sb_printf( sb_err,
|
||||
BUILTIN_ERR_MISSING,
|
||||
argv[0] );
|
||||
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
return 1;
|
||||
}
|
||||
@@ -350,7 +406,6 @@ int builtin_commandline( wchar_t **argv )
|
||||
wint_t c = input_get_code( argv[i] );
|
||||
if( c != -1 )
|
||||
{
|
||||
// fwprintf( stderr, L"Add function %ls (%d)\n", argv[i], c );
|
||||
/*
|
||||
input_unreadch inserts the specified keypress or
|
||||
readline function at the top of the stack of unused
|
||||
@@ -360,15 +415,10 @@ int builtin_commandline( wchar_t **argv )
|
||||
}
|
||||
else
|
||||
{
|
||||
// fwprintf( stderr, L"BLUR %ls %d\n", argv[i], c );
|
||||
sb_append2( sb_err,
|
||||
argv[0],
|
||||
L": Unknown readline function '",
|
||||
argv[i],
|
||||
L"'\n",
|
||||
parser_current_line(),
|
||||
L"\n",
|
||||
(void *)0 );
|
||||
sb_printf( sb_err,
|
||||
_(L"%ls: Unknown readline function '%ls'\n"),
|
||||
argv[0],
|
||||
argv[i] );
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
return 1;
|
||||
}
|
||||
@@ -380,7 +430,7 @@ int builtin_commandline( wchar_t **argv )
|
||||
/*
|
||||
Check for invalid switch combinations
|
||||
*/
|
||||
if( argc-woptind > 1 )
|
||||
if( cursor_mode && (argc-woptind > 1) )
|
||||
{
|
||||
|
||||
sb_append2( sb_err,
|
||||
@@ -391,25 +441,36 @@ int builtin_commandline( wchar_t **argv )
|
||||
return 1;
|
||||
}
|
||||
|
||||
if( (buffer_part || tokenize || cut_at_cursor) && cursor_mode )
|
||||
{
|
||||
sb_printf( sb_err,
|
||||
BUILTIN_ERR_COMBO,
|
||||
argv[0] );
|
||||
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
if( (tokenize || cut_at_cursor) && (argc-woptind) )
|
||||
{
|
||||
sb_printf( sb_err,
|
||||
BUILTIN_ERR_COMBO2,
|
||||
argv[0],
|
||||
L"--cut-at-cursor and --tokenize can not be used when setting the commandline" );
|
||||
|
||||
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 );
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -426,33 +487,73 @@ int builtin_commandline( wchar_t **argv )
|
||||
{
|
||||
buffer_part = STRING_MODE;
|
||||
}
|
||||
|
||||
if( cursor_mode )
|
||||
{
|
||||
if( argc-woptind )
|
||||
{
|
||||
wchar_t *endptr;
|
||||
int new_pos;
|
||||
errno = 0;
|
||||
|
||||
new_pos = wcstol( argv[woptind], &endptr, 10 );
|
||||
if( *endptr || errno )
|
||||
{
|
||||
sb_printf( sb_err,
|
||||
BUILTIN_ERR_NOT_NUMBER,
|
||||
argv[0],
|
||||
argv[woptind] );
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
}
|
||||
|
||||
current_buffer = reader_get_buffer();
|
||||
new_pos = maxi( 0, mini( new_pos, wcslen( current_buffer ) ) );
|
||||
reader_set_buffer( current_buffer, new_pos );
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
sb_printf( sb_out, L"%d\n", reader_get_cursor_pos() );
|
||||
return 0;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -469,7 +570,28 @@ int builtin_commandline( wchar_t **argv )
|
||||
case 1:
|
||||
{
|
||||
replace_part( begin, end, argv[woptind], append_mode );
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
string_buffer_t sb;
|
||||
int i;
|
||||
|
||||
sb_init( &sb );
|
||||
|
||||
sb_append( &sb, argv[woptind] );
|
||||
|
||||
for( i=woptind+1; i<argc; i++ )
|
||||
{
|
||||
sb_append( &sb, L"\n" );
|
||||
sb_append( &sb, argv[i] );
|
||||
}
|
||||
|
||||
replace_part( begin, end, (wchar_t *)sb.buff, append_mode );
|
||||
sb_destroy( &sb );
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
613
builtin_complete.c
Normal file
613
builtin_complete.c
Normal file
@@ -0,0 +1,613 @@
|
||||
/** \file builtin_complete.c Functions defining the complete builtin
|
||||
|
||||
Functions used for implementing the complete builtin.
|
||||
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
#include <wctype.h>
|
||||
#include <sys/types.h>
|
||||
#include <termios.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include "fallback.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"
|
||||
|
||||
|
||||
/**
|
||||
Internal storage for the builtin_get_temporary_buffer() function.
|
||||
*/
|
||||
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. This is needed since complete allows you
|
||||
to specify multiple switches on a single commandline, like 'complete
|
||||
-s a -s b -s c', but the complete_add function only accepts one
|
||||
short switch and one long switch.
|
||||
*/
|
||||
|
||||
/**
|
||||
Silly function
|
||||
*/
|
||||
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 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Silly function
|
||||
*/
|
||||
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 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
Silly function
|
||||
*/
|
||||
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 ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Silly function
|
||||
*/
|
||||
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 );
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
Silly function
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
The complete builtin. Used for specifying programmable
|
||||
tab-completions. Calls the functions in complete.c for any heavy
|
||||
lifting. Defined in builtin_complete.c
|
||||
*/
|
||||
static 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", optional_argument, 0, 'C'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"help", no_argument, 0, 'h'
|
||||
}
|
||||
,
|
||||
{
|
||||
0, 0, 0, 0
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
int opt_index = 0;
|
||||
|
||||
int opt = wgetopt_long( argc,
|
||||
argv,
|
||||
L"a:c:p:s:l:o:d:frxeun:C::h",
|
||||
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':
|
||||
case 'c':
|
||||
{
|
||||
wchar_t *a = unescape( woptarg, 1);
|
||||
if( a )
|
||||
{
|
||||
al_push( (opt=='p'?&path:&cmd), a );
|
||||
}
|
||||
else
|
||||
{
|
||||
sb_printf( sb_err, L"%ls: Invalid token '%ls'\n", argv[0], woptarg );
|
||||
res = 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 'h':
|
||||
builtin_print_help( argv[0], sb_out );
|
||||
return 0;
|
||||
|
||||
case '?':
|
||||
sb_append( sb_err,
|
||||
parser_current_line() );
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
|
||||
res = 1;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if( !res )
|
||||
{
|
||||
if( condition && wcslen( condition ) )
|
||||
{
|
||||
if( parser_test( condition, 0, 0, 0 ) )
|
||||
{
|
||||
sb_printf( sb_err,
|
||||
L"%ls: Condition '%ls' contained a syntax error\n",
|
||||
argv[0],
|
||||
condition );
|
||||
|
||||
parser_test( condition, 0, sb_err, argv[0] );
|
||||
|
||||
res = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( !res )
|
||||
{
|
||||
if( comp && wcslen( comp ) )
|
||||
{
|
||||
if( parser_test_args( comp, 0, 0 ) )
|
||||
{
|
||||
sb_printf( sb_err,
|
||||
L"%ls: Completion '%ls' contained a syntax error\n",
|
||||
argv[0],
|
||||
comp );
|
||||
|
||||
parser_test_args( comp, sb_err, argv[0] );
|
||||
|
||||
res = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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, &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, &free );
|
||||
al_foreach( &path, &free );
|
||||
|
||||
al_destroy( &cmd );
|
||||
al_destroy( &path );
|
||||
sb_destroy( &short_opt );
|
||||
al_destroy( &gnu_opt );
|
||||
al_destroy( &old_opt );
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/** \file builtin_help.h
|
||||
|
||||
Prototypes for functions for printing usage information of builtin commands. The
|
||||
corresponding .c file is automatically generated by combining the
|
||||
builtin_help.hdr file with doxygen output.
|
||||
*/
|
||||
|
||||
#ifndef FISH_BUILTIN_HELP_H
|
||||
#define FISH_BUILTIN_HELP_H
|
||||
|
||||
#include <wchar.h>
|
||||
|
||||
/**
|
||||
Return the help text for the specified builtin command. Use
|
||||
non-wide characters since wide characters have some issues with
|
||||
string formating escape sequences sometimes.
|
||||
|
||||
\param cmd The command for which to obtain help text
|
||||
*/
|
||||
char *builtin_help_get( wchar_t *cmd );
|
||||
|
||||
/**
|
||||
Initialize builtin help data
|
||||
*/
|
||||
void builtin_help_init();
|
||||
|
||||
/**
|
||||
Destory builtin help data
|
||||
*/
|
||||
void builtin_help_destroy();
|
||||
|
||||
#endif
|
||||
@@ -5,32 +5,41 @@
|
||||
various help files in the doc_src directory.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <strings.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "util.h"
|
||||
#include "common.h"
|
||||
#include "builtin_help.h"
|
||||
#include "halloc_util.h"
|
||||
|
||||
/**
|
||||
Hashtable storing the help text
|
||||
*/
|
||||
static hash_table_t tbl;
|
||||
|
||||
char *builtin_help_get( wchar_t *cmd )
|
||||
static void builtin_help_init();
|
||||
|
||||
char *builtin_help_get( const wchar_t *cmd )
|
||||
{
|
||||
builtin_help_init();
|
||||
|
||||
return (char *)hash_get( &tbl, (void *)cmd );
|
||||
}
|
||||
|
||||
void builtin_help_destroy()
|
||||
{
|
||||
hash_destroy( &tbl );
|
||||
}
|
||||
|
||||
|
||||
void builtin_help_init()
|
||||
/**
|
||||
Initialize help hash table. Don't invoke it manually,
|
||||
it is called by builtin_help_get automatically.
|
||||
*/
|
||||
static void builtin_help_init()
|
||||
{
|
||||
static int is_help_init = 0;
|
||||
if( is_help_init )
|
||||
return;
|
||||
is_help_init=1;
|
||||
halloc_register_function( global_context, (void (*)(void *))&hash_destroy, &tbl );
|
||||
hash_init( &tbl, &hash_wcs_func, &hash_wcs_cmp );
|
||||
|
||||
351
builtin_jobs.c
Normal file
351
builtin_jobs.c
Normal file
@@ -0,0 +1,351 @@
|
||||
/** \file builtin_jobs.c
|
||||
Functions for executing the jobs builtin.
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
#include <unistd.h>
|
||||
#include <termios.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <string.h>
|
||||
#include <wctype.h>
|
||||
|
||||
#include "fallback.h"
|
||||
#include "util.h"
|
||||
|
||||
#include "wutil.h"
|
||||
#include "builtin.h"
|
||||
#include "proc.h"
|
||||
#include "parser.h"
|
||||
#include "common.h"
|
||||
#include "wgetopt.h"
|
||||
|
||||
|
||||
/**
|
||||
Print modes for the jobs builtin
|
||||
*/
|
||||
enum
|
||||
{
|
||||
JOBS_DEFAULT, /**< Print lots of general info */
|
||||
JOBS_PRINT_PID, /**< Print pid of each process in job */
|
||||
JOBS_PRINT_COMMAND, /**< Print command name of each process in job */
|
||||
JOBS_PRINT_GROUP, /**< Print group id of job */
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
|
||||
#ifdef HAVE__PROC_SELF_STAT
|
||||
/**
|
||||
Calculates the cpu usage (in percent) of the specified job.
|
||||
*/
|
||||
static int cpu_use( job_t *j )
|
||||
{
|
||||
double u=0;
|
||||
process_t *p;
|
||||
|
||||
for( p=j->first_process; p; p=p->next )
|
||||
{
|
||||
struct timeval t;
|
||||
int jiffies;
|
||||
gettimeofday( &t, 0 );
|
||||
jiffies = proc_get_jiffies( p );
|
||||
|
||||
double t1 = 1000000.0*p->last_time.tv_sec+p->last_time.tv_usec;
|
||||
double t2 = 1000000.0*t.tv_sec+t.tv_usec;
|
||||
|
||||
/* fwprintf( stderr, L"t1 %f t2 %f p1 %d p2 %d\n",
|
||||
t1, t2, jiffies, p->last_jiffies );
|
||||
*/
|
||||
|
||||
u += ((double)(jiffies-p->last_jiffies))/(t2-t1);
|
||||
}
|
||||
return u*1000000;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
Print information about the specified job
|
||||
*/
|
||||
static void builtin_jobs_print( job_t *j, int mode, int header )
|
||||
{
|
||||
process_t *p;
|
||||
switch( mode )
|
||||
{
|
||||
case JOBS_DEFAULT:
|
||||
{
|
||||
|
||||
if( header )
|
||||
{
|
||||
/*
|
||||
Print table header before first job
|
||||
*/
|
||||
sb_append( sb_out, _( L"Job\tGroup\t" ));
|
||||
#ifdef HAVE__PROC_SELF_STAT
|
||||
sb_append( sb_out, _( L"CPU\t" ) );
|
||||
#endif
|
||||
sb_append( sb_out, _( L"State\tCommand\n" ) );
|
||||
}
|
||||
|
||||
sb_printf( sb_out, L"%d\t%d\t", j->job_id, j->pgid );
|
||||
|
||||
#ifdef HAVE__PROC_SELF_STAT
|
||||
sb_printf( sb_out, L"%d%%\t", cpu_use(j) );
|
||||
#endif
|
||||
sb_append2( sb_out,
|
||||
job_is_stopped(j)?_(L"stopped"):_(L"running"),
|
||||
L"\t",
|
||||
j->command,
|
||||
L"\n",
|
||||
(void *)0 );
|
||||
break;
|
||||
}
|
||||
|
||||
case JOBS_PRINT_GROUP:
|
||||
{
|
||||
if( header )
|
||||
{
|
||||
/*
|
||||
Print table header before first job
|
||||
*/
|
||||
sb_append( sb_out, _( L"Group\n" ));
|
||||
}
|
||||
sb_printf( sb_out, L"%d\n", j->pgid );
|
||||
break;
|
||||
}
|
||||
|
||||
case JOBS_PRINT_PID:
|
||||
{
|
||||
if( header )
|
||||
{
|
||||
/*
|
||||
Print table header before first job
|
||||
*/
|
||||
sb_append( sb_out, _( L"Procces\n" ));
|
||||
}
|
||||
|
||||
for( p=j->first_process; p; p=p->next )
|
||||
{
|
||||
sb_printf( sb_out, L"%d\n", p->pid );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case JOBS_PRINT_COMMAND:
|
||||
{
|
||||
if( header )
|
||||
{
|
||||
/*
|
||||
Print table header before first job
|
||||
*/
|
||||
sb_append( sb_out, _( L"Command\n" ));
|
||||
}
|
||||
|
||||
for( p=j->first_process; p; p=p->next )
|
||||
{
|
||||
sb_printf( sb_out, L"%ls\n", p->argv[0] );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
The jobs builtin. Used fopr printing running jobs. Defined in builtin_jobs.c.
|
||||
*/
|
||||
static int builtin_jobs( wchar_t **argv )
|
||||
{
|
||||
int argc=0;
|
||||
int found=0;
|
||||
int mode=JOBS_DEFAULT;
|
||||
int print_last = 0;
|
||||
job_t *j;
|
||||
|
||||
argc = builtin_count_args( argv );
|
||||
woptind=0;
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
const static struct woption
|
||||
long_options[] =
|
||||
{
|
||||
{
|
||||
L"pid", no_argument, 0, 'p'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"command", no_argument, 0, 'c'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"group", no_argument, 0, 'g'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"last", no_argument, 0, 'l'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"help", no_argument, 0, 'h'
|
||||
}
|
||||
,
|
||||
{
|
||||
0, 0, 0, 0
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
int opt_index = 0;
|
||||
|
||||
int opt = wgetopt_long( argc,
|
||||
argv,
|
||||
L"pclgh",
|
||||
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 );
|
||||
|
||||
|
||||
return 1;
|
||||
|
||||
|
||||
case 'p':
|
||||
mode=JOBS_PRINT_PID;
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
mode=JOBS_PRINT_COMMAND;
|
||||
break;
|
||||
|
||||
case 'g':
|
||||
mode=JOBS_PRINT_GROUP;
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
{
|
||||
print_last = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'h':
|
||||
builtin_print_help( argv[0], sb_out );
|
||||
return 0;
|
||||
|
||||
case '?':
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
|
||||
return 1;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Do not babble if not interactive
|
||||
*/
|
||||
if( builtin_out_redirect )
|
||||
{
|
||||
found=1;
|
||||
}
|
||||
|
||||
if( print_last )
|
||||
{
|
||||
/*
|
||||
Ignore unconstructed jobs, i.e. ourself.
|
||||
*/
|
||||
for( j=first_job; j; j=j->next )
|
||||
{
|
||||
if( (j->flags & JOB_CONSTRUCTED) && !job_is_completed(j) )
|
||||
{
|
||||
builtin_jobs_print( j, mode, !found );
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if( woptind < argc )
|
||||
{
|
||||
int i;
|
||||
|
||||
found = 1;
|
||||
|
||||
for( i=woptind; i<argc; i++ )
|
||||
{
|
||||
long pid;
|
||||
wchar_t *end;
|
||||
errno=0;
|
||||
pid=wcstol( argv[i], &end, 10 );
|
||||
if( errno || *end )
|
||||
{
|
||||
sb_printf( sb_err,
|
||||
_( L"%ls: '%ls' is not a job\n" ),
|
||||
argv[0],
|
||||
argv[i] );
|
||||
return 1;
|
||||
}
|
||||
|
||||
j = job_get_from_pid( pid );
|
||||
|
||||
if( j && !job_is_completed( j ) )
|
||||
{
|
||||
builtin_jobs_print( j, mode, !found );
|
||||
}
|
||||
else
|
||||
{
|
||||
sb_printf( sb_err,
|
||||
_( L"%ls: No suitable job: %d\n" ),
|
||||
argv[0],
|
||||
pid );
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( j= first_job; j; j=j->next )
|
||||
{
|
||||
/*
|
||||
Ignore unconstructed jobs, i.e. ourself.
|
||||
*/
|
||||
if( (j->flags & JOB_CONSTRUCTED) && !job_is_completed(j) )
|
||||
{
|
||||
builtin_jobs_print( j, mode, !found );
|
||||
found = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( !found )
|
||||
{
|
||||
sb_printf( sb_out,
|
||||
_( L"%ls: There are no jobs\n" ),
|
||||
argv[0] );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
841
builtin_set.c
841
builtin_set.c
File diff suppressed because it is too large
Load Diff
111
builtin_ulimit.c
111
builtin_ulimit.c
@@ -3,6 +3,8 @@
|
||||
Functions used for implementing the ulimit builtin.
|
||||
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
@@ -12,12 +14,14 @@ Functions used for implementing the ulimit builtin.
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "fallback.h"
|
||||
#include "util.h"
|
||||
|
||||
#include "builtin.h"
|
||||
#include "common.h"
|
||||
#include "wgetopt.h"
|
||||
|
||||
|
||||
/**
|
||||
Struct describing a resource limit
|
||||
*/
|
||||
@@ -35,6 +39,10 @@ struct resource_t
|
||||
Switch used on commandline to specify resource
|
||||
*/
|
||||
wchar_t switch_char;
|
||||
/**
|
||||
The implicit multiplier used when setting getting values
|
||||
*/
|
||||
int multiplier;
|
||||
}
|
||||
;
|
||||
|
||||
@@ -44,49 +52,55 @@ struct resource_t
|
||||
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
|
||||
}
|
||||
,
|
||||
#ifdef RLIMIT_MEMLOCK
|
||||
{
|
||||
RLIMIT_MEMLOCK, L"Maximum size that may be locked into memory", L'l', 1024
|
||||
}
|
||||
,
|
||||
#endif
|
||||
#ifdef 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
|
||||
}
|
||||
,
|
||||
#ifdef RLIMIT_NPROC
|
||||
{
|
||||
RLIMIT_NOFILE, L"Maximum number of open file descriptors", L'n'
|
||||
RLIMIT_NPROC, L"Maximum number of processes available to a single user", L'u', 1
|
||||
}
|
||||
,
|
||||
#endif
|
||||
#ifdef RLIMIT_AS
|
||||
{
|
||||
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'
|
||||
}
|
||||
,
|
||||
#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
|
||||
}
|
||||
}
|
||||
;
|
||||
@@ -96,13 +110,16 @@ const static struct resource_t resource_arr[] =
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -240,7 +257,11 @@ static int set_all( int hard, int soft, rlim_t value )
|
||||
return res;
|
||||
}
|
||||
|
||||
int builtin_ulimit( wchar_t ** argv )
|
||||
/**
|
||||
The ulimit builtin, used for setting resource limits. Defined in
|
||||
builtin_ulimit.c.
|
||||
*/
|
||||
static int builtin_ulimit( wchar_t ** argv )
|
||||
{
|
||||
int hard=0;
|
||||
int soft=0;
|
||||
@@ -309,6 +330,10 @@ int builtin_ulimit( wchar_t ** argv )
|
||||
L"virtual-memory-size", no_argument, 0, 'v'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"help", no_argument, 0, 'h'
|
||||
}
|
||||
,
|
||||
{
|
||||
0, 0, 0, 0
|
||||
}
|
||||
@@ -320,7 +345,7 @@ int builtin_ulimit( wchar_t ** argv )
|
||||
|
||||
int opt = wgetopt_long( argc,
|
||||
argv,
|
||||
L"aHScdflmnptuv",
|
||||
L"aHScdflmnptuvh",
|
||||
long_options,
|
||||
&opt_index );
|
||||
if( opt == -1 )
|
||||
@@ -331,13 +356,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;
|
||||
@@ -365,14 +387,17 @@ int builtin_ulimit( wchar_t ** argv )
|
||||
case L'f':
|
||||
what=RLIMIT_FSIZE;
|
||||
break;
|
||||
|
||||
#ifdef RLIMIT_MEMLOCK
|
||||
case L'l':
|
||||
what=RLIMIT_MEMLOCK;
|
||||
break;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef RLIMIT_RSS
|
||||
case L'm':
|
||||
what=RLIMIT_RSS;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case L'n':
|
||||
what=RLIMIT_NOFILE;
|
||||
@@ -385,17 +410,23 @@ int builtin_ulimit( wchar_t ** argv )
|
||||
case L't':
|
||||
what=RLIMIT_CPU;
|
||||
break;
|
||||
|
||||
|
||||
#ifdef RLIMIT_NPROC
|
||||
case L'u':
|
||||
what=RLIMIT_NPROC;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if HAVE_RLIMIT_AS
|
||||
#ifdef RLIMIT_AS
|
||||
case L'v':
|
||||
what=RLIMIT_AS;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case L'h':
|
||||
builtin_print_help( argv[0], sb_out );
|
||||
return 0;
|
||||
|
||||
case L'?':
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
return 1;
|
||||
|
||||
317
common.h
317
common.h
@@ -8,52 +8,52 @@
|
||||
*/
|
||||
#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.
|
||||
*/
|
||||
|
||||
#ifdef NCURSES_VERSION
|
||||
typedef int tputs_arg_t;
|
||||
#else
|
||||
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
|
||||
|
||||
/**
|
||||
Color code for set_color. Does not update the color.
|
||||
This is in the unicode private use area.
|
||||
*/
|
||||
|
||||
#define FISH_COLOR_IGNORE -1
|
||||
#define ENCODE_DIRECT_BASE 0xf100
|
||||
|
||||
/**
|
||||
Color code for set_color. Sets the default color.
|
||||
Highest legal ascii value
|
||||
*/
|
||||
#define FISH_COLOR_RESET -2
|
||||
#define ASCII_MAX 127u
|
||||
|
||||
/** Save the shell mode on startup so we can restore them on exit */
|
||||
/**
|
||||
Highest legal 16-bit unicode value
|
||||
*/
|
||||
#define UCS2_MAX 0xffffu
|
||||
|
||||
/**
|
||||
Highest legal byte value
|
||||
*/
|
||||
#define BYTE_MAX 0xffu
|
||||
|
||||
/**
|
||||
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;
|
||||
|
||||
/**
|
||||
The maximum number of charset convertion errors to report
|
||||
*/
|
||||
extern int error_max;
|
||||
|
||||
/**
|
||||
The verbosity of fish
|
||||
The verbosity level of fish. If a call to debug has a severity
|
||||
level higher than \c debug_level, it will not be printed.
|
||||
*/
|
||||
extern int debug_level;
|
||||
|
||||
@@ -69,7 +69,80 @@ extern char *profile;
|
||||
extern wchar_t *program_name;
|
||||
|
||||
/**
|
||||
Take an array_list_t containing wide strings and converts them to a wchar_t **.
|
||||
This macro is used to check that an input argument is not null. It
|
||||
is a bit lika a non-fatal form of assert. Instead of exit-ing on
|
||||
failiure, the current function is ended at once. The second
|
||||
parameter is the return value of the current function on failiure.
|
||||
*/
|
||||
#define CHECK( arg, retval ) \
|
||||
if( !(arg) ) \
|
||||
{ \
|
||||
debug( 1, \
|
||||
_( L"function %s called with null value for argument %s. " \
|
||||
L"This is a bug. " \
|
||||
L"If you can reproduce it, please send a bug report to %s." ), \
|
||||
__func__, \
|
||||
#arg, \
|
||||
PACKAGE_BUGREPORT ); \
|
||||
return retval; \
|
||||
}
|
||||
|
||||
/**
|
||||
Exit program at once, leaving an error message about running out of memory.
|
||||
*/
|
||||
#define DIE_MEM() \
|
||||
{ \
|
||||
fwprintf( stderr, \
|
||||
L"fish: Out of memory on line %d of file %s, shutting down fish\n", \
|
||||
__LINE__, \
|
||||
__FILE__ ); \
|
||||
exit(1); \
|
||||
}
|
||||
|
||||
/**
|
||||
Cause fish to crash. This should only be used for debugging. If
|
||||
this function is ever called in shipped code, this is a bug.
|
||||
*/
|
||||
#define CRASH() \
|
||||
{ \
|
||||
int *n = 0; \
|
||||
*n = 1; \
|
||||
}
|
||||
|
||||
/**
|
||||
Check if signals are blocked. If so, print an error message and
|
||||
return from the function performing this check.
|
||||
*/
|
||||
#define CHECK_BLOCK( retval ) \
|
||||
if( signal_is_blocked() ) \
|
||||
{ \
|
||||
debug( 0, \
|
||||
L"function %s called while blocking signals. " \
|
||||
L"This is a bug. " \
|
||||
L"If you can reproduce it, please send a bug report to %s.", \
|
||||
__func__, \
|
||||
PACKAGE_BUGREPORT ); \
|
||||
return retval; \
|
||||
}
|
||||
|
||||
/**
|
||||
Shorthand for wgettext call
|
||||
*/
|
||||
#define _(wstr) wgettext(wstr)
|
||||
|
||||
/**
|
||||
Noop, used to tell xgettext that a string should be translated,
|
||||
even though it is not directly sent to wgettext.
|
||||
*/
|
||||
#define N_(wstr) wstr
|
||||
|
||||
|
||||
/**
|
||||
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 );
|
||||
|
||||
@@ -87,22 +160,52 @@ 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 an array_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
|
||||
|
||||
This function encodes illegal character sequences in a reversible
|
||||
way using the private use area.
|
||||
*/
|
||||
wchar_t *str2wcs( const char *in );
|
||||
|
||||
/**
|
||||
Returns a newly allocated multibyte character string equivalent of the specified wide character string
|
||||
Converts the narrow character string \c in into it's wide
|
||||
equivalent, stored in \c out. \c out must have enough space to fit
|
||||
the entire string.
|
||||
|
||||
This function encodes illegal character sequences in a reversible
|
||||
way using the private use area.
|
||||
*/
|
||||
wchar_t *str2wcs_internal( const char *in, wchar_t *out );
|
||||
|
||||
/**
|
||||
Returns a newly allocated multibyte character string equivalent of
|
||||
the specified wide character string
|
||||
|
||||
This function decodes illegal character sequences in a reversible
|
||||
way using the private use area.
|
||||
*/
|
||||
char *wcs2str( const wchar_t *in );
|
||||
|
||||
/**
|
||||
Returns a newly allocated wide character string array equivalent of the specified multibyte character string array
|
||||
Converts the wide character string \c in into it's narrow
|
||||
equivalent, stored in \c out. \c out must have enough space to fit
|
||||
the entire string.
|
||||
|
||||
This function decodes illegal character sequences in a reversible
|
||||
way using the private use area.
|
||||
*/
|
||||
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
|
||||
*/
|
||||
char **wcsv2strv( const wchar_t **in );
|
||||
|
||||
@@ -112,74 +215,46 @@ 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 );
|
||||
|
||||
|
||||
/**
|
||||
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.
|
||||
*/
|
||||
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 );
|
||||
__sentinel wchar_t *wcsdupcat2( const wchar_t *a, ... );
|
||||
|
||||
/**
|
||||
Test if the given string is a valid variable name
|
||||
*/
|
||||
|
||||
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.
|
||||
Test if the given string is a valid variable name.
|
||||
|
||||
\return null if this is a valid name, and a pointer to the first invalid character otherwise
|
||||
*/
|
||||
int wcwidth( wchar_t c );
|
||||
|
||||
wchar_t *wcsvarname( const wchar_t *str );
|
||||
|
||||
|
||||
/**
|
||||
Test if the given string is a valid function name.
|
||||
|
||||
\return null if this is a valid name, and a pointer to the first invalid character otherwise
|
||||
*/
|
||||
|
||||
wchar_t *wcsfuncname( const wchar_t *str );
|
||||
|
||||
/**
|
||||
Test if the given string is valid in a variable name
|
||||
|
||||
\return 1 if this is a valid name, 0 otherwise
|
||||
*/
|
||||
|
||||
int wcsvarchr( wchar_t chr );
|
||||
|
||||
|
||||
/**
|
||||
@@ -188,7 +263,11 @@ 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 );
|
||||
|
||||
@@ -203,16 +282,21 @@ 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
|
||||
Checks if \c needle is included in the list of strings specified. A warning is printed if needle is zero.
|
||||
|
||||
\param needle the string to search for in the list
|
||||
|
||||
\return zero is needle is not found, of if needle is null, non-zero otherwise
|
||||
*/
|
||||
int contains_str( const wchar_t *needle, ... );
|
||||
__sentinel int contains_str( const wchar_t *needle, ... );
|
||||
|
||||
/**
|
||||
Call read while blocking the SIGCHLD signal. Should only be called
|
||||
@@ -220,22 +304,6 @@ 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.
|
||||
*/
|
||||
int writeb( tputs_arg_t b );
|
||||
|
||||
/**
|
||||
Exit program at once, leaving an error message about running out of memory
|
||||
*/
|
||||
void die_mem();
|
||||
|
||||
/**
|
||||
Clean up
|
||||
*/
|
||||
void common_destroy();
|
||||
|
||||
/**
|
||||
Issue a debug message with printf-style string formating and
|
||||
@@ -251,7 +319,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
|
||||
@@ -262,8 +330,7 @@ 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 );
|
||||
|
||||
/**
|
||||
Expand backslashed escapes and substitute them with their unescaped
|
||||
@@ -279,16 +346,6 @@ wchar_t *escape( const wchar_t *in,
|
||||
wchar_t *unescape( const wchar_t * in,
|
||||
int escape_special );
|
||||
|
||||
/**
|
||||
Block SIGCHLD. Calls to block/unblock may be nested, and only once the nest count reaches zero wiull the block be removed.
|
||||
*/
|
||||
void block();
|
||||
|
||||
/**
|
||||
undo call to block().
|
||||
*/
|
||||
void unblock();
|
||||
|
||||
/**
|
||||
Attempt to acquire a lock based on a lockfile, waiting LOCKPOLLINTERVAL
|
||||
milliseconds between polls and timing out after timeout seconds,
|
||||
@@ -324,5 +381,29 @@ int common_get_height();
|
||||
*/
|
||||
void common_handle_winch( int signal );
|
||||
|
||||
/**
|
||||
Write paragraph of output to the specified stringbuffer, and redo
|
||||
the linebreaks to fit the current screen.
|
||||
*/
|
||||
void write_screen( const wchar_t *msg, string_buffer_t *buff );
|
||||
|
||||
/**
|
||||
Tokenize the specified string into the specified array_list_t.
|
||||
Each new element is allocated using malloc and must be freed by the
|
||||
caller.
|
||||
|
||||
\param val the input string. The contents of this string is not changed.
|
||||
\param out the list in which to place the elements.
|
||||
*/
|
||||
void tokenize_variable_array( const wchar_t *val, array_list_t *out );
|
||||
|
||||
|
||||
/**
|
||||
Make sure the specified direcotry exists. If no, try to create it.
|
||||
|
||||
\return 0 if the directory exists, -1 otherwise.
|
||||
*/
|
||||
int create_directory( wchar_t *d );
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
1422
complete.c
1422
complete.c
File diff suppressed because it is too large
Load Diff
60
complete.h
60
complete.h
@@ -1,10 +1,12 @@
|
||||
/** \file complete.h
|
||||
Prototypes for functions related to tab-completion.
|
||||
|
||||
These functions are used for storing and retrieving tab-completion data, as well as for performing tab-completion.
|
||||
These functions are used for storing and retrieving tab-completion
|
||||
data, as well as for performing tab-completion.
|
||||
*/
|
||||
|
||||
#ifndef FISH_COMPLETE_H
|
||||
|
||||
/**
|
||||
Header guard
|
||||
*/
|
||||
@@ -14,40 +16,56 @@
|
||||
|
||||
#include "util.h"
|
||||
|
||||
/** Use all completions */
|
||||
/**
|
||||
Use all completions
|
||||
*/
|
||||
#define SHARED 0
|
||||
/** Do not use file completion */
|
||||
/**
|
||||
Do not use file completion
|
||||
*/
|
||||
#define NO_FILES 1
|
||||
/** Require a parameter after completion */
|
||||
/**
|
||||
Require a parameter after completion
|
||||
*/
|
||||
#define NO_COMMON 2
|
||||
/** Only use the argument list specifies with completion after option. This is the same as (NO_FILES & NO_COMMON) */
|
||||
/**
|
||||
Only use the argument list specifies with completion after
|
||||
option. This is the same as (NO_FILES & NO_COMMON)
|
||||
*/
|
||||
#define EXCLUSIVE 3
|
||||
|
||||
/** Command is a path */
|
||||
/**
|
||||
Command is a path
|
||||
*/
|
||||
#define PATH 1
|
||||
/** Command is not a path */
|
||||
/**
|
||||
Command is not a path
|
||||
*/
|
||||
#define COMMAND 0
|
||||
|
||||
/** Separateor between completion and description*/
|
||||
/**
|
||||
Separator between completion and description
|
||||
*/
|
||||
#define COMPLETE_SEP L'\004'
|
||||
/** Separateor between completion and description*/
|
||||
|
||||
/**
|
||||
Separator between completion and description
|
||||
*/
|
||||
#define COMPLETE_SEP_STR L"\004"
|
||||
|
||||
/**
|
||||
Character that separates the completion and description on programmable completions
|
||||
Separator between completion items in fish_pager. This is used for
|
||||
completion grouping, e.g. when putting completions with the same
|
||||
descriptions on the same line.
|
||||
*/
|
||||
#define COMPLETE_ITEM_SEP L'\uf500'
|
||||
|
||||
/**
|
||||
Character that separates the completion and description on
|
||||
programmable completions
|
||||
*/
|
||||
#define PROG_COMPLETE_SEP L'\t'
|
||||
|
||||
/**
|
||||
Initializes various structures used for tab-completion.
|
||||
*/
|
||||
void complete_init();
|
||||
|
||||
/**
|
||||
Destroys various structures used for tab-completion and free()s the memory used by them.
|
||||
*/
|
||||
void complete_destroy();
|
||||
|
||||
/**
|
||||
|
||||
Add a completion.
|
||||
@@ -162,6 +180,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
|
||||
|
||||
665
config.guess
vendored
665
config.guess
vendored
File diff suppressed because it is too large
Load Diff
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
|
||||
219
config.sub
vendored
219
config.sub
vendored
@@ -1,9 +1,10 @@
|
||||
#! /bin/sh
|
||||
# Configuration validation subroutine script.
|
||||
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||
# 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
|
||||
# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
|
||||
# Inc.
|
||||
|
||||
timestamp='2003-06-18'
|
||||
timestamp='2006-02-27'
|
||||
|
||||
# This file is (in principle) common to ALL GNU software.
|
||||
# The presence of a machine in this file suggests that SOME GNU software
|
||||
@@ -21,14 +22,15 @@ timestamp='2003-06-18'
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
# Boston, MA 02111-1307, USA.
|
||||
|
||||
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
|
||||
# 02110-1301, USA.
|
||||
#
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
|
||||
# Please send patches to <config-patches@gnu.org>. Submit a context
|
||||
# diff and a properly formatted ChangeLog entry.
|
||||
#
|
||||
@@ -70,7 +72,7 @@ Report bugs and patches to <config-patches@gnu.org>."
|
||||
version="\
|
||||
GNU config.sub ($timestamp)
|
||||
|
||||
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
|
||||
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
@@ -83,11 +85,11 @@ Try \`$me --help' for more information."
|
||||
while test $# -gt 0 ; do
|
||||
case $1 in
|
||||
--time-stamp | --time* | -t )
|
||||
echo "$timestamp" ; exit 0 ;;
|
||||
echo "$timestamp" ; exit ;;
|
||||
--version | -v )
|
||||
echo "$version" ; exit 0 ;;
|
||||
echo "$version" ; exit ;;
|
||||
--help | --h* | -h )
|
||||
echo "$usage"; exit 0 ;;
|
||||
echo "$usage"; exit ;;
|
||||
-- ) # Stop option processing
|
||||
shift; break ;;
|
||||
- ) # Use stdin as input.
|
||||
@@ -99,7 +101,7 @@ while test $# -gt 0 ; do
|
||||
*local*)
|
||||
# First pass through any local machine types.
|
||||
echo $1
|
||||
exit 0;;
|
||||
exit ;;
|
||||
|
||||
* )
|
||||
break ;;
|
||||
@@ -118,7 +120,9 @@ esac
|
||||
# Here we must recognize all the valid KERNEL-OS combinations.
|
||||
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
|
||||
case $maybe_os in
|
||||
nto-qnx* | linux-gnu* | freebsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*)
|
||||
nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
|
||||
uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
|
||||
storm-chaos* | os2-emx* | rtmk-nova*)
|
||||
os=-$maybe_os
|
||||
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
|
||||
;;
|
||||
@@ -144,7 +148,7 @@ case $os in
|
||||
-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
|
||||
-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
|
||||
-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
|
||||
-apple | -axis)
|
||||
-apple | -axis | -knuth | -cray)
|
||||
os=
|
||||
basic_machine=$1
|
||||
;;
|
||||
@@ -169,6 +173,10 @@ case $os in
|
||||
-hiux*)
|
||||
os=-hiuxwe2
|
||||
;;
|
||||
-sco6)
|
||||
os=-sco5v6
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-sco5)
|
||||
os=-sco3.2v5
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
@@ -185,6 +193,10 @@ case $os in
|
||||
# Don't forget version if it is 3.2v4 or newer.
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-sco5v6*)
|
||||
# Don't forget version if it is 3.2v4 or newer.
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-sco*)
|
||||
os=-sco3.2v2
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
@@ -228,14 +240,16 @@ case $basic_machine in
|
||||
| a29k \
|
||||
| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
|
||||
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
|
||||
| am33_2.0 \
|
||||
| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
|
||||
| bfin \
|
||||
| c4x | clipper \
|
||||
| d10v | d30v | dlx | dsp16xx \
|
||||
| fr30 | frv \
|
||||
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
|
||||
| i370 | i860 | i960 | ia64 \
|
||||
| ip2k \
|
||||
| m32r | m68000 | m68k | m88k | mcore \
|
||||
| ip2k | iq2000 \
|
||||
| m32r | m32rle | m68000 | m68k | m88k | maxq | mb | microblaze | mcore \
|
||||
| mips | mipsbe | mipseb | mipsel | mipsle \
|
||||
| mips16 \
|
||||
| mips64 | mips64el \
|
||||
@@ -244,31 +258,38 @@ case $basic_machine in
|
||||
| mips64vr4100 | mips64vr4100el \
|
||||
| mips64vr4300 | mips64vr4300el \
|
||||
| mips64vr5000 | mips64vr5000el \
|
||||
| mips64vr5900 | mips64vr5900el \
|
||||
| mipsisa32 | mipsisa32el \
|
||||
| mipsisa32r2 | mipsisa32r2el \
|
||||
| mipsisa64 | mipsisa64el \
|
||||
| mipsisa64r2 | mipsisa64r2el \
|
||||
| mipsisa64sb1 | mipsisa64sb1el \
|
||||
| mipsisa64sr71k | mipsisa64sr71kel \
|
||||
| mipstx39 | mipstx39el \
|
||||
| mn10200 | mn10300 \
|
||||
| mt \
|
||||
| msp430 \
|
||||
| nios | nios2 \
|
||||
| ns16k | ns32k \
|
||||
| openrisc | or32 \
|
||||
| or32 \
|
||||
| pdp10 | pdp11 | pj | pjl \
|
||||
| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
|
||||
| pyramid \
|
||||
| s390 | s390x \
|
||||
| sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
|
||||
| sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
|
||||
| sh64 | sh64le \
|
||||
| sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \
|
||||
| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
|
||||
| sparcv8 | sparcv9 | sparcv9b | sparcv9v \
|
||||
| strongarm \
|
||||
| tahoe | thumb | tic4x | tic80 | tron \
|
||||
| v850 | v850e \
|
||||
| we32k \
|
||||
| x86 | xscale | xstormy16 | xtensa \
|
||||
| x86 | xscale | xscalee[bl] | xstormy16 | xtensa \
|
||||
| z8k)
|
||||
basic_machine=$basic_machine-unknown
|
||||
;;
|
||||
m32c)
|
||||
basic_machine=$basic_machine-unknown
|
||||
;;
|
||||
m6811 | m68hc11 | m6812 | m68hc12)
|
||||
# Motorola 68HC11/12.
|
||||
basic_machine=$basic_machine-unknown
|
||||
@@ -276,6 +297,9 @@ case $basic_machine in
|
||||
;;
|
||||
m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
|
||||
;;
|
||||
ms1)
|
||||
basic_machine=mt-unknown
|
||||
;;
|
||||
|
||||
# We use `pc' rather than `unknown'
|
||||
# because (1) that's what they normally are, and
|
||||
@@ -296,19 +320,19 @@ case $basic_machine in
|
||||
| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
|
||||
| arm-* | armbe-* | armle-* | armeb-* | armv*-* \
|
||||
| avr-* \
|
||||
| bs2000-* \
|
||||
| bfin-* | bs2000-* \
|
||||
| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
|
||||
| clipper-* | cydra-* \
|
||||
| clipper-* | craynv-* | cydra-* \
|
||||
| d10v-* | d30v-* | dlx-* \
|
||||
| elxsi-* \
|
||||
| f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
|
||||
| h8300-* | h8500-* \
|
||||
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
|
||||
| i*86-* | i860-* | i960-* | ia64-* \
|
||||
| ip2k-* \
|
||||
| m32r-* \
|
||||
| ip2k-* | iq2000-* \
|
||||
| m32r-* | m32rle-* \
|
||||
| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
|
||||
| m88110-* | m88k-* | mcore-* \
|
||||
| m88110-* | m88k-* | maxq-* | mcore-* \
|
||||
| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
|
||||
| mips16-* \
|
||||
| mips64-* | mips64el-* \
|
||||
@@ -317,34 +341,41 @@ case $basic_machine in
|
||||
| mips64vr4100-* | mips64vr4100el-* \
|
||||
| mips64vr4300-* | mips64vr4300el-* \
|
||||
| mips64vr5000-* | mips64vr5000el-* \
|
||||
| mips64vr5900-* | mips64vr5900el-* \
|
||||
| mipsisa32-* | mipsisa32el-* \
|
||||
| mipsisa32r2-* | mipsisa32r2el-* \
|
||||
| mipsisa64-* | mipsisa64el-* \
|
||||
| mipsisa64r2-* | mipsisa64r2el-* \
|
||||
| mipsisa64sb1-* | mipsisa64sb1el-* \
|
||||
| mipsisa64sr71k-* | mipsisa64sr71kel-* \
|
||||
| mipstx39-* | mipstx39el-* \
|
||||
| mmix-* \
|
||||
| mt-* \
|
||||
| msp430-* \
|
||||
| none-* | np1-* | nv1-* | ns16k-* | ns32k-* \
|
||||
| nios-* | nios2-* \
|
||||
| none-* | np1-* | ns16k-* | ns32k-* \
|
||||
| orion-* \
|
||||
| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
|
||||
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
|
||||
| pyramid-* \
|
||||
| romp-* | rs6000-* \
|
||||
| s390-* | s390x-* \
|
||||
| sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \
|
||||
| sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | shbe-* \
|
||||
| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
|
||||
| sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \
|
||||
| sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
|
||||
| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
|
||||
| sparclite-* \
|
||||
| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
|
||||
| tahoe-* | thumb-* \
|
||||
| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
|
||||
| tron-* \
|
||||
| v850-* | v850e-* | vax-* \
|
||||
| we32k-* \
|
||||
| x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \
|
||||
| xtensa-* \
|
||||
| x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \
|
||||
| xstormy16-* | xtensa-* \
|
||||
| ymp-* \
|
||||
| z8k-*)
|
||||
;;
|
||||
m32c-*)
|
||||
;;
|
||||
# Recognize the various machine names and aliases which stand
|
||||
# for a CPU type and a company and sometimes even an OS.
|
||||
386bsd)
|
||||
@@ -361,6 +392,9 @@ case $basic_machine in
|
||||
basic_machine=a29k-amd
|
||||
os=-udi
|
||||
;;
|
||||
abacus)
|
||||
basic_machine=abacus-unknown
|
||||
;;
|
||||
adobe68k)
|
||||
basic_machine=m68010-adobe
|
||||
os=-scout
|
||||
@@ -378,6 +412,9 @@ case $basic_machine in
|
||||
amd64)
|
||||
basic_machine=x86_64-pc
|
||||
;;
|
||||
amd64-*)
|
||||
basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
amdahl)
|
||||
basic_machine=580-amdahl
|
||||
os=-sysv
|
||||
@@ -437,12 +474,27 @@ case $basic_machine in
|
||||
basic_machine=j90-cray
|
||||
os=-unicos
|
||||
;;
|
||||
craynv)
|
||||
basic_machine=craynv-cray
|
||||
os=-unicosmp
|
||||
;;
|
||||
cr16c)
|
||||
basic_machine=cr16c-unknown
|
||||
os=-elf
|
||||
;;
|
||||
crds | unos)
|
||||
basic_machine=m68k-crds
|
||||
;;
|
||||
crisv32 | crisv32-* | etraxfs*)
|
||||
basic_machine=crisv32-axis
|
||||
;;
|
||||
cris | cris-* | etrax*)
|
||||
basic_machine=cris-axis
|
||||
;;
|
||||
crx)
|
||||
basic_machine=crx-unknown
|
||||
os=-elf
|
||||
;;
|
||||
da30 | da30-*)
|
||||
basic_machine=m68k-da30
|
||||
;;
|
||||
@@ -465,6 +517,10 @@ case $basic_machine in
|
||||
basic_machine=m88k-motorola
|
||||
os=-sysv3
|
||||
;;
|
||||
djgpp)
|
||||
basic_machine=i586-pc
|
||||
os=-msdosdjgpp
|
||||
;;
|
||||
dpx20 | dpx20-*)
|
||||
basic_machine=rs6000-bull
|
||||
os=-bosx
|
||||
@@ -643,10 +699,6 @@ case $basic_machine in
|
||||
mips3*)
|
||||
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
|
||||
;;
|
||||
mmix*)
|
||||
basic_machine=mmix-knuth
|
||||
os=-mmixware
|
||||
;;
|
||||
monitor)
|
||||
basic_machine=m68k-rom68k
|
||||
os=-coff
|
||||
@@ -659,6 +711,9 @@ case $basic_machine in
|
||||
basic_machine=i386-pc
|
||||
os=-msdos
|
||||
;;
|
||||
ms1-*)
|
||||
basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
|
||||
;;
|
||||
mvs)
|
||||
basic_machine=i370-ibm
|
||||
os=-mvs
|
||||
@@ -727,10 +782,6 @@ case $basic_machine in
|
||||
np1)
|
||||
basic_machine=np1-gould
|
||||
;;
|
||||
nv1)
|
||||
basic_machine=nv1-cray
|
||||
os=-unicosmp
|
||||
;;
|
||||
nsr-tandem)
|
||||
basic_machine=nsr-tandem
|
||||
;;
|
||||
@@ -738,9 +789,12 @@ case $basic_machine in
|
||||
basic_machine=hppa1.1-oki
|
||||
os=-proelf
|
||||
;;
|
||||
or32 | or32-*)
|
||||
openrisc | openrisc-*)
|
||||
basic_machine=or32-unknown
|
||||
os=-coff
|
||||
;;
|
||||
os400)
|
||||
basic_machine=powerpc-ibm
|
||||
os=-os400
|
||||
;;
|
||||
OSE68000 | ose68000)
|
||||
basic_machine=m68000-ericsson
|
||||
@@ -767,6 +821,12 @@ case $basic_machine in
|
||||
pc532 | pc532-*)
|
||||
basic_machine=ns32k-pc532
|
||||
;;
|
||||
pc98)
|
||||
basic_machine=i386-pc
|
||||
;;
|
||||
pc98-*)
|
||||
basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
pentium | p5 | k5 | k6 | nexgen | viac3)
|
||||
basic_machine=i586-pc
|
||||
;;
|
||||
@@ -823,6 +883,10 @@ case $basic_machine in
|
||||
basic_machine=i586-unknown
|
||||
os=-pw32
|
||||
;;
|
||||
rdos)
|
||||
basic_machine=i386-pc
|
||||
os=-rdos
|
||||
;;
|
||||
rom68k)
|
||||
basic_machine=m68k-rom68k
|
||||
os=-coff
|
||||
@@ -833,6 +897,12 @@ case $basic_machine in
|
||||
rtpc | rtpc-*)
|
||||
basic_machine=romp-ibm
|
||||
;;
|
||||
s390 | s390-*)
|
||||
basic_machine=s390-ibm
|
||||
;;
|
||||
s390x | s390x-*)
|
||||
basic_machine=s390x-ibm
|
||||
;;
|
||||
sa29200)
|
||||
basic_machine=a29k-amd
|
||||
os=-udi
|
||||
@@ -956,6 +1026,10 @@ case $basic_machine in
|
||||
tower | tower-32)
|
||||
basic_machine=m68k-ncr
|
||||
;;
|
||||
tpf)
|
||||
basic_machine=s390x-ibm
|
||||
os=-tpf
|
||||
;;
|
||||
udi29k)
|
||||
basic_machine=a29k-amd
|
||||
os=-udi
|
||||
@@ -999,6 +1073,10 @@ case $basic_machine in
|
||||
basic_machine=hppa1.1-winbond
|
||||
os=-proelf
|
||||
;;
|
||||
xbox)
|
||||
basic_machine=i686-pc
|
||||
os=-mingw32
|
||||
;;
|
||||
xps | xps100)
|
||||
basic_machine=xps100-honeywell
|
||||
;;
|
||||
@@ -1029,6 +1107,9 @@ case $basic_machine in
|
||||
romp)
|
||||
basic_machine=romp-ibm
|
||||
;;
|
||||
mmix)
|
||||
basic_machine=mmix-knuth
|
||||
;;
|
||||
rs6000)
|
||||
basic_machine=rs6000-ibm
|
||||
;;
|
||||
@@ -1045,13 +1126,10 @@ case $basic_machine in
|
||||
we32k)
|
||||
basic_machine=we32k-att
|
||||
;;
|
||||
sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele)
|
||||
sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
|
||||
basic_machine=sh-unknown
|
||||
;;
|
||||
sh64)
|
||||
basic_machine=sh64-unknown
|
||||
;;
|
||||
sparc | sparcv9 | sparcv9b)
|
||||
sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
|
||||
basic_machine=sparc-sun
|
||||
;;
|
||||
cydra)
|
||||
@@ -1124,19 +1202,23 @@ case $os in
|
||||
| -aos* \
|
||||
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
|
||||
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
|
||||
| -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \
|
||||
| -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
|
||||
| -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
|
||||
| -openbsd* | -solidbsd* \
|
||||
| -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
|
||||
| -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
|
||||
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
|
||||
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
|
||||
| -chorusos* | -chorusrdb* \
|
||||
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
|
||||
| -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
|
||||
| -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
|
||||
| -uxpv* | -beos* | -mpeix* | -udk* \
|
||||
| -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
|
||||
| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
|
||||
| -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
|
||||
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
|
||||
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
|
||||
| -powermax* | -dnix* | -nx6 | -nx7 | -sei*)
|
||||
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
|
||||
| -skyos* | -haiku* | -rdos*)
|
||||
# Remember, each alternative MUST END IN *, to match a version number.
|
||||
;;
|
||||
-qnx*)
|
||||
@@ -1154,12 +1236,15 @@ case $os in
|
||||
os=`echo $os | sed -e 's|nto|nto-qnx|'`
|
||||
;;
|
||||
-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
|
||||
| -windows* | -osx | -abug | -netware* | -os9* | -beos* \
|
||||
| -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
|
||||
| -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
|
||||
;;
|
||||
-mac*)
|
||||
os=`echo $os | sed -e 's|mac|macos|'`
|
||||
;;
|
||||
-linux-dietlibc)
|
||||
os=-linux-dietlibc
|
||||
;;
|
||||
-linux*)
|
||||
os=`echo $os | sed -e 's|linux|linux-gnu|'`
|
||||
;;
|
||||
@@ -1172,6 +1257,9 @@ case $os in
|
||||
-opened*)
|
||||
os=-openedition
|
||||
;;
|
||||
-os400*)
|
||||
os=-os400
|
||||
;;
|
||||
-wince*)
|
||||
os=-wince
|
||||
;;
|
||||
@@ -1193,6 +1281,9 @@ case $os in
|
||||
-atheos*)
|
||||
os=-atheos
|
||||
;;
|
||||
-syllable*)
|
||||
os=-syllable
|
||||
;;
|
||||
-386bsd)
|
||||
os=-bsd
|
||||
;;
|
||||
@@ -1215,6 +1306,9 @@ case $os in
|
||||
-sinix*)
|
||||
os=-sysv4
|
||||
;;
|
||||
-tpf*)
|
||||
os=-tpf
|
||||
;;
|
||||
-triton*)
|
||||
os=-sysv3
|
||||
;;
|
||||
@@ -1251,6 +1345,9 @@ case $os in
|
||||
-kaos*)
|
||||
os=-kaos
|
||||
;;
|
||||
-zvmoe)
|
||||
os=-zvmoe
|
||||
;;
|
||||
-none)
|
||||
;;
|
||||
*)
|
||||
@@ -1282,9 +1379,9 @@ case $basic_machine in
|
||||
arm*-semi)
|
||||
os=-aout
|
||||
;;
|
||||
c4x-* | tic4x-*)
|
||||
os=-coff
|
||||
;;
|
||||
c4x-* | tic4x-*)
|
||||
os=-coff
|
||||
;;
|
||||
# This must come before the *-dec entry.
|
||||
pdp10-*)
|
||||
os=-tops20
|
||||
@@ -1328,9 +1425,15 @@ case $basic_machine in
|
||||
*-be)
|
||||
os=-beos
|
||||
;;
|
||||
*-haiku)
|
||||
os=-haiku
|
||||
;;
|
||||
*-ibm)
|
||||
os=-aix
|
||||
;;
|
||||
*-knuth)
|
||||
os=-mmixware
|
||||
;;
|
||||
*-wec)
|
||||
os=-proelf
|
||||
;;
|
||||
@@ -1463,9 +1566,15 @@ case $basic_machine in
|
||||
-mvs* | -opened*)
|
||||
vendor=ibm
|
||||
;;
|
||||
-os400*)
|
||||
vendor=ibm
|
||||
;;
|
||||
-ptx*)
|
||||
vendor=sequent
|
||||
;;
|
||||
-tpf*)
|
||||
vendor=ibm
|
||||
;;
|
||||
-vxsim* | -vxworks* | -windiss*)
|
||||
vendor=wrs
|
||||
;;
|
||||
@@ -1490,7 +1599,7 @@ case $basic_machine in
|
||||
esac
|
||||
|
||||
echo $basic_machine$os
|
||||
exit 0
|
||||
exit
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
|
||||
797
configure.ac
797
configure.ac
@@ -1,29 +1,188 @@
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
AC_INIT(fish,1.16.2,axel@liljencrantz.se)
|
||||
|
||||
AC_CANONICAL_TARGET
|
||||
#
|
||||
# This file is the main build configuration file for fish. It is used
|
||||
# to determine your systems capabilities, and tries to adapt fish to
|
||||
# take maximum advantage of the services your system offers.
|
||||
#
|
||||
# Process this file using the 'autoconf' command to produce a working
|
||||
# configure script, which should in turn be executed in order to
|
||||
# configure the build process.
|
||||
#
|
||||
|
||||
if test $target_cpu = powerpc; then
|
||||
AC_DEFINE([TPUTS_KLUDGE],[1],[Evil kludge to get Power based machines to work])
|
||||
AC_INIT(fish,1.22.1,fish-users@lists.sf.net)
|
||||
|
||||
|
||||
#
|
||||
# If needed, run autoconf to regenerate the configure file
|
||||
#
|
||||
# This makes sure that after running autoconf once to create the first
|
||||
# version of configure, we never again need to worry about manually
|
||||
# running autoconf to handle an updates configure.ac.
|
||||
#
|
||||
|
||||
AC_MSG_CHECKING([if autoconf needs to be run])
|
||||
if test configure -ot configure.ac; then
|
||||
AC_MSG_RESULT([yes])
|
||||
if which autoconf >/dev/null; then
|
||||
# No need to provide any error messages if autoconf fails, the
|
||||
# shell and autconf should take care of that themselves
|
||||
AC_MSG_NOTICE([running autoconf])
|
||||
if autoconf; then
|
||||
./configure "$@"
|
||||
exit
|
||||
fi
|
||||
exit 1
|
||||
else
|
||||
AC_MSG_ERROR(
|
||||
[cannot find the autoconf program in your path.
|
||||
This program needs to be run whenever the configure.ac file is modified.
|
||||
Please install it and try again.]
|
||||
)
|
||||
fi
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
|
||||
AC_DEFINE_UNQUOTED([CPU],[L"$target_cpu"],[CPU type])
|
||||
|
||||
#
|
||||
# If needed, run autoheader to regenerate config.h.in
|
||||
#
|
||||
# This makes sure we never ever have to run autoheader manually. It
|
||||
# will be run whenever needed 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 || exit 1
|
||||
else
|
||||
AC_MSG_ERROR(
|
||||
[cannot find the autoheader program in your path.
|
||||
This program needs to be run whenever the configure.ac file is modified.
|
||||
Please install it and try again.]
|
||||
)
|
||||
fi
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# Detect directories which may contain additional headers, libraries
|
||||
# and commands. This needs to be done early - before Autoconf starts
|
||||
# to mess with CFLAGS and all the other environemnt variables.
|
||||
#
|
||||
# This mostly helps OS X users, since fink usually installs out of
|
||||
# tree and doesn't update CFLAGS.
|
||||
#
|
||||
|
||||
for i in /usr/pkg /sw /opt /opt/local; do
|
||||
|
||||
AC_MSG_CHECKING([for $i/include include directory])
|
||||
if test -d $i/include; then
|
||||
AC_MSG_RESULT(yes)
|
||||
CPPFLAGS="$CPPFLAGS -I$i/include/"
|
||||
CFLAGS="$CFLAGS -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 )
|
||||
|
||||
|
||||
#
|
||||
# Tell autoconf to create config.h header
|
||||
#
|
||||
AC_CONFIG_HEADERS(config.h)
|
||||
|
||||
# Checks for programs.
|
||||
|
||||
#
|
||||
# This adds markup to the code that results in a few extra compile
|
||||
# time checks on recent GCC versions. It helps stop a few common bugs.
|
||||
#
|
||||
|
||||
AH_BOTTOM([#if __GNUC__ >= 3
|
||||
#define __warn_unused __attribute__ ((warn_unused_result))
|
||||
#define __sentinel __attribute__ ((sentinel))
|
||||
#else
|
||||
#define __warn_unused
|
||||
#define __sentinel
|
||||
#endif])
|
||||
|
||||
|
||||
#
|
||||
# Set up various programs needed for install
|
||||
#
|
||||
|
||||
AC_PROG_CC
|
||||
AC_PROG_CPP
|
||||
AC_PROG_INSTALL
|
||||
#AC_ISC_POSIX
|
||||
#AC_PROG_MAKE_SET
|
||||
|
||||
# Optionally drop xsel
|
||||
AC_ARG_WITH( xsel,
|
||||
AC_HELP_STRING([--without-xsel],
|
||||
[do not build the xsel program needed for X clipboard integration]),
|
||||
[xsel=$withval],
|
||||
[xsel=with_xsel] )
|
||||
|
||||
#
|
||||
# Check for seq command. If missing, make sure fallback shellscript
|
||||
# implementation is installed.
|
||||
#
|
||||
|
||||
AC_CHECK_PROG( SEQ_FALLBACK, seq, [ ], [seq])
|
||||
|
||||
|
||||
if test "$SEQ_FALLBACK"; then
|
||||
|
||||
#
|
||||
# We already have seq. Check if the seq version is installed by an
|
||||
# earlier fish version. If it is, we'll replace it.
|
||||
#
|
||||
|
||||
file=`which seq`
|
||||
if test -f "$file"; then
|
||||
|
||||
AC_MSG_CHECKING([if seq comes from a previous fish version])
|
||||
shebang=`grep "\(^#!/.*/fish\|^#!/usr/bin/env fish\)" $file`
|
||||
|
||||
if test "$shebang"; then
|
||||
AC_SUBST( SEQ_FALLBACK, seq )
|
||||
AC_MSG_RESULT(yes, replace it)
|
||||
else
|
||||
AC_MSG_RESULT(no, keep it)
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# Optionally drop xsel command
|
||||
#
|
||||
|
||||
AC_ARG_WITH(
|
||||
xsel,
|
||||
AC_HELP_STRING(
|
||||
[--without-xsel],
|
||||
[do not build the xsel program needed for X clipboard integration]
|
||||
),
|
||||
[xsel=$withval],
|
||||
[xsel=with_xsel]
|
||||
)
|
||||
|
||||
if [[ "$xsel" = "with_xsel" ]]; then
|
||||
AC_SUBST( XSEL,[xsel-0.9.6/xsel])
|
||||
@@ -35,60 +194,596 @@ else
|
||||
AC_SUBST( XSEL_MAN_PATH,[ ])
|
||||
fi
|
||||
|
||||
if [[ "$prefix" = NONE ]]; then
|
||||
AC_DEFINE_UNQUOTED( [PREFIX], L"/usr/local", [Installation directory])
|
||||
AC_SUBST( PREFIX, /usr/local)
|
||||
export prefix=/usr/local
|
||||
else
|
||||
AC_DEFINE_UNQUOTED( [PREFIX], L"$prefix", [Installation directory])
|
||||
AC_SUBST( PREFIX, [$prefix])
|
||||
|
||||
#
|
||||
# Test if the compiler accepts the -std=c99 flag. If so, using it
|
||||
# increases the odds of correct compilation, since we want to use the
|
||||
# *wprintf functions, which where defined in C99.
|
||||
#
|
||||
|
||||
XCFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS -std=c99"
|
||||
XCPPFLAGS="$CPPFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS -std=c99"
|
||||
AC_MSG_CHECKING(if -std=c99 works)
|
||||
|
||||
AC_CACHE_VAL(
|
||||
local_cv_has__std_c99,
|
||||
[
|
||||
AC_TRY_RUN(
|
||||
[
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
],
|
||||
local_cv_has__std_c99=yes,
|
||||
local_cv_has__std_c99=no,
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
AC_MSG_RESULT($local_cv_has__std_c99)
|
||||
case x$local_cv_has__std_c99 in
|
||||
xno)
|
||||
CFLAGS="$XCFLAGS"
|
||||
CPPFLAGS="$XCPPFLAGS" ;;
|
||||
esac
|
||||
|
||||
|
||||
#
|
||||
# If we are using gcc, set some flags that increase the odds of the
|
||||
# compiler producing a working binary...
|
||||
#
|
||||
|
||||
if test "$CC" = gcc; then
|
||||
|
||||
#
|
||||
# -fno-optimize-sibling-calls seems to work around a bug where
|
||||
# sending a SIGWINCH to fish on NetBSD 3.0 causes fish to exit when
|
||||
# compiled with GCC 3.3.3. This is probably either a compiler bug
|
||||
# or a libc bug, but adding this flag seems to fix things for
|
||||
# now. Long term, the real problem should be tracked down and
|
||||
# truly fixed, at which point we can remove this silly flag. This
|
||||
# bug has been verified to not exist on Linux using GCC 3.3.3.
|
||||
#
|
||||
|
||||
CFLAGS="$CFLAGS -fno-optimize-sibling-calls"
|
||||
|
||||
|
||||
#
|
||||
# -Wall is there to keep me on my toes
|
||||
#
|
||||
|
||||
CFLAGS="$CFLAGS -Wall"
|
||||
|
||||
fi
|
||||
|
||||
AC_SUBST(fishdir,[/fish.d])
|
||||
AC_SUBST(fishfile,[/fish])
|
||||
AC_SUBST(fishinputfile,[/fish_inputrc])
|
||||
|
||||
#
|
||||
# If we are compiling against glibc, set some flags to work around
|
||||
# some rather stupid attempts to hide prototypes for *wprintf
|
||||
# functions, as well as prototypes of various gnu extensions.
|
||||
#
|
||||
|
||||
AC_MSG_CHECKING([if we are compiling against glibc])
|
||||
AC_RUN_IFELSE(
|
||||
[
|
||||
AC_LANG_PROGRAM(
|
||||
[
|
||||
#include <stdlib.h>
|
||||
#ifdef __GLIBC__
|
||||
#define STATUS 0
|
||||
#else
|
||||
#define STATUS 1
|
||||
#endif
|
||||
],
|
||||
[
|
||||
return STATUS;
|
||||
]
|
||||
)
|
||||
],
|
||||
[glibc=yes],
|
||||
[glibc=no]
|
||||
)
|
||||
|
||||
if test "$glibc" = yes; then
|
||||
AC_MSG_RESULT(yes)
|
||||
|
||||
#
|
||||
# This gives us access to prototypes for gnu extensions and C99
|
||||
# functions if we are compiling agains glibc. All GNU extensions
|
||||
# that are used must have a fallback implementation available in
|
||||
# fallback.h, in order to keep fish working on non-gnu platforms.
|
||||
#
|
||||
|
||||
CFLAGS="$CFLAGS -D_GNU_SOURCE=1 -D_ISO99_SOURCE=1"
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# Test cpu for special handling of ppc
|
||||
#
|
||||
# This is used to skip use of tputs on ppc systems, since it seemed to
|
||||
# be broken, at least on older debin-based systems. This is obviously
|
||||
# not the right way to to detect whether this workaround should be
|
||||
# used, since it catches far to many systems, but I do not have the
|
||||
# hardware available to narrow this problem down, and in practice, it
|
||||
# seems that tputs is never really needed.
|
||||
#
|
||||
|
||||
AC_CANONICAL_TARGET
|
||||
|
||||
if test $target_cpu = powerpc; then
|
||||
AC_DEFINE([TPUTS_KLUDGE],[1],[Evil kludge to get Power based machines to work])
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# Solaris-specific flags go here
|
||||
#
|
||||
|
||||
AC_MSG_CHECKING([if we are under Solaris])
|
||||
case $target_os in
|
||||
solaris*)
|
||||
AC_DEFINE( __EXTENSIONS__, 1, [Macro to enable additional prototypes under Solaris])
|
||||
AC_MSG_RESULT(yes)
|
||||
;;
|
||||
*)
|
||||
AC_MSG_RESULT(no)
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
#
|
||||
# BSD-specific flags go here
|
||||
#
|
||||
|
||||
AC_MSG_CHECKING([if we are under BSD])
|
||||
case $target_os in
|
||||
*bsd*)
|
||||
AC_DEFINE( __BSD_VISIBLE, 1, [Macro to enable additional prototypes under BSD])
|
||||
AC_DEFINE( _NETBSD_SOURCE, 1, [Macro to enable additional prototypes under BSD])
|
||||
AC_MSG_RESULT(yes)
|
||||
;;
|
||||
*)
|
||||
AC_MSG_RESULT(no)
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
#
|
||||
# Set up PREFIX and related preprocessor symbols. Fish needs to know
|
||||
# where it will be installed. One of the reasons for this is so that
|
||||
# it can make sure the fish installation directory is in the path
|
||||
# during startup.
|
||||
#
|
||||
|
||||
if [[ "$prefix" = NONE ]]; then
|
||||
export prefix=/usr/local
|
||||
AC_SUBST( prefix, /usr/local)
|
||||
else
|
||||
AC_SUBST( prefix, [$prefix])
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# Set up the directory where the documentation files should be
|
||||
# installed
|
||||
#
|
||||
|
||||
AC_ARG_VAR( [docdir], [Documentation direcotry] )
|
||||
|
||||
if test -z $docdir; then
|
||||
AC_SUBST(docdir,[$datadir/doc/fish])
|
||||
AC_SUBST(docdir, [$datadir/doc/fish] )
|
||||
else
|
||||
AC_SUBST(docdir, [$docdir])
|
||||
fi
|
||||
|
||||
AC_DEFINE_UNQUOTED( DOCDIR, [L"$(eval echo $docdir)"], [Documentation directory] )
|
||||
AC_DEFINE_UNQUOTED( SYSCONFDIR, [L"$(eval echo $sysconfdir)"], [System configuration directory] )
|
||||
|
||||
# See if Linux procfs is present
|
||||
#
|
||||
# Set up locale directory. This is where the .po files will be
|
||||
# installed.
|
||||
#
|
||||
|
||||
AC_SUBST( [localedir], [$datadir/locale])
|
||||
|
||||
|
||||
#
|
||||
# See if Linux procfs is present. This is used to get extra
|
||||
# information about running processes.
|
||||
#
|
||||
|
||||
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])
|
||||
#
|
||||
# This is ued to tell the wgetopt library to translate strings. This
|
||||
# way wgetopt can be dropped into any project without requiring i18n.
|
||||
#
|
||||
|
||||
# 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>],
|
||||
[int tmp; tmp=RLIMIT_AS;], have_rlimit_as=yes, have_rlimit_as=no)
|
||||
if test "$have_rlimit_as" = yes; then
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE([HAVE_RLIMIT_AS], [1],
|
||||
[Define to 1 if HAVE_RLIMIT_AS is defined in <sys/resource.h>.])
|
||||
AC_DEFINE(
|
||||
[HAVE_TRANSLATE_H],
|
||||
[1],
|
||||
[Define to 1 if the wgettext function should be used for translating strings.]
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Check presense of various libraries
|
||||
#
|
||||
|
||||
AC_SEARCH_LIBS( gettext, intl,,)
|
||||
AC_SEARCH_LIBS( connect, socket, , [AC_MSG_ERROR([Cannot find the socket library, needed to build this package.] )] )
|
||||
AC_SEARCH_LIBS( nanosleep, rt, , [AC_MSG_ERROR([Cannot find the rt library, needed to build this package.] )] )
|
||||
AC_SEARCH_LIBS( setupterm, [ncurses curses], , [AC_MSG_ERROR([Could not find a curses implementation, needed to build fish])] )
|
||||
AC_SEARCH_LIBS( iconv_open, iconv, , [AC_MSG_ERROR([Could not find an iconv implementation, needed to build fish])] )
|
||||
|
||||
|
||||
#
|
||||
# Check presense of various header files
|
||||
#
|
||||
|
||||
AC_CHECK_HEADERS([getopt.h termio.h sys/resource.h term.h ncurses/term.h libintl.h ncurses.h curses.h stropts.h siginfo.h sys/select.h sys/ioctl.h sys/termios.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])
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# On some platforms (Solaris 10) adding -std=c99 in turn requires that
|
||||
# _POSIX_C_SOURCE be defined to 200112L otherwise several
|
||||
# POSIX-specific, non-ISO-C99 types/prototypes are made unavailable
|
||||
# e.g. siginfo_t. Defining _XOPEN_SOURCE to 600 is compatible with
|
||||
# the _POSIX_C_SOURCE value and provides a little assurance that
|
||||
# extension functions' prototypes are available, e.g. killpg().
|
||||
#
|
||||
# Some other platforms (OS X), will remove types/prototypes/macros
|
||||
# e.g. SIGWINCH if either _POSIX_C_SOURCE or _XOPEN_SOURCE is defined.
|
||||
#
|
||||
# This test adds these macros only if they enable a program that uses
|
||||
# both Posix and non-standard features to compile, and that program
|
||||
# does not compile without these macros.
|
||||
#
|
||||
# We try to make everyone happy.
|
||||
#
|
||||
# The ordering of the various autoconf tests is very critical as well:
|
||||
#
|
||||
# * This test needs to be run _after_ header detection tests, so that
|
||||
# the proper headers are included.
|
||||
#
|
||||
# * This test needs to be run _before_ testing for the presense of any
|
||||
# prototypes or other language functinality.
|
||||
#
|
||||
# * This test should be (but does not need to be) run after the
|
||||
# conditional definition of __EXTENSIONS__, to avoid redundant tests.
|
||||
#
|
||||
|
||||
XCFLAGS="$CFLAGS"
|
||||
|
||||
echo Checking how to use -D_XOPEN_SOURCE=600 and -D_POSIX_C_SOURCE=200112L...
|
||||
local_found_posix_switch=no
|
||||
|
||||
for i in "" "-D_POSIX_C_SOURCE=200112L" "-D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=200112L"; do
|
||||
|
||||
AC_MSG_CHECKING( if switches \"$i\" works)
|
||||
CFLAGS="$XCFLAGS $i"
|
||||
|
||||
#
|
||||
# Try to run this program, which should test various extensions
|
||||
# and Posix functionality. If this program works, then everything
|
||||
# should work. Hopefully.
|
||||
#
|
||||
|
||||
AC_TRY_LINK(
|
||||
[
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
/* POSIX, C89 and C99: POSIX extends this header.
|
||||
* For: kill(), killpg(), siginfo_t, sigset_t,
|
||||
* struct sigaction, sigemptyset(), sigaction(),
|
||||
* SIGIO and SIGWINCH. */
|
||||
#include <signal.h>
|
||||
|
||||
#ifdef HAVE_SIGINFO_H
|
||||
/* Neither POSIX, C89 nor C99: Solaris-specific (others?).
|
||||
* For: siginfo_t (also defined by signal.h when in
|
||||
* POSIX/extensions mode). */
|
||||
#include <siginfo.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_TERMIOS_H
|
||||
/* Neither POSIX, C89 nor C99: a common extension.
|
||||
* For: TIOCGWINSZ and struct winsize (under at least
|
||||
* Solaris, NetBSD and (dual-listed) FreeBSD). */
|
||||
#include <sys/termios.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_IOCTL_H
|
||||
/* As above (under at least Linux and FreeBSD). */
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
],
|
||||
[
|
||||
/* Avert high-level optimisation, by making the program's
|
||||
* return value depend on all tested identifiers. */
|
||||
int ret = 0;
|
||||
/* POSIX only: might be unhidden by _POSIX_C_SOURCE. */
|
||||
struct sigaction sa;
|
||||
sigset_t ss;
|
||||
siginfo_t info;
|
||||
ret += (int)(void *)&info + kill( 0, 0 ) +
|
||||
sigaction( 0, &sa, 0 ) + sigemptyset( &ss );
|
||||
/* Extended-POSIX: might be unhidden by _XOPEN_SOURCE. */
|
||||
ret += killpg( 0, 0 );
|
||||
/* Non-standard: might be hidden by the macros. */
|
||||
{
|
||||
struct winsize termsize;
|
||||
ret += (int)(void *)&termsize;
|
||||
ret += SIGWINCH + TIOCGWINSZ + SIGIO;
|
||||
}
|
||||
return ret;
|
||||
|
||||
],
|
||||
local_cv_use__posix_c_source=yes,
|
||||
local_cv_use__posix_c_source=no,
|
||||
)
|
||||
|
||||
if test x$local_cv_use__posix_c_source = xyes; then
|
||||
AC_MSG_RESULT( yes )
|
||||
local_found_posix_switch=yes
|
||||
break;
|
||||
else
|
||||
AC_MSG_RESULT( no )
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
#
|
||||
# We didn't find any combination of switches that worked - revert to
|
||||
# no switches and hope that the fallbacks work. A warning will be
|
||||
# printed at the end of the configure script.
|
||||
#
|
||||
|
||||
if test ! x$local_found_posix_switch = xyes; then
|
||||
CFLAGS="$XCFLAGS"
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# Check for presense of various functions used by fish
|
||||
#
|
||||
|
||||
AC_CHECK_FUNCS( gettext wcsdup wcsndup wcslen wcscasecmp wcsncasecmp fwprintf )
|
||||
AC_CHECK_FUNCS( futimes wcwidth wcswidth wcstok fputwc fgetwc )
|
||||
AC_CHECK_FUNCS( wcstol dcgettext wcslcat wcslcpy lrand48_r killpg)
|
||||
|
||||
|
||||
#
|
||||
# The Makefile also needs to know if we have gettext, so it knows if
|
||||
# the translations should be installed.
|
||||
#
|
||||
|
||||
AC_CHECK_FUNC( gettext, AC_SUBST( HAVE_GETTEXT, 1 ), AC_SUBST( HAVE_GETTEXT, 0 ) )
|
||||
|
||||
#
|
||||
# Here follows a list of small programs used to test for various
|
||||
# features that Autoconf doesn't tell us about
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
# 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 if struct winsize and TIOCGWINSZ exist
|
||||
#
|
||||
|
||||
AC_MSG_CHECKING([if struct winsize and TIOCGWINSZ exist])
|
||||
AC_LINK_IFELSE(
|
||||
[
|
||||
AC_LANG_PROGRAM(
|
||||
[
|
||||
#ifdef HAVE_SYS_TERMIOS_H
|
||||
#include <sys/termios.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_IOCTL_H
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
],
|
||||
[
|
||||
struct winsize termsize = {0};
|
||||
TIOCGWINSZ;
|
||||
]
|
||||
)
|
||||
],
|
||||
[
|
||||
AC_MSG_RESULT(yes);
|
||||
AC_DEFINE([HAVE_WINSIZE], [1], [Define to 1 if the winsize struct and TIOCGWINSZ macro exist])
|
||||
],
|
||||
[
|
||||
AC_MSG_RESULT(no)
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# If we have a fwprintf in libc, test that it actually works. As of
|
||||
# March 2006, it is broken under Dragonfly BSD.
|
||||
#
|
||||
|
||||
if test "$ac_cv_func_fwprintf" = yes; then
|
||||
|
||||
AC_MSG_CHECKING([if fwprintf is broken])
|
||||
AC_RUN_IFELSE(
|
||||
[
|
||||
AC_LANG_PROGRAM(
|
||||
[
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <locale.h>
|
||||
#include <wchar.h>
|
||||
],
|
||||
[
|
||||
setlocale( LC_ALL, "" );
|
||||
fwprintf( stderr, L"%ls%ls", L"", L"fish:" );
|
||||
]
|
||||
)
|
||||
],
|
||||
[
|
||||
AC_MSG_RESULT(no)
|
||||
],
|
||||
[
|
||||
AC_MSG_RESULT([yes])
|
||||
AC_DEFINE([HAVE_BROKEN_FWPRINTF], [1], [Define to 1 one if the implemented fwprintf is broken])
|
||||
]
|
||||
)
|
||||
|
||||
fi
|
||||
|
||||
|
||||
# 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
|
||||
|
||||
AC_CHECK_LIB(socket, connect)
|
||||
AC_CHECK_LIB(rt, nanosleep)
|
||||
# Check if getopt_long exists and works
|
||||
AC_MSG_CHECKING([if getopt_long exists and works])
|
||||
AC_TRY_LINK(
|
||||
[
|
||||
#if HAVE_GETOPT_H
|
||||
#include <getopt.h>
|
||||
#endif
|
||||
],
|
||||
[
|
||||
static struct option
|
||||
long_options[] =
|
||||
{
|
||||
0, 0, 0, 0
|
||||
}
|
||||
;
|
||||
int opt = getopt_long( 0,
|
||||
0,
|
||||
0,
|
||||
long_options,
|
||||
0 );
|
||||
|
||||
],
|
||||
have_working_getopt_long=yes,
|
||||
have_working_getopt_long=no
|
||||
)
|
||||
if test "$have_working_getopt_long" = yes; then
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(
|
||||
[HAVE_WORKING_GETOPT_LONG],
|
||||
[1],
|
||||
[Define to 1 if getopt_long exists and works.]
|
||||
)
|
||||
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])])
|
||||
# Check if del_curterm is broken - in that case we redefine
|
||||
# del_curterm as a no-op, to avoid a double-free
|
||||
|
||||
#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_MSG_CHECKING([If del_curterm is broken])
|
||||
case $target_os in
|
||||
*bsd*)
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(
|
||||
[HAVE_BROKEN_DEL_CURTERM],
|
||||
[1],
|
||||
[del_curterm is broken, redefine it to a no-op to avoid a double-free bug]
|
||||
)
|
||||
;;
|
||||
*)
|
||||
AC_MSG_RESULT(no)
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_CONFIG_FILES([Makefile fish.spec doc_src/fish.1 doc_src/Doxyfile init/fish])
|
||||
# Tell the world what we know
|
||||
AC_CONFIG_FILES([Makefile fish.spec doc_src/Doxyfile seq])
|
||||
AC_OUTPUT
|
||||
|
||||
if test ! x$local_found_posix_switch = xyes; then
|
||||
echo "Can't find a combination of switches to enable common extensions like detecting window size."
|
||||
echo "Some fish features may be disabled."
|
||||
fi
|
||||
|
||||
echo "fish is now configured."
|
||||
echo "Use 'make' and 'make install' to build and install fish."
|
||||
|
||||
|
||||
2
count.c
2
count.c
@@ -2,6 +2,8 @@
|
||||
The length command, used for determining the number of items in an
|
||||
environment variable array.
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
121
create_wajig_completions.py
Executable file
121
create_wajig_completions.py
Executable file
@@ -0,0 +1,121 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- python -*-
|
||||
|
||||
# Program to generate fish completion function for wajig.
|
||||
# It runs 'wajig command' and analyzes the output to build a
|
||||
# completion file which it writes to stdout.
|
||||
# To use the result, direct stdout to
|
||||
# ~/.fish.d/completions/wajig.fish.
|
||||
|
||||
# Author Reuben Thomas, from Don Rozenberg's bash_completion.py and
|
||||
# fish's apt-get.fish.
|
||||
|
||||
import os
|
||||
import re
|
||||
import pprint
|
||||
pp = pprint.PrettyPrinter()
|
||||
|
||||
def escape_quotes(s):
|
||||
return re.sub('\'', '\\\'', s)
|
||||
|
||||
# Run wajig command
|
||||
f = os.popen('wajig commands', 'r')
|
||||
|
||||
lines = f.readlines()
|
||||
|
||||
option_patt = r'^-([a-z]*)\|--([a-z]*) +([^ ].*)'
|
||||
option_patt_r = re.compile(option_patt)
|
||||
|
||||
command_patt = r'^([a-z-]*) +([^ ].*)'
|
||||
command_patt_r = re.compile(command_patt)
|
||||
|
||||
os_str = []
|
||||
os_str.append('')
|
||||
ol_str = []
|
||||
ol_str.append('')
|
||||
oh_str = []
|
||||
oh_str.append('')
|
||||
o_i = 0
|
||||
|
||||
c_str = []
|
||||
c_str.append('')
|
||||
ch_str = []
|
||||
ch_str.append('')
|
||||
c_i = 0
|
||||
|
||||
for l in lines:
|
||||
l = l.strip()
|
||||
if l == '' or l.find(':') > -1 or l.find('Run') == 0:
|
||||
continue
|
||||
if l.find('-') == 0:
|
||||
mo = option_patt_r.search(l)
|
||||
if mo == None:
|
||||
continue
|
||||
os_str[o_i] = mo.group(1)
|
||||
os_str.append('')
|
||||
ol_str[o_i] = mo.group(2)
|
||||
ol_str.append('')
|
||||
oh_str[o_i] = escape_quotes(mo.group(3))
|
||||
oh_str.append('')
|
||||
o_i += 1
|
||||
else:
|
||||
mo = command_patt_r.search(l)
|
||||
if mo == None:
|
||||
continue
|
||||
c_str[c_i] = mo.group(1)
|
||||
c_str.append('')
|
||||
ch_str[c_i] = escape_quotes(mo.group(2))
|
||||
ch_str.append('')
|
||||
c_i += 1
|
||||
|
||||
# For debugging, print the commands and options.
|
||||
#print
|
||||
#pp.pprint(c_str)
|
||||
|
||||
#print
|
||||
#pp.pprint(os_str)
|
||||
#print
|
||||
#pp.pprint(ol_str)
|
||||
|
||||
part1 = '''function __fish_wajig_no_subcommand -d (N_ 'Test if wajig has yet to be given the subcommand')
|
||||
for i in (commandline -opc)
|
||||
if contains -- $i'''
|
||||
|
||||
part2 = '''
|
||||
return 1
|
||||
end
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
function __fish_wajig_use_package -d (N_ 'Test if wajig command should have packages as potential completion')
|
||||
for i in (commandline -opc)
|
||||
if contains -- $i contains bug build build-depend changelog dependents describe detail hold install installr installrs installs list list-files news package purge purge-depend readme recursive recommended reconfigure reinstall remove remove-depend repackage show showinstall showremove showupgrade size sizes source suggested unhold upgrade versions whatis
|
||||
return 0
|
||||
end
|
||||
end
|
||||
return 1
|
||||
end
|
||||
|
||||
complete -c wajig -n '__fish_wajig_use_package' -a '(__fish_print_packages)' -d (N_ 'Package')'''
|
||||
|
||||
wajig = part1
|
||||
|
||||
#add the commands.
|
||||
for i in range(0, len(c_str) - 1):
|
||||
wajig = "%s %s" % (wajig, c_str[i])
|
||||
|
||||
#add part2
|
||||
wajig = "%s%s" % (wajig, part2)
|
||||
|
||||
#add the options.
|
||||
wajig = "%s%s" % (wajig, os_str[0].lstrip())
|
||||
for i in range(1, len(os_str) - 1):
|
||||
wajig = "%s\ncomplete -c apt-get -s %s -l %s -d (N_ '%s')" % (wajig, os_str[i], ol_str[i], oh_str[i])
|
||||
|
||||
#add the commands.
|
||||
for i in range(0, len(c_str) - 1):
|
||||
wajig = "%s\ncomplete -f -n '__fish_wajig_no_subcommand' -c wajig -a '%s' -d(N_ '%s')" % (wajig, c_str[i], ch_str[i])
|
||||
|
||||
#print it all
|
||||
print wajig
|
||||
@@ -1,23 +1,27 @@
|
||||
|
||||
\section and and - Conditionally execute a command
|
||||
\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 0.
|
||||
|
||||
The and command does not change the current exit status.
|
||||
|
||||
The exit status of the last foreground command to exit can always be
|
||||
accessed using the <a href="index.html#variables-status">$status</a>
|
||||
variable.
|
||||
|
||||
\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.
|
||||
<pre>
|
||||
and make; 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
|
||||
The following code runs the \c make command to build a program, if the
|
||||
build succceds, the program is installed. If either step fails,
|
||||
<tt>make clean</tt> is run, which removes the files created by the
|
||||
build process
|
||||
|
||||
<pre>
|
||||
or and make; make install; make clean
|
||||
make; and make install; or make clean
|
||||
</pre>
|
||||
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
|
||||
\section begin begin - Start a new block of code
|
||||
\section begin begin - start a new block of code
|
||||
|
||||
\subsection begin-synopsis Synopsis
|
||||
<tt>begin; [COMMAND;...] end </tt>
|
||||
<tt>begin; [COMMANDS...;] end</tt>
|
||||
|
||||
\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
|
||||
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
|
||||
commands as a group.
|
||||
is unconditionally executed. <code>begin; ...; end</tt> is equivalent
|
||||
to <tt>if true; ...; end</tt>. The begin command is used to group any
|
||||
number of commands into a block. The reason for doing so is usually
|
||||
either to introduce a new variable scope, to redirect the input or
|
||||
output of a set of commands as a group, or to specify precedence when
|
||||
using the conditional commands like \c and.
|
||||
|
||||
The \c begin command does not change the current exit status.
|
||||
|
||||
\subsection begin-example Example
|
||||
|
||||
@@ -28,3 +30,17 @@ end
|
||||
# the block and was killed
|
||||
echo $PIRATE
|
||||
</pre>
|
||||
|
||||
In the following code, all output is redirected to the file out.html.
|
||||
|
||||
<pre>
|
||||
begin
|
||||
echo $xml_header
|
||||
echo $html_header
|
||||
if test -e $file
|
||||
...
|
||||
end
|
||||
...
|
||||
|
||||
end > out.html
|
||||
</pre>
|
||||
|
||||
@@ -1,14 +1,21 @@
|
||||
\section bind bind - Handle key bindings.
|
||||
\section bind bind - handle key bindings
|
||||
|
||||
\subsection bind-synopsis Synopsis
|
||||
<tt>bind [OPTIONS] [BINDINGS...] </tt>
|
||||
<tt>bind [OPTIONS] [BINDINGS...]</tt>
|
||||
|
||||
The <tt>bind</tt> builtin causes fish to add the readline style bindings specified by <tt>BINDINGS</tt> to the list of key bindings. For more information on specifying keyboard bindings, use <tt>man readline</tt> to access the readline documentation.
|
||||
The <tt>bind</tt> builtin causes fish to add the readline style bindings specified by BINDINGS to the list of key bindings, as if they appeared in your <tt>~/.fish_inputrc</tt> file.
|
||||
|
||||
For more information on the syntax keyboard bindings, use <tt>man
|
||||
readline</tt> to access the readline documentation. The availiable commands
|
||||
are listed in the <a href="index.html#editor">Command Line Editor</a> section
|
||||
of the fish manual - but you may also use any fish command! To write such
|
||||
commands, see the <a href="#commandline">commandline</a> builtin. It's good
|
||||
practice to put the code into a <tt><a href="#function">function</a> -b</tt>
|
||||
and bind to the function name.
|
||||
|
||||
\subsection bind-description Description
|
||||
- <tt>-M MODE</tt> or <tt>--set-mode=MODE</tt> sets the current input mode to MODE.
|
||||
|
||||
|
||||
\subsection bind-example Example
|
||||
|
||||
<tt>bind -M vi</tt> changes to the vi input mode
|
||||
|
||||
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>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
\section break break - stop the innermost currently evaluated loop
|
||||
|
||||
\subsection break-synopsis Synopsis
|
||||
@@ -8,14 +7,13 @@
|
||||
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.
|
||||
<p>
|
||||
<tt>for i in *.c;
|
||||
<br> if grep smurf $i;
|
||||
<br> echo Smurfs are present in $i;
|
||||
<br> break;
|
||||
<br> end;
|
||||
<br>end;
|
||||
</tt>
|
||||
</p>
|
||||
The following code searches all .c files for smurfs, and halts at the first occurrence.
|
||||
|
||||
<pre>
|
||||
for i in *.c
|
||||
if grep smurf $i
|
||||
echo Smurfs are present in $i
|
||||
break
|
||||
end
|
||||
end
|
||||
</pre>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
\section builtin builtin - run a builtin command
|
||||
|
||||
\subsection builtin-synopsis Synopsis
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
\section case case - conditionally execute a block of commands
|
||||
|
||||
\subsection case-synopsis Synopsis
|
||||
<tt>switch VALUE; [case [WILDCARD...]; [COMMANDS...];...] end</tt>
|
||||
<tt>switch VALUE; [case [WILDCARD...]; [COMMANDS...]; ...] end</tt>
|
||||
|
||||
\subsection case-description Description
|
||||
|
||||
@@ -11,25 +11,42 @@ wildcarded values. The \c case statement is used together with the \c
|
||||
switch statement in order to determine which block should be
|
||||
performed.
|
||||
|
||||
Each \c case command is given one or more parameter. The first \c case
|
||||
command with a parameter that matches the string specified in the
|
||||
switch command will be evaluated. \c case parameters may contain
|
||||
wildcards. These need to be escaped or quoted in order to avoid
|
||||
regular wildcard expansion using filenames.
|
||||
|
||||
Note that fish does not fall through on case statements. Though the
|
||||
syntax may look a bit like C switch statements, it behaves more like
|
||||
the case stamantes of traditional shells.
|
||||
|
||||
Also note that command substitutions in a case statement will be
|
||||
evaluated even if it's body is not taken. This may seem
|
||||
counterintuitive at first, but it is unavoidable, since it would be
|
||||
impossible to know if a case command will evaluate to true before all
|
||||
forms of parameter expansion have been performed for the case command.
|
||||
|
||||
\subsection case-example Example
|
||||
|
||||
If the variable \$animal contains the name of an animal, the following
|
||||
code would attempt to classify it:
|
||||
|
||||
<p>
|
||||
<pre>
|
||||
switch $animal
|
||||
case cat
|
||||
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
|
||||
case '*'
|
||||
echo I have no idea what a $animal is
|
||||
end
|
||||
</pre>
|
||||
</p>
|
||||
<p>
|
||||
If the above code was run with \$animal set to \c whale, the output would be \c mammal.
|
||||
</p>
|
||||
|
||||
If the above code was run with \c \$animal set to \c whale, the output
|
||||
would be \c mammal.
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
\section commandline commandline - Set or get the current commandline buffer
|
||||
\section commandline commandline - set or get the current commandline buffer
|
||||
|
||||
\subsection commandline-synopsis Synopsis
|
||||
<tt>commandline [OPTIONS] [CMD]</tt>
|
||||
@@ -9,8 +9,22 @@
|
||||
- \c CMD is the new value of the commandline. If unspecified, the
|
||||
current value of the commandline is written to standard output.
|
||||
|
||||
The following switches change what the commandline builtin does
|
||||
|
||||
- \c -C or \c --cursor set or get the current cursor position, not
|
||||
the contents of the buffer. If no argument is given, the current
|
||||
cursor position is printed, otherwise the argument is interpreted
|
||||
as the new cursor position.
|
||||
- \c -f or \c --function inject readline functions into the
|
||||
reader. This option can not be combined with any other option. It
|
||||
will cause any additional arguments to be interpreted as readline
|
||||
functions, and these functions will be injected into the reader, so
|
||||
that they will be returned to the reader before any additional
|
||||
actual keypresses are read.
|
||||
|
||||
|
||||
The following switches change the way \c commandline updates the
|
||||
commandline
|
||||
commandline buffer
|
||||
|
||||
- \c -a or \c --append do not remove the current commandline, append
|
||||
the specified string at the end of it
|
||||
@@ -25,23 +39,19 @@ 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
|
||||
commandline buffer
|
||||
|
||||
- \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
|
||||
|
||||
- \c -f or \c --function inject readline functions into the
|
||||
reader. This option can not be combined with any other option. It
|
||||
will cause any additional arguments to be interpreted as readline
|
||||
functions, and these functions will be injected into the reader, so
|
||||
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
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
23
doc_src/contains.txt
Normal file
23
doc_src/contains.txt
Normal file
@@ -0,0 +1,23 @@
|
||||
\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.
|
||||
@@ -1,20 +1,19 @@
|
||||
|
||||
\section continue continue - skip the rest of the current lap of the innermost currently evaluated loop
|
||||
|
||||
\subsection continue-synopsis Synopsis
|
||||
<tt>LOOP_CONSTRUCT; [COMMANDS...] continue; [COMMANDS...] end</tt>
|
||||
<tt>LOOP_CONSTRUCT; [COMMANDS...;] continue; [COMMANDS...;] end</tt>
|
||||
|
||||
\subsection continue-description Description
|
||||
The \c continue builtin is used to skip the current lap of the innermost 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 continue-example Example
|
||||
The following code removes all tmp files without smurfs.
|
||||
<p>
|
||||
<tt>for i in *.tmp;
|
||||
<br> if grep smurf $i;
|
||||
<br> continue;
|
||||
<br> end;
|
||||
<br> rm $i;
|
||||
<br>end;
|
||||
</tt>
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
for i in *.tmp
|
||||
if grep smurf $i
|
||||
continue
|
||||
end
|
||||
rm $i
|
||||
end
|
||||
</pre>
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
|
||||
\section count count - Count the number of elements of an array
|
||||
\section count count - count the number of elements of an array
|
||||
|
||||
\subsection count-synopsis Synopsis
|
||||
<tt>count $VARIABLE</tt>
|
||||
|
||||
\subsection count-description Description
|
||||
|
||||
<tt>count</tt> returns the number of arguments that were passed to
|
||||
<tt>count</tt> prints the number of arguments that were passed to
|
||||
it. This is usually used to find out how many elements an environment
|
||||
variable array contains, but this is not the only potential usage for
|
||||
the count command.
|
||||
@@ -16,7 +15,10 @@ 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.
|
||||
|
||||
Count exits with a non-zero exit status if no arguments where passed
|
||||
to it, with zero otherwise.
|
||||
|
||||
\subsection count-example Example
|
||||
|
||||
|
||||
155
doc_src/design.hdr
Normal file
155
doc_src/design.hdr
Normal file
@@ -0,0 +1,155 @@
|
||||
/** \page design Design document
|
||||
|
||||
\section design-overview Overview
|
||||
|
||||
This is a description of the design principles that have been used to
|
||||
design fish. The fish design has three high level goals. These are:
|
||||
|
||||
-# Everything that can be done in other shell languages should be
|
||||
possible to do in fish, though fish may rely on external commands in
|
||||
doing so.
|
||||
-# Fish should be user friendly, but not at the expense of expressiveness.
|
||||
Most tradeoffs between power and ease of use can be avoided with careful design.
|
||||
-# Whenever possible without breaking the above goals, fish should
|
||||
follow the Posix syntax.
|
||||
|
||||
To achive these high-level goals, the fish design relies on a number
|
||||
of more specific design principles. These are presented below,
|
||||
together with a rationale and a few examples for each.
|
||||
|
||||
\section ortho The law of orthogonality
|
||||
|
||||
The shell language should have a small set of orthogonal features. Any
|
||||
situation where two features are related but not identical, one of them
|
||||
should be removed, and the other should be made powerful and general
|
||||
enough to handle all common use cases of either feature.
|
||||
|
||||
Rationale:
|
||||
|
||||
Related features make the language larger, which makes it harder to
|
||||
learn. It also increases the size of the sourcecode, making the
|
||||
program harder to maintain and update.
|
||||
|
||||
Examples:
|
||||
|
||||
- Here documents are too similar to using echo inside of a pipeline.
|
||||
- Subshells, command substitution and process substitution are strongly related. \c fish only supports command substitution, the others can be achived either using a block or the psub shellscript function.
|
||||
- Having both aliases and functions is confusing, especially since both of them have limitations and problems. \c fish functions have none of the drawbacks of either syntax.
|
||||
- The many Posix quoting styles are silly, especially \$''.
|
||||
|
||||
|
||||
\section sep The law of minimalism
|
||||
|
||||
The shell should only contain features that cannot be implemented in
|
||||
a reasonable way outside of the shell. A large performance decrease,
|
||||
as well as some program complexity increase is acceptable in order to
|
||||
improve separation.
|
||||
|
||||
Rationale:
|
||||
|
||||
A modular project is easier to maintain since smaller programs are far
|
||||
easier to understand than larger ones. A modular project is also more
|
||||
future proof since the modules can be individually
|
||||
replaced. Modularity also decreases the severity of bugs, since there
|
||||
is good hope that a bug, even a serious one, in one module, does not
|
||||
take the whole system down.
|
||||
|
||||
Examples:
|
||||
|
||||
- Builtin commands should only be created when it cannot be
|
||||
avoided. \c echo, \c kill, \c printf and \c time are among the commands
|
||||
that fish does not implement internally since they can be provided as
|
||||
external commands. Several other commands that are commonly implemented
|
||||
as builtins and can not be implemented as external commands,
|
||||
including \c type, \c vared, \c pushd and \c popd are implemented as shellscript
|
||||
functions in fish.
|
||||
- Mathematical calculations, regex matching, generating lists of numbers
|
||||
and many other funtions can easily be done in external programs. They
|
||||
should not be supported internally by the shell.
|
||||
|
||||
The law of minimalism does not imply that a large feature set is
|
||||
bad. So long as a feature is not part of the shell itself, but a
|
||||
separate command or at least a shellscript function, bloat is fine.
|
||||
|
||||
\section conf Configurability is the root of all evil
|
||||
|
||||
Every configuration option in a program is a place where the program
|
||||
is too stupid to figure out for itself what the user really wants, and
|
||||
should be considered a failiure of both the program and the programmer
|
||||
who implemented it.
|
||||
|
||||
Rationale:
|
||||
|
||||
Different configuration options are a nightmare to maintain, since the
|
||||
number of potential bugs caused by specific configuration combinations
|
||||
quickly becomes an issue. Configuration options often imply
|
||||
assumptions about the code which change when reimplementing the code,
|
||||
causing issues with backwards compatibility. But mostly, configuration
|
||||
options should be avoided since they simply should not exist, as the
|
||||
program should be smart enough to do what is best, or at least a good
|
||||
enough approximation of it.
|
||||
|
||||
Examples:
|
||||
|
||||
- Fish allows the user to set various syntax highlighting colors. This is needed because fish does not know what colors the terminal uses by default, which might make some things unreadable. The proper solution would be for text color preferences to be defined centrally by the user for all programs, and for the terminal emulator to send these color properties to fish.
|
||||
- Fish does not allow you to set the history filename, the number of history entries, different language substyles or any number of other common shell configuration options.
|
||||
|
||||
A special note on the evils of configurability is the long list of
|
||||
very useful features found in some shells, that are not turned on by
|
||||
default. Both zsh and bash support command specific completions, but
|
||||
no such completions are shipped with bash by default, and they are
|
||||
turned of by default in zsh. Other features that zsh support that are
|
||||
disabled by default include tab-completion of strings containing
|
||||
wildcards, a sane completion pager and a history file.
|
||||
|
||||
\section user The law of user focus
|
||||
|
||||
When designing a program, one should first think about how to make a
|
||||
intuitive and powerful program. Implementation issues should only be
|
||||
considered once a user interface has been designed.
|
||||
|
||||
Rationale:
|
||||
|
||||
This design rule is different than the others, since it describes how
|
||||
one should go about designing new features, not what the features
|
||||
should be. The problem with focusing on what can be done, and what is
|
||||
easy to do, is that to much of the implementation is exposed. This
|
||||
means that the user must know a great deal about the underlying system
|
||||
to be able to guess how the shell works, it also means that the
|
||||
language will often be rather low-level.
|
||||
|
||||
Examples:
|
||||
|
||||
- There should only be one type of input to the shell, lists of commands. Loops, conditionals and variable assignments are all performed through regular commands.
|
||||
- The differences between builtin commands, shellscript functions and builtin commands should be made as small as possible. Builtins and shellscript functions should have exactly the same types of argument expansion as other commands, should be possible to use in any position in a pipeline, and should support any io redirection.
|
||||
- Instead of forking when performing command substitution to provide a fake variable scope, all fish commands are performed from the same process, and fish instead supports true scoping
|
||||
- All blocks end with the \c end builtin
|
||||
|
||||
\section disc The law of discoverability
|
||||
|
||||
A program should be designed to make its features as
|
||||
easy as possible to discover for the user.
|
||||
|
||||
Rationale:
|
||||
|
||||
A program whose features are discoverable turns a new user into an
|
||||
expert in a shorter span of time, since the user will become an expert
|
||||
on the program simply by using it.
|
||||
|
||||
The main benefit of a graphical program over a command line-based
|
||||
program is discoverability. In a graphical program, one can discover
|
||||
all the common features by simply looking at the user interface and
|
||||
guessing what the different buttons, menus and other widgets do. The
|
||||
traditional way to discover features in commandline programs is
|
||||
through manual pages. This requires both that the user starts to use a
|
||||
different program, and the she/he then remembers the new information
|
||||
until the next time she/he uses the same program.
|
||||
|
||||
Examples:
|
||||
|
||||
- Everything should be tab-completable, and every tab completion should have a description
|
||||
- Every syntax error and error in a builtin command should contain an error message describing what went wrong and a relevant help page. Whenever possible, errors should be flagged red by the syntax highlighter.
|
||||
- The help manual should be easy to read, easily available from the shell, complete and contain many examples
|
||||
- The language should be uniform, so that once the user understands the command/argument syntax, he will know the whole language, and be able to use tab-completion to discover new featues.
|
||||
|
||||
*/
|
||||
@@ -1,4 +1,4 @@
|
||||
\section dirh dirh
|
||||
\section dirh dirh - print directory history
|
||||
|
||||
\subsection dirh-synopsis Synopsis
|
||||
<tt>dirh</tt>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
\section dirs dirs
|
||||
\section dirs dirs - print directory stack
|
||||
|
||||
\subsection dirs-synopsis Synopsis
|
||||
<tt>dirs</tt>
|
||||
|
||||
1854
doc_src/doc.hdr
1854
doc_src/doc.hdr
File diff suppressed because it is too large
Load Diff
@@ -1,13 +1,13 @@
|
||||
\section else else - execute command if a condition is not met.
|
||||
\section else else - execute command if a condition is not met
|
||||
|
||||
\subsection else-synopsis Synopsis
|
||||
<tt>if CONDITION; COMMAND_TRUE [else; COMMAND_FALSE] end;</tt>
|
||||
<tt>if CONDITION; COMMANDS_TRUE...; [else; COMMANDS_FALSE...;] end</tt>
|
||||
|
||||
\subsection else-description Description
|
||||
<tt>if</tt> will execute the command CONDITION. If the commands exit
|
||||
status is zero, the command COMMAND_TRUE will execute. If it is
|
||||
not zero and COMMAND_FALSE is specified, COMMAND_FALSE will be
|
||||
executed.
|
||||
<tt>if</tt> will execute the command CONDITION. If the condition's exit
|
||||
status is 0, the commands COMMANDS_TRUE will execute. If it is not 0 and
|
||||
<tt>else</tt> is given, COMMANDS_FALSE will be executed. Hint: use
|
||||
<a href="#begin"><tt>begin; ...; end</tt></a> for complex conditions.
|
||||
|
||||
\subsection else-example Example
|
||||
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
\section end end - end a block of commands.
|
||||
|
||||
\subsection end-synopsis Synopsis
|
||||
<pre>for VARNAME in [VALUES...]; COMMANDS; end
|
||||
if CONDITION; COMMAND_TRUE [else; COMMAND_FALSE] end
|
||||
while CONDITION; COMMANDS; end
|
||||
switch VALUE; [case [WILDCARD...]; [COMMANDS...];...] end
|
||||
<pre>
|
||||
begin; [COMMANDS...] end
|
||||
if CONDITION; COMMANDS_TRUE...; [else; COMMANDS_FALSE...;] end
|
||||
while CONDITION; COMMANDS...; end
|
||||
for VARNAME in [VALUES...]; COMMANDS...; end
|
||||
switch VALUE; [case [WILDCARD...]; [COMMANDS...]; ...] end
|
||||
</pre>
|
||||
|
||||
\subsection end-description Description
|
||||
<tt>end</tt> ends a block of commands. For more information, read the
|
||||
documentation for the block constructs, such as \c if, \c for and \
|
||||
documentation for the block constructs, such as \c if, \c for and \c
|
||||
while.
|
||||
|
||||
The \c end command does not change the current exit status.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
\section exec exec - Execute command in current process
|
||||
\section exec exec - execute command in current process
|
||||
|
||||
\subsection exec-synopsis Synopsis
|
||||
<tt>exec COMMAND [OPTIONS...]</tt>
|
||||
@@ -7,8 +6,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
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
|
||||
The <tt>exit</tt> builtin causes fish to exit. If <tt>STATUS</tt> is
|
||||
supplied, it will be converted to an integer and used as the exit
|
||||
code. Otherwise the exit code will be 0.
|
||||
code. Otherwise the exit code will be that of the last command executed.
|
||||
|
||||
If exit is called while sourcing a file (using the <a
|
||||
href="#source">.</a> builtin) the rest of the file will be skipped,
|
||||
but the shell will not exit.
|
||||
but the shell itself will not exit.
|
||||
|
||||
136
doc_src/faq.hdr
Normal file
136
doc_src/faq.hdr
Normal file
@@ -0,0 +1,136 @@
|
||||
/** \page faq Frequently asked questions
|
||||
|
||||
- <a href='#faq-cwd-symlink'>Why does cd, pwd and other fish commands always resolve symlinked directories to their canonical path?</a>
|
||||
- <a href='#faq-cd-autocomplete'>Why does the cd command autocompletion list the subdirectories of my home directory as completions?</a>
|
||||
- <a href='#faq-cd-implicit'>I accidentally entered a directory path and fish changed directory. What happened?</a>
|
||||
- <a href='#faq-open'>The open command doesn't work.</a>
|
||||
- <a href='#faq-default'>How do I make fish my default shell?</a>
|
||||
- <a href='#faq-titlebar'>I'm seeing weird output before each prompt when using screen. What's wrong?</a>
|
||||
- <a href='#faq-greeting'>How do I change the greeting message?</a>
|
||||
|
||||
<hr>
|
||||
|
||||
\section faq-cwd-symlink Why does cd, $PWD and and various fish commands always resolve symlinked directories to their canonical path?
|
||||
|
||||
<i>
|
||||
For example if ~/images is a symlink to ~/Documents/Images, if I write
|
||||
'cd images', my prompt will say ~/D/Images, not ~/images.
|
||||
</i>
|
||||
|
||||
Because it is impossible to consistently keep symlinked directories
|
||||
unresolved. It is indeed possible to do this partially, and many other
|
||||
shells do so. But it was felt there are enough serious corner cases
|
||||
that this is a bad idea. Most such issues have to do with how '..' is
|
||||
handled, and are varitations of the following example:
|
||||
|
||||
Writing <code>cd images; ls ..</code> given the above directory
|
||||
structure would list the contents of ~/Documents, not of ~, even
|
||||
though using <code>cd ..</code> changes the current direcotry to ~,
|
||||
and the prompt, the pwd builtin and many other directory information
|
||||
sources suggest that the the current directory is ~/images and it's
|
||||
parent is ~. This issue is not possible to fix without either making
|
||||
every single command into a builtin, breaking Unix semantics or
|
||||
implementing kludges in every single command.
|
||||
|
||||
This issue can also be seen when doing IO redirection.
|
||||
|
||||
Another related issue is that many programs that operate on recursive
|
||||
directory trees, like the find command, silently ignore symlinked
|
||||
directories. For example, <code>find $PWD -name '*.txt'</code>
|
||||
silently fails in shells that don't resolve symlinked paths.
|
||||
|
||||
<hr>
|
||||
|
||||
\section faq-cd-autocomplete Why does the cd command autocompletion list the subdirectories of my home directory as completions?
|
||||
|
||||
Because they are completions. In fish, if you specify a relative
|
||||
directory to the cd command, i.e. any path that does not start with
|
||||
either './' or '/', the environment variable CDPATH will be examined, and any
|
||||
directories in this path is used as a base direcotry. To disable this
|
||||
feature, write <code>set CDPATH .</code> on the commandline.
|
||||
|
||||
<hr>
|
||||
|
||||
\section faq-cd-implicit I accidentally entered a directory path and fish changed directory. What happened?
|
||||
|
||||
If fish is unable to locate a command with a given name, fish will
|
||||
test if a directory of that name exists. If it does, it is implicitly
|
||||
assumed that you want to change working directory. For example, the
|
||||
fastest way to switch to your home directory is to simply type
|
||||
<code>~</code>.
|
||||
|
||||
<hr>
|
||||
|
||||
\section faq-open The open command doesn't work.
|
||||
|
||||
The open command uses the mimetype database and the .desktop files
|
||||
used by Gnome and KDE to identify filetypes and default actions. If
|
||||
at least one of these two desktops are installed, but the open command is
|
||||
not working, this probably means that the relevant files are installed
|
||||
in a nonstandard location. Please contact the <a
|
||||
href='mailto:fish-users@lists.sf.net'>fish mailing list</a>, and
|
||||
hopefully this can be resolved.
|
||||
|
||||
\section faq-default How do I make fish my default shell?
|
||||
|
||||
If you installed fish manually (e.g. by compiling it, not by using a
|
||||
package manager), you first need to add fish to the list of shells by
|
||||
executing the following command (assuming you installed fish in
|
||||
/usr/local) as root:
|
||||
|
||||
\section faq-titlebar I'm seeing weird output before each prompt when using screen. What's wrong?
|
||||
|
||||
Quick answer:
|
||||
|
||||
Run the following command in fish:
|
||||
|
||||
<pre>
|
||||
echo function fish_title;end ~/.config/fish/config.fish
|
||||
</pre>
|
||||
|
||||
Problem solved!
|
||||
|
||||
The long answer:
|
||||
|
||||
Fish is trying to set the titlebar message of your terminal. While
|
||||
screen itself supports this feature, your terminal does
|
||||
not. Unfortuntaly, when the underlying terminal doesn't support
|
||||
setting the titlebar, screen simply passes through the escape codes
|
||||
and text to the underlying terminal instead of ignoring them. It is
|
||||
impossible detect and resolve this problem from inside fish since fish
|
||||
has no way of knowing what the underlying terminal type is. For now,
|
||||
the only way to fix this is to unset the titlebar message, as
|
||||
suggested above.
|
||||
|
||||
Note that fish has a default titlebar message, which will be used if
|
||||
the fish_title function is undefined. So simply unsetting the
|
||||
fish_title function will not work.
|
||||
|
||||
|
||||
<code>echo /usr/local/bin/fish >>/etc/shells</code>
|
||||
|
||||
If you installed a prepackaged version of fish, the package manager
|
||||
should have already done this for you.
|
||||
|
||||
In order to change your default shell, type:
|
||||
|
||||
<code>chsh -s /usr/bin/fish</code>
|
||||
|
||||
You may need to adjust the above path to e.g. /usr/local/bin/fish.
|
||||
|
||||
You will need to log out and back in again for the change to take
|
||||
effect.
|
||||
|
||||
<hr>
|
||||
|
||||
\section faq-greeting How do I change the greeting message?
|
||||
|
||||
Change the value of the variable fish_greeting. For example, to remove
|
||||
the greeting use:
|
||||
|
||||
<pre>
|
||||
set fish_greeting
|
||||
</pre>
|
||||
|
||||
|
||||
*/
|
||||
23
doc_src/fish.txt
Normal file
23
doc_src/fish.txt
Normal file
@@ -0,0 +1,23 @@
|
||||
\section fish fish - the friendly interactive shell
|
||||
|
||||
\subsection fish-synopsis Synopsis
|
||||
fish [-h] [-v] [-c command] [FILE [ARGUMENTS...]]
|
||||
|
||||
\subsection fish-description Description
|
||||
|
||||
A commandline shell written mainly with interactive use in mind. The
|
||||
full manual is available <a href='index.html'>in html</a> by using the
|
||||
<a href='#help'>help</a> command from inside fish.
|
||||
|
||||
- <code>-c</code> or <code>--command=COMMANDS</code> evaluate the specified commands instead of reading from the commandline
|
||||
- <code>-d</code> or <code>--debug-level=DEBUG_LEVEL</code> specify the verbosity level of fish. A higher number means higher verbosity. The default level is 1.
|
||||
- <code>-h</code> or <code>--help</code> display help and exit
|
||||
- <code>-i</code> or <code>--interactive</code> specify that fish is to run in interactive mode
|
||||
- <code>-l</code> or <code>--login</code> specify that fish is to run as a login shell
|
||||
- <code>-n</code> or <code>--no-execute</code> do not execute any commands, only perform syntax checking
|
||||
- <code>-p</code> or <code>--profile=PROFILE_FILE</code> when fish exits, output timing information on all executed commands to the specified file
|
||||
- <code>-v</code> or <code>--version</code> display version and exit
|
||||
|
||||
The fish exit status is generally the exit status of the last
|
||||
foreground command. If fish is exiting because of a parse error, the
|
||||
exit status is 127.
|
||||
8
doc_src/fish_pager.txt
Normal file
8
doc_src/fish_pager.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
\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.
|
||||
|
||||
@@ -1,51 +1,31 @@
|
||||
|
||||
\section fishd fishd - Universal variable daemon
|
||||
\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
|
||||
data. The data is stored as a set of \c set and \c set_export commands
|
||||
such as would be parsed by fishd.
|
||||
\c ~/.config/fish/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. The file must always be
|
||||
stored in ASCII format. If an instance of fishd is running (which is
|
||||
generally the case), manual modifications to ~/.fishd.HOSTNAME will be
|
||||
lost. Do NOT edit this file manually!
|
||||
|
||||
\c /tmp/fishd.socket.USERNAME the socket which fishd uses to communicate
|
||||
with all clients.
|
||||
|
||||
/tmp/fishd.log.USERNAME the fishd log file
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
|
||||
\section for for - perform a set of commands multiple times.
|
||||
|
||||
\subsection for-synopsis Synopsis
|
||||
<tt>for VARNAME in [VALUES...]; [COMMANDS...]; end</tt>
|
||||
<tt>for VARNAME in [VALUES...]; COMMANDS...; end</tt>
|
||||
|
||||
\subsection for-description Description
|
||||
<tt>for</tt> is a loop construct. It will perform the commands specified
|
||||
by <tt>COMMANDS</tt> multiple times. Each time the environment variable
|
||||
specified by <tt>VARNAME</tt> is assigned a new value from <tt>VALUES</tt>.
|
||||
<tt>for</tt> is a loop construct. It will perform the commands specified by
|
||||
COMMANDS multiple times. Each time the environment variable specified by
|
||||
VARNAME is assigned a new value from VALUES. If VALUES is empty, COMMANDS will
|
||||
not be executed at all.
|
||||
|
||||
\subsection for-example Example
|
||||
|
||||
@@ -17,7 +17,9 @@ The command
|
||||
|
||||
would output:
|
||||
|
||||
<pre>foo
|
||||
<pre>
|
||||
foo
|
||||
bar
|
||||
baz</pre>
|
||||
baz
|
||||
</pre>
|
||||
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
\section function function - create a function
|
||||
|
||||
\subsection function-synopsis Synopsis
|
||||
<tt>function [OPTIONS] NAME; BODY; end </tt>
|
||||
<code>function [OPTIONS] NAME; BODY; end </code>
|
||||
|
||||
\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.
|
||||
- <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>-v</tt> or <tt>--on-variable VARIABLE_NAME</tt> tells fish to run this function when the variable VARIABLE_NAME changes value
|
||||
- <code>-d DESCRIPTION</code> or \c --description=DESCRIPTION is a description of what the function does, suitable as a completion description
|
||||
- <code>-j PID</code> or <code> --on-job-exit PID</code> tells fish to run this function when the job with group id PID exits. Instead of PID, the string 'caller' can be specified. This is only legal when in a command substitution, and will result in the handler being triggered by the exit of the job which created this command substitution.
|
||||
- <code>-p PID</code> or <code> --on-process-exit PID</code> tells fish to run this function when the fish child process with process id PID exits
|
||||
- <code>-s</code> or <code>--on-signal SIGSPEC</code> 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)
|
||||
- <code>-v</code> or <code>--on-variable VARIABLE_NAME</code> 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
|
||||
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.
|
||||
will write <code>hello</code> whenever the user enters \c hi.
|
||||
|
||||
If the user enters any additional arguments after the function, they
|
||||
are inserted into the environment variable <a href="index.html#variables-arrays">array</a> argv.
|
||||
are inserted into the environment <a href="index.html#variables-arrays">variable array</a> argv.
|
||||
|
||||
\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,17 +1,27 @@
|
||||
\section functions functions - print or erase functions
|
||||
|
||||
\subsection function-synopsis Synopsis
|
||||
<tt>functions [-e] FUNCTIONS...</tt>
|
||||
<code>functions [-e] FUNCTIONS...</code>
|
||||
|
||||
\subsection functions-description Description
|
||||
|
||||
This builtin command is used to print or erase functions.
|
||||
|
||||
- <tt>-e</tt> or <tt>--erase</tt> causes the specified functions to be erased.
|
||||
- <tt>-n</tt> or <tt>--names</tt> List only the names of all defined functions
|
||||
- <code>-a</code> or <code>--all</code> list all functions, even those whose name start with an underscore.
|
||||
- <code>-d DESCRIPTION</code> or <code>--description=DESCRIPTION</code> change the description of this function
|
||||
- <code>-e</code> or <code>--erase</code> causes the specified functions to be erased.
|
||||
- <code>-h</code> or <code>--help</code> display a help message and exit
|
||||
- <code>-n</code> or <code>--names</code> list only the names of all defined functions, not their definition
|
||||
- <code>-q</code> or <code>--query</code> test if the specified functions exist. Does not output anything, but the builtins exit status is the number of functions specified that were not defined.
|
||||
|
||||
If \c functions is called with no arguments, the names and definition
|
||||
of all functions are printed, otherwise, the specified function
|
||||
definitions will be printed.
|
||||
The default behavior of \c functions when called with no arguments,
|
||||
is to print the names and definitions of all defined functions. If any
|
||||
non-switch parameters are given, only the definition of the specified
|
||||
functions are printed.
|
||||
|
||||
Automatically loaded functions can not be removed using functions
|
||||
-e. Either remove the definition file or change the
|
||||
$fish_function_path variable to remove autoloaded functions.
|
||||
|
||||
The exit status of the functions builtin is the number functions
|
||||
specified in the argument list that do not exist.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
\section help help - Display fish documantation
|
||||
\section help help - display fish documentation
|
||||
|
||||
\subsection help-synopsis Synopsis
|
||||
<tt>help [SECTION]</tt>
|
||||
@@ -8,8 +7,11 @@
|
||||
|
||||
The \c help command is used to display a section of the fish help documentation.
|
||||
|
||||
If the BROWSER environment variable is set, it will be used to display
|
||||
the documentation, otherwise fish will search for a suitable browser.
|
||||
If the BROWSER environment variable is set, it will be used to display the
|
||||
documentation, otherwise fish will search for a suitable browser.
|
||||
|
||||
Note also that most builtin commands display their help in the terminal when
|
||||
given the <tt>--help</tt> option.
|
||||
|
||||
\subsection help-example Example
|
||||
|
||||
|
||||
@@ -1,13 +1,23 @@
|
||||
\section if if - Conditionally execute a command
|
||||
\section if if - conditionally execute a command
|
||||
|
||||
\subsection if-synopsis Synopsis
|
||||
<tt>if CONDITION; COMMAND_TRUE [else; COMMAND_FALSE] end;</tt>
|
||||
<tt>if CONDITION; COMMANDS_TRUE...; [else; COMMANDS_FALSE...;] end</tt>
|
||||
|
||||
\subsection if-description Description
|
||||
<tt>if</tt> will execute the command CONDITION. If the commands exit
|
||||
status is zero, the command COMMAND_TRUE will execute. If it is
|
||||
not zero and COMMAND_FALSE is specified, COMMAND_FALSE will be
|
||||
executed.
|
||||
|
||||
<tt>if</tt> will execute the command CONDITION. If the condition's
|
||||
exit status is 0, the commands COMMANDS_TRUE will execute. If the
|
||||
exit status is not 0 and <tt>else</tt> is given, COMMANDS_FALSE will
|
||||
be executed.
|
||||
|
||||
In order to use the exit status of mutiple commands as the condition
|
||||
of an if block, use <a href="#begin"><tt>begin; ...; end</tt></a> and
|
||||
the short circut commands <a href="commands.html#and">and</a> and <a
|
||||
href="commands.html#or">or</a>.
|
||||
|
||||
The exit status of the last foreground command to exit can always be
|
||||
accessed using the <a href="index.html#variables-status">$status</a>
|
||||
variable.
|
||||
|
||||
\subsection if-example Example
|
||||
|
||||
|
||||
1362
doc_src/index.hdr
Normal file
1362
doc_src/index.hdr
Normal file
File diff suppressed because it is too large
Load Diff
12
doc_src/isatty.txt
Normal file
12
doc_src/isatty.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
\section isatty isatty - test if the specidied file descriptor is a tty
|
||||
|
||||
\subsection isatty-synopsis Synopsis
|
||||
<tt>isatty [FILE DESCRIPTOR]</tt>
|
||||
|
||||
where FILE DESCRIPTOR may be either the number of a file descriptor, or one
|
||||
of the strings stdin, stdout and stderr.
|
||||
|
||||
If the specified file descriptor is a tty, the exit status of the
|
||||
command is zero, otherwise, it is non-zero.
|
||||
|
||||
|
||||
@@ -1,13 +1,21 @@
|
||||
\section jobs jobs - print currently running jobs
|
||||
|
||||
\subsection jobs-synopsis
|
||||
<tt>jobs</tt>
|
||||
<code>jobs [OPTIONS] [PID]</code>
|
||||
|
||||
\subsection jobs-description Description
|
||||
The <tt>jobs</tt> builtin causes fish to print a list of the currently
|
||||
running jobs and their status.
|
||||
The <code>jobs</code> builtin causes fish to print a list of the currently
|
||||
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:
|
||||
|
||||
- <code>-c</code> or <code>--command</code> print the command name for each process in jobs
|
||||
- <code>-g</code> or <code>--group</code> only print the group id of each job
|
||||
- <code>-h</code> or <code>--help</code> display a help message and exit
|
||||
- <code>-l</code> or <code>--last</code> only the last job to be started is printed
|
||||
- <code>-p</code> or <code>--pid</code> 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\%.
|
||||
|
||||
989
doc_src/license.hdr
Normal file
989
doc_src/license.hdr
Normal file
@@ -0,0 +1,989 @@
|
||||
/** \page license Licenses
|
||||
|
||||
Fish Copyright (C) 2005-2006 Axel Liljencrantz. Fish is released under
|
||||
the GNU General Public License, version 2. The license agreement is
|
||||
included below.
|
||||
|
||||
Fish contains code under the BSD license, namely versions of the
|
||||
two functions strlcat and strlcpy, modified for use with wide
|
||||
character strings. This code is copyrighted by Todd C. Miller. The
|
||||
license agreement is included below.
|
||||
|
||||
The XSel command, written and copyrighted by Conrad Parker, is
|
||||
distributed together with, and used by fish. It is released under the MIT
|
||||
license. The license agreement is included below.
|
||||
|
||||
The xdgmime library, written and copyrighted by Red Hat, Inc, is used
|
||||
by the mimedb command, which is a part of fish. It is released under
|
||||
the LGPL. The license agreement is included below.
|
||||
|
||||
Fish contains code from the glibc library, namely the wcstok
|
||||
function. This code is licensed under the LGPL. The license agreement
|
||||
is included below.
|
||||
|
||||
|
||||
<HR>
|
||||
|
||||
<H2><A NAME="SEC1" HREF="gpl.html#TOC1">GNU GENERAL PUBLIC LICENSE</A></H2>
|
||||
<P>
|
||||
Version 2, June 1991
|
||||
|
||||
</P>
|
||||
|
||||
<PRE>
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
</PRE>
|
||||
|
||||
|
||||
<H2><A NAME="SEC2" HREF="gpl.html#TOC2">Preamble</A></H2>
|
||||
|
||||
<P>
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
</P>
|
||||
<P>
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
</P>
|
||||
<P>
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
</P>
|
||||
<P>
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
</P>
|
||||
<P>
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
</P>
|
||||
<P>
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
</P>
|
||||
<P>
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
</P>
|
||||
<P>
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
|
||||
</P>
|
||||
|
||||
|
||||
<H2><A NAME="SEC3" HREF="gpl.html#TOC3">TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION</A></H2>
|
||||
|
||||
|
||||
<P>
|
||||
|
||||
<STRONG>0.</STRONG>
|
||||
This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
<P>
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
<P>
|
||||
|
||||
<STRONG>1.</STRONG>
|
||||
You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
<P>
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
<P>
|
||||
|
||||
<STRONG>2.</STRONG>
|
||||
You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
<P>
|
||||
|
||||
<DL>
|
||||
|
||||
<DT>
|
||||
<DD>
|
||||
<STRONG>a)</STRONG>
|
||||
You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
</DD>
|
||||
</DT>
|
||||
</DL>
|
||||
<P>
|
||||
<DL>
|
||||
<DT>
|
||||
<DD>
|
||||
<STRONG>b)</STRONG>
|
||||
You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
</DD>
|
||||
</DT>
|
||||
</DL>
|
||||
<P>
|
||||
<DL>
|
||||
<DT>
|
||||
<DD>
|
||||
<STRONG>c)</STRONG>
|
||||
If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
</DD>
|
||||
</DT>
|
||||
</DL>
|
||||
<P>
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
<P>
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
<P>
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
<P>
|
||||
|
||||
<STRONG>3.</STRONG>
|
||||
You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
|
||||
<!-- we use this doubled UL to get the sub-sections indented, -->
|
||||
<!-- while making the bullets as unobvious as possible. -->
|
||||
|
||||
<DL>
|
||||
<DT>
|
||||
|
||||
<DD>
|
||||
<STRONG>a)</STRONG>
|
||||
Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
</DD>
|
||||
</DT>
|
||||
</DL>
|
||||
<P>
|
||||
<DL>
|
||||
<DT>
|
||||
<DD>
|
||||
<STRONG>b)</STRONG>
|
||||
Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
</DD>
|
||||
|
||||
</DT>
|
||||
</DL>
|
||||
<P>
|
||||
<DL>
|
||||
<DT>
|
||||
<DD>
|
||||
<STRONG>c)</STRONG>
|
||||
Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
</DD>
|
||||
</DT>
|
||||
</DL>
|
||||
<P>
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
<P>
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
<P>
|
||||
|
||||
<STRONG>4.</STRONG>
|
||||
You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
<P>
|
||||
|
||||
<STRONG>5.</STRONG>
|
||||
You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
<P>
|
||||
|
||||
<STRONG>6.</STRONG>
|
||||
|
||||
Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
<P>
|
||||
|
||||
<STRONG>7.</STRONG>
|
||||
If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
<P>
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
<P>
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
<P>
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
|
||||
<P>
|
||||
|
||||
<STRONG>8.</STRONG>
|
||||
If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
<P>
|
||||
|
||||
<STRONG>9.</STRONG>
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
<P>
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
<P>
|
||||
|
||||
<STRONG>10.</STRONG>
|
||||
If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
|
||||
|
||||
<P><STRONG>NO WARRANTY</STRONG></P>
|
||||
|
||||
<P>
|
||||
|
||||
<STRONG>11.</STRONG>
|
||||
BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
<P>
|
||||
|
||||
<STRONG>12.</STRONG>
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
<P>
|
||||
|
||||
<HR>
|
||||
|
||||
<h2>License for wcslcat and wcslcpy</h2>
|
||||
|
||||
\c fish also contains small amounts of code under the BSD
|
||||
license, namely versions of the two functions strlcat and strlcpy,
|
||||
modified for use with wide character strings. This code is copyrighted
|
||||
by Todd C. Miller.
|
||||
|
||||
Permission to use, copy, modify, and distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
||||
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
|
||||
AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
<HR>
|
||||
|
||||
<h2>License for XSel</h2>
|
||||
|
||||
The XSel command, written and copyrighted by Conrad Parker, is
|
||||
distributed together with \c fish.
|
||||
|
||||
|
||||
It is Copyright (C) 2001 Conrad Parker <conrad@vergenet.net>
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this software
|
||||
and its documentation for any purpose is hereby granted without fee,
|
||||
provided that the above copyright notice appear in all copies and that
|
||||
both that copyright notice and this permission notice appear in
|
||||
supporting documentation. No representations are made about the
|
||||
suitability of this software for any purpose. It is provided "as is"
|
||||
without express or implied warranty.
|
||||
|
||||
|
||||
<HR>
|
||||
|
||||
<H2><A NAME="SEC1" HREF="#TOC1">GNU LESSER GENERAL PUBLIC LICENSE</A></H2>
|
||||
|
||||
<P>
|
||||
Version 2.1, February 1999
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
</PRE>
|
||||
|
||||
|
||||
<H2><A NAME="SEC2" HREF="#TOC2">Preamble</A></H2>
|
||||
|
||||
<P>
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
<P>
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
<P>
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
<P>
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
<P>
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
<P>
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
<P>
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
<P>
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
<P>
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
<P>
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
<P>
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
<P>
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
<P>
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
<P>
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
<P>
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
<P>
|
||||
|
||||
<H2><A NAME="SEC3" HREF="#TOC3">TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION</A></H2>
|
||||
|
||||
|
||||
<P>
|
||||
<STRONG>0.</STRONG>
|
||||
This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
<P>
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
<P>
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
<P>
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
<P>
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
<P>
|
||||
<STRONG>1.</STRONG>
|
||||
You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
<P>
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
<P>
|
||||
<STRONG>2.</STRONG>
|
||||
|
||||
You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
<P>
|
||||
<UL>
|
||||
<LI><STRONG>a)</STRONG>
|
||||
The modified work must itself be a software library.
|
||||
<LI><STRONG>b)</STRONG>
|
||||
You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
<LI><STRONG>c)</STRONG>
|
||||
You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
<LI><STRONG>d)</STRONG>
|
||||
|
||||
If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
<P>
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
<P>
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
<P>
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
<P>
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
</UL>
|
||||
<P>
|
||||
<STRONG>3.</STRONG>
|
||||
|
||||
You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
<P>
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
<P>
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
<P>
|
||||
<STRONG>4.</STRONG>
|
||||
You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
<P>
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
<P>
|
||||
<STRONG>5.</STRONG>
|
||||
|
||||
A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
<P>
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
<P>
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
<P>
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
<P>
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
<P>
|
||||
<STRONG>6.</STRONG>
|
||||
As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
<P>
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
<P>
|
||||
<UL>
|
||||
<LI><STRONG>a)</STRONG> Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
<LI><STRONG>b)</STRONG> Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
<LI><STRONG>c)</STRONG> Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
<LI><STRONG>d)</STRONG> If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
<LI><STRONG>e)</STRONG> Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
</UL>
|
||||
<P>
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
<P>
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
<P>
|
||||
<STRONG>7.</STRONG> You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
<P>
|
||||
<UL>
|
||||
<LI><STRONG>a)</STRONG> Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
<LI><STRONG>b)</STRONG> Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
</UL>
|
||||
<P>
|
||||
<STRONG>8.</STRONG> You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
<P>
|
||||
<STRONG>9.</STRONG>
|
||||
You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
<P>
|
||||
<STRONG>10.</STRONG>
|
||||
Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
<P>
|
||||
<STRONG>11.</STRONG>
|
||||
If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
<P>
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
<P>
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
<P>
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
<P>
|
||||
<STRONG>12.</STRONG>
|
||||
If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
<P>
|
||||
<STRONG>13.</STRONG>
|
||||
The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
<P>
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
<P>
|
||||
|
||||
<STRONG>14.</STRONG>
|
||||
If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
<P>
|
||||
<STRONG>NO WARRANTY</STRONG>
|
||||
<P>
|
||||
<STRONG>15.</STRONG>
|
||||
BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
<P>
|
||||
<STRONG>16.</STRONG>
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
<P>
|
||||
|
||||
|
||||
|
||||
*/
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
\section mimedb mimedb - Lookup file information via the mime database
|
||||
\section mimedb mimedb - lookup file information via the mime database
|
||||
|
||||
\subsection mimedb-synopsis Synopsis
|
||||
<tt>mimedb [OPTIONS] FILES...</tt>
|
||||
@@ -14,6 +13,13 @@
|
||||
- \c -f, \c --output-description the output will be the description of each mimetype
|
||||
- \c -a, \c --output-action the output will be the default action of each mimetype
|
||||
- \c -l, \c --launch launch the default action for the specified file(s)
|
||||
- \c -h, \c --help Display a help message and exit
|
||||
- \c -v, \c --version Display version number and exit
|
||||
- \c -h, \c --help display a help message and exit
|
||||
- \c -v, \c --version display version number and exit
|
||||
|
||||
The mimedb command is used to query the mimetype database and the
|
||||
.desktop files installed on the system in order to find information on
|
||||
a file. The information that mimedb can retrive includes the mimetype
|
||||
for a file, a description of the type and what its default action
|
||||
is. mimedb can also be used to launch the default action for this
|
||||
file.
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
\section nextd nextd
|
||||
\section nextd nextd - move forward through directory history
|
||||
|
||||
\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.
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
|
||||
\section not not - Negate the exit status of a job
|
||||
\section not not - negate the exit status of a job
|
||||
|
||||
\subsection not-synopsis Synopsis
|
||||
<tt>not COMMAND [OPTIONS...]</tt>
|
||||
<tt>not COMMAND [OPTIONS...]</tt>
|
||||
|
||||
\subsection not-description Description
|
||||
|
||||
The \c not builtin is used to negate the exit status of another command.
|
||||
|
||||
|
||||
\subsection not-example Example
|
||||
|
||||
The following code reports an error and exits if no file named spoon can be found.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
\section open open - Open file in it's default application
|
||||
\section open open - open file in it's default application
|
||||
|
||||
\subsection open-synopsis Synopsis
|
||||
<tt>open FILES...</tt>
|
||||
|
||||
@@ -1,23 +1,27 @@
|
||||
|
||||
\section or or - Conditionally execute a command
|
||||
\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 not 0.
|
||||
|
||||
The or command does not change the current exit status.
|
||||
|
||||
The exit status of the last foreground command to exit can always be
|
||||
accessed using the <a href="index.html#variables-status">$status</a>
|
||||
variable.
|
||||
|
||||
\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
|
||||
</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
|
||||
The following code runs the \c make command to build a program, if the
|
||||
build succceds, the program is installed. If either step fails,
|
||||
<tt>make clean</tt> is run, which removes the files created by the
|
||||
build process
|
||||
|
||||
<pre>
|
||||
or and make; make install; make clean
|
||||
make; and make install; or make clean
|
||||
</pre>
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
\section popd popd
|
||||
\section popd popd - move through directory stack
|
||||
|
||||
\subsection popd-synopsis Synopsis
|
||||
<tt>popd</tt>
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
\section prevd prevd
|
||||
\section prevd prevd - move backward through direcotry history
|
||||
|
||||
\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.
|
||||
|
||||
<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,5 +1,4 @@
|
||||
|
||||
\section psub psub - Perform process substitution
|
||||
\section psub psub - perform process substitution
|
||||
|
||||
\subsection psub-synopsis Synopsis
|
||||
<tt>COMMAND1 (COMMAND2|psub) </tt>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
\section pushd pushd
|
||||
\section pushd pushd - push directory to directory stack
|
||||
|
||||
\subsection pushd-synopsis Synopsis
|
||||
<tt>pushd [DIRECTORY]</tt>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
\section random random - Generate random number
|
||||
\section random random - generate random number
|
||||
|
||||
\subsection random-synopsis Synopsis
|
||||
<tt>random [SEED]</tt>
|
||||
|
||||
@@ -8,10 +8,13 @@
|
||||
The <tt>read</tt> builtin causes fish to read one line from standard
|
||||
input and store the result in one or more environment variables.
|
||||
|
||||
- <tt>-c CMD</tt> or <tt>--command=CMD</tt> specifies that the initial string in the interactive mode command buffer should be CMD.
|
||||
- <tt>-e</tt> or <tt>--export</tt> specifies that the variables will be exported to subshells.
|
||||
- <tt>-g</tt> or <tt>--global</tt> specifies that the variables will be made global.
|
||||
- <tt>-pPROMPT_CMD</tt> or <tt>--prompt=PROMPT_CMD</tt> specifies that the output of the shell command PROMPT_CMD should be used as the prompt for the interactive mode prompt. The default prompt command is <tt>set_color green; echo read; set_color normal; echo "> "</tt>.
|
||||
- <tt>-cCMD</tt> or <tt>--command=CMD</tt> specifies that the initial string in the interactive mode command buffer should be CMD.
|
||||
- <tt>-p PROMPT_CMD</tt> or <tt>--prompt=PROMPT_CMD</tt> specifies that the output of the shell command PROMPT_CMD should be used as the prompt for the interactive mode prompt. The default prompt command is <tt>set_color green; echo read; set_color normal; echo "> "</tt>.
|
||||
- <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
|
||||
|
||||
Read starts by reading a single line of input from stdin, the line is
|
||||
then tokenized using the <tt>IFS</tt> environment variable. Each variable
|
||||
|
||||
@@ -1,22 +1,26 @@
|
||||
|
||||
\section return return - Stop the innermost currently evaluated function
|
||||
\section return return - stop the innermost currently evaluated function
|
||||
|
||||
\subsection return-synopsis Synopsis
|
||||
<tt>function NAME; [COMMANDS...] break [STATUS]; [COMMANDS...] end</tt>
|
||||
<tt>function NAME; [COMMANDS...;] return [STATUS]; [COMMANDS...;] end</tt>
|
||||
|
||||
\subsection return-description Description The \c return builtin is
|
||||
used to halt a currently running function. 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 to conditionally stop the
|
||||
executing function and return to the caller.
|
||||
\subsection return-description Description
|
||||
|
||||
- \c STATUS is the return status of the function. If unspecified, the status is set to 0.
|
||||
The \c return builtin is used to halt a currently running function. 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 to conditionally stop the executing function and return to
|
||||
the caller, but it can also be used to specify the exit status of a
|
||||
function.
|
||||
|
||||
- \c STATUS is the return status of the function. If unspecified, the status is unchanged.
|
||||
|
||||
\subsection return-example Example
|
||||
The following code is an implementation of the false program as a fish builtin
|
||||
<p>
|
||||
<pre>function false
|
||||
return 1
|
||||
end</pre>
|
||||
</p>
|
||||
The following code is an implementation of the false command as a fish function
|
||||
|
||||
<pre>
|
||||
function false
|
||||
return 1
|
||||
end
|
||||
</pre>
|
||||
|
||||
|
||||
|
||||
@@ -1,41 +1,86 @@
|
||||
\section set set - Handle environment variables.
|
||||
\section set set - handle environment variables.
|
||||
|
||||
\subsection set-synopsis Synopsis
|
||||
<tt>set [OPTIONS] VARIABLE_NAME [VALUES...]</tt>
|
||||
<pre>
|
||||
set [SCOPE_OPTIONS]
|
||||
set [OPTIONS] VARIABLE_NAME VALUES...
|
||||
set [OPTIONS] VARIABLE_NAME[INDICES]... VALUES...
|
||||
set (-q | --query) [SCOPE_OPTIONS] VARIABLE_NAMES...
|
||||
set (-e | --erase) [SCOPE_OPTIONS] VARIABLE_NAME
|
||||
set (-e | --erase) [SCOPE_OPTIONS] VARIABLE_NAME[INDICES]...
|
||||
</pre>
|
||||
|
||||
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>-l</code> or <code>--local</code> forces the specified environment variable to be given a scope that is local to the current block, even if a variable with the given name exists and is non-local
|
||||
- <code>-g</code> or <code>--global</code> causes the specified environment variable to be given a global scope. Non-global variables disappear when the block they belong to ends
|
||||
- <code>-U</code> or <code>--universal</code> causes the specified environment variable to be given a universal scope. 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>-n</code> or <code>--names</code> List only the names of all defined variables, not their value
|
||||
- <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>-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.
|
||||
|
||||
If the \c -e or \c --erase option is specified, the variable
|
||||
specified by the following arguments will be erased
|
||||
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 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. When array indices are specified to set, multiple arguments
|
||||
may be used to specify additional indexes, e.g. <code>set PATH[1]
|
||||
PATH[4] /bin /sbin</code>. If you specify a negative index when
|
||||
expanding or assigning to an array variable, the index will be
|
||||
calculated from the end of the array. For example, the index -1 means
|
||||
the last index of an array.
|
||||
|
||||
The scoping rules when creating or updating a variable are:
|
||||
|
||||
-# If a variable is explicitly set to either universal, global or local, that setting will be honored. If a variable of the same name exists in a different scope, that variable will not be changed.
|
||||
-# If a variable is not explicitly set to be either universal, global or local, but has been previously defined, the previos variable scope is used.
|
||||
-# If a variable is not explicitly set to be either universal, global or local and has never before been defined, the variable will be local to the currently executing functions. If no function is executing, the variable will be global.
|
||||
|
||||
The exporting rules when creating or updating a variable are identical
|
||||
to the scoping rules for variables:
|
||||
|
||||
-# If a variable is explicitly set to either be exported or not exported, that setting will be honored.
|
||||
-# If a variable is not explicitly set to be exported or not exported, but has been previously defined, the previous exporting rule for the variable is kept.
|
||||
-# If a variable is not explicitly set to be either global or local and has never before been defined, the variable will not be exported.
|
||||
|
||||
In query mode, the scope to be examined can be specified.
|
||||
|
||||
In erase mode, if variable indices are specified, only the specified
|
||||
slices of the array variable will be erased. When erasing an entire
|
||||
variable (i.e. no slicing), the scope of the variable to be erased can
|
||||
be specified. That way, a global variable can be erased even if a
|
||||
local variable with the same name exists. Scope can not be specified
|
||||
when erasing a slice of an array. The innermost scope is always used.
|
||||
|
||||
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.
|
||||
|
||||
In assignment mode, set exits with an exit status of zero it the
|
||||
variable assignments where sucessfully performed, with a non-zero exit
|
||||
status otherwise. In query mode, the exit status is the number of
|
||||
variables that where not found. In erase mode, set exits with a zero
|
||||
exit status in case of success, with a non-zero exit status if the
|
||||
commandline was invalid, if the variable was write-protected or if the
|
||||
variable did not exist.
|
||||
|
||||
\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
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
\section set_color set_color - Set the terminal color
|
||||
\section set_color set_color - set the terminal color
|
||||
|
||||
\subsection set_color-synopsis Synopsis
|
||||
<tt>set_color [-v --version] [-h --help] [-b --background COLOR] [COLOR]</tt>
|
||||
@@ -10,13 +9,22 @@ 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 -c, \c --print-colors Prints a list of all valid color names
|
||||
- \c -h, \c --help Display help message and exit
|
||||
- \c -o, \c --bold Set bold or extra bright mode
|
||||
- \c -u, \c --underline Set underlined mode
|
||||
- \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.
|
||||
|
||||
Not all terminal emulators support all these features. This is not a
|
||||
bug in set_color but a missing feature in the terminal emulator.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
\section source . - Evaluate contents of file.
|
||||
\section source . - evaluate contents of file.
|
||||
|
||||
\subsection source-synopsis Synopsis
|
||||
<tt>. FILENAME</tt>
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
|
||||
\section status status - Display fish runtime information
|
||||
\section status status - query fish runtime information
|
||||
|
||||
\subsection status-synopsis Synopsis
|
||||
<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.
|
||||
|
||||
@@ -1,37 +1,52 @@
|
||||
|
||||
\section switch switch - conditionally execute a block of commands
|
||||
|
||||
\subsection switch-synopsis Synopsis
|
||||
<tt>switch VALUE; [case [WILDCARD...]; [COMMANDS...];...] end</tt>
|
||||
<tt>switch VALUE; [case [WILDCARD...]; [COMMANDS...]; ...] end</tt>
|
||||
|
||||
\subsection switch-description Description
|
||||
|
||||
The \c switch statement is used to perform one of several blocks of
|
||||
commands depending on whether a specified value equals one of several
|
||||
wildcarded values.
|
||||
wildcarded values. The \c case statement is used together with the \c
|
||||
switch statement in order to determine which block should be
|
||||
performed.
|
||||
|
||||
Each \c case command is given one or more parameter. The first \c case
|
||||
command with a parameter that matches the string specified in the
|
||||
switch command will be evaluated. \c case parameters may contain
|
||||
wildcards. These need to be escaped or quoted in order to avoid
|
||||
regular wildcard expansion using filenames.
|
||||
|
||||
Note that fish does not fall through on case statements. Though the
|
||||
syntax may look a bit like C switch statements, it behaves more like
|
||||
the case stamantes of traditional shells.
|
||||
|
||||
Also note that command substitutions in a case statement will be
|
||||
evaluated even if it's body is not taken. This may seem
|
||||
counterintuitive at first, but it is unavoidable, since it would be
|
||||
impossible to know if a case command will evaluate to true before all
|
||||
forms of parameter expansion have been performed for the case command.
|
||||
|
||||
\subsection switch-example Example
|
||||
|
||||
If the variable \$animal contins the name of an animal, the
|
||||
following code would attempt to classify it:
|
||||
If the variable \$animal contains the name of an animal, the following
|
||||
code would attempt to classify it:
|
||||
|
||||
<p>
|
||||
<pre>
|
||||
switch $animal
|
||||
case cat
|
||||
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
|
||||
case '*'
|
||||
echo I have no idea what a $animal is
|
||||
end
|
||||
</pre>
|
||||
</p>
|
||||
<p>
|
||||
|
||||
If the above code was run with \$animal set to \c whale, the output
|
||||
would be \c mammal.
|
||||
If the above code was run with \c \$animal set to \c whale, the output
|
||||
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
|
||||
|
||||
36
doc_src/trap.txt
Normal file
36
doc_src/trap.txt
Normal file
@@ -0,0 +1,36 @@
|
||||
\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 exists for backwards compatibility with Posix
|
||||
shells. 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.
|
||||
@@ -1,20 +1,22 @@
|
||||
|
||||
\section type type - Indicate how a name would be interpreted if used as a command name
|
||||
\section type type - indicate how a name would be interpreted if used as a command name
|
||||
|
||||
\subsection type-synopsis Synopsis
|
||||
<tt>type [OPTIONS] name [name ...]</tt>
|
||||
|
||||
\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
|
||||
|
||||
\c type returns a zero exit status if the specified command was found,
|
||||
otherwise the exit status is one.
|
||||
|
||||
\subsection type-example Example
|
||||
|
||||
<tt>type fg</tt> outputs the string 'fg is a shell builtin'.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
\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>
|
||||
@@ -22,7 +21,7 @@ value. Other options are interpreted as follows:
|
||||
|
||||
- <code>-a</code> or <code>--all</code> Set or get all current limits
|
||||
- <code>-c</code> or <code>--core-size</code> The maximum size of core files created
|
||||
- <code>-d</code> or <code>--data-size</code> The maximum size of a process’s data segment
|
||||
- <code>-d</code> or <code>--data-size</code> The maximum size of a process's data segment
|
||||
- <code>-f</code> or <code>--file-size</code> The maximum size of files created by the shell
|
||||
- <code>-l</code> or <code>--lock-size</code> The maximum size that may be locked into memory
|
||||
- <code>-m</code> or <code>--resident-set-size</code> The maximum resident set size
|
||||
@@ -38,7 +37,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,4 @@
|
||||
|
||||
\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,7 +9,7 @@ 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.
|
||||
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
|
||||
@@ -19,7 +18,7 @@ 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
|
||||
specifiec other users rights and \c a specifies all three should be
|
||||
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
|
||||
@@ -27,7 +26,7 @@ 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 compination of \c r, \c w and \c x, representing
|
||||
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
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
\section vared vared - Interactively edit the value of an environment variable
|
||||
\section vared vared - interactively edit the value of an environment variable
|
||||
|
||||
\subsection vared-synopsis Synopsis
|
||||
<tt>vared VARIABLE_NAME</tt>
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
\section while while - perform a command multiple times
|
||||
|
||||
\subsection while-synopsis Synopsis
|
||||
<tt>while CONDITION; COMMANDS; end</tt>
|
||||
<tt>while CONDITION; COMMANDS...; end</tt>
|
||||
|
||||
\subsection while-synopsis Synopsis
|
||||
The <tt>while</tt> builtin causes fish to continually execute the command COMMANDS while the command CONDITION returns with status 0.
|
||||
\subsection while-description Description
|
||||
The <tt>while</tt> builtin causes fish to continually execute CONDITION and
|
||||
execute COMMANDS as long as CONDITION returned with status 0. If CONDITION is
|
||||
false on the first time, COMMANDS will not be executed at all. Hints: use
|
||||
<a href="#begin"><tt>begin; ...; end</tt></a> for complex conditions; more
|
||||
complex control can be achieved with <tt>while true</tt> containing a
|
||||
<a href="#break">break</a>.
|
||||
|
||||
\subsection while-example Example
|
||||
|
||||
<tt>while test -f foo.txt; echo file exists; sleep 10; end</tt>
|
||||
|
||||
causes fish to print the line 'file exists' at 10 second intervals as long as the file foo.txt exists.
|
||||
causes fish to print the line 'file exists' at 10 second intervals as long as
|
||||
the file foo.txt exists.
|
||||
|
||||
610
env.c
610
env.c
@@ -25,10 +25,22 @@
|
||||
#include <termio.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_TERM_H
|
||||
#include <term.h>
|
||||
#elif HAVE_NCURSES_TERM_H
|
||||
#include <ncurses/term.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_LIBINTL_H
|
||||
#include <libintl.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
|
||||
#include "fallback.h"
|
||||
#include "util.h"
|
||||
|
||||
#include "wutil.h"
|
||||
#include "proc.h"
|
||||
#include "common.h"
|
||||
@@ -42,10 +54,12 @@
|
||||
#include "input_common.h"
|
||||
#include "event.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"fishd ^/tmp/fishd.log.%s"
|
||||
|
||||
/**
|
||||
Value denoting a null string
|
||||
@@ -94,7 +108,11 @@ typedef struct env_node
|
||||
typedef struct var_entry
|
||||
{
|
||||
int export; /**< Whether the variable should be exported */
|
||||
wchar_t val[0]; /**< The value of the variable */
|
||||
#if __STDC_VERSION__ < 199901L
|
||||
wchar_t val[1]; /**< The value of the variable */
|
||||
#else
|
||||
wchar_t val[]; /**< The value of the variable */
|
||||
#endif
|
||||
}
|
||||
var_entry_t;
|
||||
|
||||
@@ -141,19 +159,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.
|
||||
@@ -171,6 +176,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( void *key, 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
|
||||
@@ -182,7 +217,7 @@ static void start_fishd()
|
||||
{
|
||||
string_buffer_t cmd;
|
||||
struct passwd *pw;
|
||||
|
||||
|
||||
sb_init( &cmd );
|
||||
pw = getpwuid(getuid());
|
||||
|
||||
@@ -190,7 +225,7 @@ static void start_fishd()
|
||||
|
||||
if( !pw )
|
||||
{
|
||||
debug( 0, L"Could not get user information" );
|
||||
debug( 0, _( L"Could not get user information" ) );
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -213,6 +248,88 @@ static mode_t get_umask()
|
||||
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. Both changing
|
||||
_nl_msg_cat_cntr and calling dcgettext might potentially
|
||||
tell some gettext implementation that the translation
|
||||
strings should be reloaded. We do both and hope for the
|
||||
best.
|
||||
*/
|
||||
extern int _nl_msg_cat_cntr;
|
||||
++_nl_msg_cat_cntr;
|
||||
dcgettext( "fish", "Changing language to English", LC_MESSAGES );
|
||||
|
||||
if( is_interactive )
|
||||
{
|
||||
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.
|
||||
@@ -223,6 +340,9 @@ static void universal_callback( int type,
|
||||
{
|
||||
wchar_t *str=0;
|
||||
|
||||
if( is_locale( name ) )
|
||||
handle_locale();
|
||||
|
||||
switch( type )
|
||||
{
|
||||
case SET:
|
||||
@@ -236,7 +356,6 @@ static void universal_callback( int type,
|
||||
|
||||
if( str )
|
||||
{
|
||||
array_list_t arg;
|
||||
event_t ev;
|
||||
|
||||
has_changed=1;
|
||||
@@ -245,33 +364,134 @@ 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 )
|
||||
tokenize_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, &free );
|
||||
path = env_get( L"PATH" );
|
||||
al_truncate( &l, 0 );
|
||||
tokenize_variable_array( path, &l );
|
||||
}
|
||||
}
|
||||
|
||||
al_foreach( &l, &free );
|
||||
al_destroy( &l );
|
||||
}
|
||||
|
||||
static void env_set_defaults()
|
||||
{
|
||||
if( !env_get( L"USER" ) )
|
||||
{
|
||||
struct passwd *pw = getpwuid( getuid());
|
||||
wchar_t *unam = str2wcs( pw->pw_name );
|
||||
env_set( L"USER", unam, ENV_GLOBAL );
|
||||
free( unam );
|
||||
}
|
||||
if( !env_get( L"HOME" ) )
|
||||
{
|
||||
wchar_t *unam = env_get( L"USER" );
|
||||
char *unam_narrow = wcs2str( unam );
|
||||
struct passwd *pw = getpwnam( unam_narrow );
|
||||
wchar_t *dir = str2wcs( pw->pw_dir );
|
||||
env_set( L"HOME", dir, ENV_GLOBAL );
|
||||
free( dir );
|
||||
free( unam_narrow );
|
||||
}
|
||||
}
|
||||
|
||||
void env_init()
|
||||
{
|
||||
char **p;
|
||||
struct passwd *pw;
|
||||
wchar_t *uname, *path;
|
||||
wchar_t *uname;
|
||||
wchar_t *version;
|
||||
|
||||
|
||||
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"version", L"" );
|
||||
hash_put( &env_read_only, L"_", L"" );
|
||||
hash_put( &env_read_only, L"LINES", L"" );
|
||||
hash_put( &env_read_only, L"COLUMNS", L"" );
|
||||
@@ -302,6 +522,11 @@ void env_init()
|
||||
hash_init( &top->env, &hash_wcs_func, &hash_wcs_cmp );
|
||||
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
|
||||
@@ -339,54 +564,14 @@ void env_init()
|
||||
free(key);
|
||||
}
|
||||
|
||||
path = env_get( L"PATH" );
|
||||
if( !path )
|
||||
{
|
||||
env_set( L"PATH", L"/bin" ARRAY_SEP_STR L"/usr/bin", ENV_EXPORT | ENV_GLOBAL );
|
||||
}
|
||||
else
|
||||
{
|
||||
int i;
|
||||
array_list_t l;
|
||||
int has_bin=0, has_usr_bin=0;
|
||||
|
||||
al_init( &l );
|
||||
expand_variable_array( path, &l );
|
||||
|
||||
for( i=0; i<al_get_count( &l); i++ )
|
||||
{
|
||||
wchar_t * el = (wchar_t *)al_get( &l, i );
|
||||
if( contains_str( el, L"/bin", L"/bin/", (void *)0) )
|
||||
{
|
||||
has_bin = 1;
|
||||
}
|
||||
if( contains_str( el, L"/usr/bin", L"/usr/bin/", (void *)0) )
|
||||
{
|
||||
has_bin = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if( !( has_bin && has_usr_bin ) )
|
||||
{
|
||||
string_buffer_t b;
|
||||
sb_init( &b );
|
||||
sb_append( &b, path );
|
||||
if( !has_bin )
|
||||
sb_append( &b, ARRAY_SEP_STR L"/bin" );
|
||||
if( !has_usr_bin )
|
||||
sb_append( &b, ARRAY_SEP_STR L"/usr/bin" );
|
||||
|
||||
env_set( L"PATH", (wchar_t *)b.buff, ENV_GLOBAL | ENV_EXPORT );
|
||||
sb_destroy( &b );
|
||||
}
|
||||
|
||||
al_foreach( &l, (void (*)(const void *))&free );
|
||||
al_destroy( &l );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Set up the PATH variable
|
||||
*/
|
||||
setup_path();
|
||||
|
||||
/*
|
||||
Set up the USER variable
|
||||
*/
|
||||
pw = getpwuid( getuid() );
|
||||
if( pw )
|
||||
{
|
||||
@@ -394,12 +579,23 @@ void env_init()
|
||||
env_set( L"USER", uname, ENV_GLOBAL | ENV_EXPORT );
|
||||
free( uname );
|
||||
}
|
||||
|
||||
/*
|
||||
Set up the version variable
|
||||
*/
|
||||
version = str2wcs( PACKAGE_VERSION );
|
||||
env_set( L"version", version, ENV_GLOBAL );
|
||||
free( version );
|
||||
|
||||
env_universal_init( env_get( L"FISHD_SOKET_DIR"),
|
||||
env_universal_init( env_get( L"FISHD_SOCKET_DIR"),
|
||||
env_get( L"USER" ),
|
||||
&start_fishd,
|
||||
&universal_callback );
|
||||
|
||||
|
||||
/*
|
||||
Set correct defaults for e.g. USER and HOME variables
|
||||
*/
|
||||
env_set_defaults();
|
||||
}
|
||||
|
||||
void env_destroy()
|
||||
@@ -452,10 +648,10 @@ 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 )
|
||||
|
||||
int env_set( const wchar_t *key,
|
||||
const wchar_t *val,
|
||||
int var_mode )
|
||||
{
|
||||
int free_val = 0;
|
||||
var_entry_t *entry;
|
||||
@@ -466,20 +662,16 @@ void env_set( const wchar_t *key,
|
||||
int done=0;
|
||||
|
||||
event_t ev;
|
||||
array_list_t ev_list;
|
||||
int is_universal = 0;
|
||||
|
||||
|
||||
CHECK( key, ENV_INVALID );
|
||||
|
||||
if( (var_mode & ENV_USER ) &&
|
||||
hash_get( &env_read_only, key ) )
|
||||
{
|
||||
return;
|
||||
return ENV_PERM;
|
||||
}
|
||||
|
||||
if( wcscmp(key, L"LANG" )==0 )
|
||||
{
|
||||
fish_setlocale(LC_ALL,val);
|
||||
}
|
||||
|
||||
if( wcscmp( key, L"umask" ) == 0)
|
||||
{
|
||||
wchar_t *end;
|
||||
@@ -501,14 +693,13 @@ void env_set( const wchar_t *key,
|
||||
/*
|
||||
Do not actually create a umask variable, on env_get, it will be calculated dynamically
|
||||
*/
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
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;
|
||||
}
|
||||
@@ -527,7 +718,7 @@ void env_set( const wchar_t *key,
|
||||
|
||||
env_universal_set( key, val, export );
|
||||
is_universal = 1;
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -555,6 +746,7 @@ void env_set( const wchar_t *key,
|
||||
(var_mode & ENV_GLOBAL) )
|
||||
{
|
||||
node = ( var_mode & ENV_GLOBAL )?global_env:top;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -569,8 +761,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;
|
||||
@@ -592,12 +787,13 @@ 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 )
|
||||
node = node->next;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -605,7 +801,7 @@ void env_set( const wchar_t *key,
|
||||
if( !done )
|
||||
{
|
||||
void *k, *v;
|
||||
hash_remove( &node->env, key, (const void **)&k, (const void **)&v );
|
||||
hash_remove( &node->env, key, &k, &v );
|
||||
free( k );
|
||||
free( v );
|
||||
|
||||
@@ -643,33 +839,50 @@ 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, L"SET" );
|
||||
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();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Attempt to remove/free the specified key/value pair from the
|
||||
specified hash table.
|
||||
|
||||
\return zero if the variable was not found, non-zero otherwise
|
||||
*/
|
||||
static int try_remove( env_node_t *n,
|
||||
const wchar_t *key )
|
||||
const wchar_t *key,
|
||||
int var_mode )
|
||||
{
|
||||
void *old_key_void, *old_val_void;
|
||||
wchar_t *old_key, *old_val;
|
||||
|
||||
if( n == 0 )
|
||||
return 0;
|
||||
|
||||
hash_remove( &n->env,
|
||||
key,
|
||||
(const void **)&old_key,
|
||||
(const void **)&old_val );
|
||||
&old_key_void,
|
||||
&old_val_void );
|
||||
|
||||
old_key = (wchar_t *)old_key_void;
|
||||
old_val = (wchar_t *)old_val_void;
|
||||
|
||||
if( old_key != 0 )
|
||||
{
|
||||
var_entry_t * v = (var_entry_t *)old_val;
|
||||
@@ -683,25 +896,72 @@ static int try_remove( env_node_t *n,
|
||||
return 1;
|
||||
}
|
||||
|
||||
if( var_mode & ENV_LOCAL )
|
||||
return 0;
|
||||
|
||||
if( n->new_scope )
|
||||
return try_remove( global_env, key );
|
||||
return try_remove( global_env, key, var_mode );
|
||||
else
|
||||
return try_remove( n->next, key );
|
||||
return try_remove( n->next, key, var_mode );
|
||||
}
|
||||
|
||||
|
||||
void env_remove( const wchar_t *key, int var_mode )
|
||||
int env_remove( const wchar_t *key, int var_mode )
|
||||
{
|
||||
env_node_t *first_node;
|
||||
int erased = 0;
|
||||
|
||||
CHECK( key, 1 );
|
||||
|
||||
if( (var_mode & ENV_USER ) &&
|
||||
hash_get( &env_read_only, key ) )
|
||||
{
|
||||
return;
|
||||
return 2;
|
||||
}
|
||||
|
||||
if( !try_remove( top, key ) )
|
||||
first_node = top;
|
||||
|
||||
if( ! (var_mode & ENV_UNIVERSAL ) )
|
||||
{
|
||||
env_universal_remove( key );
|
||||
|
||||
if( var_mode & ENV_GLOBAL )
|
||||
{
|
||||
first_node = global_env;
|
||||
}
|
||||
|
||||
if( try_remove( first_node, key, var_mode ) )
|
||||
{
|
||||
event_t ev;
|
||||
|
||||
ev.type=EVENT_VARIABLE;
|
||||
ev.param1.variable=key;
|
||||
ev.function_name=0;
|
||||
|
||||
al_init( &ev.arguments );
|
||||
al_push( &ev.arguments, L"VARIABLE" );
|
||||
al_push( &ev.arguments, L"ERASE" );
|
||||
al_push( &ev.arguments, key );
|
||||
|
||||
event_fire( &ev );
|
||||
|
||||
al_destroy( &ev.arguments );
|
||||
erased = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if( !erased &&
|
||||
!(var_mode & ENV_GLOBAL) &&
|
||||
!(var_mode & ENV_LOCAL) )
|
||||
{
|
||||
erased = !env_universal_remove( key );
|
||||
}
|
||||
|
||||
if( is_locale( key ) )
|
||||
{
|
||||
handle_locale();
|
||||
}
|
||||
|
||||
return !erased;
|
||||
}
|
||||
|
||||
|
||||
@@ -711,6 +971,8 @@ wchar_t *env_get( const wchar_t *key )
|
||||
env_node_t *env = top;
|
||||
wchar_t *item;
|
||||
|
||||
CHECK( key, 0 );
|
||||
|
||||
if( wcscmp( key, L"history" ) == 0 )
|
||||
{
|
||||
wchar_t *current;
|
||||
@@ -725,12 +987,11 @@ wchar_t *env_get( const wchar_t *key )
|
||||
sb_append( &dyn_var, current );
|
||||
}
|
||||
|
||||
for( i=add_current; i<8; i++ )
|
||||
for( i=add_current;; i++ )
|
||||
{
|
||||
wchar_t *next = history_get( i-add_current );
|
||||
if( !next )
|
||||
{
|
||||
debug( 1, L"No history at idx %d\n", i );
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -738,6 +999,7 @@ wchar_t *env_get( const wchar_t *key )
|
||||
sb_append( &dyn_var, ARRAY_SEP_STR );
|
||||
sb_append( &dyn_var, next );
|
||||
}
|
||||
|
||||
return (wchar_t *)dyn_var.buff;
|
||||
}
|
||||
else if( wcscmp( key, L"COLUMNS" )==0 )
|
||||
@@ -785,7 +1047,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))
|
||||
@@ -796,36 +1062,62 @@ wchar_t *env_get( const wchar_t *key )
|
||||
return item;
|
||||
}
|
||||
|
||||
int env_exist( const wchar_t *key )
|
||||
int env_exist( const wchar_t *key, int mode )
|
||||
{
|
||||
var_entry_t *res;
|
||||
env_node_t *env = top;
|
||||
wchar_t *item;
|
||||
|
||||
if( hash_get( &env_read_only, key ) || hash_get( &env_electric, key ) )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
while( env != 0 )
|
||||
env_node_t *env;
|
||||
wchar_t *item=0;
|
||||
|
||||
CHECK( key, 0 );
|
||||
|
||||
/*
|
||||
Read only variables all exist, and they are all global. A local
|
||||
version can not exist.
|
||||
*/
|
||||
if( ! (mode & ENV_LOCAL) && ! (mode & ENV_UNIVERSAL) )
|
||||
{
|
||||
res = (var_entry_t *) hash_get( &env->env,
|
||||
key );
|
||||
if( res != 0 )
|
||||
if( hash_get( &env_read_only, key ) || hash_get( &env_electric, key ) )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if( env->new_scope )
|
||||
env = global_env;
|
||||
else
|
||||
env = env->next;
|
||||
}
|
||||
if( !proc_had_barrier)
|
||||
env_universal_barrier();
|
||||
item = env_universal_get( key );
|
||||
}
|
||||
|
||||
if( ! (mode & ENV_UNIVERSAL) )
|
||||
{
|
||||
env = (mode & ENV_GLOBAL)?global_env:top;
|
||||
|
||||
while( env != 0 )
|
||||
{
|
||||
res = (var_entry_t *) hash_get( &env->env,
|
||||
key );
|
||||
if( res != 0 )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if( mode & ENV_LOCAL )
|
||||
break;
|
||||
|
||||
if( env->new_scope )
|
||||
env = global_env;
|
||||
else
|
||||
env = env->next;
|
||||
}
|
||||
}
|
||||
|
||||
if( ! (mode & ENV_LOCAL) && ! (mode & ENV_GLOBAL) )
|
||||
{
|
||||
if( !proc_had_barrier)
|
||||
{
|
||||
proc_had_barrier=1;
|
||||
env_universal_barrier();
|
||||
}
|
||||
|
||||
item = env_universal_get( key );
|
||||
|
||||
}
|
||||
return item != 0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -866,8 +1158,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 );
|
||||
@@ -877,12 +1181,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();
|
||||
}
|
||||
}
|
||||
@@ -892,20 +1199,22 @@ void env_pop()
|
||||
Function used with hash_foreach to insert keys of one table into
|
||||
another
|
||||
*/
|
||||
static void add_key_to_hash( const void *key,
|
||||
const void *data,
|
||||
static void add_key_to_hash( void *key,
|
||||
void *data,
|
||||
void *aux )
|
||||
{
|
||||
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 )
|
||||
static void add_to_hash( void *k, void *aux )
|
||||
{
|
||||
hash_put( (hash_table_t *)aux,
|
||||
k,
|
||||
@@ -915,8 +1224,8 @@ static void add_to_hash( const void *k, void *aux )
|
||||
/**
|
||||
Add key to list
|
||||
*/
|
||||
static void add_key_to_list( const void * key,
|
||||
const void * val,
|
||||
static void add_key_to_list( void * key,
|
||||
void * val,
|
||||
void *aux )
|
||||
{
|
||||
al_push( (array_list_t *)aux, key );
|
||||
@@ -932,6 +1241,8 @@ void env_get_names( array_list_t *l, int flags )
|
||||
hash_table_t names;
|
||||
env_node_t *n=top;
|
||||
|
||||
CHECK( l, );
|
||||
|
||||
get_names_show_exported =
|
||||
flags & ENV_EXPORT|| (!(flags & ENV_UNEXPORT));
|
||||
get_names_show_unexported =
|
||||
@@ -1000,7 +1311,7 @@ void env_get_names( array_list_t *l, int flags )
|
||||
/**
|
||||
Function used by env_export_arr to iterate over hashtable of variables
|
||||
*/
|
||||
static void export_func1( const void *k, const void *v, void *aux )
|
||||
static void export_func1( void *k, void *v, void *aux )
|
||||
{
|
||||
var_entry_t *val_entry = (var_entry_t *)v;
|
||||
if( val_entry->export )
|
||||
@@ -1016,7 +1327,7 @@ static void export_func1( const void *k, const void *v, void *aux )
|
||||
/**
|
||||
Function used by env_export_arr to iterate over hashtable of variables
|
||||
*/
|
||||
static void export_func2( const void *k, const void *v, void *aux )
|
||||
static void export_func2( void *k, void *v, void *aux )
|
||||
{
|
||||
wchar_t *key = (wchar_t *)k;
|
||||
wchar_t *val = (wchar_t *)v;
|
||||
@@ -1030,7 +1341,7 @@ static void export_func2( const void *k, const void *v, void *aux )
|
||||
|
||||
if( !ks || !vs )
|
||||
{
|
||||
die_mem();
|
||||
DIE_MEM();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1053,11 +1364,14 @@ static void export_func2( const void *k, const void *v, void *aux )
|
||||
free( vs );
|
||||
}
|
||||
|
||||
char **env_export_arr( int recalc)
|
||||
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;
|
||||
|
||||
36
env.h
36
env.h
@@ -41,6 +41,16 @@
|
||||
*/
|
||||
#define ENV_UNIVERSAL 32
|
||||
|
||||
/**
|
||||
Error code for trying to alter read-only variable
|
||||
*/
|
||||
enum{
|
||||
ENV_PERM = 1,
|
||||
ENV_INVALID
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
/**
|
||||
Initialize environment variable data
|
||||
*/
|
||||
@@ -61,11 +71,17 @@ void env_destroy();
|
||||
\param val The value
|
||||
\param mode The type of the variable. Can be any combination of ENV_GLOBAL, ENV_LOCAL, ENV_EXPORT and ENV_USER. If mode is zero, the current variable space is searched and the current mode is used. If no current variable with the same name is found, ENV_LOCAL is assumed.
|
||||
|
||||
\returns 0 on suicess or an error code on failiure.
|
||||
|
||||
The current error codes are:
|
||||
|
||||
* ENV_PERM, can only be returned when setting as a user, e.g. ENV_USER is set. This means that the user tried to change a read-only variable.
|
||||
* ENV_INVALID, the variable name or mode was invalid
|
||||
*/
|
||||
|
||||
void env_set( const wchar_t *key,
|
||||
const wchar_t *val,
|
||||
int mode );
|
||||
int env_set( const wchar_t *key,
|
||||
const wchar_t *val,
|
||||
int mode );
|
||||
|
||||
|
||||
/**
|
||||
@@ -78,18 +94,23 @@ void env_set( const wchar_t *key,
|
||||
wchar_t *env_get( const wchar_t *key );
|
||||
|
||||
/**
|
||||
Returns 1 if the specified key exists. This can't be reliable done
|
||||
Returns 1 if the specified key exists. This can't be reliably done
|
||||
using env_get, since env_get returns null for 0-element arrays
|
||||
|
||||
\param key The name of the variable to remove
|
||||
\param mode the scope to search in. All scopes are searched if unset
|
||||
*/
|
||||
int env_exist( const wchar_t *key );
|
||||
int env_exist( const wchar_t *key, int mode );
|
||||
|
||||
/**
|
||||
Remove environemnt variable
|
||||
|
||||
\param key The name of the variable to remove
|
||||
\param mode should be ENV_USER if this is a remove request from the user, 0 otherwise. If this is a user request, read-only variables can not be removed.
|
||||
\param mode should be ENV_USER if this is a remove request from the user, 0 otherwise. If this is a user request, read-only variables can not be removed. The mode may also specify the scope of the variable that should be erased.
|
||||
|
||||
\return zero if the variable existed, and non-zero if the variable did not exist
|
||||
*/
|
||||
void env_remove( const wchar_t *key, int mode );
|
||||
int env_remove( const wchar_t *key, int mode );
|
||||
|
||||
/**
|
||||
Push the variable stack. Used for implementing local variables for functions and for-loops.
|
||||
@@ -108,7 +129,6 @@ char **env_export_arr( int recalc );
|
||||
|
||||
/**
|
||||
Insert all variable names into l. These are not copies of the strings and should not be freed after use.
|
||||
|
||||
*/
|
||||
void env_get_names( array_list_t *l, int flags );
|
||||
|
||||
|
||||
101
env_universal.c
101
env_universal.c
@@ -1,9 +1,10 @@
|
||||
#include "config.h"
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
#include <strings.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
@@ -11,15 +12,28 @@
|
||||
#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
|
||||
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#include "fallback.h"
|
||||
#include "util.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "wutil.h"
|
||||
#include "env_universal_common.h"
|
||||
@@ -112,24 +126,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;
|
||||
}
|
||||
|
||||
@@ -153,7 +164,6 @@ static void callback( int type, const wchar_t *name, const wchar_t *val )
|
||||
{
|
||||
if( type == BARRIER_REPLY )
|
||||
{
|
||||
debug( 3, L"Got barrier reply" );
|
||||
barrier_reply = 1;
|
||||
}
|
||||
else
|
||||
@@ -174,11 +184,16 @@ static void check_connection()
|
||||
|
||||
if( env_universal_server.killme )
|
||||
{
|
||||
debug( 2, L"Lost connection to universal variable server." );
|
||||
close( env_universal_server.fd );
|
||||
debug( 3, L"Lost connection to universal variable server." );
|
||||
|
||||
if( close( env_universal_server.fd ) )
|
||||
{
|
||||
wperror( L"close" );
|
||||
}
|
||||
|
||||
env_universal_server.fd = -1;
|
||||
env_universal_server.killme=0;
|
||||
sb_clear( &env_universal_server.input );
|
||||
env_universal_server.input.used=0;
|
||||
env_universal_read_all();
|
||||
}
|
||||
}
|
||||
@@ -193,9 +208,10 @@ 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.buffer_consumed = env_universal_server.buffer_used = 0;
|
||||
env_universal_server.fd = get_socket(1);
|
||||
init = 1;
|
||||
if( env_universal_server.fd >= 0 )
|
||||
@@ -210,26 +226,21 @@ 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()" );
|
||||
path=p;
|
||||
user=u;
|
||||
start_fishd=sf;
|
||||
external_callback = cb;
|
||||
|
||||
connection_init( &env_universal_server, -1 );
|
||||
|
||||
env_universal_server.fd = -1;
|
||||
env_universal_server.killme = 0;
|
||||
env_universal_server.fd = get_socket(1);
|
||||
memset (&env_universal_server.wstate, '\0', sizeof (mbstate_t));
|
||||
q_init( &env_universal_server.unsent );
|
||||
env_universal_common_init( &callback );
|
||||
sb_init( &env_universal_server.input );
|
||||
env_universal_read_all();
|
||||
init = 1;
|
||||
if( env_universal_server.fd >= 0 )
|
||||
{
|
||||
env_universal_barrier();
|
||||
}
|
||||
debug( 2, L"end env_universal_init()" );
|
||||
}
|
||||
|
||||
void env_universal_destroy()
|
||||
@@ -243,12 +254,11 @@ void env_universal_destroy()
|
||||
{
|
||||
wperror( L"fcntl" );
|
||||
}
|
||||
try_send_all( &env_universal_server );
|
||||
try_send_all( &env_universal_server );
|
||||
}
|
||||
close( env_universal_server.fd );
|
||||
|
||||
connection_destroy( &env_universal_server );
|
||||
env_universal_server.fd =-1;
|
||||
q_destroy( &env_universal_server.unsent );
|
||||
sb_destroy( &env_universal_server.input );
|
||||
env_universal_common_destroy();
|
||||
init = 0;
|
||||
}
|
||||
@@ -286,15 +296,19 @@ wchar_t *env_universal_get( const wchar_t *name )
|
||||
{
|
||||
if( !init)
|
||||
return 0;
|
||||
|
||||
if( !name )
|
||||
return 0;
|
||||
|
||||
CHECK( name, 0 );
|
||||
|
||||
return env_universal_common_get( name );
|
||||
}
|
||||
|
||||
int env_universal_get_export( const wchar_t *name )
|
||||
{
|
||||
if( !init)
|
||||
return 0;
|
||||
|
||||
CHECK( name, 0 );
|
||||
|
||||
return env_universal_common_get_export( name );
|
||||
}
|
||||
|
||||
@@ -305,7 +319,7 @@ void env_universal_barrier()
|
||||
|
||||
if( !init || ( env_universal_server.fd == -1 ))
|
||||
return;
|
||||
|
||||
|
||||
barrier_reply = 0;
|
||||
|
||||
/*
|
||||
@@ -330,6 +344,7 @@ void env_universal_barrier()
|
||||
if( env_universal_server.fd == -1 )
|
||||
{
|
||||
reconnect();
|
||||
debug( 2, L"barrier interrupted, exiting" );
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -337,7 +352,7 @@ void env_universal_barrier()
|
||||
FD_SET( env_universal_server.fd, &fds );
|
||||
select( env_universal_server.fd+1, 0, &fds, 0, 0 );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Wait for barrier reply
|
||||
*/
|
||||
@@ -347,6 +362,7 @@ void env_universal_barrier()
|
||||
if( env_universal_server.fd == -1 )
|
||||
{
|
||||
reconnect();
|
||||
debug( 2, L"barrier interrupted, exiting (2)" );
|
||||
return;
|
||||
}
|
||||
FD_ZERO( &fds );
|
||||
@@ -364,8 +380,10 @@ 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 );
|
||||
|
||||
CHECK( name, );
|
||||
|
||||
debug( 3, L"env_universal_set( \"%ls\", \"%ls\" )", name, value );
|
||||
|
||||
msg = create_message( export?SET_EXPORT:SET,
|
||||
name,
|
||||
@@ -382,26 +400,37 @@ void env_universal_set( const wchar_t *name, const wchar_t *value, int export )
|
||||
env_universal_barrier();
|
||||
}
|
||||
|
||||
void env_universal_remove( const wchar_t *name )
|
||||
int env_universal_remove( const wchar_t *name )
|
||||
{
|
||||
int res;
|
||||
|
||||
message_t *msg;
|
||||
if( !init )
|
||||
return;
|
||||
return 1;
|
||||
|
||||
CHECK( name, 1 );
|
||||
|
||||
res = !env_universal_common_get( name );
|
||||
|
||||
debug( 2,
|
||||
L"env_universal_remove( %ls )",
|
||||
debug( 3,
|
||||
L"env_universal_remove( \"%ls\" )",
|
||||
name );
|
||||
|
||||
msg= create_message( ERASE, name, 0);
|
||||
msg->count=1;
|
||||
q_put( &env_universal_server.unsent, msg );
|
||||
env_universal_barrier();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void env_universal_get_names( array_list_t *l,
|
||||
int show_exported,
|
||||
int show_unexported )
|
||||
{
|
||||
if( !init )
|
||||
return;
|
||||
|
||||
env_universal_common_get_names( l,
|
||||
show_exported,
|
||||
show_unexported );
|
||||
|
||||
@@ -40,8 +40,10 @@ int env_universal_get_export( const wchar_t *name );
|
||||
void env_universal_set( const wchar_t *name, const wchar_t *val, int export );
|
||||
/**
|
||||
Erase a universal variable
|
||||
|
||||
\return zero if the variable existed, and non-zero if the variable did not exist
|
||||
*/
|
||||
void env_universal_remove( const wchar_t *name );
|
||||
int env_universal_remove( const wchar_t *name );
|
||||
|
||||
/**
|
||||
Read all available messages from the server.
|
||||
|
||||
@@ -5,10 +5,13 @@
|
||||
client library and by the daemon.
|
||||
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
#include <strings.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
@@ -18,6 +21,7 @@
|
||||
#include <sys/stat.h>
|
||||
#include <dirent.h>
|
||||
#include <wctype.h>
|
||||
#include <iconv.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <locale.h>
|
||||
@@ -25,7 +29,13 @@
|
||||
#include <signal.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
|
||||
#include "fallback.h"
|
||||
#include "util.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "wutil.h"
|
||||
#include "env_universal_common.h"
|
||||
@@ -60,6 +70,21 @@
|
||||
*/
|
||||
#define PARSE_ERR L"Unable to parse universal variable message: '%ls'"
|
||||
|
||||
/**
|
||||
ERROR string for internal buffered reader
|
||||
*/
|
||||
#define ENV_UNIVERSAL_ERROR 0x100
|
||||
|
||||
/**
|
||||
EAGAIN string for internal buffered reader
|
||||
*/
|
||||
#define ENV_UNIVERSAL_AGAIN 0x101
|
||||
|
||||
/**
|
||||
EOF string for internal buffered reader
|
||||
*/
|
||||
#define ENV_UNIVERSAL_EOF 0x102
|
||||
|
||||
/**
|
||||
A variable entry. Stores the value of a variable and whether it
|
||||
should be exported. Obviously, it needs to be allocated large
|
||||
@@ -101,9 +126,163 @@ static int get_names_show_exported;
|
||||
static int get_names_show_unexported;
|
||||
|
||||
|
||||
wchar_t *utf2wcs( const char *in )
|
||||
{
|
||||
iconv_t cd=(iconv_t) -1;
|
||||
int i,j;
|
||||
|
||||
wchar_t *out;
|
||||
|
||||
char *to_name[]=
|
||||
{
|
||||
"wchar_t", "WCHAR_T", "wchar", "WCHAR", 0
|
||||
}
|
||||
;
|
||||
|
||||
char *from_name[]=
|
||||
{
|
||||
"utf-8", "UTF-8", "utf8", "UTF8", 0
|
||||
}
|
||||
;
|
||||
|
||||
size_t in_len = strlen( in );
|
||||
size_t out_len = sizeof( wchar_t )*(in_len+1);
|
||||
size_t nconv;
|
||||
char *nout;
|
||||
|
||||
out = malloc( out_len );
|
||||
nout = (char *)out;
|
||||
|
||||
if( !out )
|
||||
return 0;
|
||||
|
||||
for( i=0; to_name[i]; i++ )
|
||||
{
|
||||
for( j=0; from_name[j]; j++ )
|
||||
{
|
||||
cd = iconv_open ( to_name[i], from_name[j] );
|
||||
|
||||
if( cd != (iconv_t) -1)
|
||||
{
|
||||
goto start_conversion;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
start_conversion:
|
||||
|
||||
if (cd == (iconv_t) -1)
|
||||
{
|
||||
/* Something went wrong. */
|
||||
debug( 0, L"Could not perform utf-8 conversion" );
|
||||
if(errno != EINVAL)
|
||||
wperror( L"iconv_open" );
|
||||
|
||||
/* Terminate the output string. */
|
||||
free(out);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
nconv = iconv( cd, (char **)&in, &in_len, &nout, &out_len );
|
||||
|
||||
if (nconv == (size_t) -1)
|
||||
{
|
||||
debug( 0, L"Error while converting from utf string" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
*((wchar_t *) nout) = L'\0';
|
||||
|
||||
if (iconv_close (cd) != 0)
|
||||
wperror (L"iconv_close");
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
char *wcs2utf( const wchar_t *in )
|
||||
{
|
||||
iconv_t cd=(iconv_t) -1;
|
||||
int i,j;
|
||||
|
||||
char *char_in = (char *)in;
|
||||
char *out;
|
||||
|
||||
char *from_name[]=
|
||||
{
|
||||
"wchar_t", "WCHAR_T", "wchar", "WCHAR", 0
|
||||
}
|
||||
;
|
||||
|
||||
char *to_name[]=
|
||||
{
|
||||
"utf-8", "UTF-8", "utf8", "UTF8", 0
|
||||
}
|
||||
;
|
||||
|
||||
size_t in_len = wcslen( in );
|
||||
size_t out_len = sizeof( char )*( (MAX_UTF8_BYTES*in_len)+1);
|
||||
size_t nconv;
|
||||
char *nout;
|
||||
|
||||
out = malloc( out_len );
|
||||
nout = (char *)out;
|
||||
in_len *= sizeof( wchar_t );
|
||||
|
||||
if( !out )
|
||||
return 0;
|
||||
|
||||
for( i=0; to_name[i]; i++ )
|
||||
{
|
||||
for( j=0; from_name[j]; j++ )
|
||||
{
|
||||
cd = iconv_open ( to_name[i], from_name[j] );
|
||||
|
||||
if( cd != (iconv_t) -1)
|
||||
{
|
||||
goto start_conversion;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
start_conversion:
|
||||
|
||||
if (cd == (iconv_t) -1)
|
||||
{
|
||||
/* Something went wrong. */
|
||||
debug( 0, L"Could not perform utf-8 conversion" );
|
||||
if(errno != EINVAL)
|
||||
wperror( L"iconv_open" );
|
||||
|
||||
/* Terminate the output string. */
|
||||
free(out);
|
||||
return 0;
|
||||
}
|
||||
|
||||
nconv = iconv( cd, &char_in, &in_len, &nout, &out_len );
|
||||
|
||||
|
||||
if (nconv == (size_t) -1)
|
||||
{
|
||||
debug( 0, L"%d %d", in_len, out_len );
|
||||
debug( 0, L"Error while converting from to string" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
*nout = '\0';
|
||||
|
||||
if (iconv_close (cd) != 0)
|
||||
wperror (L"iconv_close");
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void env_universal_common_init( void (*cb)(int type, const wchar_t *key, const wchar_t *val ) )
|
||||
{
|
||||
debug( 2, L"Init env_universal_common" );
|
||||
callback = cb;
|
||||
hash_init( &env_universal_var, &hash_wcs_func, &hash_wcs_cmp );
|
||||
}
|
||||
@@ -111,8 +290,8 @@ void env_universal_common_init( void (*cb)(int type, const wchar_t *key, const w
|
||||
/**
|
||||
Free both key and data
|
||||
*/
|
||||
static void erase( const void *key,
|
||||
const void *data )
|
||||
static void erase( void *key,
|
||||
void *data )
|
||||
{
|
||||
free( (void *)key );
|
||||
free( (void *)data );
|
||||
@@ -125,69 +304,118 @@ void env_universal_common_destroy()
|
||||
hash_destroy( &env_universal_var );
|
||||
}
|
||||
|
||||
static int read_byte( connection_t *src )
|
||||
{
|
||||
|
||||
if( src->buffer_consumed >= src->buffer_used )
|
||||
{
|
||||
|
||||
int res;
|
||||
|
||||
res = read( src->fd, src->buffer, ENV_UNIVERSAL_BUFFER_SIZE );
|
||||
|
||||
// debug(4, L"Read chunk '%.*s'", res, src->buffer );
|
||||
|
||||
if( res < 0 )
|
||||
{
|
||||
|
||||
if( errno == EAGAIN ||
|
||||
errno == EINTR )
|
||||
{
|
||||
return ENV_UNIVERSAL_AGAIN;
|
||||
}
|
||||
|
||||
return ENV_UNIVERSAL_ERROR;
|
||||
|
||||
}
|
||||
|
||||
if( res == 0 )
|
||||
{
|
||||
return ENV_UNIVERSAL_EOF;
|
||||
}
|
||||
|
||||
src->buffer_consumed = 0;
|
||||
src->buffer_used = res;
|
||||
}
|
||||
|
||||
return src->buffer[src->buffer_consumed++];
|
||||
|
||||
}
|
||||
|
||||
|
||||
void read_message( connection_t *src )
|
||||
{
|
||||
while( 1 )
|
||||
{
|
||||
char b;
|
||||
int read_res = read( src->fd, &b, 1 );
|
||||
wchar_t res=0;
|
||||
|
||||
if( read_res < 0 )
|
||||
int ib = read_byte( src );
|
||||
char b;
|
||||
|
||||
switch( ib )
|
||||
{
|
||||
if( errno != EAGAIN &&
|
||||
errno != EINTR )
|
||||
case ENV_UNIVERSAL_AGAIN:
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
case ENV_UNIVERSAL_ERROR:
|
||||
{
|
||||
debug( 2, L"Read error on fd %d, set killme flag", src->fd );
|
||||
wperror( L"read" );
|
||||
if( debug_level > 2 )
|
||||
wperror( L"read" );
|
||||
src->killme = 1;
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if( read_res == 0 )
|
||||
{
|
||||
src->killme = 1;
|
||||
debug( 3, L"Fd %d has reached eof, set killme flag", src->fd );
|
||||
if( src->input.used > 0 )
|
||||
|
||||
case ENV_UNIVERSAL_EOF:
|
||||
{
|
||||
debug( 1,
|
||||
L"Universal variable connection closed while reading command. Partial command recieved: '%ls'",
|
||||
(wchar_t *)src->input.buff );
|
||||
src->killme = 1;
|
||||
debug( 3, L"Fd %d has reached eof, set killme flag", src->fd );
|
||||
if( src->input.used > 0 )
|
||||
{
|
||||
char c = 0;
|
||||
b_append( &src->input, &c, 1 );
|
||||
debug( 1,
|
||||
L"Universal variable connection closed while reading command. Partial command recieved: '%s'",
|
||||
(wchar_t *)src->input.buff );
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int sz = mbrtowc( &res, &b, 1, &src->wstate );
|
||||
b = (char)ib;
|
||||
|
||||
if( sz == -1 )
|
||||
{
|
||||
debug( 1, L"Error while reading universal variable after '%ls'", (wchar_t *)src->input.buff );
|
||||
wperror( L"mbrtowc" );
|
||||
}
|
||||
else if( sz > 0 )
|
||||
if( b == '\n' )
|
||||
{
|
||||
if( res == L'\n' )
|
||||
wchar_t *msg;
|
||||
|
||||
b = 0;
|
||||
b_append( &src->input, &b, 1 );
|
||||
|
||||
msg = utf2wcs( src->input.buff );
|
||||
|
||||
/*
|
||||
Before calling parse_message, we must empty reset
|
||||
everything, since the callback function could
|
||||
potentially call read_message.
|
||||
*/
|
||||
src->input.used=0;
|
||||
|
||||
if( msg )
|
||||
{
|
||||
/*
|
||||
Before calling parse_message, we must empty reset
|
||||
everything, since the callback function could
|
||||
potentially call read_message.
|
||||
*/
|
||||
|
||||
wchar_t *msg = wcsdup( (wchar_t *)src->input.buff );
|
||||
sb_clear( &src->input );
|
||||
memset (&src->wstate, '\0', sizeof (mbstate_t));
|
||||
|
||||
|
||||
parse_message( msg, src );
|
||||
free( msg );
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
sb_printf( &src->input, L"%lc", res );
|
||||
debug( 0, _(L"Could not convert message '%s' to wide character string"), src->input.buff );
|
||||
}
|
||||
|
||||
free( msg );
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
b_append( &src->input, &b, 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -200,8 +428,8 @@ static void remove_entry( wchar_t *name )
|
||||
void *k, *v;
|
||||
hash_remove( &env_universal_var,
|
||||
name,
|
||||
(const void **)&k,
|
||||
(const void **)&v );
|
||||
&k,
|
||||
&v );
|
||||
free( k );
|
||||
free( v );
|
||||
}
|
||||
@@ -227,7 +455,7 @@ static int match( const wchar_t *msg, const wchar_t *cmd )
|
||||
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;
|
||||
@@ -256,7 +484,7 @@ static void parse_message( wchar_t *msg,
|
||||
var_uni_entry_t *entry =
|
||||
malloc( sizeof(var_uni_entry_t) + sizeof(wchar_t)*(wcslen(val)+1) );
|
||||
if( !entry )
|
||||
die_mem();
|
||||
DIE_MEM();
|
||||
entry->export=export;
|
||||
|
||||
wcscpy( entry->val, val );
|
||||
@@ -334,7 +562,16 @@ static int try_send( message_t *msg,
|
||||
L"before write of %d chars to fd %d", strlen(msg->body), fd );
|
||||
|
||||
int res = write( fd, msg->body, strlen(msg->body) );
|
||||
|
||||
|
||||
if( res != -1 )
|
||||
{
|
||||
debug( 4, L"Wrote message '%s'", msg->body );
|
||||
}
|
||||
else
|
||||
{
|
||||
debug( 4, L"Failed to write message '%s'", msg->body );
|
||||
}
|
||||
|
||||
if( res == -1 )
|
||||
{
|
||||
switch( errno )
|
||||
@@ -343,10 +580,11 @@ static int try_send( message_t *msg,
|
||||
return 0;
|
||||
|
||||
default:
|
||||
debug( 1,
|
||||
debug( 2,
|
||||
L"Error while sending universal variable message to fd %d. Closing connection",
|
||||
fd );
|
||||
wperror( L"write" );
|
||||
if( debug_level > 2 )
|
||||
wperror( L"write" );
|
||||
|
||||
return -1;
|
||||
}
|
||||
@@ -362,9 +600,9 @@ static int try_send( message_t *msg,
|
||||
|
||||
void try_send_all( connection_t *c )
|
||||
{
|
||||
debug( 3,
|
||||
/* debug( 3,
|
||||
L"Send all updates to connection on fd %d",
|
||||
c->fd );
|
||||
c->fd );*/
|
||||
while( !q_empty( &c->unsent) )
|
||||
{
|
||||
switch( try_send( (message_t *)q_peek( &c->unsent), c->fd ) )
|
||||
@@ -374,7 +612,7 @@ void try_send_all( connection_t *c )
|
||||
break;
|
||||
|
||||
case 0:
|
||||
debug( 1,
|
||||
debug( 4,
|
||||
L"Socket full, send rest later" );
|
||||
return;
|
||||
|
||||
@@ -385,6 +623,33 @@ void try_send_all( connection_t *c )
|
||||
}
|
||||
}
|
||||
|
||||
static wchar_t *full_escape( const wchar_t *in )
|
||||
{
|
||||
string_buffer_t out;
|
||||
sb_init( &out );
|
||||
for( ; *in; in++ )
|
||||
{
|
||||
if( *in < 32 )
|
||||
{
|
||||
sb_printf( &out, L"\\x%.2x", *in );
|
||||
}
|
||||
else if( *in < 128 )
|
||||
{
|
||||
sb_append_char( &out, *in );
|
||||
}
|
||||
else if( *in < 65536 )
|
||||
{
|
||||
sb_printf( &out, L"\\u%.4x", *in );
|
||||
}
|
||||
else
|
||||
{
|
||||
sb_printf( &out, L"\\U%.8x", *in );
|
||||
}
|
||||
}
|
||||
return (wchar_t *)out.buff;
|
||||
}
|
||||
|
||||
|
||||
message_t *create_message( int type,
|
||||
const wchar_t *key_in,
|
||||
const wchar_t *val_in )
|
||||
@@ -393,10 +658,18 @@ message_t *create_message( int type,
|
||||
|
||||
char *key=0;
|
||||
size_t sz;
|
||||
|
||||
// debug( 4, L"Crete message of type %d", type );
|
||||
|
||||
if( key_in )
|
||||
{
|
||||
key = wcs2str(key_in);
|
||||
if( wcsvarname( key_in ) )
|
||||
{
|
||||
debug( 0, L"Illegal variable name: '%ls'", key_in );
|
||||
return 0;
|
||||
}
|
||||
|
||||
key = wcs2utf(key_in);
|
||||
if( !key )
|
||||
{
|
||||
debug( 0,
|
||||
@@ -417,18 +690,18 @@ message_t *create_message( int type,
|
||||
val_in=L"";
|
||||
}
|
||||
|
||||
wchar_t *esc = escape(val_in,1);
|
||||
wchar_t *esc = full_escape( val_in );
|
||||
if( !esc )
|
||||
break;
|
||||
|
||||
char *val = wcs2str(esc );
|
||||
char *val = wcs2utf(esc );
|
||||
free(esc);
|
||||
|
||||
sz = strlen(type==SET?SET_MBS:SET_EXPORT_MBS) + strlen(key) + strlen(val) + 4;
|
||||
msg = malloc( sizeof( message_t ) + sz );
|
||||
|
||||
if( !msg )
|
||||
die_mem();
|
||||
DIE_MEM();
|
||||
|
||||
strcpy( msg->body, (type==SET?SET_MBS:SET_EXPORT_MBS) );
|
||||
strcat( msg->body, " " );
|
||||
@@ -448,7 +721,7 @@ message_t *create_message( int type,
|
||||
msg = malloc( sizeof( message_t ) + sz );
|
||||
|
||||
if( !msg )
|
||||
die_mem();
|
||||
DIE_MEM();
|
||||
|
||||
strcpy( msg->body, ERASE_MBS " " );
|
||||
strcat( msg->body, key );
|
||||
@@ -461,7 +734,7 @@ message_t *create_message( int type,
|
||||
msg = malloc( sizeof( message_t ) +
|
||||
strlen( BARRIER_MBS ) +2);
|
||||
if( !msg )
|
||||
die_mem();
|
||||
DIE_MEM();
|
||||
strcpy( msg->body, BARRIER_MBS "\n" );
|
||||
break;
|
||||
}
|
||||
@@ -471,7 +744,7 @@ message_t *create_message( int type,
|
||||
msg = malloc( sizeof( message_t ) +
|
||||
strlen( BARRIER_REPLY_MBS ) +2);
|
||||
if( !msg )
|
||||
die_mem();
|
||||
DIE_MEM();
|
||||
strcpy( msg->body, BARRIER_REPLY_MBS "\n" );
|
||||
break;
|
||||
}
|
||||
@@ -486,6 +759,9 @@ message_t *create_message( int type,
|
||||
|
||||
if( msg )
|
||||
msg->count=0;
|
||||
|
||||
// debug( 4, L"Message body is '%s'", msg->body );
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
@@ -493,8 +769,8 @@ message_t *create_message( int type,
|
||||
Function used with hash_foreach to insert keys of one table into
|
||||
another
|
||||
*/
|
||||
static void add_key_to_hash( const void *key,
|
||||
const void *data,
|
||||
static void add_key_to_hash( void *key,
|
||||
void *data,
|
||||
void *aux )
|
||||
{
|
||||
var_uni_entry_t *e = (var_uni_entry_t *)data;
|
||||
@@ -541,8 +817,8 @@ int env_universal_common_get_export( const wchar_t *name )
|
||||
\param v the variable value
|
||||
\param q the queue to add the message to
|
||||
*/
|
||||
static void enqueue( const void *k,
|
||||
const void *v,
|
||||
static void enqueue( void *k,
|
||||
void *v,
|
||||
void *q)
|
||||
{
|
||||
const wchar_t *key = (const wchar_t *)k;
|
||||
@@ -563,3 +839,22 @@ void enqueue_all( connection_t *c )
|
||||
try_send_all( c );
|
||||
}
|
||||
|
||||
|
||||
void connection_init( connection_t *c, int fd )
|
||||
{
|
||||
memset (c, 0, sizeof (connection_t));
|
||||
c->fd = fd;
|
||||
b_init( &c->input );
|
||||
q_init( &c->unsent );
|
||||
c->buffer_consumed = c->buffer_used = 0;
|
||||
}
|
||||
|
||||
void connection_destroy( connection_t *c)
|
||||
{
|
||||
q_destroy( &c->unsent );
|
||||
b_destroy( &c->input );
|
||||
if( close( c->fd ) )
|
||||
{
|
||||
wperror( L"close" );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,11 @@ enum
|
||||
}
|
||||
;
|
||||
|
||||
/**
|
||||
The size of the buffer used for reading from the socket
|
||||
*/
|
||||
#define ENV_UNIVERSAL_BUFFER_SIZE 1024
|
||||
|
||||
/**
|
||||
This struct represents a connection between a universal variable server/client
|
||||
*/
|
||||
@@ -66,16 +71,28 @@ typedef struct connection
|
||||
Set to one when this connection should be killed
|
||||
*/
|
||||
int killme;
|
||||
/**
|
||||
The state used for character conversions
|
||||
*/
|
||||
mbstate_t wstate;
|
||||
/**
|
||||
The input string. Input from the socket goes here. When a
|
||||
newline is encountered, the buffer is parsed and cleared.
|
||||
*/
|
||||
string_buffer_t input;
|
||||
buffer_t input;
|
||||
|
||||
/**
|
||||
The read buffer.
|
||||
*/
|
||||
char buffer[ENV_UNIVERSAL_BUFFER_SIZE];
|
||||
|
||||
/**
|
||||
Number of bytes that have already been consumed.
|
||||
*/
|
||||
int buffer_consumed;
|
||||
|
||||
/**
|
||||
Number of bytes that have been read into the buffer.
|
||||
*/
|
||||
int buffer_used;
|
||||
|
||||
|
||||
/**
|
||||
Link to the next connection
|
||||
*/
|
||||
@@ -147,5 +164,8 @@ int env_universal_common_get_export( const wchar_t *name );
|
||||
*/
|
||||
void enqueue_all( connection_t *c );
|
||||
|
||||
void connection_init( connection_t *c, int fd );
|
||||
void connection_destroy( connection_t *c);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
66
etc/config.fish.in
Normal file
66
etc/config.fish.in
Normal file
@@ -0,0 +1,66 @@
|
||||
#
|
||||
# Init file for fish
|
||||
#
|
||||
# @configure_input@
|
||||
|
||||
#
|
||||
# Set default field separators
|
||||
#
|
||||
|
||||
set -g IFS \ \t\n
|
||||
|
||||
#
|
||||
# Some things should only be done for login terminals
|
||||
#
|
||||
|
||||
if status --is-login
|
||||
|
||||
#
|
||||
# Set some value for LANG if nothing was set before, and this is a
|
||||
# login shell.
|
||||
#
|
||||
|
||||
if not set -q LANG >/dev/null
|
||||
set -gx LANG en_US.UTF-8
|
||||
end
|
||||
|
||||
# Check for i18n information in
|
||||
# /etc/sysconfig/i18n
|
||||
|
||||
if test -f /etc/sysconfig/i18n
|
||||
eval (cat /etc/sysconfig/i18n |sed -ne 's/^\([a-zA-Z]*\)=\(.*\)$/set -gx \1 \2;/p')
|
||||
end
|
||||
|
||||
#
|
||||
# Put linux consoles in unicode mode.
|
||||
#
|
||||
|
||||
if expr "$LANG" : ".*\.[Uu][Tt][Ff].*" >/dev/null
|
||||
if test "$TERM" = linux
|
||||
if which unicode_start >/dev/null
|
||||
unicode_start
|
||||
end
|
||||
end
|
||||
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
|
||||
#
|
||||
|
||||
if test -d include
|
||||
for i in include/*.fish
|
||||
. $i
|
||||
end
|
||||
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
|
||||
282
event.c
282
event.c
@@ -3,6 +3,8 @@
|
||||
Functions for handling event triggers
|
||||
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
@@ -11,8 +13,10 @@
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "fallback.h"
|
||||
#include "util.h"
|
||||
|
||||
#include "wutil.h"
|
||||
#include "function.h"
|
||||
#include "proc.h"
|
||||
#include "parser.h"
|
||||
@@ -20,6 +24,8 @@
|
||||
#include "event.h"
|
||||
#include "signal.h"
|
||||
|
||||
#include "halloc_util.h"
|
||||
|
||||
/**
|
||||
Number of signals that can be queued before an overflow occurs
|
||||
*/
|
||||
@@ -51,7 +57,7 @@ typedef struct
|
||||
active, which is the one that new events is written to. The inactive
|
||||
one contains the events that are currently beeing performed.
|
||||
*/
|
||||
static signal_list_t sig_list[2];
|
||||
static signal_list_t sig_list[]={{0,0},{0,0}};
|
||||
|
||||
/**
|
||||
The index of sig_list that is the list of signals currently written to
|
||||
@@ -67,10 +73,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 )
|
||||
@@ -120,11 +136,11 @@ 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 )
|
||||
die_mem();
|
||||
DIE_MEM();
|
||||
memcpy( e, event, sizeof(event_t));
|
||||
|
||||
if( e->function_name )
|
||||
@@ -133,15 +149,119 @@ 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 )
|
||||
{
|
||||
|
||||
CHECK( e, 0 );
|
||||
|
||||
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;
|
||||
|
||||
CHECK( event, );
|
||||
|
||||
e = event_copy( event, 0 );
|
||||
|
||||
if( !events )
|
||||
events = al_new();
|
||||
events = al_new();
|
||||
|
||||
if( e->type == EVENT_SIGNAL )
|
||||
{
|
||||
@@ -157,14 +277,19 @@ void event_remove( event_t *criterion )
|
||||
array_list_t *new_list=0;
|
||||
event_t e;
|
||||
|
||||
CHECK( criterion, );
|
||||
|
||||
/*
|
||||
Because of concurrency issues, env_remove does not actually free
|
||||
any events - instead it simply moves all events that should be
|
||||
removed from the event list to the killme list.
|
||||
Because of concurrency issues (env_remove could remove an event
|
||||
that is currently being executed), env_remove does not actually
|
||||
free any events - instead it simply moves all events that should
|
||||
be removed from the event list to the killme list, and the ones
|
||||
that shouldn't be killed to new_list, and then drops the empty
|
||||
events-list.
|
||||
*/
|
||||
|
||||
if( !events )
|
||||
return;
|
||||
return;
|
||||
|
||||
for( i=0; i<al_get_count( events); i++ )
|
||||
{
|
||||
@@ -212,6 +337,8 @@ int event_get( event_t *criterion, array_list_t *out )
|
||||
|
||||
if( !events )
|
||||
return 0;
|
||||
|
||||
CHECK( criterion, 0 );
|
||||
|
||||
for( i=0; i<al_get_count( events); i++ )
|
||||
{
|
||||
@@ -264,11 +391,11 @@ static int event_is_killed( event_t *e )
|
||||
|
||||
/**
|
||||
Perform the specified event. Since almost all event firings will
|
||||
not match a single event handler, we make sureto optimize the 'no
|
||||
matches' path. This means that nothing is allocated/initialized
|
||||
unless that is needed.
|
||||
not be matched by even a single event handler, we make sure to
|
||||
optimize the 'no matches' path. This means that nothing is
|
||||
allocated/initialized unless 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;
|
||||
@@ -317,7 +444,8 @@ static void event_fire_internal( event_t *event, array_list_t *arguments )
|
||||
for( i=0; i<al_get_count( fire ); i++ )
|
||||
{
|
||||
event_t *criterion = (event_t *)al_get( fire, i );
|
||||
|
||||
int prev_status;
|
||||
|
||||
/*
|
||||
Check if this event has been removed, if so, dont fire it
|
||||
*/
|
||||
@@ -334,9 +462,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 );
|
||||
@@ -344,13 +472,18 @@ 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
|
||||
*/
|
||||
proc_push_interactive(0);
|
||||
prev_status = proc_get_last_status();
|
||||
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();
|
||||
proc_set_last_status( prev_status );
|
||||
}
|
||||
|
||||
if( b )
|
||||
@@ -375,15 +508,47 @@ 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 is_event is one, we are running the event-handler non-recursively.
|
||||
|
||||
When the event handler has called a piece of code that triggers
|
||||
another event, we do not want to fire delayed events because of
|
||||
concurrency problems.
|
||||
*/
|
||||
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
|
||||
@@ -402,7 +567,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." ) );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -411,19 +576,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) )
|
||||
@@ -431,44 +604,57 @@ void event_fire( event_t *event, array_list_t *arguments )
|
||||
/*
|
||||
This means we are in a signal handler. We must be very
|
||||
careful not do do anything that could cause a memory
|
||||
allocation or something else that might be illegal in a
|
||||
allocation or something else that might be bad when in a
|
||||
signal handler.
|
||||
*/
|
||||
if( sig_list[active_list].count < SIG_UNHANDLED_MAX )
|
||||
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--;
|
||||
}
|
||||
|
||||
|
||||
void event_init()
|
||||
{
|
||||
sig_list[active_list].count=0;
|
||||
}
|
||||
|
||||
void event_destroy()
|
||||
{
|
||||
|
||||
if( events )
|
||||
{
|
||||
al_foreach( events, (void (*)(const void *))&event_free );
|
||||
al_foreach( events, (void (*)(void *))&event_free );
|
||||
al_destroy( events );
|
||||
free( events );
|
||||
events=0;
|
||||
}
|
||||
|
||||
if( killme )
|
||||
{
|
||||
al_foreach( killme, (void (*)(const void *))&event_free );
|
||||
al_foreach( killme, (void (*)(void *))&event_free );
|
||||
al_destroy( killme );
|
||||
free( killme );
|
||||
killme=0;
|
||||
@@ -477,9 +663,17 @@ void event_destroy()
|
||||
|
||||
void event_free( event_t *e )
|
||||
{
|
||||
CHECK( e, );
|
||||
|
||||
/*
|
||||
When apropriate, we clear the argument vector
|
||||
*/
|
||||
al_foreach( &e->arguments, &free );
|
||||
al_destroy( &e->arguments );
|
||||
|
||||
free( (void *)e->function_name );
|
||||
if( e->type == EVENT_VARIABLE )
|
||||
free( (void *)e->param1.variable );
|
||||
free( e );
|
||||
}
|
||||
|
||||
|
||||
|
||||
34
event.h
34
event.h
@@ -17,6 +17,9 @@
|
||||
*/
|
||||
#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
|
||||
|
||||
17
exec.h
17
exec.h
@@ -16,18 +16,7 @@
|
||||
/**
|
||||
pipe redirection error message
|
||||
*/
|
||||
#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
|
||||
*/
|
||||
void exec_destroy();
|
||||
#define PIPE_ERROR _(L"An error occurred while setting up pipe")
|
||||
|
||||
/**
|
||||
Execute the processes specified by j.
|
||||
@@ -62,8 +51,8 @@ void exec( job_t *j );
|
||||
|
||||
\return the status of the last job to exit, or -1 if en error was encountered.
|
||||
*/
|
||||
int exec_subshell( const wchar_t *cmd,
|
||||
array_list_t *l );
|
||||
__warn_unused int exec_subshell( const wchar_t *cmd,
|
||||
array_list_t *l );
|
||||
|
||||
|
||||
/**
|
||||
|
||||
156
expand.h
156
expand.h
@@ -1,12 +1,12 @@
|
||||
/**\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
|
||||
@@ -20,17 +20,17 @@
|
||||
#include "util.h"
|
||||
|
||||
/**
|
||||
Flag specifying that subshell expantion should be skipped
|
||||
Flag specifying that cmdsubst expansion should be skipped
|
||||
*/
|
||||
#define EXPAND_SKIP_SUBSHELL 1
|
||||
#define EXPAND_SKIP_CMDSUBST 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
|
||||
|
||||
@@ -64,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
|
||||
}
|
||||
;
|
||||
|
||||
@@ -88,102 +113,91 @@ enum
|
||||
#define ARRAY_SEP_STR L"\x1e"
|
||||
|
||||
/**
|
||||
Separate subtokens in a token with this character.
|
||||
Error issued on array out of bounds
|
||||
*/
|
||||
#define INTERNAL_SEPARATOR 0xfffffff0
|
||||
|
||||
#define ARRAY_BOUNDS_ERR _(L"Array index out of bounds")
|
||||
|
||||
|
||||
/**
|
||||
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
|
||||
(\~USER becomes the users home directory), variable expansion
|
||||
(\$VAR_NAME becomes the value of the environment variable VAR_NAME),
|
||||
cmdsubst 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
|
||||
out. If expansion is performed, the original parameter is freed and
|
||||
newly allocated strings are inserted into the list out.
|
||||
|
||||
|
||||
If \c context is non-null, all the strings contained in the
|
||||
array_list_t \c out will be registered to be free'd when context is
|
||||
free'd.
|
||||
|
||||
\param context the halloc context to use for automatic deallocation
|
||||
\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_CMDSUBST 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. EXPAND_WILDCARD_NO_MATCH and EXPAND_WILDCARD_MATCH are normal exit conditions used only on strings containing wildcards to tell if the wildcard produced any matches.
|
||||
*/
|
||||
int expand_string( wchar_t *in, array_list_t *out, int flag );
|
||||
__warn_unused 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
|
||||
expands to more than one string. This is used for expanding command
|
||||
names.
|
||||
|
||||
If \c context is non-null, the returning string ill be registered
|
||||
to be free'd when context is free'd.
|
||||
|
||||
\param context the halloc context to use for automatic deallocation
|
||||
\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_CMDSUBST 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 in a
|
||||
private use area of Unicode. This assumes wchar_t is a unicode
|
||||
character. 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.
|
||||
|
||||
\param in the value to escape
|
||||
*/
|
||||
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.
|
||||
|
||||
\param in the string to tilde expand
|
||||
*/
|
||||
wchar_t *expand_tilde(wchar_t *in);
|
||||
|
||||
/**
|
||||
Locate the first 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.
|
||||
Each new element is allocated using malloc and must be freed by the
|
||||
caller.
|
||||
|
||||
\param val the input string. The contents of this string is not changed.
|
||||
\param out the list in which to place the elements.
|
||||
Test if the specified argument is clean, i.e. it does not contain
|
||||
any tokens which need to be expanded or otherwise altered. Clean
|
||||
strings can be passed through expand_string and expand_one without
|
||||
changing them. About two thirds of all strings are clean, so
|
||||
skipping expansion on them actually does save a small amount of
|
||||
time, since it avoids multiple memory allocations during the
|
||||
expansion process.
|
||||
|
||||
\param in the string to test
|
||||
*/
|
||||
void expand_variable_array( const wchar_t *val, array_list_t *out );
|
||||
int expand_is_clean( const wchar_t *in );
|
||||
|
||||
/**
|
||||
Perform error reporting for a syntax error related to the variable
|
||||
expansion beginning at the specified character of the specified
|
||||
token. This function will call the error function with an
|
||||
explanatory string about what is wrong with the specified token.
|
||||
|
||||
\param token The token containing the error
|
||||
\param token_pos The position where the expansion begins
|
||||
\param error_pos The position on the line to report to the error function.
|
||||
*/
|
||||
void expand_variable_error( const wchar_t *token, int token_pos, int error_pos );
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
1093
fallback.c
Normal file
1093
fallback.c
Normal file
File diff suppressed because it is too large
Load Diff
427
fallback.h
Normal file
427
fallback.h
Normal file
@@ -0,0 +1,427 @@
|
||||
|
||||
#ifndef FISH_FALLBACK_H
|
||||
#define FISH_FALLBACK_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdarg.h>
|
||||
#include <wctype.h>
|
||||
#include <wchar.h>
|
||||
#include <limits.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
|
||||
#ifndef WCHAR_MAX
|
||||
/**
|
||||
This _should_ be defined by wchar.h, but e.g. OpenBSD doesn't.
|
||||
*/
|
||||
#define WCHAR_MAX INT_MAX
|
||||
#endif
|
||||
|
||||
/**
|
||||
Make sure __func__ is defined to some string. In C99, this should
|
||||
be the currently compiled function. If we aren't using C99 or
|
||||
later, older versions of GCC had __FUNCTION__.
|
||||
*/
|
||||
#if __STDC_VERSION__ < 199901L
|
||||
# if __GNUC__ >= 2
|
||||
# define __func__ __FUNCTION__
|
||||
# else
|
||||
# define __func__ "<unknown>"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
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
|
||||
typedef int tputs_arg_t;
|
||||
#else
|
||||
typedef char tputs_arg_t;
|
||||
#endif
|
||||
|
||||
#ifndef SIGIO
|
||||
#define SIGIO SIGUSR1
|
||||
#endif
|
||||
|
||||
#ifndef SIGWINCH
|
||||
#define SIGWINCH SIGUSR2
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_WINSIZE
|
||||
struct winsize
|
||||
{
|
||||
unsigned short ws_row;
|
||||
unsigned short ws_col;
|
||||
}
|
||||
;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef TPUTS_KLUDGE
|
||||
|
||||
/**
|
||||
Linux on PPC seems to have a tputs implementation that sometimes
|
||||
behaves strangely. This fallback seems to fix things.
|
||||
*/
|
||||
int tputs(const char *str, int affcnt, int (*fish_putc)(tputs_arg_t));
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_FWPRINTF
|
||||
|
||||
/**
|
||||
Print formated string. Some operating systems (Like NetBSD) do not
|
||||
have wide string formating functions. Therefore we implement our
|
||||
own. Not at all complete. Supports wide and narrow characters,
|
||||
strings and decimal numbers, position (%n), field width and
|
||||
precision.
|
||||
*/
|
||||
int fwprintf( FILE *f, const wchar_t *format, ... );
|
||||
|
||||
|
||||
/**
|
||||
Print formated string. Some operating systems (Like NetBSD) do not
|
||||
have wide string formating functions. Therefore we define our
|
||||
own. Not at all complete. Supports wide and narrow characters,
|
||||
strings and decimal numbers, position (%n), field width and
|
||||
precision.
|
||||
*/
|
||||
int swprintf( wchar_t *str, size_t l, const wchar_t *format, ... );
|
||||
|
||||
/**
|
||||
Print formated string. Some operating systems (Like NetBSD) do not
|
||||
have wide string formating functions. Therefore we define our
|
||||
own. Not at all complete. Supports wide and narrow characters,
|
||||
strings and decimal numbers, position (%n), field width and
|
||||
precision.
|
||||
*/
|
||||
int wprintf( const wchar_t *format, ... );
|
||||
|
||||
/**
|
||||
Print formated string. Some operating systems (Like NetBSD) do not
|
||||
have wide string formating functions. Therefore we define our
|
||||
own. Not at all complete. Supports wide and narrow characters,
|
||||
strings and decimal numbers, position (%n), field width and
|
||||
precision.
|
||||
*/
|
||||
int vwprintf( const wchar_t *filter, va_list va );
|
||||
|
||||
/**
|
||||
Print formated string. Some operating systems (Like NetBSD) do not
|
||||
have wide string formating functions. Therefore we define our
|
||||
own. Not at all complete. Supports wide and narrow characters,
|
||||
strings and decimal numbers, position (%n), field width and
|
||||
precision.
|
||||
*/
|
||||
int vfwprintf( FILE *f, const wchar_t *filter, va_list va );
|
||||
|
||||
/**
|
||||
Print formated string. Some operating systems (Like NetBSD) do not
|
||||
have wide string formating functions. Therefore we define our
|
||||
own. Not at all complete. Supports wide and narrow characters,
|
||||
strings and decimal numbers, position (%n), field width and
|
||||
precision.
|
||||
*/
|
||||
int vswprintf( wchar_t *out, size_t n, const wchar_t *filter, va_list va );
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_FGETWC
|
||||
/**
|
||||
Fallback implementation of fgetwc
|
||||
*/
|
||||
wint_t fgetwc(FILE *stream);
|
||||
|
||||
/**
|
||||
Fallback implementation of getwc
|
||||
*/
|
||||
wint_t getwc(FILE *stream);
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_FPUTWC
|
||||
|
||||
/**
|
||||
Fallback implementation of fputwc
|
||||
*/
|
||||
wint_t fputwc(wchar_t wc, FILE *stream);
|
||||
/**
|
||||
Fallback implementation of putwc
|
||||
*/
|
||||
wint_t putwc(wchar_t wc, FILE *stream);
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_WCSTOK
|
||||
|
||||
/**
|
||||
Fallback implementation of wcstok. Uses code borrowed from glibc.
|
||||
*/
|
||||
wchar_t *wcstok(wchar_t *wcs, const wchar_t *delim, wchar_t **ptr);
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_WCWIDTH
|
||||
|
||||
/**
|
||||
Return the number of columns used by a character. This is a libc
|
||||
function, but the prototype for this function is missing in some libc
|
||||
implementations.
|
||||
|
||||
Fish has a fallback implementation in case the implementation is
|
||||
missing altogether. In locales without a native wcwidth, Unicode
|
||||
is probably so broken that it isn't worth trying to implement a
|
||||
real wcwidth. Therefore, the fallback wcwidth assumes any printing
|
||||
character takes up one column and anything else uses 0 columns.
|
||||
*/
|
||||
int wcwidth( wchar_t c );
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_WCSDUP
|
||||
|
||||
/**
|
||||
Create a duplicate string. Wide string version of strdup. Will
|
||||
automatically exit if out of memory.
|
||||
*/
|
||||
wchar_t *wcsdup(const wchar_t *in);
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_WCSLEN
|
||||
|
||||
/**
|
||||
Fallback for wcsen. Returns the length of the specified string.
|
||||
*/
|
||||
size_t wcslen(const wchar_t *in);
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_WCSCASECMP
|
||||
/**
|
||||
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. Using wcscasecmp on
|
||||
a user-supplied string should be considered a bug.
|
||||
*/
|
||||
int wcscasecmp( const wchar_t *a, const wchar_t *b );
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_WCSNCASECMP
|
||||
|
||||
/**
|
||||
Case insensitive string compare function. Wide string version of
|
||||
strncasecmp.
|
||||
|
||||
This implementation of wcsncasecmp 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. Using wcsncasecmp on
|
||||
a user-supplied string should be considered a bug.
|
||||
*/
|
||||
int wcsncasecmp( const wchar_t *a, const wchar_t *b, int count );
|
||||
|
||||
/**
|
||||
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.
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_WCSNDUP
|
||||
|
||||
/**
|
||||
Fallback for wcsndup function. Returns a copy of \c in, truncated
|
||||
to a maximum length of \c c.
|
||||
*/
|
||||
wchar_t *wcsndup( const wchar_t *in, int c );
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
Converts from wide char to digit in the specified base. If d is not
|
||||
a valid digit in the specified base, return -1. This is a helper
|
||||
function for wcstol, but it is useful itself, so it is exported.
|
||||
*/
|
||||
long convert_digit( wchar_t d, int base );
|
||||
|
||||
#ifndef HAVE_WCSTOL
|
||||
|
||||
/**
|
||||
Fallback implementation. 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.
|
||||
*/
|
||||
long wcstol(const wchar_t *nptr,
|
||||
wchar_t **endptr,
|
||||
int base);
|
||||
|
||||
#endif
|
||||
#ifndef HAVE_WCSLCAT
|
||||
|
||||
/**
|
||||
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 );
|
||||
|
||||
#endif
|
||||
#ifndef HAVE_WCSLCPY
|
||||
|
||||
/**
|
||||
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.
|
||||
*/
|
||||
size_t wcslcpy( wchar_t *dst, const wchar_t *src, size_t siz );
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_BROKEN_DEL_CURTERM
|
||||
|
||||
/**
|
||||
BSD del_curterm seems to do a double-free. We redefine it as a no-op
|
||||
*/
|
||||
#define del_curterm(oterm) OK
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_LRAND48_R
|
||||
|
||||
/**
|
||||
Datastructure for the lrand48_r fallback implementation.
|
||||
*/
|
||||
struct drand48_data
|
||||
{
|
||||
/**
|
||||
Seed value
|
||||
*/
|
||||
unsigned int seed;
|
||||
}
|
||||
;
|
||||
|
||||
/**
|
||||
Fallback implementation of lrand48_r. Internally uses rand_r, so it is pretty weak.
|
||||
*/
|
||||
int lrand48_r( struct drand48_data *buffer, long int *result );
|
||||
|
||||
/**
|
||||
Fallback implementation of srand48_r, the seed function for lrand48_r.
|
||||
*/
|
||||
int srand48_r( long int seedval, struct drand48_data *buffer );
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_FUTIMES
|
||||
|
||||
int futimes( int fd, const struct timeval *times );
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_GETTEXT
|
||||
|
||||
/**
|
||||
Fallback implementation of gettext. Just returns the original string.
|
||||
*/
|
||||
char * gettext( const char * msgid );
|
||||
|
||||
/**
|
||||
Fallback implementation of bindtextdomain. Does nothing.
|
||||
*/
|
||||
char * bindtextdomain( const char * domainname, const char * dirname );
|
||||
|
||||
/**
|
||||
Fallback implementation of textdomain. Does nothing.
|
||||
*/
|
||||
char * textdomain( const char * domainname );
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_DCGETTEXT
|
||||
|
||||
/**
|
||||
Fallback implementation of dcgettext. Just returns the original string.
|
||||
*/
|
||||
char * dcgettext ( const char * domainname,
|
||||
const char * msgid,
|
||||
int category );
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef HAVE__NL_MSG_CAT_CNTR
|
||||
|
||||
/**
|
||||
Some gettext implementation use have this variable, and by
|
||||
increasing it, one can tell the system that the translations need
|
||||
to be reloaded.
|
||||
*/
|
||||
extern int _nl_msg_cat_cntr;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAVE_KILLPG
|
||||
int killpg( int pgr, int sig );
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAVE_WORKING_GETOPT_LONG
|
||||
|
||||
struct option
|
||||
{
|
||||
const char *name;
|
||||
int has_arg;
|
||||
int *flag;
|
||||
int val;
|
||||
}
|
||||
;
|
||||
|
||||
#ifndef no_argument
|
||||
#define no_argument 0
|
||||
#endif
|
||||
|
||||
#ifndef required_argument
|
||||
#define required_argument 1
|
||||
#endif
|
||||
|
||||
#ifndef optional_argument
|
||||
#define optional_argument 2
|
||||
#endif
|
||||
|
||||
int getopt_long(int argc,
|
||||
char * const argv[],
|
||||
const char *optstring,
|
||||
const struct option *longopts,
|
||||
int *longindex);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
134
fish.spec.in
134
fish.spec.in
@@ -6,69 +6,173 @@ Release: 0%{?dist}
|
||||
|
||||
License: GPL
|
||||
Group: System Environment/Shells
|
||||
URL: http://roo.no-ip.org/fish/
|
||||
URL: http://www.fishshell.org
|
||||
|
||||
Source0: http://roo.no-ip.org/%{name}/files/%{version}/%{name}-%{version}.tar.bz2
|
||||
Source0: http://www.fishshell.org/files/%{version}/%{name}-%{version}.tar.bz2
|
||||
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
BuildRequires: doxygen ncurses-devel xorg-x11-devel
|
||||
BuildRequires: ncurses-devel gettext groff
|
||||
|
||||
|
||||
# Locate correct build time-dependencies for providing X headers
|
||||
%if "%fedora" >= "5"
|
||||
|
||||
# Modern Fedora version, has modular X.org
|
||||
BuildRequires: xorg-x11-proto-devel libX11-devel libXt-devel libXext-devel
|
||||
|
||||
%endif
|
||||
|
||||
%if "%fedora" < "5"
|
||||
%if "%fedora" >= "3"
|
||||
|
||||
# Semi-old Fedora version, has non-modular X.org
|
||||
BuildRequires: xorg-x11-devel
|
||||
|
||||
%endif
|
||||
%endif
|
||||
|
||||
%if 0%{?fedora}
|
||||
%if "%fedora" < "3"
|
||||
|
||||
# Ancient Fedora version, has XFree86
|
||||
BuildRequires: XFree86-devel
|
||||
|
||||
%endif
|
||||
%else
|
||||
|
||||
# The %fedora variable has not been correctly defined, or this is is
|
||||
# not a Fedora system, try guessing BuildRequires by looking at the
|
||||
# directory structure
|
||||
%define xinclude /usr%(if [ -d /usr/X11R6/include ]; then echo /X11R6; fi)/include
|
||||
BuildRequires: %{xinclude}/X11/StringDefs.h, %{xinclude}/X11/Xlib.h
|
||||
BuildRequires: %{xinclude}/X11/Intrinsic.h, %{xinclude}/X11/Xatom.h
|
||||
|
||||
%endif
|
||||
|
||||
|
||||
%description
|
||||
fish is a shell geared towards interactive use. It's features are
|
||||
focused on user friendlieness and discoverability. The language syntax
|
||||
|
||||
fish is a shell geared towards interactive use. Its features are
|
||||
focused on user friendliness and discoverability. The language syntax
|
||||
is simple but incompatible with other shell languages.
|
||||
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
|
||||
%build
|
||||
|
||||
|
||||
|
||||
%build
|
||||
# The docdir argument is to make the name of the cosumantation
|
||||
# directory 'fish-VERSION', instead of the default, which is simply
|
||||
# 'fish'.
|
||||
%configure docdir=%_datadir/doc/%{name}-%{version}
|
||||
make %{?_smp_mflags}
|
||||
|
||||
|
||||
|
||||
|
||||
%install
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
make install DESTDIR="$RPM_BUILD_ROOT"
|
||||
|
||||
# Find translation files
|
||||
%find_lang %{name}.\*
|
||||
|
||||
|
||||
|
||||
%clean
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
|
||||
|
||||
|
||||
%post
|
||||
# Add fish to the list of allowed shells in /etc/shells
|
||||
if ! grep %_bindir/fish %_sysconfdir/shells >/dev/null; then
|
||||
echo %_bindir/fish >>%_sysconfdir/shells
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
%postun
|
||||
# Remove fish from the list of allowed shells in /etc/shells
|
||||
if [ "$1" = 0 ]; then
|
||||
grep -v %_bindir/fish %_sysconfdir/shells >%_sysconfdir/fish.tmp
|
||||
mv %_sysconfdir/fish.tmp %_sysconfdir/shells
|
||||
fi
|
||||
|
||||
%files
|
||||
|
||||
|
||||
|
||||
%files -f %{name}.\*.lang
|
||||
|
||||
%defattr(-,root,root,-)
|
||||
|
||||
# The documentation directory
|
||||
%doc %_datadir/doc/%{name}-%{version}
|
||||
|
||||
# man files
|
||||
%_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*
|
||||
|
||||
# The program binaries
|
||||
%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
|
||||
|
||||
# Configuration files
|
||||
%config %_sysconfdir/fish/config.fish
|
||||
%config %_sysconfdir/fish/fish_inputrc
|
||||
%dir %_sysconfdir/fish
|
||||
|
||||
# Non-configuration initialization files
|
||||
%dir %_datadir/fish
|
||||
%_datadir/fish/config.fish
|
||||
%_datadir/fish/config_interactive.fish
|
||||
|
||||
# Program specific tab-completions
|
||||
%dir %_datadir/fish/completions
|
||||
%_datadir/fish/completions/*.fish
|
||||
|
||||
# Dynamically loaded shellscript functions
|
||||
%dir %_datadir/fish/functions
|
||||
%_datadir/fish/functions/*.fish
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
%changelog
|
||||
* Sat Oct 14 2006 Axel Liljencrantz<axel@liljencrantz.se> 1.22.0-0
|
||||
- Update names of various configuration files
|
||||
|
||||
* Fri Aug 4 2006 Axel Liljencrantz<axel@liljencrantz.se> 1.21.10-4
|
||||
- Add better translation finding code from fedora spec to main spec. Thank you to Michael Schwendt.
|
||||
- Add missing dependency libXext-devel.
|
||||
- Remove one nesting level from dependency checking code.
|
||||
|
||||
* Tue Aug 1 2006 Axel Liljencrantz<axel@liljencrantz.se> 1.21.10-1
|
||||
- Improved the dependency check for X headers. Thank you to Michael Schwendt for pointers on how to do this
|
||||
|
||||
* Mon Jul 31 2006 Axel Liljencrantz<axel@liljencrantz.se> 1.21.10-1
|
||||
- Fixed spelling and punctuation as a per patch from Paul Howarth
|
||||
- Fixed dependencies as per patch from Paul Howarth
|
||||
|
||||
* 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
|
||||
|
||||
|
||||
959
fish_pager.c
959
fish_pager.c
File diff suppressed because it is too large
Load Diff
136
fish_tests.c
136
fish_tests.c
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
@@ -26,7 +27,9 @@
|
||||
#include <locale.h>
|
||||
#include <dirent.h>
|
||||
|
||||
#include "fallback.h"
|
||||
#include "util.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "proc.h"
|
||||
#include "reader.h"
|
||||
@@ -41,12 +44,18 @@
|
||||
#include "output.h"
|
||||
#include "exec.h"
|
||||
#include "event.h"
|
||||
#include "halloc_util.h"
|
||||
|
||||
/**
|
||||
Number of laps to run performance testing loop
|
||||
*/
|
||||
#define LAPS 50
|
||||
|
||||
/**
|
||||
The result of one of the test passes
|
||||
*/
|
||||
#define NUM_ANS L"-7 99999999 1234567 deadbeef DEADBEEFDEADBEEF"
|
||||
|
||||
/**
|
||||
Number of encountered errors
|
||||
*/
|
||||
@@ -79,14 +88,6 @@ static void err( wchar_t *blah, ... )
|
||||
wprintf( L"\n" );
|
||||
}
|
||||
|
||||
/**
|
||||
Print ok message
|
||||
*/
|
||||
static void ok()
|
||||
{
|
||||
wprintf( L"OK\n" );
|
||||
}
|
||||
|
||||
/**
|
||||
Compare two pointers
|
||||
*/
|
||||
@@ -98,7 +99,7 @@ static int pq_compare( void *e1, void *e2 )
|
||||
/**
|
||||
Test priority queue functionality
|
||||
*/
|
||||
static int pq_test( int elements )
|
||||
static void pq_test( int elements )
|
||||
{
|
||||
int i;
|
||||
int prev;
|
||||
@@ -111,7 +112,7 @@ static int pq_test( int elements )
|
||||
|
||||
for( i=0; i<elements; i++ )
|
||||
{
|
||||
int foo = rand() % 100;
|
||||
long foo = rand() % 100;
|
||||
// printf( "Adding %d\n", foo );
|
||||
pq_put( &q, (void *)foo );
|
||||
count[foo]++;
|
||||
@@ -121,7 +122,7 @@ static int pq_test( int elements )
|
||||
|
||||
for( i=0; i<elements; i++ )
|
||||
{
|
||||
int pos = (int)pq_get( &q );
|
||||
long pos = (long)pq_get( &q );
|
||||
count[ pos ]--;
|
||||
if( pos > prev )
|
||||
err( L"Wrong order of elements in priority_queue_t" );
|
||||
@@ -143,7 +144,7 @@ static int pq_test( int elements )
|
||||
*/
|
||||
static int stack_test( int elements )
|
||||
{
|
||||
int i;
|
||||
long i;
|
||||
|
||||
int res=1;
|
||||
|
||||
@@ -153,12 +154,12 @@ static int stack_test( int elements )
|
||||
|
||||
for( i=0; i<elements; i++ )
|
||||
{
|
||||
int foo;
|
||||
long foo;
|
||||
|
||||
al_push( &s, (void*)i);
|
||||
al_push( &s, (void*)i);
|
||||
al_push_long( &s, i);
|
||||
al_push_long( &s, i);
|
||||
|
||||
if( (foo=(int)al_pop( &s )) != i )
|
||||
if( (foo=al_pop_long( &s )) != i )
|
||||
{
|
||||
err( L"Unexpected data" );
|
||||
res = 0;
|
||||
@@ -168,16 +169,14 @@ static int stack_test( int elements )
|
||||
|
||||
for( i=0; i<elements; i++ )
|
||||
{
|
||||
int foo;
|
||||
long foo;
|
||||
|
||||
if( (foo=(int)al_pop( &s )) != (elements-i-1) )
|
||||
if( (foo=al_pop_long( &s )) != (elements-i-1) )
|
||||
{
|
||||
err( L"Unexpected data" );
|
||||
res = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -189,19 +188,19 @@ static int stack_test( int elements )
|
||||
/**
|
||||
Hash function for pointers
|
||||
*/
|
||||
static int hash_func( const void *data )
|
||||
static int hash_func( void *data )
|
||||
{
|
||||
/* srand( (int)data );
|
||||
return rand();
|
||||
*/
|
||||
int foo = (int)data;
|
||||
int foo = (int)(long)data;
|
||||
return 127*((foo^0xefc7e214)) ^(foo<<11);
|
||||
}
|
||||
|
||||
/**
|
||||
Pointer hash comparison function
|
||||
*/
|
||||
static int compare_func( const void *key1, const void *key2 )
|
||||
static int compare_func( void *key1, void *key2 )
|
||||
{
|
||||
return key1==key2;
|
||||
}
|
||||
@@ -210,9 +209,9 @@ static int compare_func( const void *key1, const void *key2 )
|
||||
/**
|
||||
Hashtable test
|
||||
*/
|
||||
static int hash_test( int elements )
|
||||
static int hash_test( long elements )
|
||||
{
|
||||
int i;
|
||||
long i;
|
||||
int res=1;
|
||||
|
||||
hash_table_t h;
|
||||
@@ -221,17 +220,17 @@ static int hash_test( int elements )
|
||||
|
||||
for( i=1; i< elements+1; i++ )
|
||||
{
|
||||
hash_put( &h, (void*)i, (void*)100-i );
|
||||
hash_put( &h, (void*)i, (void*)100l-i );
|
||||
}
|
||||
|
||||
for( i=1; i< elements+1; i++ )
|
||||
{
|
||||
if( (int)hash_get( &h, (void*)i ) != (100-i) )
|
||||
if( (long)hash_get( &h, (void*)i ) != (100l-i) )
|
||||
{
|
||||
err( L"Key %d gave data %d, expected data %d",
|
||||
i,
|
||||
(int)hash_get( &h, (void*)i ),
|
||||
100-i );
|
||||
(long)hash_get( &h, (void*)i ),
|
||||
100l-i );
|
||||
res = 0;
|
||||
|
||||
break;
|
||||
@@ -264,7 +263,7 @@ static int hash_test( int elements )
|
||||
|
||||
for( i=1; i<elements+1; i++ )
|
||||
{
|
||||
if( hash_contains( &h, (void*)i) != (i+1)%2 )
|
||||
if( hash_contains( &h, (void*)i) != (i+1l)%2l )
|
||||
{
|
||||
if( i%2 )
|
||||
err( L"Key %d remains, should be deleted",
|
||||
@@ -286,24 +285,24 @@ static int hash_test( int elements )
|
||||
/**
|
||||
Arraylist test
|
||||
*/
|
||||
static int al_test( int sz)
|
||||
static void al_test( int sz)
|
||||
{
|
||||
int i;
|
||||
long i;
|
||||
array_list_t l;
|
||||
|
||||
|
||||
|
||||
al_init( &l );
|
||||
|
||||
al_set( &l, 1, (void *)7 );
|
||||
al_set( &l, sz, (void *)7 );
|
||||
al_set_long( &l, 1, 7L );
|
||||
al_set_long( &l, sz, 7L );
|
||||
|
||||
if( al_get_count( &l ) != maxf( sz+1, 2 ) )
|
||||
if( al_get_count( &l ) != maxi( sz+1, 2 ) )
|
||||
err( L"Wrong number of elements in array list" );
|
||||
|
||||
for( i=0; i<al_get_count( &l ); i++ )
|
||||
{
|
||||
int val = (int)((long) al_get( &l, i ));
|
||||
long val = al_get_long( &l, i );
|
||||
if( (i == 1) || (i==sz))
|
||||
{
|
||||
if( val != 7 )
|
||||
@@ -327,7 +326,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 );
|
||||
}
|
||||
@@ -336,7 +335,20 @@ static void sb_test()
|
||||
{
|
||||
err( L"Error %d while testing stringbuffers", res );
|
||||
}
|
||||
|
||||
say( (wchar_t *)b.buff );
|
||||
|
||||
sb_clear( &b );
|
||||
|
||||
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" );
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -464,43 +476,43 @@ static void test_parser()
|
||||
|
||||
|
||||
say( L"Testing null input to parser" );
|
||||
if( !parser_test( 0, 0 ) )
|
||||
if( !parser_test( 0, 0, 0, 0 ) )
|
||||
{
|
||||
err( L"Null input to parser_test undetected" );
|
||||
}
|
||||
|
||||
say( L"Testing block nesting" );
|
||||
if( !parser_test( L"if; end", 0 ) )
|
||||
if( !parser_test( L"if; end", 0, 0, 0 ) )
|
||||
{
|
||||
err( L"Incomplete if statement undetected" );
|
||||
}
|
||||
if( !parser_test( L"if test; echo", 0 ) )
|
||||
if( !parser_test( L"if test; echo", 0, 0, 0 ) )
|
||||
{
|
||||
err( L"Missing end undetected" );
|
||||
}
|
||||
if( !parser_test( L"if test; end; end", 0 ) )
|
||||
if( !parser_test( L"if test; end; end", 0, 0, 0 ) )
|
||||
{
|
||||
err( L"Unbalanced end undetected" );
|
||||
}
|
||||
|
||||
say( L"Testing detection of invalid use of builtin commands" );
|
||||
if( !parser_test( L"case foo", 0 ) )
|
||||
if( !parser_test( L"case foo", 0, 0, 0 ) )
|
||||
{
|
||||
err( L"'case' command outside of block context undetected" );
|
||||
}
|
||||
if( !parser_test( L"switch ggg; if true; case foo;end;end", 0 ) )
|
||||
if( !parser_test( L"switch ggg; if true; case foo;end;end", 0, 0, 0 ) )
|
||||
{
|
||||
err( L"'case' command outside of switch block context undetected" );
|
||||
}
|
||||
if( !parser_test( L"else", 0 ) )
|
||||
if( !parser_test( L"else", 0, 0, 0 ) )
|
||||
{
|
||||
err( L"'else' command outside of conditional block context undetected" );
|
||||
}
|
||||
if( !parser_test( L"break", 0 ) )
|
||||
if( !parser_test( L"break", 0, 0, 0 ) )
|
||||
{
|
||||
err( L"'break' command outside of loop block context undetected" );
|
||||
}
|
||||
if( !parser_test( L"exec ls|less", 0 ) || !parser_test( L"echo|return", 0 ))
|
||||
if( !parser_test( L"exec ls|less", 0, 0, 0 ) || !parser_test( L"echo|return", 0, 0, 0 ))
|
||||
{
|
||||
err( L"Invalid pipe command undetected" );
|
||||
}
|
||||
@@ -518,7 +530,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
|
||||
@@ -533,7 +545,11 @@ static int expand_test( const wchar_t *in, int flags, ... )
|
||||
wchar_t *arg;
|
||||
|
||||
al_init( &out );
|
||||
expand_string( wcsdup(in), &out, flags);
|
||||
if( expand_string( 0, wcsdup(in), &out, flags) )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
va_start( va, flags );
|
||||
|
||||
@@ -555,17 +571,17 @@ static int expand_test( const wchar_t *in, int flags, ... )
|
||||
}
|
||||
va_end( va );
|
||||
|
||||
al_foreach( &out, (void (*)(const void *))&free );
|
||||
al_foreach( &out, &free );
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
Test globbing and other parameter expantion
|
||||
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 ))
|
||||
{
|
||||
@@ -574,12 +590,12 @@ 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" );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -620,7 +636,7 @@ void perf_complete()
|
||||
|
||||
matches += al_get_count( &out );
|
||||
|
||||
al_foreach( &out, (void (*)(const void *))&free );
|
||||
al_foreach( &out, &free );
|
||||
al_truncate( &out, 0 );
|
||||
}
|
||||
t2=get_time();
|
||||
@@ -642,7 +658,7 @@ void perf_complete()
|
||||
|
||||
matches += al_get_count( &out );
|
||||
|
||||
al_foreach( &out, (void (*)(const void *))&free );
|
||||
al_foreach( &out, &free );
|
||||
al_truncate( &out, 0 );
|
||||
}
|
||||
t2=get_time();
|
||||
@@ -669,13 +685,11 @@ 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();
|
||||
function_init();
|
||||
builtin_init();
|
||||
complete_init();
|
||||
reader_init();
|
||||
env_init();
|
||||
|
||||
@@ -697,11 +711,9 @@ int main( int argc, char **argv )
|
||||
parser_destroy();
|
||||
function_destroy();
|
||||
builtin_destroy();
|
||||
complete_destroy();
|
||||
wutil_destroy();
|
||||
exec_destroy();
|
||||
event_destroy();
|
||||
output_destroy();
|
||||
proc_destroy();
|
||||
halloc_util_destroy();
|
||||
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user