mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-04-19 23:21:15 -03:00
Compare commits
755 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1eb089d722 | ||
|
|
e50d0c18b0 | ||
|
|
810d5f9548 | ||
|
|
e0c317dfd4 | ||
|
|
d5320fb9f9 | ||
|
|
14c84ffbcb | ||
|
|
f71c6f3f0e | ||
|
|
6dbb9e070d | ||
|
|
47ae2a05ce | ||
|
|
810262118a | ||
|
|
f5be301a2f | ||
|
|
b1357d11b2 | ||
|
|
5fc42fcaff | ||
|
|
c1cf6a4071 | ||
|
|
972f3e121e | ||
|
|
0dd8ae4843 | ||
|
|
8a93b6f26d | ||
|
|
07717a3570 | ||
|
|
79784d3e18 | ||
|
|
c08c313c0a | ||
|
|
dfd70057b3 | ||
|
|
07dec5c3ed | ||
|
|
1ed5decf2c | ||
|
|
9b95dda6bf | ||
|
|
41015691db | ||
|
|
7e1ac2d806 | ||
|
|
35258bf1fb | ||
|
|
72025a6a38 | ||
|
|
05341b055b | ||
|
|
9d7224d756 | ||
|
|
33ec8b45a0 | ||
|
|
1dc49a4062 | ||
|
|
1123467991 | ||
|
|
4f54da3795 | ||
|
|
c8de3d24c8 | ||
|
|
31439ffb52 | ||
|
|
9111b85437 | ||
|
|
c6427c5a47 | ||
|
|
36c3bd4e8d | ||
|
|
dad549afd1 | ||
|
|
e73c2be216 | ||
|
|
b0d324f1a7 | ||
|
|
d7396ac59f | ||
|
|
3f439e9cd3 | ||
|
|
0b722864c0 | ||
|
|
75e26f0f94 | ||
|
|
8cacb33347 | ||
|
|
bf7d62fd91 | ||
|
|
4ac31e637d | ||
|
|
0ad64ad2e4 | ||
|
|
523096e5d8 | ||
|
|
0de629e009 | ||
|
|
1f6fa1208e | ||
|
|
b86856b454 | ||
|
|
6598320534 | ||
|
|
0a66dc4a31 | ||
|
|
88a2b622df | ||
|
|
e10f75483f | ||
|
|
1a66fc4c5d | ||
|
|
905b792de7 | ||
|
|
804f5ab334 | ||
|
|
f974c7c416 | ||
|
|
f3b6b74568 | ||
|
|
ab94a397c3 | ||
|
|
537ab32dd9 | ||
|
|
a2660cfb76 | ||
|
|
3743a5758b | ||
|
|
e510d10c77 | ||
|
|
f5540ff958 | ||
|
|
c2b28063e1 | ||
|
|
8d2564291d | ||
|
|
87db9517e9 | ||
|
|
ab3502fc8b | ||
|
|
22472ea980 | ||
|
|
ef705be6a5 | ||
|
|
d50fac7fe5 | ||
|
|
39c16a7770 | ||
|
|
2aad9d5a95 | ||
|
|
52aaf60510 | ||
|
|
3a2f7d0edf | ||
|
|
605fffa9d2 | ||
|
|
2229fad410 | ||
|
|
8e9384e2e8 | ||
|
|
394776c56b | ||
|
|
e3d3a1062d | ||
|
|
b4042b18c6 | ||
|
|
5379200b9e | ||
|
|
9c38ed8238 | ||
|
|
cb59da7a6f | ||
|
|
bdec900aca | ||
|
|
564d19e3bd | ||
|
|
063c4d7e67 | ||
|
|
30cfa2a445 | ||
|
|
71c2cde390 | ||
|
|
da4a4bcc18 | ||
|
|
286ce1d6a4 | ||
|
|
5064cec16d | ||
|
|
f5f5e63ddf | ||
|
|
ae878ed6ea | ||
|
|
2c5151bb78 | ||
|
|
f506f1f495 | ||
|
|
374fc09af0 | ||
|
|
54b1986986 | ||
|
|
6e9489f4f5 | ||
|
|
a52bd219b9 | ||
|
|
bdd1b6b4b2 | ||
|
|
6dfdb3ba6e | ||
|
|
48d5637178 | ||
|
|
d724b160ea | ||
|
|
7a4dc6f700 | ||
|
|
c9f43fb02d | ||
|
|
da02905250 | ||
|
|
80060229f8 | ||
|
|
10b9b06ef7 | ||
|
|
e9aba6a878 | ||
|
|
5fee5a2890 | ||
|
|
3f3fe634c8 | ||
|
|
a5156c54cb | ||
|
|
74cd64ba21 | ||
|
|
348e991d7c | ||
|
|
a1af86cb6b | ||
|
|
baa6a40d6f | ||
|
|
5082054bcb | ||
|
|
2160777d2f | ||
|
|
a97faaf664 | ||
|
|
0c1b40e3b3 | ||
|
|
e54ce9a147 | ||
|
|
36e08dc49e | ||
|
|
dd02e96712 | ||
|
|
4163040e56 | ||
|
|
0bea4c46e3 | ||
|
|
0f6fe652a4 | ||
|
|
afa0ed124f | ||
|
|
8904ab47aa | ||
|
|
25305c6b24 | ||
|
|
89c27c6d9d | ||
|
|
175dd75a3d | ||
|
|
9b74687384 | ||
|
|
fcd474afe8 | ||
|
|
3ca3b6209d | ||
|
|
9299515f3e | ||
|
|
188f0454b7 | ||
|
|
e55739296d | ||
|
|
68857220ac | ||
|
|
713c84d821 | ||
|
|
d34d05ca8b | ||
|
|
dac2129048 | ||
|
|
8cd8c3002e | ||
|
|
4b85eb32d7 | ||
|
|
5870ee7723 | ||
|
|
feec9579c2 | ||
|
|
dde3838f2d | ||
|
|
97b77d1b3a | ||
|
|
addb5a698d | ||
|
|
db0a982570 | ||
|
|
3a73b60956 | ||
|
|
f4f10a8226 | ||
|
|
d6c7e25bea | ||
|
|
f28e83d3e9 | ||
|
|
0e716763d8 | ||
|
|
50f5941a82 | ||
|
|
093cb71f91 | ||
|
|
df4fdf33c4 | ||
|
|
5694d3f027 | ||
|
|
cf8e746d0c | ||
|
|
af9c2067e1 | ||
|
|
d44dd73682 | ||
|
|
5938a93018 | ||
|
|
79ac330afb | ||
|
|
e6764f3130 | ||
|
|
710a01c945 | ||
|
|
0b7b20f013 | ||
|
|
819c20e1d8 | ||
|
|
61ebc12dd4 | ||
|
|
449a75756d | ||
|
|
5e2e9e2b9b | ||
|
|
737935ebe4 | ||
|
|
0679a6351f | ||
|
|
657e3f8147 | ||
|
|
e6b9955fc1 | ||
|
|
e1afe17671 | ||
|
|
16e2c4805a | ||
|
|
5ecd0e22bf | ||
|
|
1420744669 | ||
|
|
048f903a9d | ||
|
|
dab7e6c7b9 | ||
|
|
06de2602cb | ||
|
|
65d223e672 | ||
|
|
c0aac8996d | ||
|
|
3692074e7e | ||
|
|
954c99a5ad | ||
|
|
8c4770a26c | ||
|
|
624878d35f | ||
|
|
2375578310 | ||
|
|
084c0c5f80 | ||
|
|
d2d397d9eb | ||
|
|
607e970659 | ||
|
|
3b39b1fa03 | ||
|
|
64933d31a6 | ||
|
|
c780f1a8c9 | ||
|
|
76bb8e79b2 | ||
|
|
370aeec44d | ||
|
|
b0ae3dc9cc | ||
|
|
a900d16540 | ||
|
|
3fc1ba0f0e | ||
|
|
38ed4c0f9b | ||
|
|
5a61ae3e0d | ||
|
|
c9fe154c01 | ||
|
|
2a3b01a7a0 | ||
|
|
c2c4b24174 | ||
|
|
74a270ea32 | ||
|
|
2994378e1a | ||
|
|
baeca81305 | ||
|
|
151943f89e | ||
|
|
ad02bb9b48 | ||
|
|
e464b4270c | ||
|
|
e076f2c239 | ||
|
|
3cb24e0681 | ||
|
|
27baa6e62b | ||
|
|
fa9d00a81a | ||
|
|
04948702e0 | ||
|
|
20526687b2 | ||
|
|
0a0870180d | ||
|
|
972edef341 | ||
|
|
8ed521c817 | ||
|
|
88199d6b51 | ||
|
|
782a739736 | ||
|
|
cd19320ab2 | ||
|
|
58fd6b895a | ||
|
|
df55e89bbb | ||
|
|
91de143003 | ||
|
|
748d726ddf | ||
|
|
2caaa7526d | ||
|
|
778aa1c304 | ||
|
|
c40eb8a716 | ||
|
|
1c6236831c | ||
|
|
c1b4fa847f | ||
|
|
a6644631d9 | ||
|
|
e4f5bc69e2 | ||
|
|
03f322c715 | ||
|
|
a72d877752 | ||
|
|
d0585befb3 | ||
|
|
784c5d9fa3 | ||
|
|
52e7a7ec1c | ||
|
|
c00e1fcf26 | ||
|
|
5425970706 | ||
|
|
419b3166c8 | ||
|
|
e2714b05eb | ||
|
|
2c02b59703 | ||
|
|
ee94424b0f | ||
|
|
2b7535bb51 | ||
|
|
c5805cfd47 | ||
|
|
7ca76ef743 | ||
|
|
2c743173d3 | ||
|
|
003dfb99da | ||
|
|
dd48de068d | ||
|
|
cb179c448b | ||
|
|
c323fc226f | ||
|
|
176c1a487b | ||
|
|
2872df66d7 | ||
|
|
45412f2b1f | ||
|
|
e9790db64a | ||
|
|
8ab1d0254c | ||
|
|
4c858a10c9 | ||
|
|
b4ccce2dc3 | ||
|
|
06688fb9ea | ||
|
|
4d5c50cbb3 | ||
|
|
91d1dee06b | ||
|
|
3e030bc6c6 | ||
|
|
b9009eba96 | ||
|
|
90c5cea43d | ||
|
|
52f9560b4f | ||
|
|
91ca8610ee | ||
|
|
2efb88a30a | ||
|
|
87223c68f4 | ||
|
|
5c9570eb56 | ||
|
|
778b6a31ad | ||
|
|
4d6751c274 | ||
|
|
a03a4d1ba3 | ||
|
|
5a670e2a96 | ||
|
|
edf896f7cd | ||
|
|
e128fa1a8e | ||
|
|
e8ba091161 | ||
|
|
65d99117aa | ||
|
|
94a483d46b | ||
|
|
e750f1a3c2 | ||
|
|
3f4b47b4af | ||
|
|
f6b3fcb4f5 | ||
|
|
8fe90e4327 | ||
|
|
a17019e439 | ||
|
|
b5baac8291 | ||
|
|
f36508837b | ||
|
|
3969c1b453 | ||
|
|
1e524fbc7a | ||
|
|
3e1b0e587e | ||
|
|
2aea1d5a84 | ||
|
|
6616543991 | ||
|
|
83a3706099 | ||
|
|
7c96cb2ff8 | ||
|
|
a3c5718eb9 | ||
|
|
9b10fa4762 | ||
|
|
0f51d5ec18 | ||
|
|
73a67c2a43 | ||
|
|
6859e012d9 | ||
|
|
680cf17570 | ||
|
|
854c4aee9a | ||
|
|
104ec963c2 | ||
|
|
08eb92707a | ||
|
|
e50f43416b | ||
|
|
58755fc579 | ||
|
|
31ca1218d4 | ||
|
|
44e8a12b66 | ||
|
|
fe21577a8e | ||
|
|
a4ac924512 | ||
|
|
e936629dc3 | ||
|
|
dfabf7f206 | ||
|
|
7118269e4b | ||
|
|
100355c3c1 | ||
|
|
4b1fced1f8 | ||
|
|
abff4e5b41 | ||
|
|
25082b6528 | ||
|
|
766482d90e | ||
|
|
15e0a44fc7 | ||
|
|
3b653cd26a | ||
|
|
ba6661e9df | ||
|
|
55af8e4966 | ||
|
|
dcad2ef17b | ||
|
|
418192b312 | ||
|
|
76d9051605 | ||
|
|
ca2b2103d3 | ||
|
|
14e6bdb139 | ||
|
|
20d42378de | ||
|
|
41c9f89fcf | ||
|
|
7953863b38 | ||
|
|
3fff030ee2 | ||
|
|
da9f7227f5 | ||
|
|
ba932b6590 | ||
|
|
c02e2b1320 | ||
|
|
37a95a3096 | ||
|
|
bbd229b206 | ||
|
|
6a60377e02 | ||
|
|
fc87b3c4b4 | ||
|
|
fcbdb6f2a7 | ||
|
|
a537b01814 | ||
|
|
bd5a16d213 | ||
|
|
be0bd50bad | ||
|
|
cab5c63402 | ||
|
|
d480d892c9 | ||
|
|
f2ccbe7374 | ||
|
|
85241817f8 | ||
|
|
8cf46bdb5c | ||
|
|
5e6d1efb56 | ||
|
|
bc1f9b6f1c | ||
|
|
85d069c106 | ||
|
|
cfecb58bb6 | ||
|
|
11c2ec91d4 | ||
|
|
cc6f133368 | ||
|
|
350b637a1a | ||
|
|
f917dccf6f | ||
|
|
62d380a1ee | ||
|
|
65ef6cf217 | ||
|
|
2bba0f7b8f | ||
|
|
565970b8ca | ||
|
|
6ea3dd7dfe | ||
|
|
8176a1253b | ||
|
|
4f67c38777 | ||
|
|
86beb7b109 | ||
|
|
98a6c491b1 | ||
|
|
66c045c439 | ||
|
|
a1ec38f53b | ||
|
|
64f1024eb5 | ||
|
|
b3500bfbdc | ||
|
|
f8c45324b6 | ||
|
|
bf5d4f6b07 | ||
|
|
1300e68fa5 | ||
|
|
1a76f2ecb9 | ||
|
|
9c5fb0392d | ||
|
|
f4c5eaf05b | ||
|
|
dd90b4ece4 | ||
|
|
4930db35e2 | ||
|
|
e6409a88d5 | ||
|
|
77a48dc252 | ||
|
|
029be823e2 | ||
|
|
421aff7d67 | ||
|
|
9e7094adfc | ||
|
|
19e8d60179 | ||
|
|
9d9869e515 | ||
|
|
54e19b1efb | ||
|
|
f603b6ef68 | ||
|
|
81e0fcbc13 | ||
|
|
b999bd9c8c | ||
|
|
9c9a8f9d0f | ||
|
|
461ef2a508 | ||
|
|
7492b6cdb3 | ||
|
|
34e27ff4c2 | ||
|
|
47588c8e75 | ||
|
|
00c6fcfe98 | ||
|
|
c90f7c3203 | ||
|
|
6467ead9ad | ||
|
|
cb7caf2afc | ||
|
|
c6ebb23f38 | ||
|
|
5753d63958 | ||
|
|
e56d9765d7 | ||
|
|
a5b7ec2624 | ||
|
|
b2fa41307c | ||
|
|
fce74c73c7 | ||
|
|
e110b29c2f | ||
|
|
a3aba0269d | ||
|
|
e1f4aa5fcd | ||
|
|
e19ee86b0d | ||
|
|
6e71b5a59c | ||
|
|
b70092e281 | ||
|
|
602eac89c4 | ||
|
|
d8b5cc6717 | ||
|
|
76fedccf13 | ||
|
|
41206e70b4 | ||
|
|
bc2c37c739 | ||
|
|
4a2a47666f | ||
|
|
94fbbb7669 | ||
|
|
63010c26ad | ||
|
|
f398b2eafa | ||
|
|
1214067d03 | ||
|
|
0469d05447 | ||
|
|
2fcec27e23 | ||
|
|
42d0283489 | ||
|
|
3fbd8036f4 | ||
|
|
3b4bacb5ba | ||
|
|
7e350dab66 | ||
|
|
9c23d50e92 | ||
|
|
2ec7428e32 | ||
|
|
594f81ec8c | ||
|
|
9767b76881 | ||
|
|
0ace93c2a4 | ||
|
|
c73d165165 | ||
|
|
c1945f8275 | ||
|
|
4d368dc06c | ||
|
|
9ff0e9cf72 | ||
|
|
a971d91a70 | ||
|
|
52b74f9f34 | ||
|
|
b932a9a084 | ||
|
|
997f2dffbf | ||
|
|
1289e03134 | ||
|
|
9a8e5e64ed | ||
|
|
774c050f92 | ||
|
|
478a319442 | ||
|
|
24fea5dd7b | ||
|
|
2b05bdfa94 | ||
|
|
6c8a559023 | ||
|
|
ca8c337c94 | ||
|
|
8ccad65504 | ||
|
|
fd11f294bc | ||
|
|
b3fa76c1be | ||
|
|
d3dd9400e3 | ||
|
|
234034d302 | ||
|
|
edc20a7505 | ||
|
|
3a29028f60 | ||
|
|
f4af7603da | ||
|
|
63a28eb46f | ||
|
|
b85d9ee737 | ||
|
|
58042b0e9f | ||
|
|
23759e6eca | ||
|
|
1d3465698f | ||
|
|
b156f083be | ||
|
|
f83b754cd4 | ||
|
|
df4a0d65bd | ||
|
|
77b5532ce9 | ||
|
|
d9ec65da4d | ||
|
|
4b9dcf1cf2 | ||
|
|
1fbac89a38 | ||
|
|
ceacfb83a8 | ||
|
|
d736c8cca6 | ||
|
|
60769903a5 | ||
|
|
8b73bac580 | ||
|
|
c8162c2900 | ||
|
|
de181c91d5 | ||
|
|
687ba1c9ef | ||
|
|
02802b509d | ||
|
|
7f18dd6a4a | ||
|
|
2f7a472230 | ||
|
|
b8f2f46945 | ||
|
|
2570eb1ab8 | ||
|
|
d3062f9a97 | ||
|
|
8619d17f43 | ||
|
|
8062eb3511 | ||
|
|
e0322bf0e0 | ||
|
|
ddc617f80a | ||
|
|
f64364cced | ||
|
|
32502bfac8 | ||
|
|
1f6a98ecb8 | ||
|
|
6ad0f141be | ||
|
|
0b6366aacb | ||
|
|
deed3a63a3 | ||
|
|
cab80b452b | ||
|
|
338d32a7c6 | ||
|
|
88f15a6804 | ||
|
|
20b3f3b9a1 | ||
|
|
1145a5d483 | ||
|
|
125ca9ff73 | ||
|
|
bc1efb1556 | ||
|
|
7b5649097f | ||
|
|
c2e1d76400 | ||
|
|
f7435559a7 | ||
|
|
47afca1fdb | ||
|
|
372c811763 | ||
|
|
dd061b1dda | ||
|
|
eb3c99c54e | ||
|
|
5d864e3f69 | ||
|
|
1b71f91a01 | ||
|
|
b30886228c | ||
|
|
f91de04269 | ||
|
|
a3531db645 | ||
|
|
1e8fe508f0 | ||
|
|
54244fd33d | ||
|
|
4c1d1bb218 | ||
|
|
903326ddf5 | ||
|
|
0105ec284d | ||
|
|
55b253152c | ||
|
|
6573d2b451 | ||
|
|
cfa9ecbfd2 | ||
|
|
b139201a33 | ||
|
|
946b5d1528 | ||
|
|
3b2670532a | ||
|
|
d00bc973fe | ||
|
|
4768b37531 | ||
|
|
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 |
29
Doxyfile
29
Doxyfile
@@ -53,16 +53,6 @@ CREATE_SUBDIRS = NO
|
||||
|
||||
OUTPUT_LANGUAGE = English
|
||||
|
||||
# This tag can be used to specify the encoding used in the generated output.
|
||||
# The encoding is not always determined by the language that is chosen,
|
||||
# but also whether or not the output is meant for Windows or non-Windows users.
|
||||
# In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES
|
||||
# forces the Windows encoding (this is the default for the Windows binary),
|
||||
# whereas setting the tag to NO uses a Unix-style encoding (the default for
|
||||
# all platforms other than Windows).
|
||||
|
||||
USE_WINDOWS_ENCODING = NO
|
||||
|
||||
# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
|
||||
# include brief member descriptions after the members that are listed in
|
||||
# the file and class documentation (similar to JavaDoc).
|
||||
@@ -444,7 +434,8 @@ RECURSIVE = NO
|
||||
# excluded from the INPUT source files. This way you can easily exclude a
|
||||
# subdirectory from a directory tree whose root is specified with the INPUT tag.
|
||||
|
||||
EXCLUDE =
|
||||
EXCLUDE = print_help.c xdgmimealias.c xdgmimealias.h xdgmime.c xdgmimeglob.c xdgmimeglob.h xdgmime.h xdgmimeint.c xdgmimeint.h xdgmimemagic.c xdgmimemagic.h xdgmimeparent.c xdgmimeparent.h
|
||||
|
||||
|
||||
# The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories
|
||||
# that are symbolic links (a Unix filesystem feature) are excluded from the input.
|
||||
@@ -1112,22 +1103,6 @@ DOT_PATH =
|
||||
|
||||
DOTFILE_DIRS =
|
||||
|
||||
# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width
|
||||
# (in pixels) of the graphs generated by dot. If a graph becomes larger than
|
||||
# this value, doxygen will try to truncate the graph, so that it fits within
|
||||
# the specified constraint. Beware that most browsers cannot cope with very
|
||||
# large images.
|
||||
|
||||
MAX_DOT_GRAPH_WIDTH = 750
|
||||
|
||||
# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height
|
||||
# (in pixels) of the graphs generated by dot. If a graph becomes larger than
|
||||
# this value, doxygen will try to truncate the graph, so that it fits within
|
||||
# the specified constraint. Beware that most browsers cannot cope with very
|
||||
# large images.
|
||||
|
||||
MAX_DOT_GRAPH_HEIGHT = 1024
|
||||
|
||||
# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
|
||||
# graphs generated by dot. A depth value of 3 means that only nodes reachable
|
||||
# from the root by following a path via at most 3 edges will be shown. Nodes that
|
||||
|
||||
@@ -30,7 +30,7 @@ PROJECT_NUMBER = @PACKAGE_VERSION@
|
||||
# If a relative path is entered, it will be relative to the location
|
||||
# where doxygen was started. If left blank the current directory will be used.
|
||||
|
||||
OUTPUT_DIRECTORY = builtin_doc
|
||||
OUTPUT_DIRECTORY = help_doc
|
||||
|
||||
# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
|
||||
# 4096 sub-directories (in 2 levels) under the output directory of each output
|
||||
@@ -423,7 +423,7 @@ WARN_LOGFILE =
|
||||
# directories like "/usr/src/myproject". Separate the files or directories
|
||||
# with spaces.
|
||||
|
||||
INPUT =
|
||||
INPUT = doc_src
|
||||
|
||||
# If the value of the INPUT tag contains directories, you can use the
|
||||
# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
|
||||
23
INSTALL
23
INSTALL
@@ -32,17 +32,22 @@ separate build directories or any other fancy configure options.
|
||||
Simple install procedure
|
||||
========================
|
||||
|
||||
If you have downloaded the darcs repository of fish, you need to run
|
||||
the autoconf command first. Then use the following commands to compile
|
||||
fish:
|
||||
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.
|
||||
|
||||
% ./configure
|
||||
% make # Compile fish
|
||||
% make install # Install fish
|
||||
% echo /usr/local/bin/fish >>/etc/shells # Add fish to list of shells
|
||||
Next, if you have downloaded a fresh copy of the darcs repository of
|
||||
fish, you need to run the 'autoconf' command.
|
||||
|
||||
If you wish to use fish as your default shell, use the following
|
||||
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
|
||||
|
||||
|
||||
798
Makefile.in
798
Makefile.in
File diff suppressed because it is too large
Load Diff
37
builtin.h
37
builtin.h
@@ -8,6 +8,7 @@
|
||||
#include <wchar.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "io.h"
|
||||
|
||||
enum
|
||||
{
|
||||
@@ -35,12 +36,12 @@ enum
|
||||
/**
|
||||
Error message on multiple scope levels for variables
|
||||
*/
|
||||
#define BUILTIN_ERR_GLOCAL _( L"%ls: Variable scope can only be one of universal, global and local\n%ls\n" )
|
||||
#define BUILTIN_ERR_GLOCAL _( L"%ls: Variable scope can only be one of universal, global and local\n" )
|
||||
|
||||
/**
|
||||
Error message for specifying both export and unexport to set/read
|
||||
*/
|
||||
#define BUILTIN_ERR_EXPUNEXP _( L"%ls: Variable can't be both exported and unexported\n%ls\n" )
|
||||
#define BUILTIN_ERR_EXPUNEXP _( L"%ls: Variable can't be both exported and unexported\n" )
|
||||
|
||||
/**
|
||||
Error message for unknown switch
|
||||
@@ -62,11 +63,29 @@ enum
|
||||
*/
|
||||
#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
|
||||
*/
|
||||
@@ -110,10 +129,11 @@ int builtin_exists( wchar_t *cmd );
|
||||
of the builtin. The list is terminated by a
|
||||
null pointer. This syntax resembles the syntax
|
||||
for exec.
|
||||
\param io the io redirections to perform on this builtin.
|
||||
|
||||
\return the exit status of the builtin command
|
||||
*/
|
||||
int builtin_run( wchar_t **argv );
|
||||
int builtin_run( wchar_t **argv, io_data_t *io );
|
||||
|
||||
/**
|
||||
Insert all builtin names into l. These are not copies of the strings and should not be freed after use.
|
||||
@@ -146,12 +166,11 @@ const wchar_t *builtin_complete_get_temporary_buffer();
|
||||
|
||||
|
||||
/**
|
||||
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
|
||||
Run the __fish_print_help function to obtain the help information
|
||||
for the specified command. The resulting string will be valid until
|
||||
the next time this function is called, and must never be free'd manually.
|
||||
*/
|
||||
char *builtin_help_get( const wchar_t *cmd );
|
||||
|
||||
wchar_t *builtin_help_get( const wchar_t *cmd );
|
||||
|
||||
#endif
|
||||
|
||||
@@ -52,15 +52,23 @@ enum
|
||||
}
|
||||
;
|
||||
|
||||
/**
|
||||
Pointer to what the commandline builtin considers to be the current
|
||||
contents of the command line buffer.
|
||||
*/
|
||||
static wchar_t *current_buffer=0;
|
||||
/**
|
||||
What the commandline builtin considers to be the current cursor
|
||||
position.
|
||||
*/
|
||||
static int current_cursor_pos = -1;
|
||||
|
||||
/**
|
||||
Returns the current commandline buffer.
|
||||
*/
|
||||
static const wchar_t *get_buffer()
|
||||
static wchar_t *get_buffer()
|
||||
{
|
||||
const wchar_t *buff = builtin_complete_get_temporary_buffer();
|
||||
if( !buff )
|
||||
buff = reader_get_buffer();
|
||||
return buff;
|
||||
return current_buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,11 +76,7 @@ static const wchar_t *get_buffer()
|
||||
*/
|
||||
static int get_cursor_pos()
|
||||
{
|
||||
const wchar_t *buff = builtin_complete_get_temporary_buffer();
|
||||
if( buff )
|
||||
return wcslen( buff );
|
||||
else
|
||||
return reader_get_cursor_pos();
|
||||
return current_cursor_pos;
|
||||
}
|
||||
|
||||
|
||||
@@ -150,7 +154,6 @@ static void write_part( const wchar_t *begin,
|
||||
|
||||
if( tokenize )
|
||||
{
|
||||
|
||||
buff = wcsndup( begin, end-begin );
|
||||
// fwprintf( stderr, L"Subshell: %ls, end char %lc\n", buff, *end );
|
||||
sb_init( &out );
|
||||
@@ -163,20 +166,21 @@ static void write_part( const wchar_t *begin,
|
||||
(tok_get_pos( &tok)+wcslen(tok_last( &tok)) >= pos) )
|
||||
break;
|
||||
|
||||
// fwprintf( stderr, L"Next token %ls\n", tok_last( &tok ) );
|
||||
|
||||
switch( tok_last_type( &tok ) )
|
||||
{
|
||||
case TOK_STRING:
|
||||
sb_append2( &out, tok_last( &tok), L"\n", (void *)0 );
|
||||
{
|
||||
wchar_t *tmp = unescape( tok_last( &tok ), UNESCAPE_INCOMPLETE );
|
||||
sb_append( &out, tmp, L"\n", (void *)0 );
|
||||
free( tmp );
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if( out.buff )
|
||||
sb_append( sb_out,
|
||||
(wchar_t *)out.buff );
|
||||
|
||||
sb_append( sb_out,
|
||||
(wchar_t *)out.buff );
|
||||
|
||||
free( buff );
|
||||
tok_destroy( &tok );
|
||||
@@ -184,12 +188,24 @@ static void write_part( const wchar_t *begin,
|
||||
}
|
||||
else
|
||||
{
|
||||
wchar_t *buff, *esc;
|
||||
|
||||
if( cut_at_cursor )
|
||||
{
|
||||
end = begin+pos;
|
||||
}
|
||||
sb_append_substring( sb_out, begin, end-begin );
|
||||
sb_append( sb_out, L"\n" );
|
||||
|
||||
buff = wcsndup( begin, end-begin );
|
||||
esc = unescape( buff, UNESCAPE_INCOMPLETE );
|
||||
|
||||
// debug( 0, L"woot2 %ls -> %ls", buff, esc );
|
||||
|
||||
sb_append( sb_out, esc );
|
||||
sb_append( sb_out, L"\n" );
|
||||
|
||||
free( esc );
|
||||
free( buff );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,16 +226,42 @@ static int builtin_commandline( wchar_t **argv )
|
||||
int function_mode = 0;
|
||||
|
||||
int tokenize = 0;
|
||||
|
||||
int cursor_mode = 0;
|
||||
int line_mode = 0;
|
||||
int search_mode = 0;
|
||||
wchar_t *begin, *end;
|
||||
|
||||
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],
|
||||
L": Can not set commandline in non-interactive mode\n",
|
||||
(void *)0 );
|
||||
if (is_interactive_session)
|
||||
{
|
||||
/*
|
||||
Prompt change requested while we don't have
|
||||
a prompt, most probably while reading the
|
||||
init files. Just ignore it.
|
||||
*/
|
||||
return 1;
|
||||
}
|
||||
|
||||
sb_append( sb_err,
|
||||
argv[0],
|
||||
L": Can not set commandline in non-interactive mode\n",
|
||||
(void *)0 );
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
woptind=0;
|
||||
|
||||
@@ -272,6 +314,22 @@ static int builtin_commandline( wchar_t **argv )
|
||||
L"help", no_argument, 0, 'h'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"input", required_argument, 0, 'I'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"cursor", no_argument, 0, 'C'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"line", no_argument, 0, 'L'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"search-mode", no_argument, 0, 'S'
|
||||
}
|
||||
,
|
||||
{
|
||||
0, 0, 0, 0
|
||||
}
|
||||
@@ -282,7 +340,7 @@ static int builtin_commandline( wchar_t **argv )
|
||||
|
||||
int opt = wgetopt_long( argc,
|
||||
argv,
|
||||
L"aijpctwforh",
|
||||
L"abijpctwforhI:CLS",
|
||||
long_options,
|
||||
&opt_index );
|
||||
if( opt == -1 )
|
||||
@@ -304,6 +362,11 @@ static int builtin_commandline( wchar_t **argv )
|
||||
case L'a':
|
||||
append_mode = APPEND_MODE;
|
||||
break;
|
||||
|
||||
case L'b':
|
||||
buffer_part = STRING_MODE;
|
||||
break;
|
||||
|
||||
|
||||
case L'i':
|
||||
append_mode = INSERT_MODE;
|
||||
@@ -337,12 +400,29 @@ static 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 'L':
|
||||
line_mode = 1;
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
search_mode = 1;
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
builtin_print_help( argv[0], sb_out );
|
||||
return 0;
|
||||
|
||||
case L'?':
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
builtin_unknown_option( argv[0], argv[woptind-1] );
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -354,16 +434,13 @@ static 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 || line_mode || search_mode )
|
||||
{
|
||||
sb_printf(sb_err,
|
||||
BUILTIN_ERR_COMBO,
|
||||
argv[0] );
|
||||
|
||||
sb_append2(sb_err,
|
||||
parser_current_line(),
|
||||
L"\n",
|
||||
(void *)0);
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -374,19 +451,14 @@ static int builtin_commandline( wchar_t **argv )
|
||||
BUILTIN_ERR_MISSING,
|
||||
argv[0] );
|
||||
|
||||
sb_append2( sb_err,
|
||||
parser_current_line(),
|
||||
L"\n",
|
||||
(void *)0 );
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
return 1;
|
||||
}
|
||||
for( i=woptind; i<argc; i++ )
|
||||
{
|
||||
wint_t c = input_get_code( argv[i] );
|
||||
wint_t c = input_function_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
|
||||
@@ -396,15 +468,10 @@ static 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 input function '%ls'\n"),
|
||||
argv[0],
|
||||
argv[i] );
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
return 1;
|
||||
}
|
||||
@@ -416,10 +483,10 @@ static int builtin_commandline( wchar_t **argv )
|
||||
/*
|
||||
Check for invalid switch combinations
|
||||
*/
|
||||
if( argc-woptind > 1 )
|
||||
if( (search_mode || line_mode || cursor_mode) && (argc-woptind > 1) )
|
||||
{
|
||||
|
||||
sb_append2( sb_err,
|
||||
sb_append( sb_err,
|
||||
argv[0],
|
||||
L": Too many arguments\n",
|
||||
(void *)0 );
|
||||
@@ -427,9 +494,19 @@ static int builtin_commandline( wchar_t **argv )
|
||||
return 1;
|
||||
}
|
||||
|
||||
if( (buffer_part || tokenize || cut_at_cursor) && (cursor_mode || line_mode || search_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],
|
||||
@@ -463,14 +540,58 @@ static 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;
|
||||
}
|
||||
|
||||
if( line_mode )
|
||||
{
|
||||
int pos = reader_get_cursor_pos();
|
||||
wchar_t *buff = reader_get_buffer();
|
||||
sb_printf( sb_out, L"%d\n", parse_util_lineno( buff, pos ) );
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
if( search_mode )
|
||||
{
|
||||
return !reader_search_mode();
|
||||
}
|
||||
|
||||
|
||||
switch( buffer_part )
|
||||
{
|
||||
case STRING_MODE:
|
||||
{
|
||||
begin = (wchar_t *)get_buffer();
|
||||
begin = get_buffer();
|
||||
end = begin+wcslen(begin);
|
||||
break;
|
||||
}
|
||||
@@ -516,7 +637,28 @@ static 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,10 +48,10 @@ static void builtin_complete_add2( const wchar_t *cmd,
|
||||
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 )
|
||||
const wchar_t *desc,
|
||||
int flags )
|
||||
{
|
||||
int i;
|
||||
const wchar_t *s;
|
||||
@@ -64,10 +64,10 @@ static void builtin_complete_add2( const wchar_t *cmd,
|
||||
0,
|
||||
0,
|
||||
result_mode,
|
||||
authorative,
|
||||
condition,
|
||||
comp,
|
||||
desc );
|
||||
desc,
|
||||
flags );
|
||||
}
|
||||
|
||||
for( i=0; i<al_get_count( gnu_opt ); i++ )
|
||||
@@ -78,10 +78,10 @@ static void builtin_complete_add2( const wchar_t *cmd,
|
||||
(wchar_t *)al_get(gnu_opt, i ),
|
||||
0,
|
||||
result_mode,
|
||||
authorative,
|
||||
condition,
|
||||
comp,
|
||||
desc );
|
||||
desc,
|
||||
flags );
|
||||
}
|
||||
|
||||
for( i=0; i<al_get_count( old_opt ); i++ )
|
||||
@@ -92,10 +92,10 @@ static void builtin_complete_add2( const wchar_t *cmd,
|
||||
(wchar_t *)al_get(old_opt, i ),
|
||||
1,
|
||||
result_mode,
|
||||
authorative,
|
||||
condition,
|
||||
comp,
|
||||
desc );
|
||||
desc,
|
||||
flags );
|
||||
}
|
||||
|
||||
if( al_get_count( old_opt )+al_get_count( gnu_opt )+wcslen(short_opt) == 0 )
|
||||
@@ -106,10 +106,10 @@ static void builtin_complete_add2( const wchar_t *cmd,
|
||||
0,
|
||||
0,
|
||||
result_mode,
|
||||
authorative,
|
||||
condition,
|
||||
comp,
|
||||
desc );
|
||||
desc,
|
||||
flags );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,10 +122,11 @@ static void builtin_complete_add( array_list_t *cmd,
|
||||
array_list_t *gnu_opt,
|
||||
array_list_t *old_opt,
|
||||
int result_mode,
|
||||
int authorative,
|
||||
int authoritative,
|
||||
const wchar_t *condition,
|
||||
const wchar_t *comp,
|
||||
const wchar_t *desc )
|
||||
const wchar_t *desc,
|
||||
int flags )
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -137,10 +138,18 @@ static void builtin_complete_add( array_list_t *cmd,
|
||||
gnu_opt,
|
||||
old_opt,
|
||||
result_mode,
|
||||
authorative,
|
||||
condition,
|
||||
comp,
|
||||
desc );
|
||||
desc,
|
||||
flags );
|
||||
|
||||
if( authoritative != -1 )
|
||||
{
|
||||
complete_set_authoritative( al_get( cmd, i ),
|
||||
COMMAND,
|
||||
authoritative );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for( i=0; i<al_get_count( path ); i++ )
|
||||
@@ -151,12 +160,19 @@ static void builtin_complete_add( array_list_t *cmd,
|
||||
gnu_opt,
|
||||
old_opt,
|
||||
result_mode,
|
||||
authorative,
|
||||
condition,
|
||||
comp,
|
||||
desc );
|
||||
}
|
||||
|
||||
desc,
|
||||
flags );
|
||||
|
||||
if( authoritative != -1 )
|
||||
{
|
||||
complete_set_authoritative( al_get( path, i ),
|
||||
PATH,
|
||||
authoritative );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -278,7 +294,8 @@ static int builtin_complete( wchar_t **argv )
|
||||
int argc=0;
|
||||
int result_mode=SHARED;
|
||||
int remove = 0;
|
||||
int authorative = 1;
|
||||
int authoritative = -1;
|
||||
int flags = COMPLETE_AUTO_SPACE;
|
||||
|
||||
string_buffer_t short_opt;
|
||||
array_list_t gnu_opt, old_opt;
|
||||
@@ -291,11 +308,6 @@ static int builtin_complete( wchar_t **argv )
|
||||
|
||||
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 );
|
||||
@@ -356,7 +368,11 @@ static int builtin_complete( wchar_t **argv )
|
||||
}
|
||||
,
|
||||
{
|
||||
L"unauthorative", no_argument, 0, 'u'
|
||||
L"unauthoritative", no_argument, 0, 'u'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"authoritative", no_argument, 0, 'A'
|
||||
}
|
||||
,
|
||||
{
|
||||
@@ -381,7 +397,7 @@ static int builtin_complete( wchar_t **argv )
|
||||
|
||||
int opt = wgetopt_long( argc,
|
||||
argv,
|
||||
L"a:c:p:s:l:o:d:frxeun:C::h",
|
||||
L"a:c:p:s:l:o:d:frxeuAn:C::h",
|
||||
long_options,
|
||||
&opt_index );
|
||||
if( opt == -1 )
|
||||
@@ -396,9 +412,6 @@ static int builtin_complete( wchar_t **argv )
|
||||
BUILTIN_ERR_UNKNOWN,
|
||||
argv[0],
|
||||
long_options[opt_index].name );
|
||||
sb_append( sb_err,
|
||||
parser_current_line() );
|
||||
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
|
||||
|
||||
@@ -438,7 +451,11 @@ static int builtin_complete( wchar_t **argv )
|
||||
break;
|
||||
|
||||
case 'u':
|
||||
authorative=0;
|
||||
authoritative=0;
|
||||
break;
|
||||
|
||||
case 'A':
|
||||
authoritative=1;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
@@ -474,10 +491,7 @@ static int builtin_complete( wchar_t **argv )
|
||||
return 0;
|
||||
|
||||
case '?':
|
||||
sb_append( sb_err,
|
||||
parser_current_line() );
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
|
||||
builtin_unknown_option( argv[0], argv[woptind-1] );
|
||||
res = 1;
|
||||
break;
|
||||
|
||||
@@ -489,14 +503,14 @@ static int builtin_complete( wchar_t **argv )
|
||||
{
|
||||
if( condition && wcslen( condition ) )
|
||||
{
|
||||
if( parser_test( condition, 0, 0 ) )
|
||||
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, sb_err, argv[0] );
|
||||
parser_test( condition, 0, sb_err, argv[0] );
|
||||
|
||||
res = 1;
|
||||
}
|
||||
@@ -525,31 +539,51 @@ static int builtin_complete( wchar_t **argv )
|
||||
{
|
||||
if( do_complete )
|
||||
{
|
||||
array_list_t comp;
|
||||
array_list_t *comp;
|
||||
int i;
|
||||
|
||||
const wchar_t *prev_temporary_buffer = temporary_buffer;
|
||||
|
||||
wchar_t *token;
|
||||
|
||||
parse_util_token_extent( do_complete, wcslen( do_complete ), &token, 0, 0, 0 );
|
||||
|
||||
temporary_buffer = do_complete;
|
||||
|
||||
if( recursion_level < 1 )
|
||||
{
|
||||
recursion_level++;
|
||||
|
||||
al_init( &comp );
|
||||
comp = al_halloc( 0 );
|
||||
|
||||
complete( do_complete, &comp );
|
||||
complete( do_complete, comp );
|
||||
|
||||
for( i=0; i<al_get_count( &comp ); i++ )
|
||||
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 );
|
||||
completion_t *next = (completion_t *)al_get( comp, i );
|
||||
wchar_t *prepend;
|
||||
|
||||
if( next->flags & COMPLETE_NO_CASE )
|
||||
{
|
||||
prepend = L"";
|
||||
}
|
||||
else
|
||||
{
|
||||
prepend = token;
|
||||
}
|
||||
|
||||
|
||||
if( next->description )
|
||||
{
|
||||
sb_printf( sb_out, L"%ls%ls\t%ls\n", prepend, next->completion, next->description );
|
||||
}
|
||||
else
|
||||
{
|
||||
sb_printf( sb_out, L"%ls%ls\n", prepend, next->completion );
|
||||
}
|
||||
}
|
||||
|
||||
al_foreach( &comp, &free );
|
||||
al_destroy( &comp );
|
||||
halloc_free( comp );
|
||||
recursion_level--;
|
||||
}
|
||||
|
||||
@@ -561,8 +595,6 @@ static int builtin_complete( wchar_t **argv )
|
||||
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;
|
||||
@@ -591,10 +623,11 @@ static int builtin_complete( wchar_t **argv )
|
||||
&gnu_opt,
|
||||
&old_opt,
|
||||
result_mode,
|
||||
authorative,
|
||||
authoritative,
|
||||
condition,
|
||||
comp,
|
||||
desc );
|
||||
desc,
|
||||
flags );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
/** \file builtin_help.c
|
||||
|
||||
Functions for printing usage information of builtin commands. This
|
||||
file is automatically generated from the file builtin_help.hdr and
|
||||
various help files in the doc_src directory.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "common.h"
|
||||
#include "halloc_util.h"
|
||||
|
||||
/**
|
||||
Hashtable storing the help text
|
||||
*/
|
||||
static hash_table_t tbl;
|
||||
|
||||
static void builtin_help_init();
|
||||
|
||||
char *builtin_help_get( const wchar_t *cmd )
|
||||
{
|
||||
builtin_help_init();
|
||||
|
||||
return (char *)hash_get( &tbl, (void *)cmd );
|
||||
}
|
||||
|
||||
/**
|
||||
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 );
|
||||
@@ -96,7 +96,7 @@ static void builtin_jobs_print( job_t *j, int mode, int header )
|
||||
#ifdef HAVE__PROC_SELF_STAT
|
||||
sb_printf( sb_out, L"%d%%\t", cpu_use(j) );
|
||||
#endif
|
||||
sb_append2( sb_out,
|
||||
sb_append( sb_out,
|
||||
job_is_stopped(j)?_(L"stopped"):_(L"running"),
|
||||
L"\t",
|
||||
j->command,
|
||||
@@ -222,8 +222,6 @@ static int builtin_jobs( wchar_t **argv )
|
||||
argv[0],
|
||||
long_options[opt_index].name );
|
||||
|
||||
sb_append( sb_err,
|
||||
parser_current_line() );
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
|
||||
|
||||
@@ -253,8 +251,7 @@ static int builtin_jobs( wchar_t **argv )
|
||||
return 0;
|
||||
|
||||
case '?':
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
|
||||
builtin_unknown_option( argv[0], argv[woptind-1] );
|
||||
return 1;
|
||||
|
||||
}
|
||||
@@ -276,7 +273,7 @@ static int builtin_jobs( wchar_t **argv )
|
||||
*/
|
||||
for( j=first_job; j; j=j->next )
|
||||
{
|
||||
if( j->constructed && !job_is_completed(j) )
|
||||
if( (j->flags & JOB_CONSTRUCTED) && !job_is_completed(j) )
|
||||
{
|
||||
builtin_jobs_print( j, mode, !found );
|
||||
return 0;
|
||||
@@ -330,7 +327,7 @@ static int builtin_jobs( wchar_t **argv )
|
||||
/*
|
||||
Ignore unconstructed jobs, i.e. ourself.
|
||||
*/
|
||||
if( j->constructed && !job_is_completed(j) )
|
||||
if( (j->flags & JOB_CONSTRUCTED) && !job_is_completed(j) )
|
||||
{
|
||||
builtin_jobs_print( j, mode, !found );
|
||||
found = 1;
|
||||
|
||||
163
builtin_set.c
163
builtin_set.c
@@ -46,10 +46,9 @@ Functions used for implementing the set builtin.
|
||||
*/
|
||||
static int is_path_variable( const wchar_t *env )
|
||||
{
|
||||
return contains_str( env,
|
||||
return contains( env,
|
||||
L"PATH",
|
||||
L"CDPATH",
|
||||
(void *)0 );
|
||||
L"CDPATH" );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -141,7 +140,8 @@ static int my_env_set( const wchar_t *key, array_list_t *val, int scope )
|
||||
{
|
||||
for( i=0; i<al_get_count( val ); i++ )
|
||||
{
|
||||
sb_append( &sb, (wchar_t *)al_get( val, i ) );
|
||||
wchar_t *next =(wchar_t *)al_get( val, i );
|
||||
sb_append( &sb, next?next:L"" );
|
||||
if( i<al_get_count( val )-1 )
|
||||
{
|
||||
sb_append( &sb, ARRAY_SEP_STR );
|
||||
@@ -232,9 +232,14 @@ static int parse_index( array_list_t *indexes,
|
||||
while (*src != L']')
|
||||
{
|
||||
wchar_t *end;
|
||||
long l_ind = wcstol(src, &end, 10);
|
||||
|
||||
if (end == src)
|
||||
long l_ind;
|
||||
|
||||
errno = 0;
|
||||
|
||||
l_ind = wcstol(src, &end, 10);
|
||||
|
||||
if( end==src || errno )
|
||||
{
|
||||
sb_printf(sb_err, _(L"%ls: Invalid index starting at '%ls'\n"), L"set", src);
|
||||
return 0;
|
||||
@@ -274,11 +279,11 @@ static int update_values( array_list_t *list,
|
||||
{
|
||||
/*
|
||||
The '- 1' below is because the indices in fish are
|
||||
one-based, but the array_lsit_t uses zero-based indices
|
||||
one-based, but the array_list_t uses zero-based indices
|
||||
*/
|
||||
long ind = al_get_long(indexes, i) - 1;
|
||||
void *new = (void *) al_get(values, i);
|
||||
if( ind <= 0 )
|
||||
if( ind < 0 )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@@ -318,20 +323,20 @@ static int al_contains_long( array_list_t *list,
|
||||
*/
|
||||
static void erase_values(array_list_t *list, array_list_t *indexes)
|
||||
{
|
||||
int i;
|
||||
long i;
|
||||
array_list_t result;
|
||||
|
||||
al_init(&result);
|
||||
|
||||
for (i = 0; i < al_get_count(list); i++)
|
||||
{
|
||||
if (!al_contains_long(indexes, (long)i + 1))
|
||||
if (!al_contains_long(indexes, i + 1))
|
||||
{
|
||||
al_push(&result, al_get(list, i));
|
||||
}
|
||||
else
|
||||
{
|
||||
free((void *) al_get(list, i));
|
||||
free( (void *)al_get(list, i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -358,7 +363,7 @@ static void print_variables(int include_values, int esc, int scope)
|
||||
for( i = 0; i < al_get_count(&names); i++ )
|
||||
{
|
||||
wchar_t *key = (wchar_t *)al_get( &names, i );
|
||||
wchar_t *e_key = esc ? escape(key, 1) : wcsdup(key);
|
||||
wchar_t *e_key = esc ? escape(key, 0) : wcsdup(key);
|
||||
|
||||
sb_append(sb_out, e_key);
|
||||
|
||||
@@ -366,9 +371,32 @@ static void print_variables(int include_values, int esc, int scope)
|
||||
{
|
||||
wchar_t *value = env_get(key);
|
||||
wchar_t *e_value;
|
||||
e_value = esc ? expand_escape_variable(value) : wcsdup(value);
|
||||
sb_append2(sb_out, L" ", e_value, (void *)0);
|
||||
free(e_value);
|
||||
if( value )
|
||||
{
|
||||
int shorten = 0;
|
||||
|
||||
if( wcslen( value ) > 64 )
|
||||
{
|
||||
shorten = 1;
|
||||
value = wcsndup( value, 60 );
|
||||
if( !value )
|
||||
{
|
||||
DIE_MEM();
|
||||
}
|
||||
}
|
||||
|
||||
e_value = esc ? expand_escape_variable(value) : wcsdup(value);
|
||||
|
||||
sb_append(sb_out, L" ", e_value, (void *)0);
|
||||
free(e_value);
|
||||
|
||||
if( shorten )
|
||||
{
|
||||
sb_append(sb_out, L"\u2026");
|
||||
free( value );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
sb_append(sb_out, L"\n");
|
||||
@@ -455,6 +483,8 @@ static int builtin_set( wchar_t **argv )
|
||||
int slice=0;
|
||||
int i;
|
||||
|
||||
wchar_t *bad_char;
|
||||
|
||||
|
||||
/* Parse options to obtain the requested operation and the modifiers */
|
||||
woptind = 0;
|
||||
@@ -509,7 +539,7 @@ static int builtin_set( wchar_t **argv )
|
||||
return 0;
|
||||
|
||||
case '?':
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
builtin_unknown_option( argv[0], argv[woptind-1] );
|
||||
return 1;
|
||||
|
||||
default:
|
||||
@@ -529,9 +559,8 @@ static int builtin_set( wchar_t **argv )
|
||||
if( query && (erase || list || global || local || universal || export || unexport ) )
|
||||
{
|
||||
sb_printf(sb_err,
|
||||
BUILTIN_ERR_COMBO2,
|
||||
argv[0],
|
||||
parser_current_line() );
|
||||
BUILTIN_ERR_COMBO,
|
||||
argv[0] );
|
||||
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
return 1;
|
||||
@@ -542,9 +571,8 @@ static int builtin_set( wchar_t **argv )
|
||||
if( erase && list )
|
||||
{
|
||||
sb_printf(sb_err,
|
||||
BUILTIN_ERR_COMBO2,
|
||||
argv[0],
|
||||
parser_current_line() );
|
||||
BUILTIN_ERR_COMBO,
|
||||
argv[0] );
|
||||
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
return 1;
|
||||
@@ -557,8 +585,7 @@ static int builtin_set( wchar_t **argv )
|
||||
{
|
||||
sb_printf( sb_err,
|
||||
BUILTIN_ERR_GLOCAL,
|
||||
argv[0],
|
||||
parser_current_line() );
|
||||
argv[0] );
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
return 1;
|
||||
}
|
||||
@@ -570,8 +597,7 @@ static int builtin_set( wchar_t **argv )
|
||||
{
|
||||
sb_printf( sb_err,
|
||||
BUILTIN_ERR_EXPUNEXP,
|
||||
argv[0],
|
||||
parser_current_line() );
|
||||
argv[0] );
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
return 1;
|
||||
}
|
||||
@@ -590,15 +616,67 @@ static int builtin_set( wchar_t **argv )
|
||||
int i;
|
||||
for( i=woptind; i<argc; i++ )
|
||||
{
|
||||
if( !env_exist( argv[i], scope ) )
|
||||
wchar_t *arg = argv[i];
|
||||
int slice=0;
|
||||
|
||||
if( !(dest = wcsdup(arg)))
|
||||
{
|
||||
retcode++;
|
||||
DIE_MEM();
|
||||
}
|
||||
|
||||
if( wcschr( dest, L'[' ) )
|
||||
{
|
||||
slice = 1;
|
||||
*wcschr( dest, L'[' )=0;
|
||||
}
|
||||
|
||||
if( slice )
|
||||
{
|
||||
array_list_t indexes;
|
||||
array_list_t result;
|
||||
int j;
|
||||
|
||||
al_init( &result );
|
||||
al_init( &indexes );
|
||||
|
||||
tokenize_variable_array( env_get( dest ), &result );
|
||||
|
||||
if( !parse_index( &indexes, arg, dest, al_get_count( &result ) ) )
|
||||
{
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
retcode = 1;
|
||||
break;
|
||||
}
|
||||
for( j=0; j<al_get_count( &indexes ); j++ )
|
||||
{
|
||||
long idx = al_get_long( &indexes, j );
|
||||
if( idx < 1 || idx > al_get_count( &result ) )
|
||||
{
|
||||
retcode++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !env_exist( arg, scope ) )
|
||||
{
|
||||
retcode++;
|
||||
}
|
||||
}
|
||||
|
||||
free( dest );
|
||||
|
||||
}
|
||||
return retcode;
|
||||
}
|
||||
|
||||
if( list )
|
||||
{
|
||||
/* Maybe we should issue an error if there are any other arguments? */
|
||||
print_variables(0, 0, scope);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( woptind == argc )
|
||||
{
|
||||
/*
|
||||
@@ -609,8 +687,7 @@ static int builtin_set( wchar_t **argv )
|
||||
{
|
||||
sb_printf( sb_err,
|
||||
_(L"%ls: Erase needs a variable name\n%ls\n"),
|
||||
argv[0],
|
||||
parser_current_line() );
|
||||
argv[0] );
|
||||
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
retcode = 1;
|
||||
@@ -623,13 +700,6 @@ static int builtin_set( wchar_t **argv )
|
||||
return retcode;
|
||||
}
|
||||
|
||||
if( list )
|
||||
{
|
||||
/* Maybe we should issue an error if there are any other arguments? */
|
||||
print_variables(0, 0, scope);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( !(dest = wcsdup(argv[woptind])))
|
||||
{
|
||||
DIE_MEM();
|
||||
@@ -648,7 +718,15 @@ static int builtin_set( wchar_t **argv )
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
if( (bad_char = wcsvarname( dest ) ) )
|
||||
{
|
||||
sb_printf( sb_err, BUILTIN_ERR_VARCHAR, argv[0], *bad_char );
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
free( dest );
|
||||
return 1;
|
||||
}
|
||||
|
||||
if( slice && erase && (scope != ENV_USER) )
|
||||
{
|
||||
free( dest );
|
||||
@@ -676,9 +754,9 @@ static int builtin_set( wchar_t **argv )
|
||||
al_init(&values);
|
||||
al_init(&indexes);
|
||||
al_init(&result);
|
||||
|
||||
|
||||
tokenize_variable_array( env_get(dest), &result );
|
||||
|
||||
|
||||
for( ; woptind<argc; woptind++ )
|
||||
{
|
||||
if( !parse_index( &indexes, argv[woptind], dest, al_get_count( &result ) ) )
|
||||
@@ -766,9 +844,8 @@ static int builtin_set( wchar_t **argv )
|
||||
if( woptind != argc )
|
||||
{
|
||||
sb_printf( sb_err,
|
||||
_(L"%ls: Values cannot be specfied with erase\n%ls\n"),
|
||||
argv[0],
|
||||
parser_current_line() );
|
||||
_(L"%ls: Values cannot be specfied with erase\n"),
|
||||
argv[0] );
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
retcode=1;
|
||||
}
|
||||
|
||||
@@ -123,7 +123,9 @@ static int get_multiplier( int what )
|
||||
}
|
||||
|
||||
/**
|
||||
Return the value for the specified resource limit
|
||||
Return the value for the specified resource limit. This function
|
||||
does _not_ multiply the limit value by the multiplier constant used
|
||||
by the commandline ulimit.
|
||||
*/
|
||||
static rlim_t get( int resource, int hard )
|
||||
{
|
||||
@@ -144,7 +146,7 @@ static void print( int resource, int hard )
|
||||
if( l == RLIM_INFINITY )
|
||||
sb_append( sb_out, L"unlimited\n" );
|
||||
else
|
||||
sb_printf( sb_out, L"%d\n", l );
|
||||
sb_printf( sb_out, L"%d\n", l / get_multiplier( resource ) );
|
||||
|
||||
}
|
||||
|
||||
@@ -178,10 +180,15 @@ static void print_all( int hard )
|
||||
resource_arr[i].switch_char);
|
||||
|
||||
if( l == RLIM_INFINITY )
|
||||
{
|
||||
sb_append( sb_out, L"unlimited\n" );
|
||||
}
|
||||
else
|
||||
sb_printf( sb_out, L"%d\n", l );
|
||||
{
|
||||
sb_printf( sb_out, L"%d\n", l/get_multiplier(resource_arr[i].resource) );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -202,14 +209,14 @@ static const wchar_t *get_desc( int what )
|
||||
}
|
||||
|
||||
/**
|
||||
Set the new value of the specified resource limit
|
||||
Set the new value of the specified resource limit. This function
|
||||
does _not_ multiply the limit value by the multiplier constant used
|
||||
by the commandline ulimit.
|
||||
*/
|
||||
static int set( int resource, int hard, int soft, rlim_t value )
|
||||
{
|
||||
struct rlimit ls;
|
||||
getrlimit( resource, &ls );
|
||||
if( value != RLIM_INFINITY )
|
||||
value *= get_multiplier( resource );
|
||||
|
||||
if( hard )
|
||||
{
|
||||
@@ -241,22 +248,6 @@ static int set( int resource, int hard, int soft, rlim_t value )
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
Set all resource limits
|
||||
*/
|
||||
static int set_all( int hard, int soft, rlim_t value )
|
||||
{
|
||||
int i;
|
||||
int res=0;
|
||||
|
||||
for( i=0; resource_arr[i].desc; i++ )
|
||||
{
|
||||
if( set( resource_arr[i].resource, hard, soft, value ) )
|
||||
res = 1;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
The ulimit builtin, used for setting resource limits. Defined in
|
||||
builtin_ulimit.c.
|
||||
@@ -315,7 +306,7 @@ static int builtin_ulimit( wchar_t ** argv )
|
||||
}
|
||||
,
|
||||
{
|
||||
L"pipe-size", no_argument, 0, 'p'
|
||||
L"stack-size", no_argument, 0, 's'
|
||||
}
|
||||
,
|
||||
{
|
||||
@@ -345,7 +336,7 @@ static int builtin_ulimit( wchar_t ** argv )
|
||||
|
||||
int opt = wgetopt_long( argc,
|
||||
argv,
|
||||
L"aHScdflmnptuvh",
|
||||
L"aHScdflmnstuvh",
|
||||
long_options,
|
||||
&opt_index );
|
||||
if( opt == -1 )
|
||||
@@ -428,28 +419,41 @@ static int builtin_ulimit( wchar_t ** argv )
|
||||
return 0;
|
||||
|
||||
case L'?':
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
builtin_unknown_option( argv[0], argv[woptind-1] );
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if( report_all )
|
||||
{
|
||||
if( argc - woptind == 0 )
|
||||
{
|
||||
print_all( hard );
|
||||
}
|
||||
else
|
||||
{
|
||||
sb_append( sb_err,
|
||||
argv[0],
|
||||
L": Too many arguments\n",
|
||||
(void *)0 );
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch( argc - woptind )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
/*
|
||||
Show current limit value
|
||||
*/
|
||||
if( report_all )
|
||||
{
|
||||
print_all( hard );
|
||||
}
|
||||
else
|
||||
{
|
||||
print( what, hard );
|
||||
}
|
||||
|
||||
print( what, hard );
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case 1:
|
||||
{
|
||||
/*
|
||||
@@ -457,7 +461,7 @@ static int builtin_ulimit( wchar_t ** argv )
|
||||
*/
|
||||
rlim_t new_limit;
|
||||
wchar_t *end;
|
||||
|
||||
|
||||
/*
|
||||
Set both hard and soft limits if nothing else was specified
|
||||
*/
|
||||
@@ -466,7 +470,6 @@ static int builtin_ulimit( wchar_t ** argv )
|
||||
hard=soft=1;
|
||||
}
|
||||
|
||||
|
||||
if( wcscasecmp( argv[woptind], L"unlimited" )==0)
|
||||
{
|
||||
new_limit = RLIM_INFINITY;
|
||||
@@ -492,30 +495,22 @@ static int builtin_ulimit( wchar_t ** argv )
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
return 1;
|
||||
}
|
||||
new_limit *= get_multiplier( what );
|
||||
}
|
||||
|
||||
if( report_all )
|
||||
{
|
||||
return set_all( hard, soft, new_limit );
|
||||
}
|
||||
else
|
||||
{
|
||||
return set( what, hard, soft, new_limit );
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
return set( what, hard, soft, new_limit );
|
||||
}
|
||||
|
||||
default:
|
||||
sb_append2( sb_err,
|
||||
{
|
||||
sb_append( sb_err,
|
||||
argv[0],
|
||||
L": Too many arguments\n",
|
||||
(void *)0 );
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
return 1;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
581
common.c
581
common.c
@@ -44,6 +44,10 @@ parts of fish.
|
||||
#include <sys/time.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifdef HAVE_EXECINFO_H
|
||||
#include <execinfo.h>
|
||||
#endif
|
||||
|
||||
#ifndef HOST_NAME_MAX
|
||||
/**
|
||||
Maximum length of hostname return. It is ok if this is too short,
|
||||
@@ -110,6 +114,28 @@ static struct winsize termsize;
|
||||
*/
|
||||
static string_buffer_t *setlocale_buff=0;
|
||||
|
||||
|
||||
void show_stackframe()
|
||||
{
|
||||
void *trace[32];
|
||||
char **messages = (char **)NULL;
|
||||
int i, trace_size = 0;
|
||||
|
||||
trace_size = backtrace(trace, 32);
|
||||
messages = backtrace_symbols(trace, trace_size);
|
||||
|
||||
if( messages )
|
||||
{
|
||||
debug( 0, L"Backtrace:" );
|
||||
for( i=0; i<trace_size; i++ )
|
||||
{
|
||||
fwprintf( stderr, L"%s\n", messages[i]);
|
||||
}
|
||||
free( messages );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
wchar_t **list_to_char_arr( array_list_t *l )
|
||||
{
|
||||
wchar_t ** res = malloc( sizeof(wchar_t *)*(al_get_count( l )+1) );
|
||||
@@ -157,8 +183,6 @@ int fgetws2( wchar_t **b, int *len, FILE *f )
|
||||
|
||||
if( errno == EILSEQ )
|
||||
{
|
||||
|
||||
getc( f );
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -190,7 +214,7 @@ int fgetws2( wchar_t **b, int *len, FILE *f )
|
||||
/**
|
||||
Wrapper for wcsfilecmp
|
||||
*/
|
||||
static int completion_cmp( const void *a, const void *b )
|
||||
static int str_cmp( const void *a, const void *b )
|
||||
{
|
||||
wchar_t *c= *((wchar_t **)a);
|
||||
wchar_t *d= *((wchar_t **)b);
|
||||
@@ -202,7 +226,7 @@ void sort_list( array_list_t *comp )
|
||||
qsort( comp->arr,
|
||||
al_get_count( comp ),
|
||||
sizeof( void*),
|
||||
&completion_cmp );
|
||||
&str_cmp );
|
||||
}
|
||||
|
||||
wchar_t *str2wcs( const char *in )
|
||||
@@ -234,15 +258,27 @@ wchar_t *str2wcs_internal( const char *in, wchar_t *out )
|
||||
len = strlen(in);
|
||||
|
||||
memset( &state, 0, sizeof(state) );
|
||||
|
||||
|
||||
while( in[in_pos] )
|
||||
{
|
||||
res = mbrtowc( &out[out_pos], &in[in_pos], len-in_pos, &state );
|
||||
|
||||
switch( res )
|
||||
if( ( ( out[out_pos] >= ENCODE_DIRECT_BASE) &&
|
||||
( out[out_pos] < ENCODE_DIRECT_BASE+256)) ||
|
||||
( out[out_pos] == INTERNAL_SEPARATOR ) )
|
||||
{
|
||||
case (size_t)(-2):
|
||||
case (size_t)(-1):
|
||||
out[out_pos] = ENCODE_DIRECT_BASE + (unsigned char)in[in_pos];
|
||||
in_pos++;
|
||||
memset( &state, 0, sizeof(state) );
|
||||
out_pos++;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
switch( res )
|
||||
{
|
||||
case (size_t)(-2):
|
||||
case (size_t)(-1):
|
||||
{
|
||||
out[out_pos] = ENCODE_DIRECT_BASE + (unsigned char)in[in_pos];
|
||||
in_pos++;
|
||||
@@ -250,18 +286,20 @@ wchar_t *str2wcs_internal( const char *in, wchar_t *out )
|
||||
break;
|
||||
}
|
||||
|
||||
case 0:
|
||||
{
|
||||
return out;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
return out;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
in_pos += res;
|
||||
break;
|
||||
default:
|
||||
{
|
||||
in_pos += res;
|
||||
break;
|
||||
}
|
||||
}
|
||||
out_pos++;
|
||||
}
|
||||
out_pos++;
|
||||
|
||||
}
|
||||
out[out_pos] = 0;
|
||||
|
||||
@@ -296,8 +334,11 @@ char *wcs2str_internal( const wchar_t *in, char *out )
|
||||
|
||||
while( in[in_pos] )
|
||||
{
|
||||
if( ( in[in_pos] >= ENCODE_DIRECT_BASE) &&
|
||||
( in[in_pos] < ENCODE_DIRECT_BASE+256) )
|
||||
if( in[in_pos] == INTERNAL_SEPARATOR )
|
||||
{
|
||||
}
|
||||
else if( ( in[in_pos] >= ENCODE_DIRECT_BASE) &&
|
||||
( in[in_pos] < ENCODE_DIRECT_BASE+256) )
|
||||
{
|
||||
out[out_pos++] = in[in_pos]- ENCODE_DIRECT_BASE;
|
||||
}
|
||||
@@ -307,7 +348,7 @@ char *wcs2str_internal( const wchar_t *in, char *out )
|
||||
|
||||
if( res == (size_t)(-1) )
|
||||
{
|
||||
debug( 1, L"Wide character has no narrow representation" );
|
||||
debug( 1, L"Wide character %d has no narrow representation", in[in_pos] );
|
||||
memset( &state, 0, sizeof(state) );
|
||||
}
|
||||
else
|
||||
@@ -344,12 +385,7 @@ char **wcsv2strv( const wchar_t **in )
|
||||
|
||||
}
|
||||
|
||||
wchar_t *wcsdupcat( const wchar_t *a, const wchar_t *b )
|
||||
{
|
||||
return wcsdupcat2( a, b, (void *)0 );
|
||||
}
|
||||
|
||||
wchar_t *wcsdupcat2( const wchar_t *a, ... )
|
||||
wchar_t *wcsdupcat_internal( const wchar_t *a, ... )
|
||||
{
|
||||
int len=wcslen(a);
|
||||
int pos;
|
||||
@@ -405,19 +441,25 @@ wchar_t **strv2wcsv( const char **in )
|
||||
|
||||
}
|
||||
|
||||
wchar_t *wcsvarname( wchar_t *str )
|
||||
wchar_t *wcsvarname( const wchar_t *str )
|
||||
{
|
||||
while( *str )
|
||||
{
|
||||
if( (!iswalnum(*str)) && (*str != L'_' ) )
|
||||
{
|
||||
return str;
|
||||
return (wchar_t *)str;
|
||||
}
|
||||
str++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
wchar_t *wcsfuncname( const wchar_t *str )
|
||||
{
|
||||
return wcschr( str, L'/' );
|
||||
}
|
||||
|
||||
|
||||
int wcsvarchr( wchar_t chr )
|
||||
{
|
||||
return ( (iswalnum(chr)) || (chr == L'_' ));
|
||||
@@ -501,7 +543,7 @@ const wchar_t *wsetlocale(int category, const wchar_t *locale)
|
||||
return (wchar_t *)setlocale_buff->buff;
|
||||
}
|
||||
|
||||
int contains_str( const wchar_t *a, ... )
|
||||
int contains_internal( const wchar_t *a, ... )
|
||||
{
|
||||
wchar_t *arg;
|
||||
va_list va;
|
||||
@@ -536,17 +578,50 @@ int read_blocked(int fd, void *buf, size_t count)
|
||||
return res;
|
||||
}
|
||||
|
||||
ssize_t write_loop(int fd, char *buff, size_t count)
|
||||
{
|
||||
ssize_t out=0;
|
||||
ssize_t out_cum=0;
|
||||
while( 1 )
|
||||
{
|
||||
out = write( fd,
|
||||
&buff[out_cum],
|
||||
count - out_cum );
|
||||
if (out == -1)
|
||||
{
|
||||
if( errno != EAGAIN &&
|
||||
errno != EINTR )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
} else
|
||||
{
|
||||
out_cum += out;
|
||||
}
|
||||
if( out_cum >= count )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return out_cum;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void debug( int level, const wchar_t *msg, ... )
|
||||
{
|
||||
va_list va;
|
||||
|
||||
string_buffer_t sb;
|
||||
string_buffer_t sb2;
|
||||
|
||||
int errno_old = errno;
|
||||
|
||||
CHECK( msg, );
|
||||
|
||||
if( level > debug_level )
|
||||
return;
|
||||
|
||||
CHECK( msg, );
|
||||
|
||||
sb_init( &sb );
|
||||
sb_init( &sb2 );
|
||||
|
||||
@@ -561,6 +636,8 @@ void debug( int level, const wchar_t *msg, ... )
|
||||
|
||||
sb_destroy( &sb );
|
||||
sb_destroy( &sb2 );
|
||||
|
||||
errno = errno_old;
|
||||
}
|
||||
|
||||
void write_screen( const wchar_t *msg, string_buffer_t *buff )
|
||||
@@ -655,17 +732,55 @@ void write_screen( const wchar_t *msg, string_buffer_t *buff )
|
||||
sb_append_char( buff, L'\n' );
|
||||
}
|
||||
|
||||
wchar_t *escape( const wchar_t *in,
|
||||
int escape_all )
|
||||
/**
|
||||
Perform string escaping of a strinng by only quoting it. Assumes
|
||||
the string has already been checked for characters that can not be
|
||||
escaped this way.
|
||||
*/
|
||||
static wchar_t *escape_simple( const wchar_t *in )
|
||||
{
|
||||
wchar_t *out;
|
||||
size_t len = wcslen(in);
|
||||
out = malloc( sizeof(wchar_t)*(len+3));
|
||||
if( !out )
|
||||
DIE_MEM();
|
||||
|
||||
out[0] = L'\'';
|
||||
wcscpy(&out[1], in );
|
||||
out[len+1]=L'\'';
|
||||
out[len+2]=0;
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
wchar_t *escape( const wchar_t *in_orig,
|
||||
int flags )
|
||||
{
|
||||
const wchar_t *in = in_orig;
|
||||
|
||||
int escape_all = flags & ESCAPE_ALL;
|
||||
int no_quoted = flags & ESCAPE_NO_QUOTED;
|
||||
|
||||
wchar_t *out;
|
||||
wchar_t *pos;
|
||||
|
||||
int need_escape=0;
|
||||
int need_complex_escape=0;
|
||||
|
||||
if( !in )
|
||||
{
|
||||
debug( 0, L"%s called with null input", __func__ );
|
||||
exit(1);
|
||||
FATAL_EXIT();
|
||||
}
|
||||
|
||||
if( !no_quoted && (wcslen( in ) == 0) )
|
||||
{
|
||||
out = wcsdup(L"''");
|
||||
if( !out )
|
||||
DIE_MEM();
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
out = malloc( sizeof(wchar_t)*(wcslen(in)*4 + 1));
|
||||
pos = out;
|
||||
@@ -690,6 +805,7 @@ wchar_t *escape( const wchar_t *in,
|
||||
|
||||
tmp = val%16;
|
||||
*pos++ = tmp > 9? L'a'+(tmp-10):L'0'+tmp;
|
||||
need_escape=need_complex_escape=1;
|
||||
|
||||
}
|
||||
else
|
||||
@@ -700,29 +816,44 @@ wchar_t *escape( const wchar_t *in,
|
||||
case L'\t':
|
||||
*(pos++) = L'\\';
|
||||
*(pos++) = L't';
|
||||
need_escape=need_complex_escape=1;
|
||||
break;
|
||||
|
||||
case L'\n':
|
||||
*(pos++) = L'\\';
|
||||
*(pos++) = L'n';
|
||||
need_escape=need_complex_escape=1;
|
||||
break;
|
||||
|
||||
case L'\b':
|
||||
*(pos++) = L'\\';
|
||||
*(pos++) = L'b';
|
||||
need_escape=need_complex_escape=1;
|
||||
break;
|
||||
|
||||
case L'\r':
|
||||
*(pos++) = L'\\';
|
||||
*(pos++) = L'r';
|
||||
need_escape=need_complex_escape=1;
|
||||
break;
|
||||
|
||||
case L'\e':
|
||||
case L'\x1b':
|
||||
*(pos++) = L'\\';
|
||||
*(pos++) = L'e';
|
||||
need_escape=need_complex_escape=1;
|
||||
break;
|
||||
|
||||
|
||||
case L'\\':
|
||||
case L'\'':
|
||||
{
|
||||
need_escape=need_complex_escape=1;
|
||||
if( escape_all )
|
||||
*pos++ = L'\\';
|
||||
*pos++ = *in;
|
||||
break;
|
||||
}
|
||||
|
||||
case L'&':
|
||||
case L'$':
|
||||
case L' ':
|
||||
@@ -740,12 +871,11 @@ wchar_t *escape( const wchar_t *in,
|
||||
case L'*':
|
||||
case L'|':
|
||||
case L';':
|
||||
case L':':
|
||||
case L'\'':
|
||||
case L'"':
|
||||
case L'%':
|
||||
case L'~':
|
||||
{
|
||||
need_escape=1;
|
||||
if( escape_all )
|
||||
*pos++ = L'\\';
|
||||
*pos++ = *in;
|
||||
@@ -756,11 +886,24 @@ wchar_t *escape( const wchar_t *in,
|
||||
{
|
||||
if( *in < 32 )
|
||||
{
|
||||
if( *in <27 && *in > 0 )
|
||||
{
|
||||
*(pos++) = L'\\';
|
||||
*(pos++) = L'c';
|
||||
*(pos++) = L'a' + *in -1;
|
||||
|
||||
need_escape=need_complex_escape=1;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
int tmp = (*in)%16;
|
||||
*pos++ = L'\\';
|
||||
*pos++ = L'x';
|
||||
*pos++ = ((*in>15)? L'1' : L'0');
|
||||
*pos++ = tmp > 9? L'a'+(tmp-10):L'0'+tmp;
|
||||
need_escape=need_complex_escape=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -774,11 +917,22 @@ wchar_t *escape( const wchar_t *in,
|
||||
in++;
|
||||
}
|
||||
*pos = 0;
|
||||
|
||||
/*
|
||||
Use quoted escaping if possible, since most people find it
|
||||
easier to read.
|
||||
*/
|
||||
if( !no_quoted && need_escape && !need_complex_escape && escape_all )
|
||||
{
|
||||
free( out );
|
||||
out = escape_simple( in_orig );
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
wchar_t *unescape( const wchar_t * orig, int unescape_special )
|
||||
wchar_t *unescape( const wchar_t * orig, int flags )
|
||||
{
|
||||
|
||||
int mode = 0;
|
||||
@@ -787,7 +941,9 @@ wchar_t *unescape( const wchar_t * orig, int unescape_special )
|
||||
int bracket_count=0;
|
||||
wchar_t prev=0;
|
||||
wchar_t *in;
|
||||
|
||||
int unescape_special = flags & UNESCAPE_SPECIAL;
|
||||
int allow_incomplete = flags & UNESCAPE_INCOMPLETE;
|
||||
|
||||
CHECK( orig, 0 );
|
||||
|
||||
len = wcslen( orig );
|
||||
@@ -813,64 +969,25 @@ wchar_t *unescape( const wchar_t * orig, int unescape_special )
|
||||
{
|
||||
switch( in[++in_pos] )
|
||||
{
|
||||
|
||||
/*
|
||||
A null character after a backslash is an
|
||||
error, return null
|
||||
*/
|
||||
case L'\0':
|
||||
{
|
||||
free(in);
|
||||
return 0;
|
||||
if( !allow_incomplete )
|
||||
{
|
||||
free(in);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Numeric escape sequences. No prefix means
|
||||
octal escape, otherwise hexadecimal.
|
||||
*/
|
||||
|
||||
case L'n':
|
||||
{
|
||||
in[out_pos]=L'\n';
|
||||
break;
|
||||
}
|
||||
|
||||
case L'r':
|
||||
{
|
||||
in[out_pos]=L'\r';
|
||||
break;
|
||||
}
|
||||
|
||||
case L't':
|
||||
{
|
||||
in[out_pos]=L'\t';
|
||||
break;
|
||||
}
|
||||
|
||||
case L'b':
|
||||
{
|
||||
in[out_pos]=L'\b';
|
||||
break;
|
||||
}
|
||||
|
||||
case L'a':
|
||||
{
|
||||
in[out_pos]=L'\a';
|
||||
break;
|
||||
}
|
||||
|
||||
case L'f':
|
||||
{
|
||||
in[out_pos]=L'\f';
|
||||
break;
|
||||
}
|
||||
|
||||
case L'v':
|
||||
{
|
||||
in[out_pos]=L'\v';
|
||||
break;
|
||||
}
|
||||
|
||||
case L'e':
|
||||
{
|
||||
in[out_pos]=L'\x1b';
|
||||
break;
|
||||
}
|
||||
|
||||
case L'u':
|
||||
case L'U':
|
||||
case L'x':
|
||||
case L'X':
|
||||
case L'0':
|
||||
case L'1':
|
||||
case L'2':
|
||||
@@ -879,6 +996,10 @@ wchar_t *unescape( const wchar_t * orig, int unescape_special )
|
||||
case L'5':
|
||||
case L'6':
|
||||
case L'7':
|
||||
case L'u':
|
||||
case L'U':
|
||||
case L'x':
|
||||
case L'X':
|
||||
{
|
||||
int i;
|
||||
long long res=0;
|
||||
@@ -951,8 +1072,107 @@ wchar_t *unescape( const wchar_t * orig, int unescape_special )
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
\a means bell (alert)
|
||||
*/
|
||||
case L'a':
|
||||
{
|
||||
in[out_pos]=L'\a';
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
\b means backspace
|
||||
*/
|
||||
case L'b':
|
||||
{
|
||||
in[out_pos]=L'\b';
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
\cX means control sequence X
|
||||
*/
|
||||
case L'c':
|
||||
{
|
||||
in_pos++;
|
||||
if( in[in_pos] >= L'a' &&
|
||||
in[in_pos] <= (L'a'+32) )
|
||||
{
|
||||
in[out_pos]=in[in_pos]-L'a'+1;
|
||||
}
|
||||
else if( in[in_pos] >= L'A' &&
|
||||
in[in_pos] <= (L'A'+32) )
|
||||
{
|
||||
in[out_pos]=in[in_pos]-L'A'+1;
|
||||
}
|
||||
else
|
||||
{
|
||||
free(in);
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
\x1b means escape
|
||||
*/
|
||||
case L'e':
|
||||
{
|
||||
in[out_pos]=L'\x1b';
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
\f means form feed
|
||||
*/
|
||||
case L'f':
|
||||
{
|
||||
in[out_pos]=L'\f';
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
\n means newline
|
||||
*/
|
||||
case L'n':
|
||||
{
|
||||
in[out_pos]=L'\n';
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
\r means carriage return
|
||||
*/
|
||||
case L'r':
|
||||
{
|
||||
in[out_pos]=L'\r';
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
\t means tab
|
||||
*/
|
||||
case L't':
|
||||
{
|
||||
in[out_pos]=L'\t';
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
\v means vertical tab
|
||||
*/
|
||||
case L'v':
|
||||
{
|
||||
in[out_pos]=L'\v';
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
if( unescape_special )
|
||||
in[out_pos++] = INTERNAL_SEPARATOR;
|
||||
in[out_pos]=in[in_pos];
|
||||
break;
|
||||
}
|
||||
@@ -960,7 +1180,8 @@ wchar_t *unescape( const wchar_t * orig, int unescape_special )
|
||||
}
|
||||
else
|
||||
{
|
||||
switch( in[in_pos]){
|
||||
switch( in[in_pos])
|
||||
{
|
||||
case L'~':
|
||||
{
|
||||
if( unescape_special && (in_pos == 0) )
|
||||
@@ -1076,14 +1297,20 @@ wchar_t *unescape( const wchar_t * orig, int unescape_special )
|
||||
case L'\'':
|
||||
{
|
||||
mode = 1;
|
||||
in[out_pos] = INTERNAL_SEPARATOR;
|
||||
if( unescape_special )
|
||||
in[out_pos] = INTERNAL_SEPARATOR;
|
||||
else
|
||||
out_pos--;
|
||||
break;
|
||||
}
|
||||
|
||||
case L'\"':
|
||||
{
|
||||
mode = 2;
|
||||
in[out_pos] = INTERNAL_SEPARATOR;
|
||||
if( unescape_special )
|
||||
in[out_pos] = INTERNAL_SEPARATOR;
|
||||
else
|
||||
out_pos--;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1108,6 +1335,7 @@ wchar_t *unescape( const wchar_t * orig, int unescape_special )
|
||||
{
|
||||
case '\\':
|
||||
case L'\'':
|
||||
case L'\n':
|
||||
{
|
||||
in[out_pos]=in[in_pos];
|
||||
break;
|
||||
@@ -1115,8 +1343,13 @@ wchar_t *unescape( const wchar_t * orig, int unescape_special )
|
||||
|
||||
case 0:
|
||||
{
|
||||
free(in);
|
||||
return 0;
|
||||
if( !allow_incomplete )
|
||||
{
|
||||
free(in);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
out_pos--;
|
||||
}
|
||||
|
||||
default:
|
||||
@@ -1129,7 +1362,10 @@ wchar_t *unescape( const wchar_t * orig, int unescape_special )
|
||||
}
|
||||
if( c == L'\'' )
|
||||
{
|
||||
in[out_pos] = INTERNAL_SEPARATOR;
|
||||
if( unescape_special )
|
||||
in[out_pos] = INTERNAL_SEPARATOR;
|
||||
else
|
||||
out_pos--;
|
||||
mode = 0;
|
||||
}
|
||||
else
|
||||
@@ -1150,7 +1386,10 @@ wchar_t *unescape( const wchar_t * orig, int unescape_special )
|
||||
case '"':
|
||||
{
|
||||
mode = 0;
|
||||
in[out_pos] = INTERNAL_SEPARATOR;
|
||||
if( unescape_special )
|
||||
in[out_pos] = INTERNAL_SEPARATOR;
|
||||
else
|
||||
out_pos--;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1160,13 +1399,19 @@ wchar_t *unescape( const wchar_t * orig, int unescape_special )
|
||||
{
|
||||
case L'\0':
|
||||
{
|
||||
free(in);
|
||||
return 0;
|
||||
if( !allow_incomplete )
|
||||
{
|
||||
free(in);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
out_pos--;
|
||||
}
|
||||
|
||||
case '\\':
|
||||
case L'$':
|
||||
case '"':
|
||||
case '\n':
|
||||
{
|
||||
in[out_pos]=in[in_pos];
|
||||
break;
|
||||
@@ -1206,6 +1451,13 @@ wchar_t *unescape( const wchar_t * orig, int unescape_special )
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( !allow_incomplete && mode )
|
||||
{
|
||||
free( in );
|
||||
return 0;
|
||||
}
|
||||
|
||||
in[out_pos]=L'\0';
|
||||
return in;
|
||||
}
|
||||
@@ -1348,7 +1600,7 @@ int acquire_lock_file( const char *lockfile, const int timeout, int force )
|
||||
goto done;
|
||||
}
|
||||
(void)unlink( linkfile );
|
||||
if( ( fd = open( linkfile, O_CREAT|O_RDONLY ) ) == -1 )
|
||||
if( ( fd = open( linkfile, O_CREAT|O_RDONLY, 0600 ) ) == -1 )
|
||||
{
|
||||
debug( 1, L"acquire_lock_file: open: %s", strerror( errno ) );
|
||||
goto done;
|
||||
@@ -1466,6 +1718,7 @@ void tokenize_variable_array( const wchar_t *val, array_list_t *out )
|
||||
{
|
||||
wchar_t *cpy = wcsdup( val );
|
||||
wchar_t *pos, *start;
|
||||
wchar_t *next;
|
||||
|
||||
if( !cpy )
|
||||
{
|
||||
@@ -1476,13 +1729,131 @@ void tokenize_variable_array( const wchar_t *val, array_list_t *out )
|
||||
{
|
||||
if( *pos == ARRAY_SEP )
|
||||
{
|
||||
|
||||
*pos=0;
|
||||
al_push( out, start==cpy?cpy:wcsdup(start) );
|
||||
next = start==cpy?cpy:wcsdup(start);
|
||||
if( !next )
|
||||
DIE_MEM();
|
||||
al_push( out, next );
|
||||
start=pos+1;
|
||||
}
|
||||
}
|
||||
al_push( out, start==cpy?cpy:wcsdup(start) );
|
||||
next = start==cpy?cpy:wcsdup(start);
|
||||
if( !next )
|
||||
DIE_MEM();
|
||||
al_push( out, next );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int create_directory( wchar_t *d )
|
||||
{
|
||||
int ok = 0;
|
||||
struct stat buf;
|
||||
int stat_res = 0;
|
||||
|
||||
while( (stat_res = wstat(d, &buf ) ) != 0 )
|
||||
{
|
||||
if( errno != EAGAIN )
|
||||
break;
|
||||
}
|
||||
|
||||
if( stat_res == 0 )
|
||||
{
|
||||
if( S_ISDIR( buf.st_mode ) )
|
||||
{
|
||||
ok = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( errno == ENOENT )
|
||||
{
|
||||
wchar_t *dir = wcsdup( d );
|
||||
dir = wdirname( dir );
|
||||
if( !create_directory( dir ) )
|
||||
{
|
||||
if( !wmkdir( d, 0700 ) )
|
||||
{
|
||||
ok = 1;
|
||||
}
|
||||
}
|
||||
free(dir);
|
||||
}
|
||||
}
|
||||
|
||||
return ok?0:-1;
|
||||
}
|
||||
|
||||
void bugreport()
|
||||
{
|
||||
debug( 1,
|
||||
_( L"This is a bug. "
|
||||
L"If you can reproduce it, please send a bug report to %s." ),
|
||||
PACKAGE_BUGREPORT );
|
||||
}
|
||||
|
||||
|
||||
void sb_format_size( string_buffer_t *sb,
|
||||
long long sz )
|
||||
{
|
||||
wchar_t *sz_name[]=
|
||||
{
|
||||
L"kB", L"MB", L"GB", L"TB", L"PB", L"EB", L"ZB", L"YB", 0
|
||||
}
|
||||
;
|
||||
|
||||
if( sz < 0 )
|
||||
{
|
||||
sb_append( sb, L"unknown" );
|
||||
}
|
||||
else if( sz < 1 )
|
||||
{
|
||||
sb_append( sb, _( L"empty" ) );
|
||||
}
|
||||
else if( sz < 1024 )
|
||||
{
|
||||
sb_printf( sb, L"%lldB", sz );
|
||||
}
|
||||
else
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i=0; sz_name[i]; i++ )
|
||||
{
|
||||
if( sz < (1024*1024) || !sz_name[i+1] )
|
||||
{
|
||||
int isz = sz/1024;
|
||||
if( isz > 9 )
|
||||
sb_printf( sb, L"%d%ls", isz, sz_name[i] );
|
||||
else
|
||||
sb_printf( sb, L"%.1f%ls", (double)sz/1024, sz_name[i] );
|
||||
break;
|
||||
}
|
||||
sz /= 1024;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double timef()
|
||||
{
|
||||
int time_res;
|
||||
struct timeval tv;
|
||||
|
||||
time_res = gettimeofday(&tv, 0);
|
||||
|
||||
if( time_res )
|
||||
{
|
||||
/*
|
||||
Fixme: What on earth is the correct parameter value for NaN?
|
||||
The man pages and the standard helpfully state that this
|
||||
parameter is implementation defined. Gcc gives a warning if
|
||||
a null pointer is used. But not even all mighty Google gives
|
||||
a hint to what value should actually be returned.
|
||||
*/
|
||||
return nan("");
|
||||
}
|
||||
|
||||
return (double)tv.tv_sec + 0.000001*tv.tv_usec;
|
||||
}
|
||||
|
||||
173
common.h
173
common.h
@@ -40,6 +40,26 @@
|
||||
*/
|
||||
#define BYTE_MAX 0xffu
|
||||
|
||||
/**
|
||||
Escape special fish syntax characters like the semicolon
|
||||
*/
|
||||
#define UNESCAPE_SPECIAL 1
|
||||
|
||||
/**
|
||||
Allow incomplete escape sequences
|
||||
*/
|
||||
#define UNESCAPE_INCOMPLETE 2
|
||||
|
||||
/**
|
||||
Escape all characters, including magic characters like the semicolon
|
||||
*/
|
||||
#define ESCAPE_ALL 1
|
||||
/**
|
||||
Do not try to use 'simplified' quoted escapes, and do not use empty quotes as the empty string
|
||||
*/
|
||||
#define ESCAPE_NO_QUOTED 2
|
||||
|
||||
|
||||
/**
|
||||
Save the shell mode on startup so we can restore them on exit
|
||||
*/
|
||||
@@ -52,7 +72,8 @@ extern struct termios shell_modes;
|
||||
extern wchar_t ellipsis_char;
|
||||
|
||||
/**
|
||||
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;
|
||||
|
||||
@@ -71,30 +92,58 @@ extern wchar_t *program_name;
|
||||
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 exit status of the current function on failiure.
|
||||
parameter is the return value of the current function on failiure.
|
||||
*/
|
||||
#define CHECK( arg, retval ) \
|
||||
#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.", \
|
||||
debug( 0, \
|
||||
_( L"function %s called with null value for argument %s. " ), \
|
||||
__func__, \
|
||||
#arg, \
|
||||
PACKAGE_BUGREPORT ); \
|
||||
#arg ); \
|
||||
bugreport(); \
|
||||
show_stackframe(); \
|
||||
return retval; \
|
||||
} \
|
||||
}
|
||||
|
||||
/**
|
||||
Pause for input, then exit the program. If supported, print a backtrace first.
|
||||
*/
|
||||
#define FATAL_EXIT() \
|
||||
{ \
|
||||
int exit_read_count;char exit_read_buff; \
|
||||
show_stackframe(); \
|
||||
exit_read_count=read( 0, &exit_read_buff, 1 ); \
|
||||
exit( 1 ); \
|
||||
} \
|
||||
|
||||
|
||||
/**
|
||||
Exit program at once, leaving an error message about running out of memory
|
||||
Exit program at once, leaving an error message about running out of memory.
|
||||
*/
|
||||
#define DIE_MEM() \
|
||||
#define DIE_MEM() \
|
||||
{ \
|
||||
fwprintf( stderr, L"fish: Out of memory on line %d of file %s, shutting down fish\n", __LINE__, __FILE__ ); \
|
||||
exit(1); \
|
||||
} \
|
||||
fwprintf( stderr, \
|
||||
L"fish: Out of memory on line %d of file %s, shutting down fish\n", \
|
||||
__LINE__, \
|
||||
__FILE__ ); \
|
||||
FATAL_EXIT(); \
|
||||
}
|
||||
|
||||
/**
|
||||
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. " ), \
|
||||
__func__); \
|
||||
bugreport(); \
|
||||
show_stackframe(); \
|
||||
return retval; \
|
||||
}
|
||||
|
||||
/**
|
||||
Shorthand for wgettext call
|
||||
@@ -102,16 +151,29 @@ extern wchar_t *program_name;
|
||||
#define _(wstr) wgettext(wstr)
|
||||
|
||||
/**
|
||||
Noop, used to tell xgettext that a string should be translated, even though it is not directly sent to wgettext.
|
||||
Noop, used to tell xgettext that a string should be translated,
|
||||
even though it is not directly sent to wgettext.
|
||||
*/
|
||||
#define N_(wstr) wstr
|
||||
|
||||
/**
|
||||
Check if the specified stringelement is a part of the specified string list
|
||||
*/
|
||||
#define contains( str,... ) contains_internal( str, __VA_ARGS__, (void *)0 )
|
||||
/**
|
||||
Concatenate all the specified strings into a single newly allocated one
|
||||
*/
|
||||
#define wcsdupcat( str,... ) wcsdupcat_internal( str, __VA_ARGS__, (void *)0 )
|
||||
|
||||
/**
|
||||
Print a stack trace to stderr
|
||||
*/
|
||||
void show_stackframe();
|
||||
|
||||
/**
|
||||
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().
|
||||
malloc, and needs to be fred's by the caller.
|
||||
*/
|
||||
wchar_t **list_to_char_arr( array_list_t *l );
|
||||
|
||||
@@ -183,17 +245,12 @@ char **wcsv2strv( const wchar_t **in );
|
||||
*/
|
||||
wchar_t **strv2wcsv( const char **in );
|
||||
|
||||
/**
|
||||
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.
|
||||
*/
|
||||
wchar_t *wcsdupcat2( const wchar_t *a, ... );
|
||||
__sentinel wchar_t *wcsdupcat_internal( const wchar_t *a, ... );
|
||||
|
||||
/**
|
||||
Test if the given string is a valid variable name
|
||||
@@ -206,7 +263,16 @@ wchar_t *wcsdupcat2( const wchar_t *a, ... );
|
||||
\return null if this is a valid name, and a pointer to the first invalid character otherwise
|
||||
*/
|
||||
|
||||
wchar_t *wcsvarname( wchar_t *str );
|
||||
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
|
||||
@@ -254,21 +320,32 @@ const wchar_t *wsetlocale( int category, const wchar_t *locale );
|
||||
|
||||
\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
|
||||
\return zero if needle is not found, of if needle is null, non-zero otherwise
|
||||
*/
|
||||
int contains_str( const wchar_t *needle, ... );
|
||||
__sentinel int contains_internal( const wchar_t *needle, ... );
|
||||
|
||||
/**
|
||||
Call read while blocking the SIGCHLD signal. Should only be called
|
||||
if you _know_ there is data available for reading.
|
||||
if you _know_ there is data available for reading, or the program
|
||||
will hang until there is data.
|
||||
*/
|
||||
int read_blocked(int fd, void *buf, size_t count);
|
||||
|
||||
/**
|
||||
Loop a write request while failiure is non-critical. Return -1 and set errno
|
||||
in case of critical error.
|
||||
*/
|
||||
ssize_t write_loop(int fd, char *buff, size_t count);
|
||||
|
||||
|
||||
/**
|
||||
Issue a debug message with printf-style string formating and
|
||||
automatic line breaking. The string will begin with the string \c
|
||||
program_name, followed by a colon and a whitespace.
|
||||
|
||||
Because debug is often called to tell the user about an error,
|
||||
before using wperror to give a specific error message, debug will
|
||||
never ever modify the value of errno.
|
||||
|
||||
\param level the priority of the message. Lower number means higher priority. Messages with a priority_number higher than \c debug_level will be ignored..
|
||||
\param msg the message format string.
|
||||
@@ -318,17 +395,17 @@ wchar_t *unescape( const wchar_t * in,
|
||||
int acquire_lock_file( const char *lockfile, const int timeout, int force );
|
||||
|
||||
/**
|
||||
Returns the width of the terminal window, so that not all
|
||||
functions that use these values continually have to keep track of
|
||||
it.
|
||||
Returns the width of the terminal window, so that not all
|
||||
functions that use these values continually have to keep track of
|
||||
it separately.
|
||||
|
||||
Only works if common_handle_winch is registered to handle winch signals.
|
||||
Only works if common_handle_winch is registered to handle winch signals.
|
||||
*/
|
||||
int common_get_width();
|
||||
/**
|
||||
Returns the height of the terminal window, so that not all
|
||||
functions that use these values continually have to keep track of
|
||||
it.
|
||||
it separatly.
|
||||
|
||||
Only works if common_handle_winch is registered to handle winch signals.
|
||||
*/
|
||||
@@ -357,6 +434,34 @@ void write_screen( const wchar_t *msg, string_buffer_t *buff );
|
||||
*/
|
||||
void tokenize_variable_array( const wchar_t *val, array_list_t *out );
|
||||
|
||||
/**
|
||||
Make sure the specified direcotry exists. If needed, try to create
|
||||
it and any currently not existing parent directories..
|
||||
|
||||
\return 0 if, at the time of function return the directory exists, -1 otherwise.
|
||||
*/
|
||||
int create_directory( wchar_t *d );
|
||||
|
||||
/**
|
||||
Print a short message about how to file a bug report to stderr
|
||||
*/
|
||||
void bugreport();
|
||||
|
||||
/**
|
||||
Format the specified size (in bytes, kilobytes, etc.) into the specified stringbuffer.
|
||||
*/
|
||||
void sb_format_size( string_buffer_t *sb,
|
||||
long long sz );
|
||||
|
||||
/**
|
||||
Return the number of seconds from the UNIX epoch, with subsecond
|
||||
precision. This function uses the gettimeofday function, and will
|
||||
have the same precision as that function.
|
||||
|
||||
If an error occurs, NAN is returned.
|
||||
*/
|
||||
double timef();
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
1731
complete.c
1731
complete.c
File diff suppressed because it is too large
Load Diff
124
complete.h
124
complete.h
@@ -67,15 +67,75 @@
|
||||
#define PROG_COMPLETE_SEP L'\t'
|
||||
|
||||
/**
|
||||
Terminator for completions sent to the fish_pager
|
||||
Do not insert space afterwards if this is the only completion. (The
|
||||
default is to try insert a space)
|
||||
*/
|
||||
#define COMPLETE_TERMINATOR L'\006'
|
||||
#define COMPLETE_NO_SPACE 1
|
||||
|
||||
/**
|
||||
This compeltion is case insensitive.
|
||||
|
||||
Warning: The contents of the completion_t structure is actually
|
||||
different if this flag is set! Specifically, the completion string
|
||||
contains the _entire_ completion token, not only the current
|
||||
*/
|
||||
#define COMPLETE_NO_CASE 2
|
||||
|
||||
/**
|
||||
This compeltion is the whole argument, not just the remainder. This
|
||||
flag must never be set on completions returned from the complete()
|
||||
function. It is strictly for internal use in the completion code.
|
||||
*/
|
||||
#define COMPLETE_WHOLE_ARGUMENT 4
|
||||
|
||||
/**
|
||||
This completion may or may not want a space at the end - guess by
|
||||
checking the last character of the completion.
|
||||
*/
|
||||
#define COMPLETE_AUTO_SPACE 8
|
||||
|
||||
/**
|
||||
This completion should be inserted as-is, without escaping.
|
||||
*/
|
||||
#define COMPLETE_DONT_ESCAPE 16
|
||||
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
||||
/**
|
||||
The completion string
|
||||
*/
|
||||
const wchar_t *completion;
|
||||
|
||||
/**
|
||||
The description for this completion
|
||||
*/
|
||||
const wchar_t *description;
|
||||
|
||||
/**
|
||||
Flags determining the completion behaviour.
|
||||
|
||||
Determines whether a space should be inserted after this
|
||||
compeltion if it is the only possible completion using the
|
||||
COMPLETE_NO_SPACE flag.
|
||||
|
||||
The COMPLETE_NO_CASE can be used to signal that this completion
|
||||
is case insensitive.
|
||||
*/
|
||||
int flags;
|
||||
|
||||
}
|
||||
completion_t;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Add a completion.
|
||||
|
||||
Values are copied and should be freed by the caller.
|
||||
All supplied values are copied, they should be freed by or otherwise
|
||||
disposed by the caller.
|
||||
|
||||
Examples:
|
||||
|
||||
@@ -109,28 +169,35 @@
|
||||
file completion is not performed.
|
||||
\param comp A space separated list of completions which may contain subshells.
|
||||
\param desc A description of the completion.
|
||||
\param authorative Whether there list of completions for this command is complete. If true, any options not matching one of the provided options will be flagged as an error by syntax highlighting.
|
||||
\param condition a command to be run to check it this completion should be used. If \c condition is empty, the completion is always used.
|
||||
|
||||
\param flags A set of completion flags
|
||||
*/
|
||||
void complete_add( const wchar_t *cmd,
|
||||
int cmd_type,
|
||||
wchar_t short_opt,
|
||||
const wchar_t *long_opt,
|
||||
int long_mode,
|
||||
int result_mode,
|
||||
int authorative,
|
||||
const wchar_t *condition,
|
||||
const wchar_t *comp,
|
||||
const wchar_t *desc );
|
||||
int cmd_type,
|
||||
wchar_t short_opt,
|
||||
const wchar_t *long_opt,
|
||||
int long_mode,
|
||||
int result_mode,
|
||||
const wchar_t *condition,
|
||||
const wchar_t *comp,
|
||||
const wchar_t *desc,
|
||||
int flags );
|
||||
/**
|
||||
Sets whether the completion list for this command is complete. If
|
||||
true, any options not matching one of the provided options will be
|
||||
flagged as an error by syntax highlighting.
|
||||
*/
|
||||
void complete_set_authoritative( const wchar_t *cmd,
|
||||
int cmd_type,
|
||||
int authoritative );
|
||||
|
||||
/**
|
||||
Remove a previously defined completion
|
||||
*/
|
||||
void complete_remove( const wchar_t *cmd,
|
||||
int cmd_type,
|
||||
wchar_t short_opt,
|
||||
const wchar_t *long_opt );
|
||||
int cmd_type,
|
||||
wchar_t short_opt,
|
||||
const wchar_t *long_opt );
|
||||
|
||||
/**
|
||||
Find all completions of the command cmd, insert them into out. The
|
||||
@@ -151,15 +218,6 @@ void complete( const wchar_t *cmd, array_list_t *out );
|
||||
*/
|
||||
void complete_print( string_buffer_t *out );
|
||||
|
||||
/**
|
||||
Obtain a description string for the file specified by the filename.
|
||||
|
||||
The returned value is a string constant and should not be freed.
|
||||
|
||||
\param filename The file for which to find a description string
|
||||
*/
|
||||
const wchar_t *complete_get_desc( const wchar_t *filename );
|
||||
|
||||
/**
|
||||
Tests if the specified option is defined for the specified command
|
||||
*/
|
||||
@@ -187,4 +245,18 @@ int complete_is_valid_argument( const wchar_t *str,
|
||||
*/
|
||||
void complete_load( const wchar_t *cmd, int reload );
|
||||
|
||||
/**
|
||||
Create a new completion entry
|
||||
|
||||
\param context The halloc context to use for allocating new memory
|
||||
\param comp The completion string
|
||||
\param desc The description of the completion
|
||||
\param flags completion flags
|
||||
*/
|
||||
void completion_allocate( array_list_t *context,
|
||||
const wchar_t *comp,
|
||||
const wchar_t *desc,
|
||||
int flags );
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
843
configure.ac
843
configure.ac
File diff suppressed because it is too large
Load Diff
24
count.c
24
count.c
@@ -1,24 +0,0 @@
|
||||
/** \file count.c
|
||||
The length command, used for determining the number of items in an
|
||||
environment variable array.
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/**
|
||||
The main function. Does nothing but return the number of arguments.
|
||||
|
||||
This command, unlike all other fish commands, does not feature a -h
|
||||
or --help option. This is because we want to avoid errors on arrays
|
||||
that have -h or --help as entries, which is very common when
|
||||
parsing options, etc. For this reason, the main fish binary does a
|
||||
check and prints help usage if -h or --help is explicitly given to
|
||||
the command, but not if it is the contents of a variable.
|
||||
*/
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
printf( "%d\n", argc-1 );
|
||||
return argc==1;
|
||||
}
|
||||
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
|
||||
18
doc_src/alias.txt
Normal file
18
doc_src/alias.txt
Normal file
@@ -0,0 +1,18 @@
|
||||
\section alias alias - create a function
|
||||
|
||||
\subsection alias-synopsis Synopsis
|
||||
<pre>alias NAME DEFINITION
|
||||
alias NAME=DEFINITION</pre>
|
||||
|
||||
\subsection alias-description Description
|
||||
|
||||
Alias is a shellscript wrapper around the function builtin.
|
||||
It exists for backwards compatibility with Posix
|
||||
shells. For other uses, it is recommended to define a <a
|
||||
href='#function'>function</a>.
|
||||
|
||||
Alias does not keep track of which functions have been defined using
|
||||
alias, nor does it allow erasing of aliases.
|
||||
|
||||
- NAME is the name of the function to define
|
||||
- DEFINITION is the body of the function. The string " $argv" will be appended to the body.
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
\section and and - Conditionally execute a command
|
||||
\section and and - conditionally execute a command
|
||||
|
||||
\subsection and-synopsis Synopsis
|
||||
<tt>COMMAND1; and COMMAND2</tt>
|
||||
@@ -7,14 +6,18 @@
|
||||
\subsection and-description Description
|
||||
|
||||
The \c and builtin is used to execute a command if the current exit
|
||||
status (as set by the last previous command) is zero
|
||||
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, if the
|
||||
build succceds, the program is installed. If either step fails,
|
||||
build succeeds, the program is installed. If either step fails,
|
||||
<tt>make clean</tt> is run, which removes the files created by the
|
||||
build process
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
|
||||
\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
|
||||
|
||||
@@ -24,11 +23,11 @@ scope, they will be automatically deleted when the block ends.
|
||||
|
||||
<pre>
|
||||
begin
|
||||
set -x PIRATE Yarrr
|
||||
set -l PIRATE Yarrr
|
||||
...
|
||||
end
|
||||
# This will not output anything, since PIRATE went out of scope at the end of
|
||||
# the block and was killed
|
||||
# This will not output anything, since the PIRATE variable went out
|
||||
# of scope at the end of the block
|
||||
echo $PIRATE
|
||||
</pre>
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ Sends the specified jobs to the background. A background job is
|
||||
executed simultaneously with fish, and does not have access to the
|
||||
keyboard. If no job is specified, the last job to be used is put in the background. If PID is specified, the jobs with the specified group ids are put in the background.
|
||||
|
||||
The PID of the desired process is usually found by using process globbing.
|
||||
The PID of the desired process is usually found by using <a href="index.html#expand-process">process expansion</a>.
|
||||
|
||||
\subsection bg-example Example
|
||||
|
||||
|
||||
@@ -1,16 +1,60 @@
|
||||
\section bind bind - Handle key bindings.
|
||||
\section bind bind - handle fish key bindings
|
||||
|
||||
\subsection bind-synopsis Synopsis
|
||||
<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.
|
||||
<tt>bind [OPTIONS] SEQUENCE COMMAND</tt>
|
||||
|
||||
\subsection bind-description Description
|
||||
- <tt>-M MODE</tt> or <tt>--set-mode=MODE</tt> sets the current input mode to MODE.
|
||||
|
||||
The <tt>bind</tt> builtin causes fish to add a key binding from the specified sequence.
|
||||
|
||||
SEQUENCE is the character sequence to bind to. Usually, one would use
|
||||
fish escape sequences to express them. For example, because pressing
|
||||
the Alt key and another character sends that character prefixed with
|
||||
an escape character, Alt-based key bindings can be written using the
|
||||
\c \\e escape. For example, Alt-w can be written as
|
||||
<tt>\\ew</tt>. Control character can be written in much the same way
|
||||
using the \c \\c escape, for example Control-x can be written as
|
||||
<tt>\\cx</tt>. Note that Alt-based key bindings are case sensitive and
|
||||
Control base key bindings are not. This is not a design choice in
|
||||
fish, it is simply how terminals work.
|
||||
|
||||
If SEQUENCE is the empty string, i.e. an empty set of quotes, this is
|
||||
interpreted as the default keybinding. It will be used whenever no
|
||||
other binding matches. For most key bindings, it makes sense to use
|
||||
the \c self-insert function (i.e. <tt>bind '' self-insert</tt> as the
|
||||
default keybining. This will insert any keystrokes not specifically
|
||||
bound to into the editor. Non-printable characters are ignored by the
|
||||
editor, so this will not result in e.g. control sequences being
|
||||
printable.
|
||||
|
||||
If the -k switch is used, the name of the key (such as down, up or
|
||||
backspace) is used instead of a sequence. The names used are the same
|
||||
as the corresponding curses variables, but without the 'key_'
|
||||
prefix. (See man 5 terminfo for more information, or use <tt>bind
|
||||
--key-names</tt> for a list of all available named keys)
|
||||
|
||||
COMMAND can be any fish command, but it can also be one of a set of
|
||||
special input functions. These include functions for moving the
|
||||
cursor, operating on the kill-ring, performing tab completion,
|
||||
etc. Use 'bind --function-names' for a complete list of these input
|
||||
functions.
|
||||
|
||||
When COMMAND is a shellscript command, it is a good practice to put
|
||||
the actual code into a <a href="#function">function</a> and simply
|
||||
bind to the function name. This way it becomes significantly easier to
|
||||
test the function while editing, and the result is usually more
|
||||
readable as well.
|
||||
|
||||
- <tt>-a</tt> or <tt>--all</tt> If --key-names is specified, show all key names, not only the ones that actually are defined for the current terminal. If erase mode is specified, this switch will cause all current bindings to be erased.
|
||||
- <tt>-e</tt> or <tt>--erase</tt> Erase mode. All non-switch arguments are interpreted as character sequences and any commands associated with those sequences are erased.
|
||||
- <tt>-h</tt> or <tt>--help</tt> Display help and exit
|
||||
- <tt>-k</tt> or <tt>--key</tt> Specify a key name, such as 'left' or 'backspace' instead of a character sequence
|
||||
- <tt>-K</tt> or <tt>--key-names</tt> Display a list of available key names
|
||||
- <tt>-f</tt> or <tt>--function-names</tt> Display a list of available input functions
|
||||
|
||||
\subsection bind-example Example
|
||||
|
||||
<tt>bind -M vi</tt> changes to the vi input mode
|
||||
<tt>bind \\cd 'exit'</tt> causes fish to exit on Control-d
|
||||
|
||||
<tt>bind -k ppage history-search-backward</tt> Causes fish to perform a history search when the page up key is pressed
|
||||
|
||||
<tt>bind '"\\M-j": jobs'</tt> Binds the jobs command to the Alt-j keyboard shortcut
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
\section block block - Temporarily block delivery of events
|
||||
\section block block - temporarily block delivery of events
|
||||
|
||||
\subsection block-synopsis Synopsis
|
||||
<tt>block [OPTIONS...]</tt>
|
||||
@@ -12,7 +11,8 @@
|
||||
|
||||
\subsection block-example Example
|
||||
|
||||
<pre>block -g
|
||||
<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
|
||||
@@ -9,13 +8,12 @@ The \c break builtin is used to halt a currently running loop, such as a <a href
|
||||
|
||||
\subsection break-example Example
|
||||
The following code searches all .c files for smurfs, and halts at the first occurrence.
|
||||
<p>
|
||||
<tt>for i in *.c;
|
||||
<br> if grep smurf $i;
|
||||
<br> echo Smurfs are present in $i;
|
||||
<br> break;
|
||||
<br> end;
|
||||
<br>end;
|
||||
</tt>
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
for i in *.c
|
||||
if grep smurf $i
|
||||
echo Smurfs are present in $i
|
||||
break
|
||||
end
|
||||
end
|
||||
</pre>
|
||||
|
||||
10
doc_src/breakpoint.txt
Normal file
10
doc_src/breakpoint.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
\section breakpoint breakpoint - Launch debug mode
|
||||
|
||||
\subsection breakpoint-synopsis Synopsis
|
||||
<tt>breakpoint</tt>
|
||||
|
||||
\subsection breakpoint-description Description
|
||||
|
||||
The \c breakpoint builtin is used to halt a running script and launch
|
||||
an interactive debug prompt.
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
\section builtin builtin - run a builtin command
|
||||
|
||||
\subsection builtin-synopsis Synopsis
|
||||
@@ -8,7 +7,7 @@
|
||||
|
||||
- <tt>-n</tt> or <tt>--names</tt> List the names of all defined builtins
|
||||
|
||||
Prefixing a command with the word 'builtin' forces fish to ignore any aliases with the same name.
|
||||
Prefixing a command with the word 'builtin' forces fish to ignore any functions with the same name.
|
||||
|
||||
\subsection builtin-example Example
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -19,7 +19,7 @@ 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.
|
||||
the case statements 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
|
||||
@@ -32,7 +32,6 @@ forms of parameter expansion have been performed for the case command.
|
||||
If the variable \$animal contains the name of an animal, the following
|
||||
code would attempt to classify it:
|
||||
|
||||
<p>
|
||||
<pre>
|
||||
switch $animal
|
||||
case cat
|
||||
@@ -47,7 +46,7 @@ switch $animal
|
||||
echo I have no idea what a $animal is
|
||||
end
|
||||
</pre>
|
||||
</p>
|
||||
<p>
|
||||
If the above code was run with \c \$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.
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
<tt>command COMMANDNAME [OPTIONS...]</tt>
|
||||
|
||||
\subsection command-description Description
|
||||
prefixing a command with the word 'command' forces fish to ignore any aliases or builtins with the same name.
|
||||
prefixing a command with the word 'command' forces fish to ignore any functions or builtins with the same name.
|
||||
|
||||
\subsection command-example Example
|
||||
|
||||
|
||||
<tt>command ls</tt>
|
||||
|
||||
causes fish to execute the ls program, even if there exists a 'ls' alias.
|
||||
causes fish to execute the ls program, even if there exists a 'ls' function.
|
||||
|
||||
@@ -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>
|
||||
@@ -7,10 +7,26 @@
|
||||
|
||||
|
||||
- \c CMD is the new value of the commandline. If unspecified, the
|
||||
current value of the commandline is written to standard output.
|
||||
current value of the commandline is written to standard output. All
|
||||
output from the commandline builtin is escaped, i.e. quotes are
|
||||
removed, backslash escapes are expanded, etc..
|
||||
|
||||
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 key presses 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 +41,15 @@ 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
|
||||
|
||||
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
|
||||
|
||||
6
doc_src/commands.hdr.in
Normal file
6
doc_src/commands.hdr.in
Normal file
@@ -0,0 +1,6 @@
|
||||
/** \page commands Commands, functions and builtins bundled with fish
|
||||
Fish ships with a large number of builtin commands, shellscript functions and external commands. These are all described below.
|
||||
|
||||
@command_list@
|
||||
|
||||
*/
|
||||
@@ -21,7 +21,8 @@ the fish manual.
|
||||
- <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
|
||||
- <tt>-u</tt> or <tt>--unauthoritative</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
|
||||
- <tt>-A</tt> or <tt>--authoritative</tt> implies that there may be no more options than the ones specified, and that fish should assume that options not listed are spelling errors
|
||||
- <tt>-x</tt> or <tt>--exclusive</tt> implies both <tt>-r</tt> and <tt>-f</tt>
|
||||
|
||||
Command specific tab-completions in \c fish are based on the notion
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
\section contains contains - Test if a word is present in a list
|
||||
\section contains contains - test if a word is present in a list
|
||||
|
||||
\subsection contains-synopsis Synopsis
|
||||
<code>contains [OPTIONS] KEY [VALUES...]</code>
|
||||
|
||||
@@ -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,22 +1,22 @@
|
||||
|
||||
\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> 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.
|
||||
The <tt>count</tt> builtin 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.
|
||||
|
||||
The count command does not accept any options, not even '-h'. This way
|
||||
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
|
||||
count command, 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 expansion, it will be passed on to the count program.
|
||||
is the result of expansion, it will simply be counted like any other
|
||||
argument.
|
||||
|
||||
Count exits with a non-zero exit status if no arguments where passed
|
||||
to it, with zero otherwise.
|
||||
|
||||
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>
|
||||
|
||||
2574
doc_src/doc.hdr
2574
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
|
||||
|
||||
|
||||
19
doc_src/emit.txt
Normal file
19
doc_src/emit.txt
Normal file
@@ -0,0 +1,19 @@
|
||||
\section emit emit - Emit a generic event
|
||||
|
||||
\subsection block-synopsis Synopsis
|
||||
<tt>emit EVENT_NAME</tt>
|
||||
|
||||
\subsection emit-description Description
|
||||
|
||||
The emit builtin fires a generic fish event. Such events can be caught by special functions called event handlers.
|
||||
|
||||
\subsection emit-example Example
|
||||
|
||||
The following code first defines an event handler for the generic
|
||||
event named 'test_event', and then emits an event of that type.
|
||||
|
||||
<pre>function event_test --on-event test_event
|
||||
echo event test!!!
|
||||
end
|
||||
|
||||
emit test_event</pre>
|
||||
@@ -1,11 +1,12 @@
|
||||
\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
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
\section eval eval - eval the specified commands
|
||||
\section eval eval - evaluate the specified commands
|
||||
|
||||
\subsection eval-synopsis Synopsis
|
||||
<tt>eval [COMMANDS...]</tt>
|
||||
|
||||
\subsection eval-description Description
|
||||
The <tt>eval</tt> builtin causes fish to evaluate the specified parameters as a command. If more than one parameter is specified, all parameters will be joined using a space character as a separator.
|
||||
The <tt>eval</tt> function causes fish to evaluate the specified parameters as a command. If more than one parameter is specified, all parameters will be joined using a space character as a separator.
|
||||
|
||||
\subsection eval-example Example
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
161
doc_src/faq.hdr
Normal file
161
doc_src/faq.hdr
Normal file
@@ -0,0 +1,161 @@
|
||||
/** \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>
|
||||
- <a href='#faq-history'>Why doesn't history substitution ("!$" etc.) work?</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 press
|
||||
<code>~</code> and enter.
|
||||
|
||||
<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.
|
||||
|
||||
<hr>
|
||||
|
||||
\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:
|
||||
|
||||
|
||||
<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/local/bin/fish</code>
|
||||
|
||||
You may need to adjust the above path to e.g. /usr/bin/fish. Use the command <code>which fish</code> if you are unsure of where fish is installed.
|
||||
|
||||
Unfortunatly, there is no way to make the changes take effect at once,
|
||||
you will need to log out and back in again.
|
||||
|
||||
<hr>
|
||||
|
||||
\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.
|
||||
|
||||
<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>
|
||||
|
||||
<hr>
|
||||
|
||||
\section faq-history Why doesn't history substitution ("!$" etc.) work?
|
||||
|
||||
Because history substitution is an awkward interface that was invented before
|
||||
interactive line editing was even possible. Fish drops it in favor of
|
||||
perfecting the interactive history recall interface. Switching requires a
|
||||
small change of habits: if you want to modify an old line/word, first recall
|
||||
it, then edit. E.g. don't type "sudo !!" - first press Up, then Home, then
|
||||
type "sudo ".
|
||||
|
||||
Fish history recall is very simple yet effective:
|
||||
|
||||
- As in any modern shell, the Up arrow recalls whole lines, starting from the last line executed. A single press replaces "!!", later presses replace "!-3" and the like.
|
||||
- If the line you want is far back in the history, type any part of the line and then press Up one or more times. This will constrain the recall to lines that include this text, and you will get to the line you want much faster. This replaces "!vi", "!?bar.c" and the like.
|
||||
- Alt+Up recalls individual arguments, starting from the last argument in the last line executed. A single press replaces "!$", later presses replace "!!:4" and the like.
|
||||
- If the argument you want is far back in history (e.g. 2 lines back - that's a lot of words!), type any part of it and then press Alt+Up. This will show only arguments containing that part and you will get what you want much faster. Try it out, this is very convenient!
|
||||
- If you want to reuse several arguments from the same line ("!!:3*" and the like), consider recalling the whole line and removing what you don't need (Alt+D and Alt+Backspace are your friends).
|
||||
|
||||
See <a href='index.html#editor'>documentation</a> for more details about line editing in fish.
|
||||
|
||||
*/
|
||||
@@ -7,7 +7,7 @@
|
||||
Sends the specified job to the foreground. While a foreground job is
|
||||
executed, fish is suspended. If no job is specified, the last job to be used is put in the foreground. If PID is specified, the job with the specified group id is put in the foreground.
|
||||
|
||||
The PID of the desired process is usually found by using process globbing.
|
||||
The PID of the desired process is usually found by using <a href="index.html#expand-process">process expansion</a>.
|
||||
|
||||
\subsection fg-example Example
|
||||
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
.TH fish 1 "February 25, 2005" "version @PACKAGE_VERSION@" "USER COMMANDS"
|
||||
.SH NAME
|
||||
fish - friendly interactive shell
|
||||
.SH SYNOPSIS
|
||||
.B fish
|
||||
[\-h] [\-v] [\-c command] [FILE [ARGUMENTS...]]
|
||||
.SH DESCRIPTION
|
||||
A shell written mainly with interactive use in mind. The complete fish manuals are written in HTML format. You can find them by using the
|
||||
.I
|
||||
help
|
||||
command from inside the fish shell.
|
||||
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\-h
|
||||
display help and exit
|
||||
.TP
|
||||
\-c
|
||||
Evaluate the specified commands instead of reading from the commandline
|
||||
.TP
|
||||
\-i
|
||||
Specify that fish is to run in interactive mode
|
||||
.TP
|
||||
\-v
|
||||
display version and exit
|
||||
.SH AUTHOR
|
||||
Axel Liljencrantz ( @PACKAGE_BUGREPORT@ )
|
||||
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.
|
||||
17
doc_src/fish_indent.txt
Normal file
17
doc_src/fish_indent.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
\section fish_indent fish_indent - indenter and prettyfier
|
||||
|
||||
\subsection fish_indent-synopsis Synopsis
|
||||
<tt>fish_indent [options]</tt>
|
||||
|
||||
\subsection fish_indent-description Description
|
||||
|
||||
\c fish_indent is used to indent or otherwise prettify a piece of fish
|
||||
code. \c fish_indent reads commands from standard input and outputs
|
||||
them to standard output.
|
||||
|
||||
\c fish_indent understands the following options:
|
||||
|
||||
- <tt>-h</tt> or <tt>--help</tt> displays this help message and then exits
|
||||
- <tt>-i</tt> or <tt>--no-indent</tt> do not indent commands
|
||||
- <tt>-v</tt> or <tt>--version</tt> displays the current fish version and then exits
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
\section fish_pager fish_pager - Internal command used by fish
|
||||
\section fish_pager fish_pager - internal command used by fish
|
||||
|
||||
\subsection fish_pager-description Description
|
||||
|
||||
|
||||
23
doc_src/fish_prompt.txt
Normal file
23
doc_src/fish_prompt.txt
Normal file
@@ -0,0 +1,23 @@
|
||||
\section fish_prompt fish_prompt - define the apperance of the command line prompt
|
||||
|
||||
\subsection fish_promt-synopsis Synopsis
|
||||
<pre>function fish_prompt
|
||||
...
|
||||
end</pre>
|
||||
|
||||
\subsection fish_prompt-description Description
|
||||
|
||||
By defining the \c fish_prompt function, the user can choose a custom
|
||||
prompt. The \c fish_prompt function is executed when the prompt is to
|
||||
be shown, and the output is used as a prompt.
|
||||
|
||||
\subsection fish_prompt-example Example
|
||||
|
||||
A simple prompt:
|
||||
|
||||
<pre>
|
||||
function fish_prompt -d "Write out the prompt"
|
||||
printf '\%s\@\%s\%s\%s\%s> ' (whoami) (hostname|cut -d . -f 1) (set_color \$fish_color_cwd) (prompt_pwd) (set_color normal)
|
||||
end
|
||||
</pre>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
\section fishd fishd - Universal variable daemon
|
||||
\section fishd fishd - universal variable daemon
|
||||
|
||||
\subsection fishd-synopsis Synopsis
|
||||
<tt>fishd [(-h|--help|-v|--version)]</tt>
|
||||
@@ -18,13 +17,14 @@ When no clients are connected, fishd will automatically shut down.
|
||||
|
||||
\subsection fishd-files Files
|
||||
|
||||
~/.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. 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 ~/.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!
|
||||
|
||||
/tmp/fishd.socket.USERNAME the socket which fishd uses to communicate
|
||||
\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>
|
||||
|
||||
|
||||
9
doc_src/funced.txt
Normal file
9
doc_src/funced.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
\section funced funced - edit a function interactively
|
||||
|
||||
\subsection funced-synopsis Synopsis
|
||||
<code>funced NAME</code>
|
||||
|
||||
\subsection funced-description Description
|
||||
|
||||
Use the funced command to interactively edit the definition of a
|
||||
function. If there is no function with the name specified, a skeleton function is inserted, if a function exist, the definion will be shown on the command line.
|
||||
12
doc_src/funcsave.txt
Normal file
12
doc_src/funcsave.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
\section funcsave funcsave - save the definition of a function to the users autoload directory
|
||||
|
||||
\subsection funcsave-synopsis Synopsis
|
||||
<tt>funcsave FUNCTION_NAME</tt>
|
||||
|
||||
\subsection funcsave-description Description
|
||||
|
||||
funcsave is used to save the current definition of a function to
|
||||
a file which will be autoloaded by current and future fish
|
||||
sessions. This can be useful if you have interactively created a new
|
||||
function and wish to save it for later use.
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
\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.
|
||||
- <code>-d DESCRIPTION</code> or \c --description=DESCRIPTION is a description of what the function does, suitable as a completion description
|
||||
- <code>-e</code> or <code>--on-event EVENT_NAME</code> tells fish to run this function when the specified named event is emitted. Fish internally generates named events e.g. when showing the prompt.
|
||||
- <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)
|
||||
@@ -27,9 +27,15 @@ 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 <a href="index.html#variables-arrays">variable array</a> argv.
|
||||
|
||||
By using one of the event handler switches, a function can be made to run automatically at specific events. The user may generate new events using the <a href='#emit">emit</a> builtin. Fish generates the following named events:
|
||||
|
||||
- \c fish_prompt, which is emitted whenever a new fish prompt is about to be displayed
|
||||
- \c fish_command_not_found, which is emitted whenever a command lookup failed
|
||||
|
||||
\subsection function-example Example
|
||||
|
||||
<pre>function ll
|
||||
<pre>
|
||||
function ll
|
||||
ls -l $argv
|
||||
end
|
||||
</pre>
|
||||
|
||||
@@ -11,7 +11,7 @@ This builtin command is used to print or erase functions.
|
||||
- <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
|
||||
- <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.
|
||||
|
||||
The default behavior of \c functions when called with no arguments,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
\section help help - Display fish documentation
|
||||
\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 multiple commands as the condition
|
||||
of an if block, use <a href="#begin"><tt>begin; ...; end</tt></a> and
|
||||
the short circuit 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
|
||||
|
||||
|
||||
1440
doc_src/index.hdr.in
Normal file
1440
doc_src/index.hdr.in
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 specified 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.
|
||||
|
||||
|
||||
984
doc_src/license.hdr
Normal file
984
doc_src/license.hdr
Normal file
@@ -0,0 +1,984 @@
|
||||
/** \page license Licenses
|
||||
|
||||
<h2>License for fish</h2>
|
||||
|
||||
Fish Copyright (C) 2005-2009 Axel Liljencrantz. Fish is released under
|
||||
the GNU General Public License, version 2. The license agreement is
|
||||
included below.
|
||||
|
||||
|
||||
<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>License for xdgmime and glibc</h2>
|
||||
|
||||
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, version 2 or later, or under the Academic Free License,
|
||||
version 2. Version 2 of the LGPL license agreement is included below.
|
||||
|
||||
Fish contains code from the glibc library, namely the wcstok
|
||||
function. This code is licensed under the LGPL, version 2 or
|
||||
later. Version 2 of the LPGL license agreement is included below.
|
||||
|
||||
|
||||
<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>
|
||||
|
||||
|
||||
|
||||
*/
|
||||
20
doc_src/math.txt
Normal file
20
doc_src/math.txt
Normal file
@@ -0,0 +1,20 @@
|
||||
|
||||
\section math math - Perform mathematics calculations
|
||||
|
||||
\subsection math-synopsis Synopsis
|
||||
<tt>math EXPRESSION</tt>
|
||||
|
||||
\subsection math-description Description
|
||||
|
||||
math is used to perform mathematical calculations. It is only a very
|
||||
thin wrapper for the bc program, that makes it possible to specify an
|
||||
expression from the command line without using non-standard extensions
|
||||
or a pipeline. Simply use a command like <code>math 1+1</code>.
|
||||
|
||||
For a description of the syntax supported by math, see the manual for
|
||||
the bc program. Keep in mind that parameter expansion takes place on
|
||||
any expressions before they are evaluated. This can be very useful in
|
||||
order to perform calculations involving environment variables or the
|
||||
output of command substitutions, but it also means that parenthesis
|
||||
have to be escaped.
|
||||
|
||||
@@ -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>
|
||||
@@ -19,7 +18,7 @@
|
||||
|
||||
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
|
||||
a file. The information that mimedb can retrieve 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,10 +1,10 @@
|
||||
\section nextd nextd
|
||||
\section nextd nextd - move forward through directory history
|
||||
|
||||
\subsection nextd-synopsis Synopsis
|
||||
<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
|
||||
<code>-l></code> or <code>--list</code> flag is specified, the current
|
||||
\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,13 +1,12 @@
|
||||
|
||||
\section open open - Open file in it's default application
|
||||
\section open open - open file in its default application
|
||||
|
||||
\subsection open-synopsis Synopsis
|
||||
<tt>open FILES...</tt>
|
||||
|
||||
\subsection open-description Description
|
||||
|
||||
The \c open command is used to open a file in it's default application. \c open is implemented using the <a href="commands.html#mimedb">mimedb</a> command.
|
||||
The \c open command is used to open a file in its default application. \c open is implemented using the \c xdg-open command if it exists, or else the <a href="commands.html#mimedb">mimedb</a> command.
|
||||
|
||||
\subsection open-example Example
|
||||
|
||||
<tt>open *.txt</tt> opens all the text files in the current directory using your systems default text editor.
|
||||
<tt>open *.txt</tt> opens all the text files in the current directory using your system's default text editor.
|
||||
|
||||
@@ -1,19 +1,23 @@
|
||||
|
||||
\section or or - Conditionally execute a command
|
||||
\section or or - conditionally execute a command
|
||||
|
||||
\subsection or-synopsis Synopsis
|
||||
<tt>COMMAND1; or COMMAND2</tt>
|
||||
|
||||
\subsection or-description Description
|
||||
|
||||
The \c or builtin is used to execute a command if the current exit status (as set by the last previous command) is non-zero
|
||||
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, if the
|
||||
build succceds, the program is installed. If either step fails,
|
||||
build succeeds, the program is installed. If either step fails,
|
||||
<tt>make clean</tt> is run, which removes the files created by the
|
||||
build process
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
\section popd popd
|
||||
\section popd popd - move through directory stack
|
||||
|
||||
\subsection popd-synopsis Synopsis
|
||||
<tt>popd</tt>
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
\section prevd prevd
|
||||
\section prevd prevd - move backward through directory history
|
||||
|
||||
\subsection prevd-synopsis Synopsis
|
||||
<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 <code>-l</code> or <code>--list</code> flag is
|
||||
specified, the current history is also displayed.
|
||||
\subsection prevd-description Description
|
||||
|
||||
<tt>prevd</tt> moves backwards <tt>pos</tt> positions in the history
|
||||
of visited directories; if the beginning of the history has been hit,
|
||||
a warning is printed. If the <code>-l</code> or <code>--list</code>
|
||||
flag is specified, the current history is also displayed.
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
|
||||
\section psub psub - Perform process substitution
|
||||
\section psub psub - perform process substitution
|
||||
|
||||
\subsection psub-synopsis Synopsis
|
||||
<tt>COMMAND1 (COMMAND2|psub) </tt>
|
||||
<tt>COMMAND1 (COMMAND2|psub [-f]) </tt>
|
||||
|
||||
\subsection psub-description Description
|
||||
|
||||
@@ -15,6 +14,12 @@ filename of the named pipe sent as an argument to the calling
|
||||
program. The psub shellscript function, which when combined with a
|
||||
regular command substitution provides the same functionality.
|
||||
|
||||
If the \c -f or \c --file switch is given to psub, psub will use a
|
||||
regular file instead of a named pipe to communicate with the calling
|
||||
process. This will cause psub to be significantly slower when large
|
||||
amounts of data are involved, but has the advantage that the reading
|
||||
process can seek in the stream.
|
||||
|
||||
\subsection psub-example Example
|
||||
|
||||
<tt>diff (sort a.txt|psub) (sort b.txt|psub)</tt> shows the difference
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -11,7 +11,9 @@ 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>-m NAME</tt> or <tt>--mode-name=NAME</tt> specifies that the name NAME should be used to save/load the history file. If NAME is fish, the regular fish history will be available.
|
||||
- <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>-s</code> or <code>--shell</code> Use syntax highlighting, tab completions and command termination suitable for entering shellscript code
|
||||
- <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
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
|
||||
\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...] return [STATUS]; [COMMANDS...] end</tt>
|
||||
<tt>function NAME; [COMMANDS...;] return [STATUS]; [COMMANDS...;] end</tt>
|
||||
|
||||
\subsection return-description Description
|
||||
|
||||
@@ -17,9 +16,11 @@ function.
|
||||
|
||||
\subsection return-example Example
|
||||
The following code is an implementation of the false command as a fish function
|
||||
<p>
|
||||
<pre>function false
|
||||
return 1
|
||||
end</pre>
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
function false
|
||||
return 1
|
||||
end
|
||||
</pre>
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
\section set set - Handle environment variables.
|
||||
\section set set - handle environment variables.
|
||||
|
||||
\subsection set-synopsis Synopsis
|
||||
<pre>set [SCOPE_OPTIONS]
|
||||
<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>
|
||||
set (-e | --erase) [SCOPE_OPTIONS] VARIABLE_NAME[INDICES]...
|
||||
</pre>
|
||||
|
||||
The <code>set</code> builtin causes fish to assign the variable <code>VARIABLE_NAME</code> the values <code>VALUES...</code>.
|
||||
|
||||
@@ -15,7 +17,7 @@ The <code>set</code> builtin causes fish to assign the variable <code>VARIABLE_N
|
||||
- <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
|
||||
- <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
|
||||
@@ -41,7 +43,7 @@ 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, but has been previously defined, the previous 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
|
||||
@@ -49,7 +51,7 @@ 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.
|
||||
-# If a variable is not explicitly set to be either exported or unexported and has never before been defined, the variable will not be exported.
|
||||
|
||||
In query mode, the scope to be examined can be specified.
|
||||
|
||||
|
||||
@@ -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>
|
||||
@@ -27,5 +26,11 @@ 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.
|
||||
bug in set_color but a missing feature in the terminal emulator.
|
||||
|
||||
set_color uses the terminfo database to look up how to change terminal
|
||||
colors on whatever terminal is in use. Some systems have old and
|
||||
incomplete terminfo databases, and may lack color information for
|
||||
terminals that support it. Download and install the latest version of
|
||||
ncurses and recompile fish against it in order to fix this issue.
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
\section source . - Evaluate contents of file.
|
||||
\section source . - evaluate contents of file.
|
||||
|
||||
\subsection source-synopsis Synopsis
|
||||
<tt>. FILENAME</tt>
|
||||
<tt>. FILENAME [ARGUMENTS...]</tt>
|
||||
|
||||
\subsection source-description Description
|
||||
|
||||
@@ -9,7 +9,16 @@ Evaluates the commands of the specified file in the current
|
||||
shell. This is different from starting a new process to perform the
|
||||
commands (i.e. <tt>fish < FILENAME</tt>) since the commands will be
|
||||
evaluated by the current shell, which means that changes in
|
||||
environment variables, etc., will remain.
|
||||
environment variables, etc., will remain. If additional arguments are
|
||||
specified after the file name, they will be inserted into the $argv
|
||||
variable.
|
||||
|
||||
If no file is specified, or if the file name '-' is used, stdin will
|
||||
be read.
|
||||
|
||||
The return status of . is the return status of the last job to
|
||||
execute. If something goes wrong while opening or reading the file,
|
||||
. exits with a non-zero status.
|
||||
|
||||
\subsection source-example Example
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
\section status status - Display fish runtime information
|
||||
\section status status - query fish runtime information
|
||||
|
||||
\subsection status-synopsis Synopsis
|
||||
<tt>status [OPTION]</tt>
|
||||
@@ -9,3 +8,11 @@
|
||||
- <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>--is-full-job-control</tt> returns 0 if full job control is enabled
|
||||
- <tt>--is-interactive-job-control</tt> returns 0 if interactive job control is enabled
|
||||
- <tt>--is-no-job-control</tt> returns 0 if no job control is enabled
|
||||
- <tt>-f</tt> or <tt>--current-filename</tt> prints the filename of the currently running script
|
||||
- <tt>-n</tt> or <tt>--current-line-number</tt> prints the line number of the currently running script
|
||||
- <tt>-j CONTROLTYPE</tt> or <tt>--job-control=CONTROLTYPE</tt> set the job control type. Can be one of: none, full, interactive
|
||||
- <tt>-t</tt> or <tt>--print-stack-trace</tt> prints a stack trace of all function calls on the call stack
|
||||
- <tt>-h</tt> or <tt>--help</tt> display a help message and exit
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
|
||||
\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
|
||||
|
||||
@@ -20,14 +19,19 @@ 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.
|
||||
the case statements 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 contains 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
|
||||
@@ -42,10 +46,7 @@ switch $animal
|
||||
echo I have no idea what a $animal is
|
||||
end
|
||||
</pre>
|
||||
</p>
|
||||
<p>
|
||||
|
||||
If the above code was run with \c \$animal set to \c whale, the output
|
||||
would be \c mammal.
|
||||
|
||||
</p>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
\section trap trap - perform an action when the shell receives a signal
|
||||
|
||||
\subsection trap-synopsis Synopsis
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
\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>
|
||||
|
||||
@@ -1,27 +1,17 @@
|
||||
|
||||
\section ulimit ulimit - Set or get the shells resource usage limits
|
||||
\section ulimit ulimit - set or get the shells resource usage limits
|
||||
|
||||
\subsection ulimit-synopsis Synopsis
|
||||
<tt>ulimit [OPTIONS] [LIMIT]</tt>
|
||||
|
||||
\subsection ulimit-description Description
|
||||
|
||||
The ulimit builtin provides control over the resources available to
|
||||
the shell and to processes started by it. The -H and -S options
|
||||
specify that the hard or soft limit is set for the given resource. A
|
||||
hard limit cannot be increased once it is set; a soft limit may be
|
||||
increased up to the value of the hard limit. If neither -H nor -S is
|
||||
specified, both the soft and hard limits are set. The value of limit
|
||||
can be a number in the unit specified for the resource or one of the
|
||||
special values hard, soft, or unlimited, which stand for the current
|
||||
hard limit, the current soft limit, and no limit, respectively. If
|
||||
limit is omitted, the current value of the soft limit of the resource
|
||||
is printed, unless the -H option is given. When more than one
|
||||
resource is specified, the limit name and unit are printed before the
|
||||
value. Other options are interpreted as follows:
|
||||
The ulimit builtin is used to set the resource usage limits of the
|
||||
shell and any processes spawned by it. If a new limit value is
|
||||
omitted, the current value of the limit of the resource is printed.
|
||||
|
||||
- <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
|
||||
Use one of the following switches to specify which resource limit to set or report:
|
||||
|
||||
- <code>-c</code> or <code>--core-size</code> The maximum size of core files created. By setting this limit to zero, core dumps can be disabled.
|
||||
- <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
|
||||
@@ -32,17 +22,42 @@ value. Other options are interpreted as follows:
|
||||
- <code>-u</code> or <code>--process-count</code> The maximum number of processes available to a single user
|
||||
- <code>-v</code> or <code>--virtual-memory-size</code> The maximum amount of virtual memory available to the shell. If supported by OS.
|
||||
|
||||
Note that not all these limits are available in all operating systems.
|
||||
|
||||
The value of limit can be a number in the unit specified for
|
||||
the resource or one of the special values hard, soft, or unlimited,
|
||||
which stand for the current hard limit, the current soft limit, and no
|
||||
limit, respectively.
|
||||
|
||||
If limit is given, it is the new value of the specified resource. If
|
||||
no option is given, then -f is assumed. Values are in kilobytes,
|
||||
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:
|
||||
ulimit also accepts the following switches that determine what type of
|
||||
limit to set:
|
||||
|
||||
- <code>-H</code> or <code>--hard</code> Set hard resource limit
|
||||
- <code>-S</code> or <code>--soft</code> Set soft resource limit
|
||||
|
||||
A hard limit can only be decreased, once it is set it can not be
|
||||
increased; a soft limit may be increased up to the value of the hard
|
||||
limit. If neither -H nor -S is specified, both the soft and hard
|
||||
limits are updated when assigning a new limit value, and the soft
|
||||
limit is used when reporting the current value.
|
||||
|
||||
The following additional options are also understood by ulimit:
|
||||
|
||||
- <code>-a</code> or <code>--all</code> Print all current limits
|
||||
- <code>-h</code> or <code>--help</code> Display help and exit
|
||||
|
||||
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.
|
||||
- Fish ulimit does not support getting the values of multiple limits in one command, except by using the -a switch
|
||||
- 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. Fish does not do this because it this method of determining pipe size is unreliable. Depending on bash version, there may also be further additional limits to set in bash that do not exist in fish.
|
||||
- Fish ulimit does not support getting or setting multiple limits in one command, except reporting all values using the -a switch
|
||||
|
||||
\subsection ulimit-example Example
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
\section umask umask - Set or get the shells resource usage limits
|
||||
\section umask umask - set or get the file-creation mask
|
||||
|
||||
\subsection umask-synopsis Synopsis
|
||||
<code>umask [OPTIONS] [MASK]</code>
|
||||
@@ -44,7 +43,7 @@ in bash.
|
||||
|
||||
\subsection umask-example Example
|
||||
|
||||
<code>umask 177</code> or <code>umask u=rw</code>sets the file
|
||||
<code>umask 177</code> or <code>umask u=rw</code> sets the file
|
||||
creation mask to read and write for the owner and no permissions at
|
||||
all for any other users.
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
328
env.c
328
env.c
@@ -1,7 +1,6 @@
|
||||
/** \file env.c
|
||||
Functions for setting and getting environment variables.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -53,13 +52,16 @@
|
||||
#include "env_universal.h"
|
||||
#include "input_common.h"
|
||||
#include "event.h"
|
||||
#include "path.h"
|
||||
#include "halloc.h"
|
||||
#include "halloc_util.h"
|
||||
|
||||
#include "complete.h"
|
||||
|
||||
/**
|
||||
Command used to start fishd
|
||||
*/
|
||||
#define FISHD_CMD L"if which fishd 2>/dev/null >/dev/null; fishd ^/tmp/fishd.log.%s; end"
|
||||
#define FISHD_CMD L"fishd ^/tmp/fishd.log.%s"
|
||||
|
||||
/**
|
||||
Value denoting a null string
|
||||
@@ -67,9 +69,13 @@
|
||||
#define ENV_NULL L"\x1d"
|
||||
|
||||
/**
|
||||
At init, we read all the environment variables from this array
|
||||
At init, we read all the environment variables from this array.
|
||||
*/
|
||||
extern char **environ;
|
||||
/**
|
||||
This should be the same thing as \c environ, but it is possible only one of the two work...
|
||||
*/
|
||||
extern char **__environ;
|
||||
|
||||
|
||||
/**
|
||||
@@ -108,6 +114,8 @@ typedef struct env_node
|
||||
typedef struct var_entry
|
||||
{
|
||||
int export; /**< Whether the variable should be exported */
|
||||
size_t size; /**< The maximum length (excluding the NULL) that will fit into this var_entry_t */
|
||||
|
||||
#if __STDC_VERSION__ < 199901L
|
||||
wchar_t val[1]; /**< The value of the variable */
|
||||
#else
|
||||
@@ -200,7 +208,9 @@ 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 );
|
||||
@@ -255,8 +265,12 @@ 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;
|
||||
}
|
||||
|
||||
@@ -301,8 +315,11 @@ static void handle_locale()
|
||||
for( i=2; locale_variable[i]; i++ )
|
||||
{
|
||||
const wchar_t *val = env_get( locale_variable[i] );
|
||||
|
||||
if( val )
|
||||
{
|
||||
wsetlocale( cat[i], val );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -316,8 +333,10 @@ static void handle_locale()
|
||||
strings should be reloaded. We do both and hope for the
|
||||
best.
|
||||
*/
|
||||
|
||||
extern int _nl_msg_cat_cntr;
|
||||
++_nl_msg_cat_cntr;
|
||||
_nl_msg_cat_cntr++;
|
||||
|
||||
dcgettext( "fish", "Changing language to English", LC_MESSAGES );
|
||||
|
||||
if( is_interactive )
|
||||
@@ -341,17 +360,24 @@ static void universal_callback( int type,
|
||||
wchar_t *str=0;
|
||||
|
||||
if( is_locale( name ) )
|
||||
{
|
||||
handle_locale();
|
||||
}
|
||||
|
||||
switch( type )
|
||||
{
|
||||
case SET:
|
||||
case SET_EXPORT:
|
||||
{
|
||||
str=L"SET";
|
||||
break;
|
||||
}
|
||||
|
||||
case ERASE:
|
||||
{
|
||||
str=L"ERASE";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( str )
|
||||
@@ -393,28 +419,31 @@ static void setup_path()
|
||||
;
|
||||
|
||||
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) )
|
||||
}
|
||||
|
||||
if( (wcslen( path_el[j] ) == len) &&
|
||||
(wcsncmp( el, path_el[j], len)==0) )
|
||||
{
|
||||
has_el = 1;
|
||||
}
|
||||
@@ -432,10 +461,9 @@ static void setup_path()
|
||||
sb_append( &b, path );
|
||||
}
|
||||
|
||||
sb_append2( &b,
|
||||
ARRAY_SEP_STR,
|
||||
path_el[j],
|
||||
(void *)0 );
|
||||
sb_append( &b,
|
||||
ARRAY_SEP_STR,
|
||||
path_el[j] );
|
||||
|
||||
env_set( L"PATH", (wchar_t *)b.buff, ENV_GLOBAL | ENV_EXPORT );
|
||||
|
||||
@@ -452,12 +480,54 @@ static void setup_path()
|
||||
al_destroy( &l );
|
||||
}
|
||||
|
||||
int env_set_pwd()
|
||||
{
|
||||
wchar_t dir_path[4096];
|
||||
wchar_t *res = wgetcwd( dir_path, 4096 );
|
||||
if( !res )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
env_set( L"PWD", dir_path, ENV_EXPORT | ENV_GLOBAL );
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
Set up default values for various variables if not defined.
|
||||
*/
|
||||
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 );
|
||||
}
|
||||
|
||||
env_set_pwd();
|
||||
|
||||
}
|
||||
|
||||
void env_init()
|
||||
{
|
||||
char **p;
|
||||
struct passwd *pw;
|
||||
wchar_t *uname;
|
||||
|
||||
wchar_t *version;
|
||||
|
||||
sb_init( &dyn_var );
|
||||
b_init( &export_buffer );
|
||||
|
||||
@@ -468,6 +538,7 @@ void env_init()
|
||||
|
||||
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"" );
|
||||
@@ -498,7 +569,7 @@ 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
|
||||
@@ -507,7 +578,7 @@ void env_init()
|
||||
/*
|
||||
Import environment variables
|
||||
*/
|
||||
for( p=environ; *p; p++ )
|
||||
for( p=environ?environ:__environ; p && *p; p++ )
|
||||
{
|
||||
wchar_t *key, *val;
|
||||
wchar_t *pos;
|
||||
@@ -515,13 +586,16 @@ void env_init()
|
||||
key = str2wcs(*p);
|
||||
|
||||
if( !key )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
val = wcschr( key, L'=' );
|
||||
|
||||
|
||||
if( val == 0 )
|
||||
{
|
||||
env_set( key, L"", ENV_EXPORT );
|
||||
}
|
||||
else
|
||||
{
|
||||
*val = L'\0';
|
||||
@@ -531,7 +605,9 @@ void env_init()
|
||||
while( *pos )
|
||||
{
|
||||
if( *pos == L':' )
|
||||
{
|
||||
*pos = ARRAY_SEP;
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
|
||||
@@ -539,7 +615,7 @@ void env_init()
|
||||
}
|
||||
free(key);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Set up the PATH variable
|
||||
*/
|
||||
@@ -555,12 +631,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_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()
|
||||
@@ -572,8 +659,10 @@ void env_destroy()
|
||||
b_destroy( &export_buffer );
|
||||
|
||||
while( &top->env != global )
|
||||
{
|
||||
env_pop();
|
||||
|
||||
}
|
||||
|
||||
hash_destroy( &env_read_only );
|
||||
|
||||
hash_destroy( &env_electric );
|
||||
@@ -587,8 +676,8 @@ void env_destroy()
|
||||
}
|
||||
|
||||
/**
|
||||
Find the scope hashtable containing the variable with the specified
|
||||
key
|
||||
Search all visible scopes in order for the specified key. Return
|
||||
the first scope in which it was found.
|
||||
*/
|
||||
static env_node_t *env_get_node( const wchar_t *key )
|
||||
{
|
||||
@@ -606,9 +695,13 @@ static env_node_t *env_get_node( const wchar_t *key )
|
||||
}
|
||||
|
||||
if( env->new_scope )
|
||||
{
|
||||
env = global_env;
|
||||
}
|
||||
else
|
||||
{
|
||||
env = env->next;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -628,9 +721,22 @@ int env_set( const wchar_t *key,
|
||||
|
||||
event_t ev;
|
||||
int is_universal = 0;
|
||||
|
||||
|
||||
CHECK( key, ENV_INVALID );
|
||||
|
||||
if( val && contains( key, L"PWD", L"HOME" ) )
|
||||
{
|
||||
void *context = halloc( 0, 0 );
|
||||
const wchar_t *val_canonical = path_make_canonical( context, val );
|
||||
if( wcscmp( val_canonical, val ) )
|
||||
{
|
||||
int res = env_set( key, val_canonical, var_mode );
|
||||
halloc_free( context );
|
||||
return res;
|
||||
}
|
||||
halloc_free( context );
|
||||
}
|
||||
|
||||
if( (var_mode & ENV_USER ) &&
|
||||
hash_get( &env_read_only, key ) )
|
||||
{
|
||||
@@ -656,13 +762,15 @@ int env_set( const wchar_t *key,
|
||||
}
|
||||
}
|
||||
/*
|
||||
Do not actually create a umask variable, on env_get, it will be calculated dynamically
|
||||
Do not actually create a umask variable, on env_get, it will
|
||||
be calculated dynamically
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
Zero element arrays are internaly not coded as null but as this placeholder string
|
||||
Zero element arrays are internaly not coded as null but as this
|
||||
placeholder string
|
||||
*/
|
||||
if( !val )
|
||||
{
|
||||
@@ -679,23 +787,17 @@ int env_set( const wchar_t *key,
|
||||
env_universal_get_export( key );
|
||||
}
|
||||
else
|
||||
{
|
||||
export = (var_mode & ENV_EXPORT );
|
||||
}
|
||||
|
||||
env_universal_set( key, val, export );
|
||||
is_universal = 1;
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if( val == 0 )
|
||||
{
|
||||
wchar_t *prev_val;
|
||||
free_val = 1;
|
||||
prev_val = env_get( key );
|
||||
val = wcsdup( prev_val?prev_val:L"" );
|
||||
}
|
||||
|
||||
node = env_get_node( key );
|
||||
if( node && &node->env != 0 )
|
||||
{
|
||||
@@ -703,8 +805,9 @@ int env_set( const wchar_t *key,
|
||||
key );
|
||||
|
||||
if( e->export )
|
||||
{
|
||||
has_changed_new = 1;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if( (var_mode & ENV_LOCAL) ||
|
||||
@@ -740,8 +843,10 @@ int env_set( const wchar_t *key,
|
||||
env_universal_get_export( key );
|
||||
}
|
||||
else
|
||||
{
|
||||
export = (var_mode & ENV_EXPORT );
|
||||
|
||||
}
|
||||
|
||||
env_universal_set( key, val, export );
|
||||
is_universal = 1;
|
||||
|
||||
@@ -752,12 +857,15 @@ int env_set( const wchar_t *key,
|
||||
{
|
||||
/*
|
||||
New variable with unspecified scope. The default
|
||||
scope is the innermost scope that is shadowing
|
||||
scope is the innermost scope that is shadowing,
|
||||
which will be either the current function or the
|
||||
global scope.
|
||||
*/
|
||||
node = top;
|
||||
while( node->next && !node->new_scope )
|
||||
{
|
||||
node = node->next;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -765,24 +873,59 @@ int env_set( const wchar_t *key,
|
||||
if( !done )
|
||||
{
|
||||
void *k, *v;
|
||||
hash_remove( &node->env, key, &k, &v );
|
||||
free( k );
|
||||
free( v );
|
||||
var_entry_t *old_entry;
|
||||
size_t val_len = wcslen(val);
|
||||
|
||||
entry = malloc( sizeof( var_entry_t ) +
|
||||
sizeof(wchar_t )*(wcslen(val)+1));
|
||||
|
||||
if( var_mode & ENV_EXPORT)
|
||||
hash_remove( &node->env, key, &k, &v );
|
||||
|
||||
/*
|
||||
Try to reuse previous key string
|
||||
*/
|
||||
if( !k )
|
||||
{
|
||||
entry->export = 1;
|
||||
has_changed_new = 1;
|
||||
k = wcsdup(key);
|
||||
}
|
||||
|
||||
old_entry = (var_entry_t *)v;
|
||||
if( old_entry && old_entry->size >= val_len )
|
||||
{
|
||||
entry = old_entry;
|
||||
|
||||
if( !!(var_mode & ENV_EXPORT) || entry->export )
|
||||
{
|
||||
entry->export = !!(var_mode & ENV_EXPORT);
|
||||
has_changed_new = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
entry->export = 0;
|
||||
{
|
||||
free( v );
|
||||
|
||||
entry = malloc( sizeof( var_entry_t ) +
|
||||
sizeof(wchar_t )*(val_len+1));
|
||||
|
||||
if( !entry )
|
||||
{
|
||||
DIE_MEM();
|
||||
}
|
||||
|
||||
entry->size = val_len;
|
||||
|
||||
if( var_mode & ENV_EXPORT)
|
||||
{
|
||||
entry->export = 1;
|
||||
has_changed_new = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
entry->export = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
wcscpy( entry->val, val );
|
||||
|
||||
hash_put( &node->env, wcsdup(key), entry );
|
||||
|
||||
hash_put( &node->env, k, entry );
|
||||
|
||||
if( entry->export )
|
||||
{
|
||||
@@ -790,8 +933,10 @@ int env_set( const wchar_t *key,
|
||||
}
|
||||
|
||||
if( free_val )
|
||||
{
|
||||
free((void *)val);
|
||||
|
||||
}
|
||||
|
||||
has_changed = has_changed_old || has_changed_new;
|
||||
}
|
||||
|
||||
@@ -837,8 +982,10 @@ static int try_remove( env_node_t *n,
|
||||
wchar_t *old_key, *old_val;
|
||||
|
||||
if( n == 0 )
|
||||
{
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
hash_remove( &n->env,
|
||||
key,
|
||||
&old_key_void,
|
||||
@@ -861,12 +1008,18 @@ static int try_remove( env_node_t *n,
|
||||
}
|
||||
|
||||
if( var_mode & ENV_LOCAL )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( n->new_scope )
|
||||
{
|
||||
return try_remove( global_env, key, var_mode );
|
||||
}
|
||||
else
|
||||
{
|
||||
return try_remove( n->next, key, var_mode );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -936,7 +1089,7 @@ wchar_t *env_get( const wchar_t *key )
|
||||
wchar_t *item;
|
||||
|
||||
CHECK( key, 0 );
|
||||
|
||||
|
||||
if( wcscmp( key, L"history" ) == 0 )
|
||||
{
|
||||
wchar_t *current;
|
||||
@@ -951,22 +1104,22 @@ 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 )
|
||||
{
|
||||
/*
|
||||
This is not an error - it simply means the user has
|
||||
a short history
|
||||
*/
|
||||
break;
|
||||
}
|
||||
|
||||
if( i!=0)
|
||||
{
|
||||
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 )
|
||||
@@ -1005,13 +1158,19 @@ wchar_t *env_get( const wchar_t *key )
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return res->val;
|
||||
}
|
||||
}
|
||||
|
||||
if( env->new_scope )
|
||||
{
|
||||
env = global_env;
|
||||
}
|
||||
else
|
||||
{
|
||||
env = env->next;
|
||||
}
|
||||
}
|
||||
if( !proc_had_barrier)
|
||||
{
|
||||
@@ -1026,7 +1185,9 @@ wchar_t *env_get( const wchar_t *key )
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
int env_exist( const wchar_t *key, int mode )
|
||||
@@ -1063,12 +1224,18 @@ int env_exist( const wchar_t *key, int mode )
|
||||
}
|
||||
|
||||
if( mode & ENV_LOCAL )
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if( env->new_scope )
|
||||
{
|
||||
env = global_env;
|
||||
}
|
||||
else
|
||||
{
|
||||
env = env->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1281,16 +1448,34 @@ void env_get_names( array_list_t *l, int flags )
|
||||
static void export_func1( void *k, void *v, void *aux )
|
||||
{
|
||||
var_entry_t *val_entry = (var_entry_t *)v;
|
||||
if( val_entry->export )
|
||||
{
|
||||
hash_table_t *h = (hash_table_t *)aux;
|
||||
|
||||
if( !hash_get( h, k ) )
|
||||
hash_put( h, k, val_entry->val );
|
||||
hash_table_t *h = (hash_table_t *)aux;
|
||||
|
||||
hash_remove( h, k, 0, 0 );
|
||||
|
||||
if( val_entry->export && wcscmp( val_entry->val, ENV_NULL ) )
|
||||
{
|
||||
hash_put( h, k, val_entry->val );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
Get list of all exported variables
|
||||
*/
|
||||
static void get_exported( env_node_t *n, hash_table_t *h )
|
||||
{
|
||||
if( !n )
|
||||
return;
|
||||
|
||||
if( n->new_scope )
|
||||
get_exported( global_env, h );
|
||||
else
|
||||
get_exported( n->next, h );
|
||||
|
||||
hash_foreach2( &n->env, &export_func1, h );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Function used by env_export_arr to iterate over hashtable of variables
|
||||
*/
|
||||
@@ -1343,7 +1528,6 @@ char **env_export_arr( int recalc )
|
||||
{
|
||||
array_list_t uni;
|
||||
hash_table_t vals;
|
||||
env_node_t *n=top;
|
||||
int prev_was_null=1;
|
||||
int pos=0;
|
||||
int i;
|
||||
@@ -1352,15 +1536,7 @@ char **env_export_arr( int recalc )
|
||||
|
||||
hash_init( &vals, &hash_wcs_func, &hash_wcs_cmp );
|
||||
|
||||
while( n )
|
||||
{
|
||||
hash_foreach2( &n->env, &export_func1, &vals );
|
||||
|
||||
if( n->new_scope )
|
||||
n = global_env;
|
||||
else
|
||||
n = n->next;
|
||||
}
|
||||
get_exported( top, &vals );
|
||||
|
||||
al_init( &uni );
|
||||
env_universal_get_names( &uni, 1, 0 );
|
||||
@@ -1368,7 +1544,7 @@ char **env_export_arr( int recalc )
|
||||
{
|
||||
wchar_t *key = (wchar_t *)al_get( &uni, i );
|
||||
wchar_t *val = env_universal_get( key );
|
||||
if( !hash_get( &vals, key ) )
|
||||
if( wcscmp( val, ENV_NULL) && !hash_get( &vals, key ) )
|
||||
hash_put( &vals, key, val );
|
||||
}
|
||||
al_destroy( &uni );
|
||||
|
||||
14
env.h
14
env.h
@@ -80,8 +80,8 @@ void env_destroy();
|
||||
*/
|
||||
|
||||
int env_set( const wchar_t *key,
|
||||
const wchar_t *val,
|
||||
int mode );
|
||||
const wchar_t *val,
|
||||
int mode );
|
||||
|
||||
|
||||
/**
|
||||
@@ -94,7 +94,7 @@ int 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
|
||||
@@ -129,8 +129,14 @@ 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 );
|
||||
|
||||
/**
|
||||
Update the PWD variable
|
||||
directory
|
||||
*/
|
||||
int env_set_pwd();
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
121
env_universal.c
121
env_universal.c
@@ -70,6 +70,11 @@ static int barrier_reply = 0;
|
||||
|
||||
void env_universal_barrier();
|
||||
|
||||
static int is_dead()
|
||||
{
|
||||
return env_universal_server.fd < 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Get a socket for reading from the server
|
||||
@@ -140,18 +145,18 @@ static int get_socket( int fork_ok )
|
||||
return get_socket( 0 );
|
||||
}
|
||||
|
||||
debug( 2, L"Could not connect to socket %d, already tried manual restart (or no command supplied), giving up", s );
|
||||
debug( 1, L"Could not connect to universal variable server, already tried manual restart (or no command supplied). You will not be able to share variable values between fish sessions. Is fish properly installed?" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
if( fcntl( s, F_SETFL, O_NONBLOCK ) != 0 )
|
||||
if( (fcntl( s, F_SETFL, O_NONBLOCK ) != 0) || (fcntl( s, F_SETFD, FD_CLOEXEC ) != 0) )
|
||||
{
|
||||
wperror( L"fcntl" );
|
||||
close( s );
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
debug( 3, L"Connected to fd %d", s );
|
||||
|
||||
return s;
|
||||
@@ -164,7 +169,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
|
||||
@@ -194,11 +198,36 @@ static void check_connection()
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Remove all universal variables.
|
||||
*/
|
||||
static void env_universal_remove_all()
|
||||
{
|
||||
array_list_t lst;
|
||||
int i;
|
||||
|
||||
al_init( &lst );
|
||||
|
||||
env_universal_common_get_names( &lst,
|
||||
1,
|
||||
1 );
|
||||
|
||||
for( i=0; i<al_get_count( &lst ); i++ )
|
||||
{
|
||||
wchar_t *key = (wchar_t *)al_get( &lst, i );
|
||||
env_universal_common_remove( key );
|
||||
}
|
||||
|
||||
al_destroy( &lst );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Try to establish a new connection to fishd. If successfull, end
|
||||
with call to env_universal_barrier(), to make sure everything is in
|
||||
@@ -212,10 +241,12 @@ static void reconnect()
|
||||
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 )
|
||||
{
|
||||
env_universal_remove_all();
|
||||
env_universal_barrier();
|
||||
}
|
||||
}
|
||||
@@ -226,26 +257,21 @@ void env_universal_init( wchar_t * p,
|
||||
void (*sf)(),
|
||||
void (*cb)( int type, const wchar_t *name, const wchar_t *val ))
|
||||
{
|
||||
debug( 3, 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( 3, L"end env_universal_init()" );
|
||||
}
|
||||
|
||||
void env_universal_destroy()
|
||||
@@ -259,17 +285,11 @@ void env_universal_destroy()
|
||||
{
|
||||
wperror( L"fcntl" );
|
||||
}
|
||||
try_send_all( &env_universal_server );
|
||||
|
||||
if( close( env_universal_server.fd ) )
|
||||
{
|
||||
wperror( L"close" );
|
||||
}
|
||||
try_send_all( &env_universal_server );
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -283,8 +303,6 @@ int env_universal_read_all()
|
||||
if( !init)
|
||||
return 0;
|
||||
|
||||
debug( 3, L"env_universal_read_all()" );
|
||||
|
||||
if( env_universal_server.fd == -1 )
|
||||
{
|
||||
reconnect();
|
||||
@@ -312,7 +330,6 @@ wchar_t *env_universal_get( const wchar_t *name )
|
||||
|
||||
CHECK( name, 0 );
|
||||
|
||||
debug( 3, L"env_universal_get( \"%ls\" )", name );
|
||||
return env_universal_common_get( name );
|
||||
}
|
||||
|
||||
@@ -323,7 +340,6 @@ int env_universal_get_export( const wchar_t *name )
|
||||
|
||||
CHECK( name, 0 );
|
||||
|
||||
debug( 3, L"env_universal_get_export()" );
|
||||
return env_universal_common_get_export( name );
|
||||
}
|
||||
|
||||
@@ -332,7 +348,7 @@ void env_universal_barrier()
|
||||
message_t *msg;
|
||||
fd_set fds;
|
||||
|
||||
if( !init || ( env_universal_server.fd == -1 ))
|
||||
if( !init || is_dead() )
|
||||
return;
|
||||
|
||||
barrier_reply = 0;
|
||||
@@ -367,7 +383,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
|
||||
*/
|
||||
@@ -399,20 +415,27 @@ void env_universal_set( const wchar_t *name, const wchar_t *value, int export )
|
||||
CHECK( name, );
|
||||
|
||||
debug( 3, L"env_universal_set( \"%ls\", \"%ls\" )", name, value );
|
||||
|
||||
msg = create_message( export?SET_EXPORT:SET,
|
||||
name,
|
||||
value);
|
||||
|
||||
if( !msg )
|
||||
if( is_dead() )
|
||||
{
|
||||
debug( 1, L"Could not create universal variable message" );
|
||||
return;
|
||||
env_universal_common_set( name, value, export );
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = create_message( export?SET_EXPORT:SET,
|
||||
name,
|
||||
value);
|
||||
|
||||
if( !msg )
|
||||
{
|
||||
debug( 1, L"Could not create universal variable message" );
|
||||
return;
|
||||
}
|
||||
|
||||
msg->count=1;
|
||||
q_put( &env_universal_server.unsent, msg );
|
||||
env_universal_barrier();
|
||||
}
|
||||
|
||||
msg->count=1;
|
||||
q_put( &env_universal_server.unsent, msg );
|
||||
env_universal_barrier();
|
||||
}
|
||||
|
||||
int env_universal_remove( const wchar_t *name )
|
||||
@@ -426,16 +449,22 @@ int env_universal_remove( const wchar_t *name )
|
||||
CHECK( name, 1 );
|
||||
|
||||
res = !env_universal_common_get( name );
|
||||
|
||||
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();
|
||||
|
||||
|
||||
if( is_dead() )
|
||||
{
|
||||
env_universal_common_remove( name );
|
||||
}
|
||||
else
|
||||
{
|
||||
msg= create_message( ERASE, name, 0);
|
||||
msg->count=1;
|
||||
q_put( &env_universal_server.unsent, msg );
|
||||
env_universal_barrier();
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -445,6 +474,8 @@ void env_universal_get_names( array_list_t *l,
|
||||
{
|
||||
if( !init )
|
||||
return;
|
||||
|
||||
CHECK( l, );
|
||||
|
||||
env_universal_common_get_names( l,
|
||||
show_exported,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/** \file env_universal.h
|
||||
Universal variable client library
|
||||
Universal variable client library.
|
||||
*/
|
||||
|
||||
#ifndef ENV_UNIVERSAL_H
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <sys/stat.h>
|
||||
#include <dirent.h>
|
||||
#include <wctype.h>
|
||||
#include <iconv.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <locale.h>
|
||||
@@ -69,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
|
||||
@@ -77,13 +93,13 @@
|
||||
typedef struct var_uni_entry
|
||||
{
|
||||
int export; /**< Whether the variable should be exported */
|
||||
wchar_t val[0]; /**< The value of the variable */
|
||||
wchar_t val[1]; /**< The value of the variable */
|
||||
}
|
||||
var_uni_entry_t;
|
||||
|
||||
|
||||
static void parse_message( wchar_t *msg,
|
||||
connection_t *src );
|
||||
connection_t *src );
|
||||
|
||||
/**
|
||||
The table of all universal variables
|
||||
@@ -97,7 +113,6 @@ void (*callback)( int type,
|
||||
const wchar_t *key,
|
||||
const wchar_t *val );
|
||||
|
||||
|
||||
/**
|
||||
Variable used by env_get_names to communicate auxiliary information
|
||||
to add_key_to_hash
|
||||
@@ -109,10 +124,270 @@ static int get_names_show_exported;
|
||||
*/
|
||||
static int get_names_show_unexported;
|
||||
|
||||
/**
|
||||
List of names for the UTF-8 character set.
|
||||
*/
|
||||
static char *iconv_utf8_names[]=
|
||||
{
|
||||
"utf-8", "UTF-8",
|
||||
"utf8", "UTF8",
|
||||
0
|
||||
}
|
||||
;
|
||||
|
||||
/**
|
||||
List of wide character names, undefined byte length.
|
||||
*/
|
||||
static char *iconv_wide_names_unknown[]=
|
||||
{
|
||||
"wchar_t", "WCHAR_T",
|
||||
"wchar", "WCHAR",
|
||||
0
|
||||
}
|
||||
;
|
||||
|
||||
/**
|
||||
List of wide character names, 4 bytes long.
|
||||
*/
|
||||
static char *iconv_wide_names_4[]=
|
||||
{
|
||||
"wchar_t", "WCHAR_T",
|
||||
"wchar", "WCHAR",
|
||||
"ucs-4", "UCS-4",
|
||||
"ucs4", "UCS4",
|
||||
"utf-32", "UTF-32",
|
||||
"utf32", "UTF32",
|
||||
0
|
||||
}
|
||||
;
|
||||
|
||||
/**
|
||||
List of wide character names, 2 bytes long.
|
||||
*/
|
||||
static char *iconv_wide_names_2[]=
|
||||
{
|
||||
"wchar_t", "WCHAR_T",
|
||||
"wchar", "WCHAR",
|
||||
"ucs-2", "UCS-2",
|
||||
"ucs2", "UCS2",
|
||||
"utf-16", "UTF-16",
|
||||
"utf16", "UTF16",
|
||||
0
|
||||
}
|
||||
;
|
||||
|
||||
/**
|
||||
Convert utf-8 string to wide string
|
||||
*/
|
||||
static wchar_t *utf2wcs( const char *in )
|
||||
{
|
||||
iconv_t cd=(iconv_t) -1;
|
||||
int i,j;
|
||||
|
||||
wchar_t *out;
|
||||
|
||||
/*
|
||||
Try to convert to wchar_t. If that is not a valid character set,
|
||||
try various names for ucs-4. We can't be sure that ucs-4 is
|
||||
really the character set used by wchar_t, but it is the best
|
||||
assumption we can make.
|
||||
*/
|
||||
char **to_name=0;
|
||||
|
||||
switch (sizeof (wchar_t))
|
||||
{
|
||||
|
||||
case 2:
|
||||
to_name = iconv_wide_names_2;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
to_name = iconv_wide_names_4;
|
||||
break;
|
||||
|
||||
default:
|
||||
to_name = iconv_wide_names_unknown;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
The line protocol fish uses is always utf-8.
|
||||
*/
|
||||
char **from_name = iconv_utf8_names;
|
||||
|
||||
size_t in_len = strlen( in );
|
||||
size_t out_len = sizeof( wchar_t )*(in_len+2);
|
||||
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, (const 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';
|
||||
|
||||
/*
|
||||
Check for silly iconv behaviour inserting an bytemark in the output
|
||||
string.
|
||||
*/
|
||||
if (*out == L'\xfeff' || *out == L'\xffef' || *out == L'\xefbbbf')
|
||||
{
|
||||
wchar_t *out_old = out;
|
||||
out = wcsdup(out+1);
|
||||
if (! out )
|
||||
{
|
||||
debug(0, L"FNORD!!!!");
|
||||
free( out_old );
|
||||
return 0;
|
||||
}
|
||||
free( out_old );
|
||||
}
|
||||
|
||||
|
||||
if (iconv_close (cd) != 0)
|
||||
wperror (L"iconv_close");
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
Convert wide string to utf-8
|
||||
*/
|
||||
static char *wcs2utf( const wchar_t *in )
|
||||
{
|
||||
iconv_t cd=(iconv_t) -1;
|
||||
int i,j;
|
||||
|
||||
char *char_in = (char *)in;
|
||||
char *out;
|
||||
|
||||
/*
|
||||
Try to convert to wchar_t. If that is not a valid character set,
|
||||
try various names for ucs-4. We can't be sure that ucs-4 is
|
||||
really the character set used by wchar_t, but it is the best
|
||||
assumption we can make.
|
||||
*/
|
||||
char **from_name=0;
|
||||
|
||||
switch (sizeof (wchar_t))
|
||||
{
|
||||
|
||||
case 2:
|
||||
from_name = iconv_wide_names_2;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
from_name = iconv_wide_names_4;
|
||||
break;
|
||||
|
||||
default:
|
||||
from_name = iconv_wide_names_unknown;
|
||||
break;
|
||||
}
|
||||
|
||||
char **to_name = iconv_utf8_names;
|
||||
|
||||
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( 3, L"Init env_universal_common" );
|
||||
callback = cb;
|
||||
hash_init( &env_universal_var, &hash_wcs_func, &hash_wcs_cmp );
|
||||
}
|
||||
@@ -134,69 +409,121 @@ void env_universal_common_destroy()
|
||||
hash_destroy( &env_universal_var );
|
||||
}
|
||||
|
||||
/**
|
||||
Read one byte of date form the specified connection
|
||||
*/
|
||||
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_append_char( &src->input, 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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -204,7 +531,7 @@ void read_message( connection_t *src )
|
||||
/**
|
||||
Remove variable with specified name
|
||||
*/
|
||||
static void remove_entry( wchar_t *name )
|
||||
void env_universal_common_remove( const wchar_t *name )
|
||||
{
|
||||
void *k, *v;
|
||||
hash_remove( &env_universal_var,
|
||||
@@ -230,20 +557,48 @@ static int match( const wchar_t *msg, const wchar_t *cmd )
|
||||
return 1;
|
||||
}
|
||||
|
||||
void env_universal_common_set( const wchar_t *key, const wchar_t *val, int export )
|
||||
{
|
||||
var_uni_entry_t *entry;
|
||||
wchar_t *name;
|
||||
|
||||
CHECK( key, );
|
||||
CHECK( val, );
|
||||
|
||||
entry = malloc( sizeof(var_uni_entry_t) + sizeof(wchar_t)*(wcslen(val)+1) );
|
||||
name = wcsdup(key);
|
||||
|
||||
if( !entry || !name )
|
||||
DIE_MEM();
|
||||
|
||||
entry->export=export;
|
||||
|
||||
wcscpy( entry->val, val );
|
||||
env_universal_common_remove( name );
|
||||
|
||||
hash_put( &env_universal_var, name, entry );
|
||||
|
||||
if( callback )
|
||||
{
|
||||
callback( export?SET_EXPORT:SET, name, val );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Parse message msg
|
||||
*/
|
||||
static void parse_message( wchar_t *msg,
|
||||
connection_t *src )
|
||||
{
|
||||
debug( 3, L"parse_message( %ls );", msg );
|
||||
// debug( 3, L"parse_message( %ls );", msg );
|
||||
|
||||
if( msg[0] == L'#' )
|
||||
return;
|
||||
|
||||
if( match( msg, SET_STR ) || match( msg, SET_EXPORT_STR ))
|
||||
{
|
||||
wchar_t *name, *val, *tmp;
|
||||
wchar_t *name, *tmp;
|
||||
int export = match( msg, SET_EXPORT_STR );
|
||||
|
||||
name = msg+(export?wcslen(SET_EXPORT_STR):wcslen(SET_STR));
|
||||
@@ -253,31 +608,20 @@ static void parse_message( wchar_t *msg,
|
||||
tmp = wcschr( name, L':' );
|
||||
if( tmp )
|
||||
{
|
||||
wchar_t *key =malloc( sizeof( wchar_t)*(tmp-name+1));
|
||||
wchar_t *key;
|
||||
wchar_t *val;
|
||||
|
||||
key = malloc( sizeof( wchar_t)*(tmp-name+1));
|
||||
memcpy( key, name, sizeof( wchar_t)*(tmp-name));
|
||||
key[tmp-name]=0;
|
||||
|
||||
val = tmp+1;
|
||||
|
||||
|
||||
val = unescape( val, 0 );
|
||||
|
||||
var_uni_entry_t *entry =
|
||||
malloc( sizeof(var_uni_entry_t) + sizeof(wchar_t)*(wcslen(val)+1) );
|
||||
if( !entry )
|
||||
DIE_MEM();
|
||||
entry->export=export;
|
||||
env_universal_common_set( key, val, export );
|
||||
|
||||
wcscpy( entry->val, val );
|
||||
remove_entry( key );
|
||||
|
||||
hash_put( &env_universal_var, key, entry );
|
||||
|
||||
if( callback )
|
||||
{
|
||||
callback( export?SET_EXPORT:SET, key, val );
|
||||
}
|
||||
free(val );
|
||||
free( val );
|
||||
free( key );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -303,7 +647,7 @@ static void parse_message( wchar_t *msg,
|
||||
debug( 1, PARSE_ERR, msg );
|
||||
}
|
||||
|
||||
remove_entry( name );
|
||||
env_universal_common_remove( name );
|
||||
|
||||
if( callback )
|
||||
{
|
||||
@@ -343,7 +687,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 )
|
||||
@@ -352,10 +705,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;
|
||||
}
|
||||
@@ -371,9 +725,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 ) )
|
||||
@@ -383,7 +737,7 @@ void try_send_all( connection_t *c )
|
||||
break;
|
||||
|
||||
case 0:
|
||||
debug( 1,
|
||||
debug( 4,
|
||||
L"Socket full, send rest later" );
|
||||
return;
|
||||
|
||||
@@ -394,6 +748,36 @@ void try_send_all( connection_t *c )
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Escape specified string
|
||||
*/
|
||||
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 )
|
||||
@@ -402,10 +786,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,
|
||||
@@ -426,11 +818,11 @@ 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;
|
||||
@@ -495,6 +887,9 @@ message_t *create_message( int type,
|
||||
|
||||
if( msg )
|
||||
msg->count=0;
|
||||
|
||||
// debug( 4, L"Message body is '%s'", msg->body );
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
@@ -572,3 +967,30 @@ 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 );
|
||||
|
||||
/*
|
||||
A connection need not always be open - we only try to close it
|
||||
if it is open.
|
||||
*/
|
||||
if( c->fd >= 0 )
|
||||
{
|
||||
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
|
||||
*/
|
||||
@@ -95,7 +112,7 @@ typedef struct
|
||||
/**
|
||||
Message body. The message must be allocated using enough memory to actually contain the message.
|
||||
*/
|
||||
char body[0];
|
||||
char body[1];
|
||||
}
|
||||
message_t;
|
||||
|
||||
@@ -126,19 +143,50 @@ void env_universal_common_destroy();
|
||||
|
||||
/**
|
||||
Add all variable names to the specified list
|
||||
|
||||
This function operate agains the local copy of all universal
|
||||
variables, it does not communicate with any other process.
|
||||
*/
|
||||
void env_universal_common_get_names( array_list_t *l,
|
||||
int show_exported,
|
||||
int show_unexported );
|
||||
|
||||
/**
|
||||
Perform the specified variable assignment.
|
||||
|
||||
This function operate agains the local copy of all universal
|
||||
variables, it does not communicate with any other process.
|
||||
|
||||
Do not call this function. Create a message to do it. This function
|
||||
is only to be used when fishd is dead.
|
||||
*/
|
||||
void env_universal_common_set( const wchar_t *key, const wchar_t *val, int export );
|
||||
|
||||
/**
|
||||
Remove the specified variable.
|
||||
|
||||
This function operate agains the local copy of all universal
|
||||
variables, it does not communicate with any other process.
|
||||
|
||||
Do not call this function. Create a message to do it. This function
|
||||
is only to be used when fishd is dead.
|
||||
*/
|
||||
void env_universal_common_remove( const wchar_t *key );
|
||||
|
||||
/**
|
||||
Get the value of the variable with the specified name
|
||||
|
||||
This function operate agains the local copy of all universal
|
||||
variables, it does not communicate with any other process.
|
||||
*/
|
||||
wchar_t *env_universal_common_get( const wchar_t *name );
|
||||
|
||||
/**
|
||||
Get the export flag of the variable with the specified
|
||||
name. Returns 0 if the variable doesn't exist.
|
||||
|
||||
This function operate agains the local copy of all universal
|
||||
variables, it does not communicate with any other process.
|
||||
*/
|
||||
int env_universal_common_get_export( const wchar_t *name );
|
||||
|
||||
@@ -147,5 +195,17 @@ int env_universal_common_get_export( const wchar_t *name );
|
||||
*/
|
||||
void enqueue_all( connection_t *c );
|
||||
|
||||
/**
|
||||
Fill in the specified connection_t struct. Use the specified file
|
||||
descriptor for communication.
|
||||
*/
|
||||
void connection_init( connection_t *c, int fd );
|
||||
|
||||
/**
|
||||
Close and destroy the specified connection struct. This frees
|
||||
allstructures allocated by the connection, such as ques of unsent
|
||||
messages.
|
||||
*/
|
||||
void connection_destroy( connection_t *c);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3,19 +3,6 @@
|
||||
#
|
||||
# @configure_input@
|
||||
|
||||
#
|
||||
# Set default search paths for completions and shellscript functions
|
||||
#
|
||||
|
||||
set -g fish_function_path ~/.fish.d/functions @sysconfdir@/fish.d/functions @datadir@/fish/functions
|
||||
set -g fish_complete_path ~/.fish.d/completions @sysconfdir@/fish.d/completions @datadir@/fish/completions
|
||||
|
||||
#
|
||||
# Set default field separators
|
||||
#
|
||||
|
||||
set -g IFS \ \t\n
|
||||
|
||||
#
|
||||
# Some things should only be done for login terminals
|
||||
#
|
||||
@@ -66,6 +53,9 @@ end
|
||||
# Load additional initialization files
|
||||
#
|
||||
|
||||
for i in fish.d/*.fish
|
||||
. $i
|
||||
if test -d include
|
||||
for i in include/*.fish
|
||||
. $i
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
#
|
||||
# This file contains key bindings for fish
|
||||
#
|
||||
|
||||
# Include system-wide inputrc file before including fish-specific key
|
||||
# bindings if it exists
|
||||
|
||||
$include /etc/inputrc
|
||||
|
||||
$if fish
|
||||
"\M-l": __fish_list_current_token
|
||||
"\M-w": set tok (commandline -pt); if test $tok[1]; whatis $tok[1]; end
|
||||
"\C-l": clear
|
||||
"\C-c": delete-line
|
||||
"\C-u": backward-kill-line
|
||||
"\M-d": kill-word
|
||||
"\C-w": backward-kill-word
|
||||
"\M-k": dump-functions
|
||||
"\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
|
||||
$endif
|
||||
|
||||
# Include user-specific inputrc file after including fish-specific
|
||||
# bindings so that they will override fish defaults
|
||||
|
||||
$include ~/.inputrc
|
||||
@@ -1,110 +0,0 @@
|
||||
#
|
||||
# Initializations that should only be performed when in interactive mode
|
||||
#
|
||||
# @configure_input@
|
||||
|
||||
if not status --is-interactive
|
||||
exit
|
||||
end
|
||||
|
||||
#
|
||||
# Print a greeting
|
||||
#
|
||||
|
||||
printf (_ 'Welcome to fish, the friendly interactive shell\n')
|
||||
printf (_ 'Type %shelp%s for instructions on how to use fish\n') (set_color green) (set_color normal)
|
||||
|
||||
#
|
||||
# Set exit message
|
||||
#
|
||||
|
||||
function fish_on_exit -d (_ "Commands to execute when fish exits") --on-process %self
|
||||
printf (_ "Good bye\n")
|
||||
end
|
||||
|
||||
#
|
||||
# Set INPUTRC to something nice
|
||||
#
|
||||
# We override INPUTRC if already set, since it may be set by a shell
|
||||
# other than fish, which may use a different file. The new value should
|
||||
# be exported, since the fish inputrc file plays nice with other files
|
||||
# by including them when found.
|
||||
# Give priority to the default file installed with fish in
|
||||
# @sysconfdir@/fish_inputrc.
|
||||
#
|
||||
|
||||
for i in ~/.fish_inputrc @sysconfdir@/fish_inputrc ~/.inputrc /etc/inputrc
|
||||
if test -f $i
|
||||
set -xg INPUTRC $i
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
#
|
||||
# Set various defaults using these throwaway functions
|
||||
#
|
||||
|
||||
function set_default -d "Set an universal variable, unless it has already been set"
|
||||
if not set -q $argv[1]
|
||||
set -U -- $argv
|
||||
end
|
||||
if not set -q $argv[1]
|
||||
set -g -- $argv
|
||||
end
|
||||
end
|
||||
|
||||
function set_exported_default -d "Set an exported universal variable, unless it has already been set"
|
||||
if not set -q $argv[1]
|
||||
set -Ux -- $argv
|
||||
end
|
||||
if not set -q $argv[1]
|
||||
set -gx -- $argv
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# Regular syntax highlighting colors
|
||||
set_default fish_color_normal normal
|
||||
set_default fish_color_command green
|
||||
set_default fish_color_redirection normal
|
||||
set_default fish_color_comment red
|
||||
set_default fish_color_error red --bold
|
||||
set_default fish_color_escape cyan
|
||||
set_default fish_color_operator cyan
|
||||
set_default fish_color_quote brown
|
||||
set_default fish_color_valid_path --underline
|
||||
|
||||
set_default fish_color_cwd green
|
||||
|
||||
# Background color for matching quotes and parenthesis
|
||||
set_default fish_color_match cyan
|
||||
|
||||
# Background color for search matches
|
||||
set_default fish_color_search_match purple
|
||||
|
||||
# Pager colors
|
||||
set_default fish_pager_color_prefix cyan
|
||||
set_default fish_pager_color_completion normal
|
||||
set_default fish_pager_color_description normal
|
||||
set_default fish_pager_color_progress cyan
|
||||
|
||||
#
|
||||
# Directory history colors
|
||||
#
|
||||
|
||||
set_default fish_color_history_current cyan
|
||||
|
||||
|
||||
#
|
||||
# Setup the CDPATH variable
|
||||
#
|
||||
|
||||
set_default CDPATH . ~
|
||||
|
||||
#
|
||||
# Remove temporary functions for setting default variable values
|
||||
#
|
||||
|
||||
functions -e set_exported_default
|
||||
functions -e set_default
|
||||
75
event.c
75
event.c
@@ -78,11 +78,6 @@ static array_list_t *killme;
|
||||
*/
|
||||
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 both the class and the instance name a function,
|
||||
@@ -91,6 +86,7 @@ static string_buffer_t *get_desc_buff=0;
|
||||
*/
|
||||
static int event_match( event_t *class, event_t *instance )
|
||||
{
|
||||
|
||||
if( class->function_name && instance->function_name )
|
||||
{
|
||||
if( wcscmp( class->function_name, instance->function_name ) != 0 )
|
||||
@@ -103,15 +99,15 @@ static int event_match( event_t *class, event_t *instance )
|
||||
if( class->type != instance->type )
|
||||
return 0;
|
||||
|
||||
|
||||
|
||||
switch( class->type )
|
||||
{
|
||||
|
||||
|
||||
case EVENT_SIGNAL:
|
||||
if( class->param1.signal == EVENT_ANY_SIGNAL )
|
||||
return 1;
|
||||
return class->param1.signal == instance->param1.signal;
|
||||
|
||||
|
||||
case EVENT_VARIABLE:
|
||||
return wcscmp( instance->param1.variable,
|
||||
class->param1.variable )==0;
|
||||
@@ -123,6 +119,11 @@ static int event_match( event_t *class, event_t *instance )
|
||||
|
||||
case EVENT_JOB_ID:
|
||||
return class->param1.job_id == instance->param1.job_id;
|
||||
|
||||
case EVENT_GENERIC:
|
||||
return wcscmp( instance->param1.param,
|
||||
class->param1.param )==0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,8 +140,10 @@ static int event_match( event_t *class, event_t *instance )
|
||||
static event_t *event_copy( event_t *event, int copy_arguments )
|
||||
{
|
||||
event_t *e = malloc( sizeof( event_t ) );
|
||||
|
||||
if( !e )
|
||||
DIE_MEM();
|
||||
|
||||
memcpy( e, event, sizeof(event_t));
|
||||
|
||||
if( e->function_name )
|
||||
@@ -148,6 +151,8 @@ static event_t *event_copy( event_t *event, int copy_arguments )
|
||||
|
||||
if( e->type == EVENT_VARIABLE )
|
||||
e->param1.variable = wcsdup( e->param1.variable );
|
||||
else if( e->type == EVENT_GENERIC )
|
||||
e->param1.param = wcsdup( e->param1.param );
|
||||
|
||||
al_init( &e->arguments );
|
||||
if( copy_arguments )
|
||||
@@ -197,6 +202,11 @@ static int event_is_blocked( event_t *e )
|
||||
const wchar_t *event_get_desc( event_t *e )
|
||||
{
|
||||
|
||||
/*
|
||||
String buffer used for formating event descriptions in event_get_desc()
|
||||
*/
|
||||
static string_buffer_t *get_desc_buff=0;
|
||||
|
||||
CHECK( e, 0 );
|
||||
|
||||
if( !get_desc_buff )
|
||||
@@ -246,6 +256,14 @@ const wchar_t *event_get_desc( event_t *e )
|
||||
break;
|
||||
}
|
||||
|
||||
case EVENT_GENERIC:
|
||||
sb_printf( get_desc_buff, _(L"handler for generic event '%ls'"), e->param1.param );
|
||||
break;
|
||||
|
||||
default:
|
||||
sb_printf( get_desc_buff, _(L"Unknown event type") );
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return (const wchar_t *)get_desc_buff->buff;
|
||||
@@ -444,7 +462,8 @@ static void event_fire_internal( event_t *event )
|
||||
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
|
||||
*/
|
||||
@@ -476,11 +495,13 @@ static void event_fire_internal( event_t *event )
|
||||
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 );
|
||||
parser_pop_block();
|
||||
proc_pop_interactive();
|
||||
proc_set_last_status( prev_status );
|
||||
}
|
||||
|
||||
if( b )
|
||||
@@ -611,7 +632,9 @@ void event_fire( event_t *event )
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/*
|
||||
Fire events triggered by signals
|
||||
*/
|
||||
event_fire_delayed();
|
||||
|
||||
if( event )
|
||||
@@ -670,7 +693,39 @@ void event_free( event_t *e )
|
||||
|
||||
free( (void *)e->function_name );
|
||||
if( e->type == EVENT_VARIABLE )
|
||||
{
|
||||
free( (void *)e->param1.variable );
|
||||
}
|
||||
else if( e->type == EVENT_GENERIC )
|
||||
{
|
||||
free( (void *)e->param1.param );
|
||||
}
|
||||
free( e );
|
||||
}
|
||||
|
||||
|
||||
void event_fire_generic_internal(const wchar_t *name, ...)
|
||||
{
|
||||
event_t ev;
|
||||
va_list va;
|
||||
wchar_t *arg;
|
||||
|
||||
CHECK( name, );
|
||||
|
||||
ev.type = EVENT_GENERIC;
|
||||
ev.param1.param = name;
|
||||
ev.function_name=0;
|
||||
|
||||
al_init( &ev.arguments );
|
||||
va_start( va, name );
|
||||
while( (arg=va_arg(va, wchar_t *) )!= 0 )
|
||||
{
|
||||
al_push( &ev.arguments, arg );
|
||||
}
|
||||
va_end( va );
|
||||
|
||||
event_fire( &ev );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
38
event.h
38
event.h
@@ -2,6 +2,12 @@
|
||||
|
||||
Functions for handling event triggers
|
||||
|
||||
Because most of these functions can be called by signal
|
||||
handler, it is important to make it well defined when these
|
||||
functions produce output or perform memory allocations, since
|
||||
such functions may not be safely called by signal handlers.
|
||||
|
||||
|
||||
*/
|
||||
#ifndef FISH_EVENT_H
|
||||
#define FISH_EVENT_H
|
||||
@@ -27,6 +33,7 @@ enum
|
||||
EVENT_VARIABLE, /**< An event triggered by a variable update */
|
||||
EVENT_EXIT, /**< An event triggered by a job or process exit */
|
||||
EVENT_JOB_ID, /**< An event triggered by a job exit */
|
||||
EVENT_GENERIC, /**< A generic event */
|
||||
}
|
||||
;
|
||||
|
||||
@@ -67,7 +74,11 @@ typedef struct
|
||||
Job id for EVENT_JOB_ID type events
|
||||
*/
|
||||
int job_id;
|
||||
|
||||
/**
|
||||
The parameter describing this generic event
|
||||
*/
|
||||
const wchar_t *param;
|
||||
|
||||
} param1;
|
||||
|
||||
/**
|
||||
@@ -86,17 +97,24 @@ typedef struct
|
||||
|
||||
/**
|
||||
Add an event handler
|
||||
|
||||
May not be called by a signal handler, since it may allocate new memory.
|
||||
*/
|
||||
void event_add_handler( event_t *event );
|
||||
|
||||
/**
|
||||
Remove all events matching the specified criterion.
|
||||
|
||||
May not be called by a signal handler, since it may free allocated memory.
|
||||
*/
|
||||
void event_remove( event_t *event );
|
||||
|
||||
/**
|
||||
Return all events which match the specified event class
|
||||
|
||||
This function is safe to call from a signal handler _ONLY_ if the
|
||||
out parameter is null.
|
||||
|
||||
\param criterion Is the class of events to return. If the criterion has a non-null function_name, only events which trigger the specified function will return.
|
||||
\param out the list to add events to. May be 0, in which case no events will be added, but the result count will still be valid
|
||||
|
||||
@@ -111,7 +129,14 @@ int event_get( event_t *criterion, array_list_t *out );
|
||||
called. If event is a null-pointer, all pending events are
|
||||
dispatched.
|
||||
|
||||
\param event the specific event whose handlers should fire
|
||||
This function is safe to call from a signal handler _ONLY_ if the
|
||||
event parameter is for a signal. Signal events not be fired, by the
|
||||
call to event_fire, instead they will be fired the next time
|
||||
event_fire is called with anull argument. This is needed to make
|
||||
sure that no code evaluation is ever performed by a signal handler.
|
||||
|
||||
\param event the specific event whose handlers should fire. If
|
||||
null, then all delayed events will be fired.
|
||||
*/
|
||||
void event_fire( event_t *event );
|
||||
|
||||
@@ -126,7 +151,7 @@ void event_init();
|
||||
void event_destroy();
|
||||
|
||||
/**
|
||||
Free all memory used by event
|
||||
Free all memory used by the specified event
|
||||
*/
|
||||
void event_free( event_t *e );
|
||||
|
||||
@@ -136,4 +161,11 @@ void event_free( event_t *e );
|
||||
*/
|
||||
const wchar_t *event_get_desc( event_t *e );
|
||||
|
||||
/**
|
||||
Fire a generic event with the specified name
|
||||
*/
|
||||
#define event_fire_generic( ... ) event_fire_generic_internal( __VA_ARGS__, (void *)0 )
|
||||
|
||||
void event_fire_generic_internal(const wchar_t *name,...);
|
||||
|
||||
#endif
|
||||
|
||||
4
exec.h
4
exec.h
@@ -51,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 );
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user