mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-08 02:31:18 -03:00
Compare commits
1398 Commits
1.22.0
...
pre_whites
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5827bfd9a2 | ||
|
|
dc8cc39bc8 | ||
|
|
c9c2fc5ee3 | ||
|
|
b79854ad1a | ||
|
|
8229b17f0d | ||
|
|
4a5d02aab4 | ||
|
|
ed4e6cd3a5 | ||
|
|
7d45e6f12f | ||
|
|
0302162d8e | ||
|
|
1dfa404210 | ||
|
|
bd4551e2ef | ||
|
|
d6a56428d1 | ||
|
|
a10fa3a20b | ||
|
|
be5fde9e54 | ||
|
|
abfc7e16a1 | ||
|
|
d76f880faf | ||
|
|
21e83a881e | ||
|
|
5ba1261285 | ||
|
|
7bb844a778 | ||
|
|
8c24d49c73 | ||
|
|
5e371e8fe7 | ||
|
|
e46324ced9 | ||
|
|
5ea486b20a | ||
|
|
425afa63ce | ||
|
|
7c09a767b6 | ||
|
|
768f92303e | ||
|
|
34054fa1fb | ||
|
|
4a37d6d1f9 | ||
|
|
8dfc8625a7 | ||
|
|
e878947cb2 | ||
|
|
f56f84c6ac | ||
|
|
239d43dac4 | ||
|
|
8a63326411 | ||
|
|
01608cf062 | ||
|
|
e06d6ce4a2 | ||
|
|
58a0c6f9d3 | ||
|
|
f310f1e96c | ||
|
|
c7bf1aa222 | ||
|
|
be3fff9282 | ||
|
|
e52cf09bc1 | ||
|
|
57de1388e8 | ||
|
|
7ee0ce745e | ||
|
|
469743cd23 | ||
|
|
91e1d59869 | ||
|
|
5fb97f05a3 | ||
|
|
618b42980d | ||
|
|
211b9ea8b9 | ||
|
|
833abc27cc | ||
|
|
3d5a3f03fa | ||
|
|
51de26960c | ||
|
|
b67526aae8 | ||
|
|
14bf057c62 | ||
|
|
8eb53ea7ca | ||
|
|
9b60af4d52 | ||
|
|
956f99365a | ||
|
|
9904415144 | ||
|
|
83febbdc7d | ||
|
|
6b026e399c | ||
|
|
a661c03743 | ||
|
|
ffc03735e8 | ||
|
|
c7e24488eb | ||
|
|
fe7d2c57e3 | ||
|
|
4fc80b5057 | ||
|
|
12f3f5dcbb | ||
|
|
16f2ffc29d | ||
|
|
86a978d9ee | ||
|
|
f6fe3df59b | ||
|
|
e0764bb25e | ||
|
|
1ba0bfd10c | ||
|
|
593ab75a76 | ||
|
|
3589554028 | ||
|
|
1a59346b51 | ||
|
|
ff124465fd | ||
|
|
de5223db66 | ||
|
|
cc1395797e | ||
|
|
122791646e | ||
|
|
a3c4de52d6 | ||
|
|
95de6cf5a7 | ||
|
|
d788c84440 | ||
|
|
96046ffd30 | ||
|
|
b5e92a831b | ||
|
|
a2788129ff | ||
|
|
5bbf220077 | ||
|
|
f5d4e3f94c | ||
|
|
04ea680e9a | ||
|
|
3a940781d9 | ||
|
|
00fcd63b88 | ||
|
|
f3093649de | ||
|
|
670e33ab27 | ||
|
|
3606664cf7 | ||
|
|
81f45208b0 | ||
|
|
9145d05397 | ||
|
|
ef566836c4 | ||
|
|
10dfca1a75 | ||
|
|
b3e3f041fe | ||
|
|
e3ec361552 | ||
|
|
bfccc7133d | ||
|
|
f41a699f5d | ||
|
|
7d029778e6 | ||
|
|
26857fabdc | ||
|
|
a9b119833a | ||
|
|
c5ffe8a974 | ||
|
|
df1b4e1f21 | ||
|
|
61686aff34 | ||
|
|
ad6645c48d | ||
|
|
1e328c3546 | ||
|
|
0e2a625815 | ||
|
|
6eb66770a4 | ||
|
|
84729c4dfa | ||
|
|
8de8877c7c | ||
|
|
fdc6c3722a | ||
|
|
deca475972 | ||
|
|
ba070e21e4 | ||
|
|
35e9fd1bb0 | ||
|
|
4906609dd9 | ||
|
|
682353f9cc | ||
|
|
25c6671a87 | ||
|
|
c67702a498 | ||
|
|
5880cd88c8 | ||
|
|
54ceb4211e | ||
|
|
7a46227141 | ||
|
|
b904aa78e8 | ||
|
|
8185bee4b8 | ||
|
|
2e1b3325c6 | ||
|
|
1b8f1650dc | ||
|
|
1070b34996 | ||
|
|
13b1b73c15 | ||
|
|
e1de72d0ac | ||
|
|
dc837eb8a3 | ||
|
|
f6b76e6ecb | ||
|
|
e7cbcc83a4 | ||
|
|
390700ca71 | ||
|
|
b604321169 | ||
|
|
62c49f13ce | ||
|
|
eba75dbc2e | ||
|
|
32d2d0f0d0 | ||
|
|
81e0342bf6 | ||
|
|
56599621cc | ||
|
|
261bf12c91 | ||
|
|
b08fb86637 | ||
|
|
b290fd33b9 | ||
|
|
966bbd476f | ||
|
|
cf9bfe9e66 | ||
|
|
bb4a05032b | ||
|
|
7039e01136 | ||
|
|
e9f43f1097 | ||
|
|
150789690f | ||
|
|
e284233013 | ||
|
|
d06d6c6964 | ||
|
|
977a4477f6 | ||
|
|
33c6410809 | ||
|
|
7e321afd2a | ||
|
|
548ea1e54a | ||
|
|
4755c5f8c8 | ||
|
|
ea1bfd715e | ||
|
|
b1281c3fb9 | ||
|
|
257e9b04fe | ||
|
|
8643870822 | ||
|
|
6819696222 | ||
|
|
193bbd4e00 | ||
|
|
1bf168348e | ||
|
|
f8b4c1b389 | ||
|
|
830fba64b1 | ||
|
|
1cd61952b0 | ||
|
|
4ee1cc3b37 | ||
|
|
11dd904b6d | ||
|
|
0c03b6ddc7 | ||
|
|
176a3913aa | ||
|
|
6f0b00f983 | ||
|
|
69ace201f8 | ||
|
|
a04f31c5c0 | ||
|
|
1d9f47d1e5 | ||
|
|
36a91fc6ff | ||
|
|
cd3ed71137 | ||
|
|
73e56527bf | ||
|
|
24059924b1 | ||
|
|
bb100a2511 | ||
|
|
0c8c32cd03 | ||
|
|
a38d6e74f5 | ||
|
|
05d8dacb27 | ||
|
|
d6a0859eab | ||
|
|
4912967eab | ||
|
|
76e1cda495 | ||
|
|
c1a23bf450 | ||
|
|
b25b5bf5f6 | ||
|
|
079f17761c | ||
|
|
e1b8c425da | ||
|
|
5f05756e65 | ||
|
|
c0e996acf8 | ||
|
|
41ec58a524 | ||
|
|
0a5e7be129 | ||
|
|
b23d65b014 | ||
|
|
60ef7903e2 | ||
|
|
ee8fd21d28 | ||
|
|
232ed91ec7 | ||
|
|
7fccad156e | ||
|
|
11e56456a0 | ||
|
|
d07e78c59a | ||
|
|
c45479a6e5 | ||
|
|
345a528625 | ||
|
|
01d8490255 | ||
|
|
ea4b37d5c5 | ||
|
|
a1319cb8aa | ||
|
|
35c49d62d7 | ||
|
|
0576a11a6f | ||
|
|
c8f86d94c9 | ||
|
|
2b24eab26a | ||
|
|
7bbc7a61ce | ||
|
|
fe26284376 | ||
|
|
ab62fe6496 | ||
|
|
bc9bae0f7f | ||
|
|
e5939d1a18 | ||
|
|
5fadb7f200 | ||
|
|
a02aa7a316 | ||
|
|
3ab26a5d40 | ||
|
|
a8bae31939 | ||
|
|
faea588fb8 | ||
|
|
792e246262 | ||
|
|
85f19f9b8c | ||
|
|
40e4f49dbe | ||
|
|
05c721bebb | ||
|
|
e995cc9329 | ||
|
|
9457c115be | ||
|
|
1eddc79a90 | ||
|
|
ccfc909eb2 | ||
|
|
1a93cbba1e | ||
|
|
529d410bec | ||
|
|
4d1c0eaa52 | ||
|
|
adfd3c1098 | ||
|
|
f7d0c4b065 | ||
|
|
5fb32f1e2d | ||
|
|
f69489a4fc | ||
|
|
d34ce26c4e | ||
|
|
3f7fe94009 | ||
|
|
ae593decfc | ||
|
|
eea62125a1 | ||
|
|
96f36a63dc | ||
|
|
19e183f02f | ||
|
|
57f3df3cab | ||
|
|
08e78e63cf | ||
|
|
9228dffe5e | ||
|
|
93dc7d4cc1 | ||
|
|
1bead8adf7 | ||
|
|
6681f3bfec | ||
|
|
71f8960ef1 | ||
|
|
01780f19b1 | ||
|
|
1fa0c4d4d3 | ||
|
|
eebe126842 | ||
|
|
ebfa285122 | ||
|
|
27212719dc | ||
|
|
17567028da | ||
|
|
34fd8e0e00 | ||
|
|
6cf42075fc | ||
|
|
afd8d2f9ba | ||
|
|
1d54bff385 | ||
|
|
6dd0013a5d | ||
|
|
f2b5292bcb | ||
|
|
3a94f6e8b3 | ||
|
|
f2846a0b78 | ||
|
|
dbde7033d8 | ||
|
|
18f04adccb | ||
|
|
1ed65b6bd7 | ||
|
|
9b781c4c06 | ||
|
|
25f9105a97 | ||
|
|
602109bd8d | ||
|
|
631d27f7a8 | ||
|
|
aad27a7a68 | ||
|
|
4ac01154d9 | ||
|
|
4e2c7c57d7 | ||
|
|
6e65cfcc9a | ||
|
|
96a4b7eaa7 | ||
|
|
64afada7f0 | ||
|
|
9f563f4873 | ||
|
|
ca61d0ee8b | ||
|
|
e96dabadf1 | ||
|
|
b6601338c2 | ||
|
|
8167e1e07e | ||
|
|
23ce927301 | ||
|
|
c7941fc7b0 | ||
|
|
1078ad9ae9 | ||
|
|
c0085cbc61 | ||
|
|
a49d245b92 | ||
|
|
0ce6829e4c | ||
|
|
4e3acdcbdc | ||
|
|
85f808130d | ||
|
|
b187538339 | ||
|
|
93f6aabe12 | ||
|
|
10aa107380 | ||
|
|
53cba2a2e6 | ||
|
|
d871095d0b | ||
|
|
9bf8a5e877 | ||
|
|
3836bfe5a1 | ||
|
|
7698553c3a | ||
|
|
be1d216b34 | ||
|
|
85cbb943b5 | ||
|
|
ec34f2527a | ||
|
|
b877181e17 | ||
|
|
69446be1ee | ||
|
|
cc90f9cf80 | ||
|
|
457e6a5f46 | ||
|
|
e7db18bae2 | ||
|
|
f8e3e853aa | ||
|
|
b7ba252965 | ||
|
|
ae12e1b537 | ||
|
|
9255f625fa | ||
|
|
377d93d1cf | ||
|
|
19d14c7c3a | ||
|
|
6e3a823b7b | ||
|
|
51f9ff5389 | ||
|
|
4986e6e3f9 | ||
|
|
9d8ae184c9 | ||
|
|
4afdcf56fc | ||
|
|
0fe43eb880 | ||
|
|
4edfd6d9d6 | ||
|
|
8351ec0afd | ||
|
|
92ce84c26a | ||
|
|
9d31e52b2a | ||
|
|
dcd7d6769d | ||
|
|
87c0e0e971 | ||
|
|
6f9a523151 | ||
|
|
673faf7152 | ||
|
|
18ace555b0 | ||
|
|
d09c9fba02 | ||
|
|
f1d22b6300 | ||
|
|
da6295c428 | ||
|
|
86645b32e1 | ||
|
|
977c585f8b | ||
|
|
4c1ddab560 | ||
|
|
f5442bdd4a | ||
|
|
129525af21 | ||
|
|
c15975113a | ||
|
|
2d3d6e1c17 | ||
|
|
b0f4ff2879 | ||
|
|
070b10689c | ||
|
|
39863ce4d7 | ||
|
|
7cae1ae415 | ||
|
|
eca2100312 | ||
|
|
175249b455 | ||
|
|
294fbc8309 | ||
|
|
9bcc7df96f | ||
|
|
4bd63020ca | ||
|
|
4885842ae8 | ||
|
|
4df6b599b8 | ||
|
|
0c79bb6e7c | ||
|
|
1a264ab7c2 | ||
|
|
99b51ce6ea | ||
|
|
e0baab2722 | ||
|
|
71a8d39372 | ||
|
|
90826e4031 | ||
|
|
0e4f2cca01 | ||
|
|
ac3dce38f0 | ||
|
|
3be07cc645 | ||
|
|
07f5319472 | ||
|
|
47019e315a | ||
|
|
fe7fa46d57 | ||
|
|
007c5bc9f0 | ||
|
|
8c423b56df | ||
|
|
a868abb55a | ||
|
|
ecab34c787 | ||
|
|
307ea6dce2 | ||
|
|
d456b4f68e | ||
|
|
17e815348b | ||
|
|
953ab4b3cf | ||
|
|
9204780c1b | ||
|
|
fb2ed355ec | ||
|
|
675106cfa5 | ||
|
|
3aeadd9fb7 | ||
|
|
0e3eb38f11 | ||
|
|
dc23af6b32 | ||
|
|
b1bfa71338 | ||
|
|
71bff26607 | ||
|
|
3c190374b4 | ||
|
|
d8428463d8 | ||
|
|
725982cc5b | ||
|
|
f977dfcfe7 | ||
|
|
15079fa3bd | ||
|
|
79a92120ef | ||
|
|
a34565ca0f | ||
|
|
49ece586d5 | ||
|
|
2ec0778d78 | ||
|
|
cccd1cefbe | ||
|
|
8f145fa7fa | ||
|
|
ceb32f63e7 | ||
|
|
576c12b184 | ||
|
|
e2c3ca9950 | ||
|
|
8585e0e9b8 | ||
|
|
7394374a15 | ||
|
|
37defa739b | ||
|
|
51ed3fbc4b | ||
|
|
ab78075d06 | ||
|
|
52070ea577 | ||
|
|
f930303d3e | ||
|
|
268fb37517 | ||
|
|
ff17101316 | ||
|
|
ab536e5199 | ||
|
|
c10b3017d6 | ||
|
|
0f63e1f988 | ||
|
|
3bb537c183 | ||
|
|
ff23bf6f0c | ||
|
|
00d3e18780 | ||
|
|
a62f300753 | ||
|
|
0bc644abf0 | ||
|
|
31b7d076b7 | ||
|
|
a11687fc5c | ||
|
|
fa346cec3b | ||
|
|
0bdf7a598a | ||
|
|
0c9a1a56c2 | ||
|
|
c0655b6b08 | ||
|
|
dca9b83ec0 | ||
|
|
7ded90ae6a | ||
|
|
a6ab66080e | ||
|
|
89e1cad470 | ||
|
|
e55bc92d1f | ||
|
|
d6a59b538f | ||
|
|
1a87f44325 | ||
|
|
c8bc535f22 | ||
|
|
1889db3263 | ||
|
|
73b88f2304 | ||
|
|
21b8e5a5c6 | ||
|
|
b1ff14162f | ||
|
|
c6c55823ac | ||
|
|
8b8a970098 | ||
|
|
ebfcee6e67 | ||
|
|
63b330439e | ||
|
|
52d8fb301c | ||
|
|
dfe159e719 | ||
|
|
4e7e45a431 | ||
|
|
d81bd296fc | ||
|
|
6d3f257439 | ||
|
|
f92b24221a | ||
|
|
afd78f3f0b | ||
|
|
44f3f51e0d | ||
|
|
14a35e7c21 | ||
|
|
d173bb6e0a | ||
|
|
ce859c9e92 | ||
|
|
8ed20f3c28 | ||
|
|
0ced7d8e56 | ||
|
|
143ead8d00 | ||
|
|
6788c2710f | ||
|
|
ed7c10f366 | ||
|
|
68b93c624f | ||
|
|
36fe1e4a46 | ||
|
|
9ee4e4e05c | ||
|
|
ea65a0c519 | ||
|
|
f35d2629d4 | ||
|
|
0e5578204e | ||
|
|
063a465227 | ||
|
|
230fb921ec | ||
|
|
82a93d8406 | ||
|
|
2dda8634e9 | ||
|
|
2f313b799a | ||
|
|
d371256913 | ||
|
|
a7ec93b287 | ||
|
|
2c5001a5b3 | ||
|
|
191221eec5 | ||
|
|
27f374a38b | ||
|
|
baa813c46f | ||
|
|
79a22b1f8d | ||
|
|
087940ec9e | ||
|
|
8a46931e34 | ||
|
|
a9313fc0c3 | ||
|
|
dfba35aee8 | ||
|
|
5ae77b4317 | ||
|
|
a0bb2cdc6e | ||
|
|
0a5680c3e8 | ||
|
|
00764406d7 | ||
|
|
3ead99b088 | ||
|
|
8c0803e3c5 | ||
|
|
2da8df6202 | ||
|
|
17a75a5aa5 | ||
|
|
8b26d0104c | ||
|
|
36622c3578 | ||
|
|
fd4df6f9bb | ||
|
|
5d18d60e3b | ||
|
|
e4d98597c7 | ||
|
|
72da14e414 | ||
|
|
8ada404c5f | ||
|
|
ebba30d671 | ||
|
|
909d24cde6 | ||
|
|
4e912ef83d | ||
|
|
b17dfff3fd | ||
|
|
52dc415d0b | ||
|
|
392232246e | ||
|
|
cf54ad8242 | ||
|
|
fdfa5c0602 | ||
|
|
50ee5d28cd | ||
|
|
f74a82776f | ||
|
|
3553e65089 | ||
|
|
ad7c5886bc | ||
|
|
b30090f946 | ||
|
|
8f637975a4 | ||
|
|
94a764d6ea | ||
|
|
38e40862fe | ||
|
|
5ea78f55f2 | ||
|
|
a515db4aea | ||
|
|
90e979d0d9 | ||
|
|
8232857d07 | ||
|
|
2ae56564ef | ||
|
|
f24a0170be | ||
|
|
fd56465931 | ||
|
|
376e199ebb | ||
|
|
a837a27b34 | ||
|
|
62bd43f17f | ||
|
|
917b4ff8bc | ||
|
|
5fe7c065dc | ||
|
|
e074ad4807 | ||
|
|
5f3fe4acff | ||
|
|
4ccc197451 | ||
|
|
237cf19a77 | ||
|
|
2206e221bd | ||
|
|
d9bb9b73ad | ||
|
|
d5c382bb1a | ||
|
|
52daf6cf41 | ||
|
|
74a7303c23 | ||
|
|
d8a9991738 | ||
|
|
ca1c8243c8 | ||
|
|
14b3a5be56 | ||
|
|
ed89df7e9d | ||
|
|
1bedc16544 | ||
|
|
ac0b97a571 | ||
|
|
7b3d670e23 | ||
|
|
c9f4e91df8 | ||
|
|
c0ed169fdc | ||
|
|
412894bfc8 | ||
|
|
aad6e5648b | ||
|
|
8f1423946f | ||
|
|
51da4856e2 | ||
|
|
3b56c58f00 | ||
|
|
4fd2531302 | ||
|
|
fdef238a83 | ||
|
|
9787901ddb | ||
|
|
6e58c9f7c8 | ||
|
|
a08450bcb6 | ||
|
|
a92d9d442b | ||
|
|
e2ff77b4ec | ||
|
|
caf7a93382 | ||
|
|
afcda2f724 | ||
|
|
fcea723aa7 | ||
|
|
faf80588ab | ||
|
|
fc589611e2 | ||
|
|
5ecd350311 | ||
|
|
4b6c6c59b5 | ||
|
|
0f8ffa6226 | ||
|
|
6def61dfe9 | ||
|
|
b39bebee06 | ||
|
|
dce189fc6d | ||
|
|
0a4c72e78b | ||
|
|
d66700a0e4 | ||
|
|
b59a22bef0 | ||
|
|
9b1930588f | ||
|
|
18bb64cd43 | ||
|
|
d975187433 | ||
|
|
910863e9ea | ||
|
|
a38490429b | ||
|
|
80e8f6a0d1 | ||
|
|
e5ff5f7484 | ||
|
|
646240fc54 | ||
|
|
19cd7a248d | ||
|
|
f1b1d1ca75 | ||
|
|
e5bba2294d | ||
|
|
19cfd9b5d6 | ||
|
|
7e1b15a0cc | ||
|
|
19858c574d | ||
|
|
f891ea5713 | ||
|
|
d3311c81e5 | ||
|
|
b6bc4381fb | ||
|
|
b3d0561c09 | ||
|
|
1bbe901bcd | ||
|
|
4f8b4379f5 | ||
|
|
bc8a288386 | ||
|
|
3dc56de0ae | ||
|
|
b2e5809180 | ||
|
|
7e52523541 | ||
|
|
8bc83c5967 | ||
|
|
029c8c06c2 | ||
|
|
063fc0c48b | ||
|
|
191eeab589 | ||
|
|
3f8621e566 | ||
|
|
5f686ebb47 | ||
|
|
6a31457c6d | ||
|
|
e6f7912a25 | ||
|
|
8a2737566c | ||
|
|
006523ac59 | ||
|
|
c0e783eb6e | ||
|
|
399c78fbf7 | ||
|
|
a0a43046b3 | ||
|
|
e8af86017a | ||
|
|
382ffe9b6a | ||
|
|
e5b34d5cd5 | ||
|
|
0dba7b3313 | ||
|
|
27f2859258 | ||
|
|
eeed45da0f | ||
|
|
067dff8489 | ||
|
|
7d3151191d | ||
|
|
98fa1325f5 | ||
|
|
bd45b79ed8 | ||
|
|
0a616a9dbb | ||
|
|
a534c397f5 | ||
|
|
737589ec01 | ||
|
|
a7f8ee90c0 | ||
|
|
b14683200a | ||
|
|
c82410bfda | ||
|
|
00ad837eb4 | ||
|
|
9ab54030b9 | ||
|
|
5ad6849d4e | ||
|
|
7fcf25a78f | ||
|
|
5c205c43d1 | ||
|
|
f20f49d872 | ||
|
|
fb63c3908c | ||
|
|
623eb42a6a | ||
|
|
6afc06b97e | ||
|
|
cdd5b1ed26 | ||
|
|
884b4026dd | ||
|
|
62f49c55ce | ||
|
|
0b4b6c498d | ||
|
|
409f70c7f3 | ||
|
|
bb19fe703a | ||
|
|
eef1e3e77e | ||
|
|
562ba1291e | ||
|
|
3adf6d25f6 | ||
|
|
beece6a828 | ||
|
|
207ab2aa5b | ||
|
|
4ccc2550d0 | ||
|
|
0c9e398bef | ||
|
|
af2d348543 | ||
|
|
23bc10dfe6 | ||
|
|
13f72decf4 | ||
|
|
3ad7de0fcb | ||
|
|
48408b0a0b | ||
|
|
cd7d1f2bfe | ||
|
|
ed66a46113 | ||
|
|
8e4e30d266 | ||
|
|
f988dcd6f9 | ||
|
|
143091edad | ||
|
|
79e0405f6a | ||
|
|
316f81119f | ||
|
|
8d016040ab | ||
|
|
4da6986a68 | ||
|
|
3b8a4e56b0 | ||
|
|
966cd6a8ca | ||
|
|
f243cd86c9 | ||
|
|
1a5d866a91 | ||
|
|
a1d8ed83dd | ||
|
|
7f284c404f | ||
|
|
d1b3b6a0ed | ||
|
|
9b37bc667f | ||
|
|
4eea68b5a4 | ||
|
|
87429bc03c | ||
|
|
6c28448e84 | ||
|
|
843ba4ac2c | ||
|
|
d6545588a3 | ||
|
|
26b375a0de | ||
|
|
2f1cac604d | ||
|
|
8e56763c98 | ||
|
|
e94e1cc72f | ||
|
|
8ae00697c9 | ||
|
|
b0c6d891e9 | ||
|
|
548164cd5e | ||
|
|
4dfe36feb1 | ||
|
|
0d1c2a3b2a | ||
|
|
378fd60756 | ||
|
|
fa569b32fb | ||
|
|
78f8317de8 | ||
|
|
6e8637fbc9 | ||
|
|
8403aae928 | ||
|
|
b43c8da66b | ||
|
|
da85bdc401 | ||
|
|
7e486e3b5c | ||
|
|
062e423125 | ||
|
|
3d8face1f9 | ||
|
|
0c99fc5b4d | ||
|
|
51d7d5d0da | ||
|
|
c959584831 | ||
|
|
fa796d668f | ||
|
|
e4ee4ec3d1 | ||
|
|
0073a93079 | ||
|
|
7e124cf95e | ||
|
|
c647bed9d5 | ||
|
|
6f330f961b | ||
|
|
140ead65b6 | ||
|
|
f12fd3707e | ||
|
|
55091d9deb | ||
|
|
1b3427acd9 | ||
|
|
60d1ac4fec | ||
|
|
9b133a978d | ||
|
|
203c749e6c | ||
|
|
f3e2d2f68f | ||
|
|
a359f45df2 | ||
|
|
e8b6d48ad0 | ||
|
|
8ba79d6ab9 | ||
|
|
57c9eeeecb | ||
|
|
f78c4fa751 | ||
|
|
3ba6e9db5d | ||
|
|
610246c48f | ||
|
|
d0e18e3d20 | ||
|
|
72cfdbbb4e | ||
|
|
15296dedd5 | ||
|
|
943cc68f54 | ||
|
|
3bb4d0b276 | ||
|
|
9cc2217a26 | ||
|
|
ee687ee433 | ||
|
|
9b56b67c0e | ||
|
|
48655e882e | ||
|
|
7f49d37a51 | ||
|
|
9f8a1168e6 | ||
|
|
c18d177b8c | ||
|
|
7bde2b5cbf | ||
|
|
7b3377e78c | ||
|
|
feed900f3d | ||
|
|
7530057c6e | ||
|
|
a6b3f6b5d4 | ||
|
|
76f870a30a | ||
|
|
02092f315e | ||
|
|
9ef9284a34 | ||
|
|
820acb981b | ||
|
|
2516fd90eb | ||
|
|
de23368d03 | ||
|
|
4df57fda09 | ||
|
|
6f45832aed | ||
|
|
fec0415d4e | ||
|
|
04c7d87261 | ||
|
|
6abf3db13e | ||
|
|
99000e68b7 | ||
|
|
bef046a51a | ||
|
|
78322a6321 | ||
|
|
46fa2dd2f0 | ||
|
|
451399b344 | ||
|
|
22a8e57a57 | ||
|
|
9cd279e0e9 | ||
|
|
b67eaa3abd | ||
|
|
046c9b56f5 | ||
|
|
6ad80247ce | ||
|
|
0b744edfa4 | ||
|
|
0d8bb78f66 | ||
|
|
28ecc68841 | ||
|
|
7c7aba1202 | ||
|
|
74a1d70b8a | ||
|
|
165a5aaa83 | ||
|
|
8b407a32ff | ||
|
|
04856aded0 | ||
|
|
a9c238a1fc | ||
|
|
8d2f107d61 | ||
|
|
3f16ace678 | ||
|
|
344b9bdba3 | ||
|
|
834ea94eb9 | ||
|
|
a060cc5893 | ||
|
|
7ef0b3b821 | ||
|
|
39a2fd1717 | ||
|
|
c66ec4df3d | ||
|
|
c25c48f763 | ||
|
|
5105d8d87e | ||
|
|
35af336ff6 | ||
|
|
157ca12d4b | ||
|
|
e9d1a54983 | ||
|
|
c8981c048f | ||
|
|
1ae44c6b3c | ||
|
|
b2887477e3 | ||
|
|
8e2db29c9a | ||
|
|
d38de7365a | ||
|
|
cde6067cae | ||
|
|
2583638f4b | ||
|
|
11360b018f | ||
|
|
bdfc62184d | ||
|
|
74f06d550a | ||
|
|
46986ad4c2 | ||
|
|
6a5d6471c5 | ||
|
|
cf0850edfd | ||
|
|
fd4ac87382 | ||
|
|
164144f126 | ||
|
|
f2ad4a2e8e | ||
|
|
df23913bb8 | ||
|
|
4ccf26fbcc | ||
|
|
081e277fe4 | ||
|
|
dcecab384a | ||
|
|
4f9b07e979 | ||
|
|
9b97c55546 | ||
|
|
364d3dbbf8 | ||
|
|
9f3a4d1640 | ||
|
|
5fca92994f | ||
|
|
fefd17fe5e | ||
|
|
6b243fbcd3 | ||
|
|
82f8c3834e | ||
|
|
e0ba91db31 | ||
|
|
fa148bf59f | ||
|
|
1b0ce33669 | ||
|
|
0cf2a1eb33 | ||
|
|
8a46a8ecb2 | ||
|
|
4f0221bc4f | ||
|
|
ce08bb2ad2 | ||
|
|
93f797326e | ||
|
|
ceba377ab8 | ||
|
|
b9b6e867df | ||
|
|
f47caefdb9 | ||
|
|
41ae7bccc2 | ||
|
|
1e27024d75 | ||
|
|
6654fff377 | ||
|
|
89d999df72 | ||
|
|
a941d82be3 | ||
|
|
694cdf5ae1 | ||
|
|
2bfe4afea2 | ||
|
|
d559c3fe2e | ||
|
|
27df727ca1 | ||
|
|
8910226d2f | ||
|
|
04f58b1a31 | ||
|
|
1b9dd0c75f | ||
|
|
a7af415b6a | ||
|
|
f8a5a59513 | ||
|
|
ac3dfb3f96 | ||
|
|
d957d23d8f | ||
|
|
d049947801 | ||
|
|
21a10c3c74 | ||
|
|
04951f8b34 | ||
|
|
c08bae6aeb | ||
|
|
3aa107c4ae | ||
|
|
e196091714 | ||
|
|
d35d65cc40 | ||
|
|
7f7b30959b | ||
|
|
70322077d2 | ||
|
|
f529b2e057 | ||
|
|
c6372a1b3f | ||
|
|
41b8db063c | ||
|
|
1b16758d7e | ||
|
|
51b5adc306 | ||
|
|
56f8993b8c | ||
|
|
8c4d1ca587 | ||
|
|
ec8b3593f3 | ||
|
|
5c9b42e260 | ||
|
|
7914c92824 | ||
|
|
208be0f4d4 | ||
|
|
7cfac5bb59 | ||
|
|
1bd09bfd40 | ||
|
|
517751f2a3 | ||
|
|
006952c571 | ||
|
|
7a8b7201a1 | ||
|
|
1157e4d7b2 | ||
|
|
6b8e7b16f6 | ||
|
|
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 |
4
.gitattributes
vendored
Normal file
4
.gitattributes
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
.gitattributes export-ignore
|
||||||
|
.gitignore export-ignore
|
||||||
|
/build_tools export-ignore
|
||||||
|
|
||||||
34
.gitignore
vendored
Normal file
34
.gitignore
vendored
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
*.o
|
||||||
|
*~
|
||||||
|
|
||||||
|
Doxyfile.help
|
||||||
|
Makefile
|
||||||
|
autom4te.cache/
|
||||||
|
builtin_scripts.cpp
|
||||||
|
builtin_scripts.h
|
||||||
|
command_list.txt
|
||||||
|
config.h
|
||||||
|
config.h.in
|
||||||
|
config.log
|
||||||
|
config.status
|
||||||
|
configure
|
||||||
|
doc.h
|
||||||
|
doc_src/commands.hdr
|
||||||
|
doc_src/index.hdr
|
||||||
|
po/*.gmo
|
||||||
|
fish
|
||||||
|
fish.spec
|
||||||
|
fish_indent
|
||||||
|
fish_pager
|
||||||
|
fish_tests
|
||||||
|
fishd
|
||||||
|
mimedb
|
||||||
|
seq
|
||||||
|
set_color
|
||||||
|
share/config.fish
|
||||||
|
share/man/
|
||||||
|
toc.txt
|
||||||
|
user_doc/
|
||||||
|
xsel-1.2.0/
|
||||||
|
tests/*tmp.*
|
||||||
|
tests/foo.txt
|
||||||
3
CHANGELOG
Normal file
3
CHANGELOG
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
24-01-2012 Jan Kanis
|
||||||
|
* Added a changelog file
|
||||||
|
* removed unescaping if the 'commandline' builtin is called without the -o (tokenise) flag
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -10,8 +10,8 @@ ABBREVIATE_BRIEF = YES
|
|||||||
ALWAYS_DETAILED_SEC = NO
|
ALWAYS_DETAILED_SEC = NO
|
||||||
INLINE_INHERITED_MEMB = NO
|
INLINE_INHERITED_MEMB = NO
|
||||||
FULL_PATH_NAMES = YES
|
FULL_PATH_NAMES = YES
|
||||||
STRIP_FROM_PATH =
|
STRIP_FROM_PATH =
|
||||||
STRIP_FROM_INC_PATH =
|
STRIP_FROM_INC_PATH =
|
||||||
SHORT_NAMES = NO
|
SHORT_NAMES = NO
|
||||||
JAVADOC_AUTOBRIEF = YES
|
JAVADOC_AUTOBRIEF = YES
|
||||||
MULTILINE_CPP_IS_BRIEF = NO
|
MULTILINE_CPP_IS_BRIEF = NO
|
||||||
@@ -19,7 +19,7 @@ DETAILS_AT_TOP = NO
|
|||||||
INHERIT_DOCS = YES
|
INHERIT_DOCS = YES
|
||||||
DISTRIBUTE_GROUP_DOC = NO
|
DISTRIBUTE_GROUP_DOC = NO
|
||||||
TAB_SIZE = 8
|
TAB_SIZE = 8
|
||||||
ALIASES =
|
ALIASES =
|
||||||
OPTIMIZE_OUTPUT_FOR_C = YES
|
OPTIMIZE_OUTPUT_FOR_C = YES
|
||||||
OPTIMIZE_OUTPUT_JAVA = NO
|
OPTIMIZE_OUTPUT_JAVA = NO
|
||||||
SUBGROUPING = YES
|
SUBGROUPING = YES
|
||||||
@@ -44,7 +44,7 @@ GENERATE_TODOLIST = YES
|
|||||||
GENERATE_TESTLIST = YES
|
GENERATE_TESTLIST = YES
|
||||||
GENERATE_BUGLIST = YES
|
GENERATE_BUGLIST = YES
|
||||||
GENERATE_DEPRECATEDLIST= YES
|
GENERATE_DEPRECATEDLIST= YES
|
||||||
ENABLED_SECTIONS =
|
ENABLED_SECTIONS =
|
||||||
MAX_INITIALIZER_LINES = 30
|
MAX_INITIALIZER_LINES = 30
|
||||||
SHOW_USED_FILES = YES
|
SHOW_USED_FILES = YES
|
||||||
SHOW_DIRECTORIES = YES
|
SHOW_DIRECTORIES = YES
|
||||||
@@ -53,19 +53,19 @@ WARNINGS = YES
|
|||||||
WARN_IF_UNDOCUMENTED = YES
|
WARN_IF_UNDOCUMENTED = YES
|
||||||
WARN_IF_DOC_ERROR = YES
|
WARN_IF_DOC_ERROR = YES
|
||||||
WARN_FORMAT = "$file:$line: $text"
|
WARN_FORMAT = "$file:$line: $text"
|
||||||
WARN_LOGFILE =
|
WARN_LOGFILE =
|
||||||
INPUT =
|
INPUT =
|
||||||
FILE_PATTERNS = doc.h
|
FILE_PATTERNS = doc.h
|
||||||
RECURSIVE = NO
|
RECURSIVE = NO
|
||||||
EXCLUDE =
|
EXCLUDE =
|
||||||
EXCLUDE_SYMLINKS = NO
|
EXCLUDE_SYMLINKS = NO
|
||||||
EXCLUDE_PATTERNS =
|
EXCLUDE_PATTERNS =
|
||||||
EXAMPLE_PATH =
|
EXAMPLE_PATH =
|
||||||
EXAMPLE_PATTERNS =
|
EXAMPLE_PATTERNS =
|
||||||
EXAMPLE_RECURSIVE = NO
|
EXAMPLE_RECURSIVE = NO
|
||||||
IMAGE_PATH =
|
IMAGE_PATH =
|
||||||
INPUT_FILTER =
|
INPUT_FILTER =
|
||||||
FILTER_PATTERNS =
|
FILTER_PATTERNS =
|
||||||
FILTER_SOURCE_FILES = NO
|
FILTER_SOURCE_FILES = NO
|
||||||
SOURCE_BROWSER = NO
|
SOURCE_BROWSER = NO
|
||||||
INLINE_SOURCES = NO
|
INLINE_SOURCES = NO
|
||||||
@@ -75,17 +75,17 @@ REFERENCES_RELATION = YES
|
|||||||
VERBATIM_HEADERS = YES
|
VERBATIM_HEADERS = YES
|
||||||
ALPHABETICAL_INDEX = NO
|
ALPHABETICAL_INDEX = NO
|
||||||
COLS_IN_ALPHA_INDEX = 5
|
COLS_IN_ALPHA_INDEX = 5
|
||||||
IGNORE_PREFIX =
|
IGNORE_PREFIX =
|
||||||
GENERATE_HTML = YES
|
GENERATE_HTML = YES
|
||||||
HTML_OUTPUT = html
|
HTML_OUTPUT = html
|
||||||
HTML_FILE_EXTENSION = .html
|
HTML_FILE_EXTENSION = .html
|
||||||
HTML_HEADER = user_doc.head.html
|
HTML_HEADER = user_doc.head.html
|
||||||
HTML_FOOTER =
|
HTML_FOOTER =
|
||||||
HTML_STYLESHEET =
|
HTML_STYLESHEET =
|
||||||
HTML_ALIGN_MEMBERS = YES
|
HTML_ALIGN_MEMBERS = YES
|
||||||
GENERATE_HTMLHELP = NO
|
GENERATE_HTMLHELP = NO
|
||||||
CHM_FILE =
|
CHM_FILE =
|
||||||
HHC_LOCATION =
|
HHC_LOCATION =
|
||||||
GENERATE_CHI = NO
|
GENERATE_CHI = NO
|
||||||
BINARY_TOC = NO
|
BINARY_TOC = NO
|
||||||
TOC_EXPAND = NO
|
TOC_EXPAND = NO
|
||||||
@@ -99,8 +99,8 @@ LATEX_CMD_NAME = latex
|
|||||||
MAKEINDEX_CMD_NAME = makeindex
|
MAKEINDEX_CMD_NAME = makeindex
|
||||||
COMPACT_LATEX = NO
|
COMPACT_LATEX = NO
|
||||||
PAPER_TYPE = a4wide
|
PAPER_TYPE = a4wide
|
||||||
EXTRA_PACKAGES =
|
EXTRA_PACKAGES =
|
||||||
LATEX_HEADER =
|
LATEX_HEADER =
|
||||||
PDF_HYPERLINKS = YES
|
PDF_HYPERLINKS = YES
|
||||||
USE_PDFLATEX = YES
|
USE_PDFLATEX = YES
|
||||||
LATEX_BATCHMODE = NO
|
LATEX_BATCHMODE = NO
|
||||||
@@ -109,33 +109,33 @@ GENERATE_RTF = NO
|
|||||||
RTF_OUTPUT = rtf
|
RTF_OUTPUT = rtf
|
||||||
COMPACT_RTF = NO
|
COMPACT_RTF = NO
|
||||||
RTF_HYPERLINKS = NO
|
RTF_HYPERLINKS = NO
|
||||||
RTF_STYLESHEET_FILE =
|
RTF_STYLESHEET_FILE =
|
||||||
RTF_EXTENSIONS_FILE =
|
RTF_EXTENSIONS_FILE =
|
||||||
GENERATE_MAN = NO
|
GENERATE_MAN = NO
|
||||||
MAN_OUTPUT = man
|
MAN_OUTPUT = man
|
||||||
MAN_EXTENSION = .3
|
MAN_EXTENSION = .3
|
||||||
MAN_LINKS = NO
|
MAN_LINKS = NO
|
||||||
GENERATE_XML = NO
|
GENERATE_XML = NO
|
||||||
XML_OUTPUT = xml
|
XML_OUTPUT = xml
|
||||||
XML_SCHEMA =
|
XML_SCHEMA =
|
||||||
XML_DTD =
|
XML_DTD =
|
||||||
XML_PROGRAMLISTING = YES
|
XML_PROGRAMLISTING = YES
|
||||||
GENERATE_AUTOGEN_DEF = NO
|
GENERATE_AUTOGEN_DEF = NO
|
||||||
GENERATE_PERLMOD = NO
|
GENERATE_PERLMOD = NO
|
||||||
PERLMOD_LATEX = NO
|
PERLMOD_LATEX = NO
|
||||||
PERLMOD_PRETTY = YES
|
PERLMOD_PRETTY = YES
|
||||||
PERLMOD_MAKEVAR_PREFIX =
|
PERLMOD_MAKEVAR_PREFIX =
|
||||||
ENABLE_PREPROCESSING = YES
|
ENABLE_PREPROCESSING = YES
|
||||||
MACRO_EXPANSION = NO
|
MACRO_EXPANSION = NO
|
||||||
EXPAND_ONLY_PREDEF = NO
|
EXPAND_ONLY_PREDEF = NO
|
||||||
SEARCH_INCLUDES = YES
|
SEARCH_INCLUDES = YES
|
||||||
INCLUDE_PATH =
|
INCLUDE_PATH =
|
||||||
INCLUDE_FILE_PATTERNS =
|
INCLUDE_FILE_PATTERNS =
|
||||||
PREDEFINED =
|
PREDEFINED =
|
||||||
EXPAND_AS_DEFINED =
|
EXPAND_AS_DEFINED =
|
||||||
SKIP_FUNCTION_MACROS = YES
|
SKIP_FUNCTION_MACROS = YES
|
||||||
TAGFILES =
|
TAGFILES =
|
||||||
GENERATE_TAGFILE =
|
GENERATE_TAGFILE =
|
||||||
ALLEXTERNALS = NO
|
ALLEXTERNALS = NO
|
||||||
EXTERNAL_GROUPS = YES
|
EXTERNAL_GROUPS = YES
|
||||||
PERL_PATH = /usr/bin/perl
|
PERL_PATH = /usr/bin/perl
|
||||||
@@ -151,8 +151,8 @@ INCLUDED_BY_GRAPH = YES
|
|||||||
CALL_GRAPH = YES
|
CALL_GRAPH = YES
|
||||||
GRAPHICAL_HIERARCHY = YES
|
GRAPHICAL_HIERARCHY = YES
|
||||||
DOT_IMAGE_FORMAT = png
|
DOT_IMAGE_FORMAT = png
|
||||||
DOT_PATH =
|
DOT_PATH =
|
||||||
DOTFILE_DIRS =
|
DOTFILE_DIRS =
|
||||||
MAX_DOT_GRAPH_WIDTH = 750
|
MAX_DOT_GRAPH_WIDTH = 750
|
||||||
MAX_DOT_GRAPH_HEIGHT = 1024
|
MAX_DOT_GRAPH_HEIGHT = 1024
|
||||||
MAX_DOT_GRAPH_DEPTH = 0
|
MAX_DOT_GRAPH_DEPTH = 0
|
||||||
|
|||||||
1413
FishsFish.xcodeproj/project.pbxproj
Normal file
1413
FishsFish.xcodeproj/project.pbxproj
Normal file
File diff suppressed because it is too large
Load Diff
30
INSTALL
30
INSTALL
@@ -32,22 +32,32 @@ separate build directories or any other fancy configure options.
|
|||||||
Simple install procedure
|
Simple install procedure
|
||||||
========================
|
========================
|
||||||
|
|
||||||
If you have downloaded the darcs repository of fish, you need to run
|
Always begin by uninstalling any previous fish versions. This is done
|
||||||
the autoconf command first. Then use the following commands to compile
|
by running the command 'make uninstall' in the source directory of
|
||||||
fish:
|
your previous fish installation.
|
||||||
|
|
||||||
% ./configure
|
Next, if you have downloaded a fresh copy of the darcs repository of
|
||||||
% make # Compile fish
|
fish, you need to run the 'autoconf' command.
|
||||||
% make install # Install fish
|
|
||||||
% echo /usr/local/bin/fish >>/etc/shells # Add fish to list of shells
|
|
||||||
|
|
||||||
If you wish to use fish as your default shell, use the following
|
Then, use following commands to compile fish:
|
||||||
command:
|
|
||||||
|
|
||||||
% chsh -s /usr/local/bin/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
|
||||||
|
|
||||||
chsh will prompt you for your password, and change your default shell.
|
chsh will prompt you for your password, and change your default shell.
|
||||||
|
|
||||||
|
To switch your default shell back, you can run:
|
||||||
|
|
||||||
|
% chsh -s /bin/bash
|
||||||
|
|
||||||
|
Substitute /bin/bash with /bin/tcsh or /bin/zsh as appropriate.
|
||||||
|
|
||||||
Local install procedure
|
Local install procedure
|
||||||
=======================
|
=======================
|
||||||
|
|||||||
744
Makefile.in
744
Makefile.in
File diff suppressed because it is too large
Load Diff
15
README
15
README
@@ -1,15 +0,0 @@
|
|||||||
How to find documentation for fish
|
|
||||||
==================================
|
|
||||||
|
|
||||||
The fish documentation is distributed in an intermediate format. To
|
|
||||||
view it, you have to type:
|
|
||||||
|
|
||||||
% make user_doc
|
|
||||||
|
|
||||||
Which will create the directory user_doc, containing html
|
|
||||||
documentation for fish. If you build and install fish, the
|
|
||||||
documentation will be available through the 'help' builtin.
|
|
||||||
|
|
||||||
After installation, you can start fish by typing fish in the
|
|
||||||
terminal. After fish has started, try using the help command for more
|
|
||||||
information.
|
|
||||||
39
README.md
Normal file
39
README.md
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
[fish](http://ridiculousfish.com/shell/) - the friendly interactive shell
|
||||||
|
================================================
|
||||||
|
|
||||||
|
fish is a smart and user-friendly command line shell for OS X, Linux, and the rest of the family. fish includes features like syntax highlighting, autosuggest-as-you-type, and fancy tab completions that just work, with no configuration required.
|
||||||
|
|
||||||
|
For more on fish's design philosophy, see the [design document](http://ridiculousfish.com/shell/user_doc/html/design.html).
|
||||||
|
|
||||||
|
## Quick Start
|
||||||
|
|
||||||
|
fish generally works like other shells, like bash or zsh. A few important differences are documented at <http://ridiculousfish.com/shell/faq.html>
|
||||||
|
|
||||||
|
Detailed user documentation is available by running `help` within fish, and also at <http://ridiculousfish.com/shell/user_doc/html/>
|
||||||
|
|
||||||
|
## Building
|
||||||
|
|
||||||
|
fish can be built using autotools or Xcode.
|
||||||
|
|
||||||
|
### Autotools Build
|
||||||
|
|
||||||
|
autoconf
|
||||||
|
./configure [--without-xsel]
|
||||||
|
make [gmake on BSD]
|
||||||
|
sudo make install
|
||||||
|
|
||||||
|
### Xcode Development Build
|
||||||
|
|
||||||
|
* Build the `base` target in Xcode
|
||||||
|
* Run the fish executable, for example, in `DerivedData/FishsFish/Build/Products/Debug/base/bin/fish`
|
||||||
|
|
||||||
|
### Xcode Build and Install
|
||||||
|
|
||||||
|
mkdir /tmp/fish_build
|
||||||
|
xcodebuild install -target install_tree DSTROOT=/tmp/fish_build
|
||||||
|
sudo ditto /tmp/fish_build/ /
|
||||||
|
|
||||||
|
## Contact Us
|
||||||
|
|
||||||
|
Questions, comments, rants and raves can be posted to the official fish mailing list at <https://lists.sourceforge.net/lists/listinfo/fish-users>
|
||||||
|
Found a bug? Have an awesome idea? Please open an issue on this github page.
|
||||||
344
autoload.cpp
Normal file
344
autoload.cpp
Normal file
@@ -0,0 +1,344 @@
|
|||||||
|
/** \file autoload.cpp
|
||||||
|
|
||||||
|
The classes responsible for autoloading functions and completions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "autoload.h"
|
||||||
|
#include "wutil.h"
|
||||||
|
#include "common.h"
|
||||||
|
#include "signal.h"
|
||||||
|
#include "env.h"
|
||||||
|
#include "builtin_scripts.h"
|
||||||
|
#include "exec.h"
|
||||||
|
#include <assert.h>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
/* The time before we'll recheck an autoloaded file */
|
||||||
|
static const int kAutoloadStalenessInterval = 15;
|
||||||
|
|
||||||
|
file_access_attempt_t access_file(const wcstring &path, int mode) {
|
||||||
|
//printf("Touch %ls\n", path.c_str());
|
||||||
|
file_access_attempt_t result = {0};
|
||||||
|
struct stat statbuf;
|
||||||
|
if (wstat(path, &statbuf)) {
|
||||||
|
result.error = errno;
|
||||||
|
} else {
|
||||||
|
result.mod_time = statbuf.st_mtime;
|
||||||
|
if (waccess(path, mode)) {
|
||||||
|
result.error = errno;
|
||||||
|
} else {
|
||||||
|
result.accessible = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Note that we record the last checked time after the call, on the assumption that in a slow filesystem, the lag comes before the kernel check, not after.
|
||||||
|
result.stale = false;
|
||||||
|
result.last_checked = time(NULL);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
autoload_t::autoload_t(const wcstring &env_var_name_var, const builtin_script_t * const scripts, size_t script_count) :
|
||||||
|
lock(),
|
||||||
|
env_var_name(env_var_name_var),
|
||||||
|
builtin_scripts(scripts),
|
||||||
|
builtin_script_count(script_count),
|
||||||
|
last_path(),
|
||||||
|
is_loading_set()
|
||||||
|
{
|
||||||
|
pthread_mutex_init(&lock, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
autoload_t::~autoload_t() {
|
||||||
|
pthread_mutex_destroy(&lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
void autoload_t::node_was_evicted(autoload_function_t *node) {
|
||||||
|
// This should only ever happen on the main thread
|
||||||
|
ASSERT_IS_MAIN_THREAD();
|
||||||
|
|
||||||
|
// Tell ourselves that the command was removed if it was loaded
|
||||||
|
if (! node->is_loaded)
|
||||||
|
this->command_removed(node->key);
|
||||||
|
delete node;
|
||||||
|
}
|
||||||
|
|
||||||
|
int autoload_t::unload( const wcstring &cmd )
|
||||||
|
{
|
||||||
|
return this->evict_node(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
int autoload_t::load( const wcstring &cmd, bool reload )
|
||||||
|
{
|
||||||
|
int res;
|
||||||
|
CHECK_BLOCK( 0 );
|
||||||
|
ASSERT_IS_MAIN_THREAD();
|
||||||
|
|
||||||
|
env_var_t path_var = env_get_string( env_var_name );
|
||||||
|
|
||||||
|
/*
|
||||||
|
Do we know where to look?
|
||||||
|
*/
|
||||||
|
if( path_var.empty() )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* Check if the lookup path has changed. If so, drop all loaded files. path_var may only be inspected on the main thread. */
|
||||||
|
if( path_var != this->last_path )
|
||||||
|
{
|
||||||
|
this->last_path = path_var;
|
||||||
|
scoped_lock locker(lock);
|
||||||
|
this->evict_all_nodes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Warn and fail on infinite recursion. It's OK to do this because this function is only called on the main thread. */
|
||||||
|
if (this->is_loading(cmd))
|
||||||
|
{
|
||||||
|
debug( 0,
|
||||||
|
_( L"Could not autoload item '%ls', it is already being autoloaded. "
|
||||||
|
L"This is a circular dependency in the autoloading scripts, please remove it."),
|
||||||
|
cmd.c_str() );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Mark that we're loading this */
|
||||||
|
is_loading_set.insert(cmd);
|
||||||
|
|
||||||
|
/* Get the list of paths from which we will try to load */
|
||||||
|
std::vector<wcstring> path_list;
|
||||||
|
tokenize_variable_array( path_var, path_list );
|
||||||
|
|
||||||
|
/* Try loading it */
|
||||||
|
res = this->locate_file_and_maybe_load_it( cmd, true, reload, path_list );
|
||||||
|
|
||||||
|
/* Clean up */
|
||||||
|
bool erased = !! is_loading_set.erase(cmd);
|
||||||
|
assert(erased);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool autoload_t::can_load( const wcstring &cmd, const env_vars_snapshot_t &vars )
|
||||||
|
{
|
||||||
|
const env_var_t path_var = vars.get(env_var_name);
|
||||||
|
if (path_var.missing_or_empty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
std::vector<wcstring> path_list;
|
||||||
|
tokenize_variable_array( path_var, path_list );
|
||||||
|
return this->locate_file_and_maybe_load_it( cmd, false, false, path_list );
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool script_name_precedes_script_name(const builtin_script_t &script1, const builtin_script_t &script2)
|
||||||
|
{
|
||||||
|
return wcscmp(script1.name, script2.name) < 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void autoload_t::unload_all(void) {
|
||||||
|
scoped_lock locker(lock);
|
||||||
|
this->evict_all_nodes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Check whether the given command is loaded. */
|
||||||
|
bool autoload_t::has_tried_loading( const wcstring &cmd )
|
||||||
|
{
|
||||||
|
scoped_lock locker(lock);
|
||||||
|
autoload_function_t * func = this->get_node(cmd);
|
||||||
|
return func != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool is_stale(const autoload_function_t *func) {
|
||||||
|
/** Return whether this function is stale. Internalized functions can never be stale. */
|
||||||
|
return ! func->is_internalized && time(NULL) - func->access.last_checked > kAutoloadStalenessInterval;
|
||||||
|
}
|
||||||
|
|
||||||
|
autoload_function_t *autoload_t::get_autoloaded_function_with_creation(const wcstring &cmd, bool allow_eviction)
|
||||||
|
{
|
||||||
|
ASSERT_IS_LOCKED(lock);
|
||||||
|
autoload_function_t *func = this->get_node(cmd);
|
||||||
|
if (! func) {
|
||||||
|
func = new autoload_function_t(cmd);
|
||||||
|
if (allow_eviction) {
|
||||||
|
this->add_node(func);
|
||||||
|
} else {
|
||||||
|
this->add_node_without_eviction(func);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return func;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
This internal helper function does all the real work. By using two
|
||||||
|
functions, the internal function can return on various places in
|
||||||
|
the code, and the caller can take care of various cleanup work.
|
||||||
|
|
||||||
|
cmd: the command name ('grep')
|
||||||
|
really_load: whether to actually parse it as a function, or just check it it exists
|
||||||
|
reload: whether to reload it if it's already loaded
|
||||||
|
path_list: the set of paths to check
|
||||||
|
|
||||||
|
Result: if really_load is true, returns whether the function was loaded. Otherwise returns whether the function existed.
|
||||||
|
*/
|
||||||
|
bool autoload_t::locate_file_and_maybe_load_it( const wcstring &cmd, bool really_load, bool reload, const wcstring_list_t &path_list )
|
||||||
|
{
|
||||||
|
/* Note that we are NOT locked in this function! */
|
||||||
|
size_t i;
|
||||||
|
bool reloaded = 0;
|
||||||
|
|
||||||
|
/* Try using a cached function. If we really want the function to be loaded, require that it be really loaded. If we're not reloading, allow stale functions. */
|
||||||
|
{
|
||||||
|
bool allow_stale_functions = ! reload;
|
||||||
|
|
||||||
|
/* Take a lock */
|
||||||
|
scoped_lock locker(lock);
|
||||||
|
|
||||||
|
/* Get the function */
|
||||||
|
autoload_function_t * func = this->get_node(cmd);
|
||||||
|
|
||||||
|
/* Determine if we can use this cached function */
|
||||||
|
bool use_cached;
|
||||||
|
if (! func) {
|
||||||
|
/* Can't use a function that doesn't exist */
|
||||||
|
use_cached = false;
|
||||||
|
} else if (really_load && ! func->is_placeholder && ! func->is_loaded) {
|
||||||
|
/* Can't use an unloaded function */
|
||||||
|
use_cached = false;
|
||||||
|
} else if ( ! allow_stale_functions && is_stale(func)) {
|
||||||
|
/* Can't use a stale function */
|
||||||
|
use_cached = false;
|
||||||
|
} else {
|
||||||
|
/* I guess we can use it */
|
||||||
|
use_cached = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If we can use this function, return whether we were able to access it */
|
||||||
|
if (use_cached) {
|
||||||
|
return func->is_internalized || func->access.accessible;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* The source of the script will end up here */
|
||||||
|
wcstring script_source;
|
||||||
|
bool has_script_source = false;
|
||||||
|
|
||||||
|
/* Whether we found an accessible file */
|
||||||
|
bool found_file = false;
|
||||||
|
|
||||||
|
/* Look for built-in scripts via a binary search */
|
||||||
|
const builtin_script_t *matching_builtin_script = NULL;
|
||||||
|
if (builtin_script_count > 0)
|
||||||
|
{
|
||||||
|
const builtin_script_t test_script = {cmd.c_str(), NULL};
|
||||||
|
const builtin_script_t *array_end = builtin_scripts + builtin_script_count;
|
||||||
|
const builtin_script_t *found = std::lower_bound(builtin_scripts, array_end, test_script, script_name_precedes_script_name);
|
||||||
|
if (found != array_end && ! wcscmp(found->name, test_script.name))
|
||||||
|
{
|
||||||
|
/* We found it */
|
||||||
|
matching_builtin_script = found;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (matching_builtin_script) {
|
||||||
|
has_script_source = true;
|
||||||
|
script_source = str2wcstring(matching_builtin_script->def);
|
||||||
|
|
||||||
|
/* Make a node representing this function */
|
||||||
|
scoped_lock locker(lock);
|
||||||
|
autoload_function_t *func = this->get_autoloaded_function_with_creation(cmd, really_load);
|
||||||
|
|
||||||
|
/* This function is internalized */
|
||||||
|
func->is_internalized = true;
|
||||||
|
|
||||||
|
/* It's a fiction to say the script is loaded at this point, but we're definitely going to load it down below. */
|
||||||
|
if (really_load) func->is_loaded = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! has_script_source)
|
||||||
|
{
|
||||||
|
/* Iterate over path searching for suitable completion files */
|
||||||
|
for( i=0; i<path_list.size(); i++ )
|
||||||
|
{
|
||||||
|
wcstring next = path_list.at(i);
|
||||||
|
wcstring path = next + L"/" + cmd + L".fish";
|
||||||
|
|
||||||
|
const file_access_attempt_t access = access_file(path, R_OK);
|
||||||
|
if (access.accessible) {
|
||||||
|
/* Found it! */
|
||||||
|
found_file = true;
|
||||||
|
|
||||||
|
/* Now we're actually going to take the lock. */
|
||||||
|
scoped_lock locker(lock);
|
||||||
|
autoload_function_t *func = this->get_node(cmd);
|
||||||
|
|
||||||
|
/* Generate the source if we need to load it */
|
||||||
|
bool need_to_load_function = really_load && (func == NULL || func->access.mod_time != access.mod_time || ! func->is_loaded);
|
||||||
|
if (need_to_load_function) {
|
||||||
|
|
||||||
|
/* Generate the script source */
|
||||||
|
wcstring esc = escape_string(path, 1);
|
||||||
|
script_source = L". " + esc;
|
||||||
|
has_script_source = true;
|
||||||
|
|
||||||
|
/* Remove any loaded command because we are going to reload it. Note that this will deadlock if command_removed calls back into us. */
|
||||||
|
if (func && func->is_loaded) {
|
||||||
|
command_removed(cmd);
|
||||||
|
func->is_placeholder = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Mark that we're reloading it */
|
||||||
|
reloaded = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create the function if we haven't yet. This does not load it. Do not trigger eviction unless we are actually loading, because we don't want to evict off of the main thread. */
|
||||||
|
if (! func) {
|
||||||
|
func = get_autoloaded_function_with_creation(cmd, really_load);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* It's a fiction to say the script is loaded at this point, but we're definitely going to load it down below. */
|
||||||
|
if (need_to_load_function) func->is_loaded = true;
|
||||||
|
|
||||||
|
/* Unconditionally record our access time */
|
||||||
|
func->access = access;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
If no file or builtin script was found we insert a placeholder function.
|
||||||
|
Later we only research if the current time is at least five seconds later.
|
||||||
|
This way, the files won't be searched over and over again.
|
||||||
|
*/
|
||||||
|
if( ! found_file && ! has_script_source )
|
||||||
|
{
|
||||||
|
scoped_lock locker(lock);
|
||||||
|
/* Generate a placeholder */
|
||||||
|
autoload_function_t *func = this->get_node(cmd);
|
||||||
|
if (! func) {
|
||||||
|
func = new autoload_function_t(cmd);
|
||||||
|
func->is_placeholder = true;
|
||||||
|
if (really_load) {
|
||||||
|
this->add_node(func);
|
||||||
|
} else {
|
||||||
|
this->add_node_without_eviction(func);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func->access.last_checked = time(NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If we have a script, either built-in or a file source, then run it */
|
||||||
|
if (really_load && has_script_source)
|
||||||
|
{
|
||||||
|
if( exec_subshell( script_source) == -1 )
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Do nothing on failiure
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (really_load) {
|
||||||
|
return reloaded;
|
||||||
|
} else {
|
||||||
|
return found_file || has_script_source;
|
||||||
|
}
|
||||||
|
}
|
||||||
129
autoload.h
Normal file
129
autoload.h
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
/** \file autoload.h
|
||||||
|
|
||||||
|
The classes responsible for autoloading functions and completions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FISH_AUTOLOAD_H
|
||||||
|
#define FISH_AUTOLOAD_H
|
||||||
|
|
||||||
|
#include <wchar.h>
|
||||||
|
#include <map>
|
||||||
|
#include <set>
|
||||||
|
#include <list>
|
||||||
|
#include "common.h"
|
||||||
|
#include "lru.h"
|
||||||
|
|
||||||
|
/** A struct responsible for recording an attempt to access a file. */
|
||||||
|
struct file_access_attempt_t {
|
||||||
|
time_t mod_time; /** The modification time of the file */
|
||||||
|
time_t last_checked; /** When we last checked the file */
|
||||||
|
bool accessible; /** Whether we believe we could access this file */
|
||||||
|
bool stale; /** Whether the access attempt is stale */
|
||||||
|
int error; /** If we could not access the file, the error code */
|
||||||
|
};
|
||||||
|
|
||||||
|
file_access_attempt_t access_file(const wcstring &path, int mode);
|
||||||
|
|
||||||
|
struct autoload_function_t : public lru_node_t
|
||||||
|
{
|
||||||
|
autoload_function_t(const wcstring &key) : lru_node_t(key), access(), is_loaded(false), is_placeholder(false), is_internalized(false) { }
|
||||||
|
file_access_attempt_t access; /** The last access attempt */
|
||||||
|
bool is_loaded; /** Whether we have actually loaded this function */
|
||||||
|
bool is_placeholder; /** Whether we are a placeholder that stands in for "no such function". If this is true, then is_loaded must be false. */
|
||||||
|
bool is_internalized; /** Whether this function came from a builtin "internalized" script */
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct builtin_script_t;
|
||||||
|
class env_vars_snapshot_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
A class that represents a path from which we can autoload, and the autoloaded contents.
|
||||||
|
*/
|
||||||
|
class autoload_t : private lru_cache_t<autoload_function_t> {
|
||||||
|
private:
|
||||||
|
|
||||||
|
/** Lock for thread safety */
|
||||||
|
pthread_mutex_t lock;
|
||||||
|
|
||||||
|
/** The environment variable name */
|
||||||
|
const wcstring env_var_name;
|
||||||
|
|
||||||
|
/** Builtin script array */
|
||||||
|
const struct builtin_script_t *const builtin_scripts;
|
||||||
|
|
||||||
|
/** Builtin script count */
|
||||||
|
const size_t builtin_script_count;
|
||||||
|
|
||||||
|
/** The path from which we most recently autoloaded */
|
||||||
|
wcstring last_path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
A table containing all the files that are currently being
|
||||||
|
loaded. This is here to help prevent recursion.
|
||||||
|
*/
|
||||||
|
std::set<wcstring> is_loading_set;
|
||||||
|
|
||||||
|
bool is_loading(const wcstring &name) const {
|
||||||
|
return is_loading_set.find(name) != is_loading_set.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
void remove_all_functions(void) {
|
||||||
|
this->evict_all_nodes();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool locate_file_and_maybe_load_it( const wcstring &cmd, bool really_load, bool reload, const wcstring_list_t &path_list );
|
||||||
|
|
||||||
|
virtual void node_was_evicted(autoload_function_t *node);
|
||||||
|
|
||||||
|
autoload_function_t *get_autoloaded_function_with_creation(const wcstring &cmd, bool allow_eviction);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/** Overridable callback for when a command is removed */
|
||||||
|
virtual void command_removed(const wcstring &cmd) { }
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
/** Create an autoload_t for the given environment variable name */
|
||||||
|
autoload_t(const wcstring &env_var_name_var, const builtin_script_t *scripts, size_t script_count );
|
||||||
|
|
||||||
|
/** Destructor */
|
||||||
|
virtual ~autoload_t();
|
||||||
|
|
||||||
|
/**
|
||||||
|
Autoload the specified file, if it exists in the specified path. Do
|
||||||
|
not load it multiple times unless it's timestamp changes or
|
||||||
|
parse_util_unload is called.
|
||||||
|
|
||||||
|
Autoloading one file may unload another.
|
||||||
|
|
||||||
|
\param cmd the filename to search for. The suffix '.fish' is always added to this name
|
||||||
|
\param on_unload a callback function to run if a suitable file is found, which has not already been run. unload will also be called for old files which are unloaded.
|
||||||
|
\param reload wheter to recheck file timestamps on already loaded files
|
||||||
|
*/
|
||||||
|
int load( const wcstring &cmd, bool reload );
|
||||||
|
|
||||||
|
/** Check whether we have tried loading the given command. Does not do any I/O. */
|
||||||
|
bool has_tried_loading( const wcstring &cmd );
|
||||||
|
|
||||||
|
/**
|
||||||
|
Tell the autoloader that the specified file, in the specified path,
|
||||||
|
is no longer loaded.
|
||||||
|
|
||||||
|
\param cmd the filename to search for. The suffix '.fish' is always added to this name
|
||||||
|
\param on_unload a callback function which will be called before (re)loading a file, may be used to unload the previous file.
|
||||||
|
\return non-zero if the file was removed, zero if the file had not yet been loaded
|
||||||
|
*/
|
||||||
|
int unload( const wcstring &cmd );
|
||||||
|
|
||||||
|
/**
|
||||||
|
Unloads all files.
|
||||||
|
*/
|
||||||
|
void unload_all( );
|
||||||
|
|
||||||
|
/** Check whether the given command could be loaded, but do not load it. */
|
||||||
|
bool can_load( const wcstring &cmd, const env_vars_snapshot_t &vars );
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
3
build_tools/description-pak
Normal file
3
build_tools/description-pak
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
This is the_ridiculous'fish s delightful fork of, fish friendly interactive shell. For more information, visit http://ridiculousfish.com/shell/ .
|
||||||
|
|
||||||
|
This installer will install fish, but will not modify your /etc/shells file or your default shell. I trust you know how to do that yourself if you care to!
|
||||||
1
build_tools/fish_shell.pmdoc/01fish-contents.xml
Normal file
1
build_tools/fish_shell.pmdoc/01fish-contents.xml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<pkg-contents spec="1.12"/>
|
||||||
1
build_tools/fish_shell.pmdoc/01fish.xml
Normal file
1
build_tools/fish_shell.pmdoc/01fish.xml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<pkgref spec="1.12" uuid="6A7E1ED5-E40E-4ACE-959B-B9D77555AD39"><config><identifier>com.ridiculousfish.fish-shell.fishShell.fish_pkg.pkg</identifier><version>1.0</version><description></description><post-install type="none"/><requireAuthorization/><installFrom>/private/tmp/fish_pkg</installFrom><installTo>/</installTo><flags><followSymbolicLinks/></flags><packageStore type="internal"></packageStore><mod>parent</mod><mod>installTo</mod></config></pkgref>
|
||||||
40
build_tools/fish_shell.pmdoc/index.xml
Normal file
40
build_tools/fish_shell.pmdoc/index.xml
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<pkmkdoc spec="1.12"><properties><title>fish shell</title><organization>com.ridiculousfish.fish-shell</organization><userSees ui="easy"/><min-target os="3"/><domain anywhere="true"/></properties><distribution><versions min-spec="1.000000"/><scripts></scripts></distribution><contents><choice title="fish_pkg" id="fish shell" starts_selected="true" starts_enabled="true" starts_hidden="false"><pkgref id="com.ridiculousfish.fish-shell.fishShell.fish_pkg.pkg"/></choice></contents><resources bg-scale="proportional" bg-align="bottomleft"><locale lang="en"><resource mod="true" type="background">/Users/peter/Desktop/Untitled.pdf</resource><resource mime-type="text/rtf" kind="embedded" type="welcome"><![CDATA[{\rtf1\ansi\ansicpg1252\cocoartf1138\cocoasubrtf470
|
||||||
|
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
|
||||||
|
{\colortbl;\red255\green255\blue255;}
|
||||||
|
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
|
||||||
|
|
||||||
|
\f0\fs30 \cf0 This installs ridiculous_fish's fork of fish, a command line shell for Mac OS X, Linux, and the rest of the family. For more information on fish, visit {\field{\*\fldinst{HYPERLINK "http://ridiculousfish.com/shell/"}}{\fldrslt http://ridiculousfish.com/shell/}}\
|
||||||
|
\
|
||||||
|
The path to fish will be added to /etc/shells, but your default shell will not be modified. \
|
||||||
|
\
|
||||||
|
This release is beta r2.\
|
||||||
|
}]]></resource><resource mime-type="text/rtf" kind="embedded" type="conclusion"><![CDATA[{\rtf1\ansi\ansicpg1252\cocoartf1138\cocoasubrtf470
|
||||||
|
{\fonttbl\f0\fswiss\fcharset0 Helvetica;\f1\fnil\fcharset0 Monaco;}
|
||||||
|
{\colortbl;\red255\green255\blue255;}
|
||||||
|
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
|
||||||
|
|
||||||
|
\f0\fs26 \cf0 Run
|
||||||
|
\f1 fish
|
||||||
|
\f0 at the command line to start it up! Some useful commands:\
|
||||||
|
\
|
||||||
|
Interactively set your colors from a web page:\
|
||||||
|
\
|
||||||
|
|
||||||
|
\f1 fish_config
|
||||||
|
\f0 \
|
||||||
|
\
|
||||||
|
Update man-page completions:\
|
||||||
|
\
|
||||||
|
|
||||||
|
\f1 fish_update_completions
|
||||||
|
\f0 \
|
||||||
|
\
|
||||||
|
Make fish your default shell:\
|
||||||
|
\
|
||||||
|
|
||||||
|
\f1 chsh -s /usr/local/bin/fish\
|
||||||
|
|
||||||
|
\f0 \
|
||||||
|
\
|
||||||
|
Enjoy!\
|
||||||
|
}]]></resource></locale></resources><flags/><item type="file">01fish.xml</item><mod>properties.title</mod><mod>description</mod></pkmkdoc>
|
||||||
18
build_tools/make_deb.sh
Executable file
18
build_tools/make_deb.sh
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Terminate on error
|
||||||
|
set -e
|
||||||
|
|
||||||
|
sudo rm -Rf /tmp/fishfish
|
||||||
|
mkdir /tmp/fishfish
|
||||||
|
git archive --format=tar fish_fish | tar -x -C /tmp/fishfish
|
||||||
|
mkdir /tmp/fishfish/doc-pak
|
||||||
|
cp README INSTALL CHANGELOG release_notes.html /tmp/fishfish/doc-pak/
|
||||||
|
cp build_tools/description-pak /tmp/fishfish/
|
||||||
|
cd /tmp/fishfish
|
||||||
|
autoconf
|
||||||
|
./configure
|
||||||
|
make -j 3
|
||||||
|
sudo checkinstall --default --pakdir ~/fish_built/ --pkgversion 0.9 make install
|
||||||
|
mv ~/fish_built/fishfish_0.9-1_i386.deb ~/fish_built/fishfish_0.9_i386.deb
|
||||||
|
|
||||||
31
build_tools/make_pkg.sh
Executable file
31
build_tools/make_pkg.sh
Executable file
@@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/sh -x
|
||||||
|
|
||||||
|
make distclean
|
||||||
|
rm -rf /tmp/fish_pkg
|
||||||
|
mkdir -p /tmp/fish_pkg/
|
||||||
|
|
||||||
|
# Make sure what we build can run on SnowLeopard
|
||||||
|
export OSX_SDK="/Developer/SDKs/MacOSX10.6.sdk"
|
||||||
|
export MACOSX_DEPLOYMENT_TARGET="10.6"
|
||||||
|
export CC="clang -isysroot $OSX_SDK -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET"
|
||||||
|
export CCX="clang++ -isysroot $OSX_SDK -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET"
|
||||||
|
export CFLAGS="$CFLAGS -isysroot $OSX_SDK -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET"
|
||||||
|
export CXXFLAGS="$CXXFLAGS -isysroot $OSX_SDK -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET"
|
||||||
|
export LDFLAGS="$LDFLAGS -isysroot $OSX_SDK -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET"
|
||||||
|
autoconf
|
||||||
|
./configure --without-xsel
|
||||||
|
|
||||||
|
# Actually build it now
|
||||||
|
if make -j 4 DESTDIR=/tmp/fish_pkg install
|
||||||
|
then
|
||||||
|
echo "Root written to /tmp/fish_pkg/"
|
||||||
|
if /Developer/usr/bin/packagemaker --doc ./build_tools/fish_shell.pmdoc --out ~/fish_built/fishfish.pkg
|
||||||
|
then
|
||||||
|
echo "Package written to ~/fish_built/fishfish.pkg"
|
||||||
|
else
|
||||||
|
echo "Package could not be written"
|
||||||
|
fi
|
||||||
|
|
||||||
|
else
|
||||||
|
echo "Root could not be written"
|
||||||
|
fi
|
||||||
46
build_tools/make_tarball.sh
Executable file
46
build_tools/make_tarball.sh
Executable file
@@ -0,0 +1,46 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Script to generate a tarball
|
||||||
|
# We use git to output a tree. But we also want to build the user documentation
|
||||||
|
# and put that in the tarball, so that nobody needs to have doxygen installed
|
||||||
|
# to build it.
|
||||||
|
|
||||||
|
# Exit on error
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# We wil generate a tarball with a prefix "fish"
|
||||||
|
# git can do that automatically for us via git-archive
|
||||||
|
# but to get the documentation in, we need to make a symlink called "fish"
|
||||||
|
# and tar from that, so that the documentation gets the right prefix
|
||||||
|
|
||||||
|
# Get the current directory, which we'll use for symlinks
|
||||||
|
wd="$PWD"
|
||||||
|
|
||||||
|
# The name of the prefix, which is the directory that you get when you untar
|
||||||
|
prefix="fish"
|
||||||
|
|
||||||
|
# The path where we will output the tar file
|
||||||
|
path=~/fish_built/fish-2.0.tar
|
||||||
|
|
||||||
|
# Clean up stuff we've written before
|
||||||
|
rm -f "$path" "$path".gz
|
||||||
|
|
||||||
|
# git starts the archive
|
||||||
|
git archive --format=tar --prefix="$prefix"/ master > "$path"
|
||||||
|
|
||||||
|
# tarball out the documentation
|
||||||
|
make user_doc
|
||||||
|
make share/man
|
||||||
|
cd /tmp
|
||||||
|
rm -f "$prefix"
|
||||||
|
ln -s "$wd" "$prefix"
|
||||||
|
tar --append --file="$path" "$prefix"/user_doc/html
|
||||||
|
tar --append --file="$path" "$prefix"/share/man
|
||||||
|
rm -f "$prefix"
|
||||||
|
|
||||||
|
# gzip it
|
||||||
|
gzip "$path"
|
||||||
|
|
||||||
|
# Output what we did, and the sha1 hash
|
||||||
|
echo "Tarball written to $path".gz
|
||||||
|
openssl sha1 "$path".gz
|
||||||
53
build_tools/osx_package_scripts/add-shell
Executable file
53
build_tools/osx_package_scripts/add-shell
Executable file
@@ -0,0 +1,53 @@
|
|||||||
|
#!/bin/sh -e
|
||||||
|
|
||||||
|
# Modified from Debian's add-shell to work on OS X
|
||||||
|
|
||||||
|
if test $# -eq 0
|
||||||
|
then
|
||||||
|
echo usage: $0 shellname [shellname ...]
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
scriptname=`basename "$0"`
|
||||||
|
if [[ $UID -ne 0 ]]; then
|
||||||
|
echo "${scriptname} must be run as root"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
file=/etc/shells
|
||||||
|
# I want this to be GUARANTEED to be on the same filesystem as $file
|
||||||
|
tmpfile=${file}.tmp
|
||||||
|
|
||||||
|
set -o noclobber
|
||||||
|
|
||||||
|
trap "rm -f $tmpfile" EXIT
|
||||||
|
|
||||||
|
if ! cat $file > $tmpfile
|
||||||
|
then
|
||||||
|
cat 1>&2 <<EOF
|
||||||
|
Either another instance of $0 is running, or it was previously interrupted.
|
||||||
|
Please examine ${tmpfile} to see if it should be moved onto ${file}.
|
||||||
|
EOF
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Append a newline if it doesn't exist
|
||||||
|
if [ "$(tail -c1 "$tmpfile"; echo x)" != $'\nx' ]; then
|
||||||
|
echo "" >> "$tmpfile"
|
||||||
|
fi
|
||||||
|
|
||||||
|
for i
|
||||||
|
do
|
||||||
|
if ! grep -q "^${i}$" "$tmpfile"
|
||||||
|
then
|
||||||
|
echo $i >> "$tmpfile"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
chmod 0644 $tmpfile
|
||||||
|
chown root:wheel $tmpfile
|
||||||
|
|
||||||
|
mv $tmpfile $file
|
||||||
|
|
||||||
|
trap "" EXIT
|
||||||
|
exit 0
|
||||||
3
build_tools/osx_package_scripts/postinstall
Executable file
3
build_tools/osx_package_scripts/postinstall
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/sh -x
|
||||||
|
|
||||||
|
./add-shell /usr/local/bin/fish > /tmp/fish_postinstall_output.log
|
||||||
4105
builtin.cpp
Normal file
4105
builtin.cpp
Normal file
File diff suppressed because it is too large
Load Diff
65
builtin.h
65
builtin.h
@@ -8,6 +8,10 @@
|
|||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "io.h"
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
|
class parser_t;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
@@ -35,12 +39,12 @@ enum
|
|||||||
/**
|
/**
|
||||||
Error message on multiple scope levels for variables
|
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
|
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
|
Error message for unknown switch
|
||||||
@@ -69,6 +73,10 @@ enum
|
|||||||
|
|
||||||
#define BUILTIN_FOR_ERR_NAME _( L"%ls: '%ls' is not a valid variable name\n" )
|
#define BUILTIN_FOR_ERR_NAME _( L"%ls: '%ls' is not a valid variable name\n" )
|
||||||
|
|
||||||
|
/** Error messages for 'else if' */
|
||||||
|
#define BUILTIN_ELSEIF_ERR_COUNT _( L"%ls: can only take 'if' and then another command as an argument\n")
|
||||||
|
#define BUILTIN_ELSEIF_ERR_ARGUMENT _( L"%ls: any second argument must be 'if'\n")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Error message when too many arguments are supplied to a builtin
|
Error message when too many arguments are supplied to a builtin
|
||||||
*/
|
*/
|
||||||
@@ -85,15 +93,13 @@ enum
|
|||||||
#define BUILTIN_END_BLOCK_UNKNOWN _( L"%ls: Unknown block type '%ls'\n" )
|
#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" )
|
#define BUILTIN_ERR_NOT_NUMBER _( L"%ls: Argument '%ls' is not a number\n" )
|
||||||
/**
|
|
||||||
Stringbuffer used to represent standard output
|
|
||||||
*/
|
|
||||||
extern string_buffer_t *sb_out;
|
|
||||||
|
|
||||||
/**
|
/** Get the string used to represent stdout and stderr */
|
||||||
Stringbuffer used to represent standard error
|
const wcstring &get_stdout_buffer();
|
||||||
*/
|
const wcstring &get_stderr_buffer();
|
||||||
extern string_buffer_t *sb_err;
|
|
||||||
|
/** Output an error */
|
||||||
|
void builtin_show_error(const wcstring &err);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Kludge. Tells builtins if output is to screen
|
Kludge. Tells builtins if output is to screen
|
||||||
@@ -119,40 +125,43 @@ void builtin_destroy();
|
|||||||
/**
|
/**
|
||||||
Is there a builtin command with the given name?
|
Is there a builtin command with the given name?
|
||||||
*/
|
*/
|
||||||
int builtin_exists( wchar_t *cmd );
|
int builtin_exists( const wcstring &cmd );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Execute a builtin command
|
Execute a builtin command
|
||||||
|
|
||||||
|
\param parser The parser being used
|
||||||
\param argv Array containing the command and parameters
|
\param argv Array containing the command and parameters
|
||||||
of the builtin. The list is terminated by a
|
of the builtin. The list is terminated by a
|
||||||
null pointer. This syntax resembles the syntax
|
null pointer. This syntax resembles the syntax
|
||||||
for exec.
|
for exec.
|
||||||
|
\param io the io redirections to perform on this builtin.
|
||||||
|
|
||||||
\return the exit status of the builtin command
|
\return the exit status of the builtin command
|
||||||
*/
|
*/
|
||||||
int builtin_run( wchar_t **argv );
|
int builtin_run( parser_t &parser, const wchar_t * const *argv, const io_chain_t &io );
|
||||||
|
|
||||||
|
/** Returns a list of all builtin names */
|
||||||
|
wcstring_list_t builtin_get_names(void);
|
||||||
|
|
||||||
|
/** Insert all builtin names into list. */
|
||||||
|
void builtin_get_names(std::vector<completion_t> &list);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Insert all builtin names into l. These are not copies of the strings and should not be freed after use.
|
Pushes a new set of input/output to the stack. The new stdin is supplied, a new set of output strings is created.
|
||||||
*/
|
*/
|
||||||
void builtin_get_names( array_list_t *list );
|
void builtin_push_io( parser_t &parser, int stdin_fd );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Pushes a new set of input/output to the stack. The new stdin is supplied, a new set of output string_buffer_ts is created.
|
Pops a set of input/output from the stack. The output strings are destroued, but the input file is not closed.
|
||||||
*/
|
*/
|
||||||
void builtin_push_io( int stdin_fd );
|
void builtin_pop_io(parser_t &parser);
|
||||||
|
|
||||||
/**
|
|
||||||
Pops a set of input/output from the stack. The output string_buffer_ts are destroued, but the input file is not closed.
|
|
||||||
*/
|
|
||||||
void builtin_pop_io();
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Return a one-line description of the specified builtin
|
Return a one-line description of the specified builtin.
|
||||||
*/
|
*/
|
||||||
const wchar_t *builtin_get_desc( const wchar_t *b );
|
wcstring builtin_get_desc( const wcstring &b );
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -164,12 +173,10 @@ const wchar_t *builtin_complete_get_temporary_buffer();
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Return the help text for the specified builtin command. Use
|
Run the __fish_print_help function to obtain the help information
|
||||||
non-wide characters since wide characters have some issues with
|
for the specified command.
|
||||||
string formating escape sequences sometimes.
|
|
||||||
|
|
||||||
\param cmd The command for which to obtain help text
|
|
||||||
*/
|
*/
|
||||||
char *builtin_help_get( const wchar_t *cmd );
|
|
||||||
|
wcstring builtin_help_get( parser_t &parser, const wchar_t *cmd );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -52,13 +52,21 @@ enum
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
static wchar_t *current_buffer=0;
|
/**
|
||||||
static int current_cursor_pos = -1;
|
Pointer to what the commandline builtin considers to be the current
|
||||||
|
contents of the command line buffer.
|
||||||
|
*/
|
||||||
|
static const wchar_t *current_buffer=0;
|
||||||
|
/**
|
||||||
|
What the commandline builtin considers to be the current cursor
|
||||||
|
position.
|
||||||
|
*/
|
||||||
|
static size_t current_cursor_pos = (size_t)(-1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the current commandline buffer.
|
Returns the current commandline buffer.
|
||||||
*/
|
*/
|
||||||
static wchar_t *get_buffer()
|
static const wchar_t *get_buffer()
|
||||||
{
|
{
|
||||||
return current_buffer;
|
return current_buffer;
|
||||||
}
|
}
|
||||||
@@ -66,7 +74,7 @@ static wchar_t *get_buffer()
|
|||||||
/**
|
/**
|
||||||
Returns the position of the cursor
|
Returns the position of the cursor
|
||||||
*/
|
*/
|
||||||
static int get_cursor_pos()
|
static size_t get_cursor_pos()
|
||||||
{
|
{
|
||||||
return current_cursor_pos;
|
return current_cursor_pos;
|
||||||
}
|
}
|
||||||
@@ -82,46 +90,44 @@ static int get_cursor_pos()
|
|||||||
*/
|
*/
|
||||||
static void replace_part( const wchar_t *begin,
|
static void replace_part( const wchar_t *begin,
|
||||||
const wchar_t *end,
|
const wchar_t *end,
|
||||||
wchar_t *insert,
|
const wchar_t *insert,
|
||||||
int append_mode )
|
int append_mode )
|
||||||
{
|
{
|
||||||
const wchar_t *buff = get_buffer();
|
const wchar_t *buff = get_buffer();
|
||||||
string_buffer_t out;
|
size_t out_pos = get_cursor_pos();
|
||||||
int out_pos=get_cursor_pos();
|
|
||||||
|
wcstring out;
|
||||||
sb_init( &out );
|
|
||||||
|
|
||||||
sb_append_substring( &out, buff, begin-buff );
|
out.append(buff, begin - buff);
|
||||||
|
|
||||||
switch( append_mode)
|
switch( append_mode)
|
||||||
{
|
{
|
||||||
case REPLACE_MODE:
|
case REPLACE_MODE:
|
||||||
{
|
{
|
||||||
|
|
||||||
sb_append( &out, insert );
|
out.append(insert);
|
||||||
out_pos = wcslen( insert ) + (begin-buff);
|
out_pos = wcslen( insert ) + (begin-buff);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
case APPEND_MODE:
|
case APPEND_MODE:
|
||||||
{
|
{
|
||||||
sb_append_substring( &out, begin, end-begin );
|
out.append( begin, end-begin );
|
||||||
sb_append( &out, insert );
|
out.append( insert );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case INSERT_MODE:
|
case INSERT_MODE:
|
||||||
{
|
{
|
||||||
int cursor = get_cursor_pos() -(begin-buff);
|
long cursor = get_cursor_pos() -(begin-buff);
|
||||||
sb_append_substring( &out, begin, cursor );
|
out.append( begin, cursor );
|
||||||
sb_append( &out, insert );
|
out.append( insert );
|
||||||
sb_append_substring( &out, begin+cursor, end-begin-cursor );
|
out.append( begin+cursor, end-begin-cursor );
|
||||||
out_pos += wcslen( insert );
|
out_pos += wcslen( insert );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sb_append( &out, end );
|
out.append( end );
|
||||||
reader_set_buffer( (wchar_t *)out.buff, out_pos );
|
reader_set_buffer( out, out_pos );
|
||||||
sb_destroy( &out );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -138,18 +144,17 @@ static void write_part( const wchar_t *begin,
|
|||||||
int tokenize )
|
int tokenize )
|
||||||
{
|
{
|
||||||
tokenizer tok;
|
tokenizer tok;
|
||||||
string_buffer_t out;
|
wcstring out;
|
||||||
wchar_t *buff;
|
wchar_t *buff;
|
||||||
int pos;
|
size_t pos;
|
||||||
|
|
||||||
pos = get_cursor_pos()-(begin-get_buffer());
|
pos = get_cursor_pos()-(begin-get_buffer());
|
||||||
|
|
||||||
if( tokenize )
|
if( tokenize )
|
||||||
{
|
{
|
||||||
|
|
||||||
buff = wcsndup( begin, end-begin );
|
buff = wcsndup( begin, end-begin );
|
||||||
// fwprintf( stderr, L"Subshell: %ls, end char %lc\n", buff, *end );
|
// fwprintf( stderr, L"Subshell: %ls, end char %lc\n", buff, *end );
|
||||||
sb_init( &out );
|
out.clear();
|
||||||
|
|
||||||
for( tok_init( &tok, buff, TOK_ACCEPT_UNFINISHED );
|
for( tok_init( &tok, buff, TOK_ACCEPT_UNFINISHED );
|
||||||
tok_has_next( &tok );
|
tok_has_next( &tok );
|
||||||
@@ -159,24 +164,22 @@ static void write_part( const wchar_t *begin,
|
|||||||
(tok_get_pos( &tok)+wcslen(tok_last( &tok)) >= pos) )
|
(tok_get_pos( &tok)+wcslen(tok_last( &tok)) >= pos) )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// fwprintf( stderr, L"Next token %ls\n", tok_last( &tok ) );
|
|
||||||
|
|
||||||
switch( tok_last_type( &tok ) )
|
switch( tok_last_type( &tok ) )
|
||||||
{
|
{
|
||||||
case TOK_STRING:
|
case TOK_STRING:
|
||||||
sb_append2( &out, tok_last( &tok), L"\n", (void *)0 );
|
{
|
||||||
|
out.append(escape_string(tok_last( &tok ), UNESCAPE_INCOMPLETE));
|
||||||
|
out.push_back(L'\n');
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( out.buff )
|
stdout_buffer.append(out);
|
||||||
sb_append( sb_out,
|
|
||||||
(wchar_t *)out.buff );
|
|
||||||
|
|
||||||
free( buff );
|
free( buff );
|
||||||
tok_destroy( &tok );
|
tok_destroy( &tok );
|
||||||
sb_destroy( &out );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -184,8 +187,12 @@ static void write_part( const wchar_t *begin,
|
|||||||
{
|
{
|
||||||
end = begin+pos;
|
end = begin+pos;
|
||||||
}
|
}
|
||||||
sb_append_substring( sb_out, begin, end-begin );
|
|
||||||
sb_append( sb_out, L"\n" );
|
// debug( 0, L"woot2 %ls -> %ls", buff, esc );
|
||||||
|
|
||||||
|
stdout_buffer.append(begin, end - begin);
|
||||||
|
stdout_buffer.append(L"\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,7 +201,7 @@ static void write_part( const wchar_t *begin,
|
|||||||
The commandline builtin. It is used for specifying a new value for
|
The commandline builtin. It is used for specifying a new value for
|
||||||
the commandline.
|
the commandline.
|
||||||
*/
|
*/
|
||||||
static int builtin_commandline( wchar_t **argv )
|
static int builtin_commandline( parser_t &parser, wchar_t **argv )
|
||||||
{
|
{
|
||||||
|
|
||||||
int buffer_part=0;
|
int buffer_part=0;
|
||||||
@@ -208,7 +215,9 @@ static int builtin_commandline( wchar_t **argv )
|
|||||||
int tokenize = 0;
|
int tokenize = 0;
|
||||||
|
|
||||||
int cursor_mode = 0;
|
int cursor_mode = 0;
|
||||||
wchar_t *begin, *end;
|
int line_mode = 0;
|
||||||
|
int search_mode = 0;
|
||||||
|
const wchar_t *begin, *end;
|
||||||
|
|
||||||
current_buffer = (wchar_t *)builtin_complete_get_temporary_buffer();
|
current_buffer = (wchar_t *)builtin_complete_get_temporary_buffer();
|
||||||
if( current_buffer )
|
if( current_buffer )
|
||||||
@@ -223,19 +232,27 @@ static int builtin_commandline( wchar_t **argv )
|
|||||||
|
|
||||||
if( !get_buffer() )
|
if( !get_buffer() )
|
||||||
{
|
{
|
||||||
sb_append2( sb_err,
|
if (is_interactive_session)
|
||||||
argv[0],
|
{
|
||||||
L": Can not set commandline in non-interactive mode\n",
|
/*
|
||||||
(void *)0 );
|
Prompt change requested while we don't have
|
||||||
builtin_print_help( argv[0], sb_err );
|
a prompt, most probably while reading the
|
||||||
return 1;
|
init files. Just ignore it.
|
||||||
}
|
*/
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
stderr_buffer.append(argv[0]);
|
||||||
|
stderr_buffer.append(L": Can not set commandline in non-interactive mode\n");
|
||||||
|
builtin_print_help( parser, argv[0], stderr_buffer );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
woptind=0;
|
woptind=0;
|
||||||
|
|
||||||
while( 1 )
|
while( 1 )
|
||||||
{
|
{
|
||||||
const static struct woption
|
static const struct woption
|
||||||
long_options[] =
|
long_options[] =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
@@ -290,6 +307,14 @@ static int builtin_commandline( wchar_t **argv )
|
|||||||
L"cursor", no_argument, 0, 'C'
|
L"cursor", no_argument, 0, 'C'
|
||||||
}
|
}
|
||||||
,
|
,
|
||||||
|
{
|
||||||
|
L"line", no_argument, 0, 'L'
|
||||||
|
}
|
||||||
|
,
|
||||||
|
{
|
||||||
|
L"search-mode", no_argument, 0, 'S'
|
||||||
|
}
|
||||||
|
,
|
||||||
{
|
{
|
||||||
0, 0, 0, 0
|
0, 0, 0, 0
|
||||||
}
|
}
|
||||||
@@ -300,7 +325,7 @@ static int builtin_commandline( wchar_t **argv )
|
|||||||
|
|
||||||
int opt = wgetopt_long( argc,
|
int opt = wgetopt_long( argc,
|
||||||
argv,
|
argv,
|
||||||
L"aijpctwforhI:C",
|
L"abijpctwforhI:CLS",
|
||||||
long_options,
|
long_options,
|
||||||
&opt_index );
|
&opt_index );
|
||||||
if( opt == -1 )
|
if( opt == -1 )
|
||||||
@@ -311,17 +336,22 @@ static int builtin_commandline( wchar_t **argv )
|
|||||||
case 0:
|
case 0:
|
||||||
if(long_options[opt_index].flag != 0)
|
if(long_options[opt_index].flag != 0)
|
||||||
break;
|
break;
|
||||||
sb_printf( sb_err,
|
append_format( stderr_buffer,
|
||||||
BUILTIN_ERR_UNKNOWN,
|
BUILTIN_ERR_UNKNOWN,
|
||||||
argv[0],
|
argv[0],
|
||||||
long_options[opt_index].name );
|
long_options[opt_index].name );
|
||||||
builtin_print_help( argv[0], sb_err );
|
builtin_print_help( parser, argv[0], stderr_buffer );
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
case L'a':
|
case L'a':
|
||||||
append_mode = APPEND_MODE;
|
append_mode = APPEND_MODE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case L'b':
|
||||||
|
buffer_part = STRING_MODE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
case L'i':
|
case L'i':
|
||||||
append_mode = INSERT_MODE;
|
append_mode = INSERT_MODE;
|
||||||
@@ -364,12 +394,20 @@ static int builtin_commandline( wchar_t **argv )
|
|||||||
cursor_mode = 1;
|
cursor_mode = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'L':
|
||||||
|
line_mode = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'S':
|
||||||
|
search_mode = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'h':
|
case 'h':
|
||||||
builtin_print_help( argv[0], sb_out );
|
builtin_print_help( parser, argv[0], stdout_buffer );
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case L'?':
|
case L'?':
|
||||||
builtin_print_help( argv[0], sb_err );
|
builtin_unknown_option( parser, argv[0], argv[woptind-1] );
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -381,29 +419,29 @@ static int builtin_commandline( wchar_t **argv )
|
|||||||
/*
|
/*
|
||||||
Check for invalid switch combinations
|
Check for invalid switch combinations
|
||||||
*/
|
*/
|
||||||
if( buffer_part || cut_at_cursor || append_mode || tokenize || cursor_mode )
|
if( buffer_part || cut_at_cursor || append_mode || tokenize || cursor_mode || line_mode || search_mode )
|
||||||
{
|
{
|
||||||
sb_printf(sb_err,
|
append_format(stderr_buffer,
|
||||||
BUILTIN_ERR_COMBO,
|
BUILTIN_ERR_COMBO,
|
||||||
argv[0] );
|
argv[0] );
|
||||||
|
|
||||||
builtin_print_help( argv[0], sb_err );
|
builtin_print_help( parser, argv[0], stderr_buffer );
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if( argc == woptind )
|
if( argc == woptind )
|
||||||
{
|
{
|
||||||
sb_printf( sb_err,
|
append_format(stderr_buffer,
|
||||||
BUILTIN_ERR_MISSING,
|
BUILTIN_ERR_MISSING,
|
||||||
argv[0] );
|
argv[0] );
|
||||||
|
|
||||||
builtin_print_help( argv[0], sb_err );
|
builtin_print_help( parser, argv[0], stderr_buffer );
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
for( i=woptind; i<argc; i++ )
|
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 )
|
if( c != -1 )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@@ -415,11 +453,11 @@ static int builtin_commandline( wchar_t **argv )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sb_printf( sb_err,
|
append_format(stderr_buffer,
|
||||||
_(L"%ls: Unknown readline function '%ls'\n"),
|
_(L"%ls: Unknown input function '%ls'\n"),
|
||||||
argv[0],
|
argv[0],
|
||||||
argv[i] );
|
argv[i] );
|
||||||
builtin_print_help( argv[0], sb_err );
|
builtin_print_help( parser, argv[0], stderr_buffer );
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -430,48 +468,48 @@ static int builtin_commandline( wchar_t **argv )
|
|||||||
/*
|
/*
|
||||||
Check for invalid switch combinations
|
Check for invalid switch combinations
|
||||||
*/
|
*/
|
||||||
if( cursor_mode && (argc-woptind > 1) )
|
if( (search_mode || line_mode || cursor_mode) && (argc-woptind > 1) )
|
||||||
{
|
{
|
||||||
|
|
||||||
sb_append2( sb_err,
|
append_format(stderr_buffer,
|
||||||
argv[0],
|
argv[0],
|
||||||
L": Too many arguments\n",
|
L": Too many arguments\n",
|
||||||
(void *)0 );
|
NULL );
|
||||||
builtin_print_help( argv[0], sb_err );
|
builtin_print_help( parser, argv[0], stderr_buffer );
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( (buffer_part || tokenize || cut_at_cursor) && cursor_mode )
|
if( (buffer_part || tokenize || cut_at_cursor) && (cursor_mode || line_mode || search_mode) )
|
||||||
{
|
{
|
||||||
sb_printf( sb_err,
|
append_format(stderr_buffer,
|
||||||
BUILTIN_ERR_COMBO,
|
BUILTIN_ERR_COMBO,
|
||||||
argv[0] );
|
argv[0] );
|
||||||
|
|
||||||
builtin_print_help( argv[0], sb_err );
|
builtin_print_help( parser, argv[0], stderr_buffer );
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if( (tokenize || cut_at_cursor) && (argc-woptind) )
|
if( (tokenize || cut_at_cursor) && (argc-woptind) )
|
||||||
{
|
{
|
||||||
sb_printf( sb_err,
|
append_format(stderr_buffer,
|
||||||
BUILTIN_ERR_COMBO2,
|
BUILTIN_ERR_COMBO2,
|
||||||
argv[0],
|
argv[0],
|
||||||
L"--cut-at-cursor and --tokenize can not be used when setting the commandline" );
|
L"--cut-at-cursor and --tokenize can not be used when setting the commandline" );
|
||||||
|
|
||||||
|
|
||||||
builtin_print_help( argv[0], sb_err );
|
builtin_print_help( parser, argv[0], stderr_buffer );
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( append_mode && !(argc-woptind) )
|
if( append_mode && !(argc-woptind) )
|
||||||
{
|
{
|
||||||
sb_printf( sb_err,
|
append_format(stderr_buffer,
|
||||||
BUILTIN_ERR_COMBO2,
|
BUILTIN_ERR_COMBO2,
|
||||||
argv[0],
|
argv[0],
|
||||||
L"insertion mode switches can not be used when not in insertion mode" );
|
L"insertion mode switches can not be used when not in insertion mode" );
|
||||||
|
|
||||||
builtin_print_help( argv[0], sb_err );
|
builtin_print_help( parser, argv[0], stderr_buffer );
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -493,32 +531,46 @@ static int builtin_commandline( wchar_t **argv )
|
|||||||
if( argc-woptind )
|
if( argc-woptind )
|
||||||
{
|
{
|
||||||
wchar_t *endptr;
|
wchar_t *endptr;
|
||||||
int new_pos;
|
long new_pos;
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
|
||||||
new_pos = wcstol( argv[woptind], &endptr, 10 );
|
new_pos = wcstol( argv[woptind], &endptr, 10 );
|
||||||
if( *endptr || errno )
|
if( *endptr || errno )
|
||||||
{
|
{
|
||||||
sb_printf( sb_err,
|
append_format(stderr_buffer,
|
||||||
BUILTIN_ERR_NOT_NUMBER,
|
BUILTIN_ERR_NOT_NUMBER,
|
||||||
argv[0],
|
argv[0],
|
||||||
argv[woptind] );
|
argv[woptind] );
|
||||||
builtin_print_help( argv[0], sb_err );
|
builtin_print_help( parser, argv[0], stderr_buffer );
|
||||||
}
|
}
|
||||||
|
|
||||||
current_buffer = reader_get_buffer();
|
current_buffer = reader_get_buffer();
|
||||||
new_pos = maxi( 0, mini( new_pos, wcslen( current_buffer ) ) );
|
new_pos = maxi( 0L, mini( new_pos, (long)wcslen( current_buffer ) ) );
|
||||||
reader_set_buffer( current_buffer, new_pos );
|
reader_set_buffer( current_buffer, (size_t)new_pos );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sb_printf( sb_out, L"%d\n", reader_get_cursor_pos() );
|
append_format(stdout_buffer, L"%lu\n", (unsigned long)reader_get_cursor_pos() );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( line_mode )
|
||||||
|
{
|
||||||
|
size_t pos = reader_get_cursor_pos();
|
||||||
|
const wchar_t *buff = reader_get_buffer();
|
||||||
|
append_format(stdout_buffer, L"%lu\n", (unsigned long)parse_util_lineno( buff, pos ) );
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if( search_mode )
|
||||||
|
{
|
||||||
|
return !reader_search_mode();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
switch( buffer_part )
|
switch( buffer_part )
|
||||||
{
|
{
|
||||||
@@ -575,21 +627,16 @@ static int builtin_commandline( wchar_t **argv )
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
string_buffer_t sb;
|
wcstring sb = argv[woptind];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
sb_init( &sb );
|
|
||||||
|
|
||||||
sb_append( &sb, argv[woptind] );
|
|
||||||
|
|
||||||
for( i=woptind+1; i<argc; i++ )
|
for( i=woptind+1; i<argc; i++ )
|
||||||
{
|
{
|
||||||
sb_append( &sb, L"\n" );
|
sb.push_back(L'\n');
|
||||||
sb_append( &sb, argv[i] );
|
sb.append(argv[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
replace_part( begin, end, (wchar_t *)sb.buff, append_mode );
|
replace_part( begin, end, sb.c_str(), append_mode );
|
||||||
sb_destroy( &sb );
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -26,9 +26,9 @@ Functions used for implementing the complete builtin.
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Internal storage for the builtin_get_temporary_buffer() function.
|
Internal storage for the builtin_complete_get_temporary_buffer() function.
|
||||||
*/
|
*/
|
||||||
const static wchar_t *temporary_buffer;
|
static const wchar_t *temporary_buffer;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
builtin_complete_* are a set of rather silly looping functions that
|
builtin_complete_* are a set of rather silly looping functions that
|
||||||
@@ -45,15 +45,15 @@ const static wchar_t *temporary_buffer;
|
|||||||
static void builtin_complete_add2( const wchar_t *cmd,
|
static void builtin_complete_add2( const wchar_t *cmd,
|
||||||
int cmd_type,
|
int cmd_type,
|
||||||
const wchar_t *short_opt,
|
const wchar_t *short_opt,
|
||||||
array_list_t *gnu_opt,
|
const wcstring_list_t &gnu_opt,
|
||||||
array_list_t *old_opt,
|
const wcstring_list_t &old_opt,
|
||||||
int result_mode,
|
int result_mode,
|
||||||
int authorative,
|
|
||||||
const wchar_t *condition,
|
const wchar_t *condition,
|
||||||
const wchar_t *comp,
|
const wchar_t *comp,
|
||||||
const wchar_t *desc )
|
const wchar_t *desc,
|
||||||
|
int flags )
|
||||||
{
|
{
|
||||||
int i;
|
size_t i;
|
||||||
const wchar_t *s;
|
const wchar_t *s;
|
||||||
|
|
||||||
for( s=short_opt; *s; s++ )
|
for( s=short_opt; *s; s++ )
|
||||||
@@ -64,41 +64,41 @@ static void builtin_complete_add2( const wchar_t *cmd,
|
|||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
result_mode,
|
result_mode,
|
||||||
authorative,
|
|
||||||
condition,
|
condition,
|
||||||
comp,
|
comp,
|
||||||
desc );
|
desc,
|
||||||
|
flags );
|
||||||
}
|
}
|
||||||
|
|
||||||
for( i=0; i<al_get_count( gnu_opt ); i++ )
|
for( i=0; i<gnu_opt.size(); i++ )
|
||||||
{
|
{
|
||||||
complete_add( cmd,
|
complete_add( cmd,
|
||||||
cmd_type,
|
cmd_type,
|
||||||
0,
|
0,
|
||||||
(wchar_t *)al_get(gnu_opt, i ),
|
gnu_opt.at(i).c_str(),
|
||||||
0,
|
0,
|
||||||
result_mode,
|
result_mode,
|
||||||
authorative,
|
|
||||||
condition,
|
condition,
|
||||||
comp,
|
comp,
|
||||||
desc );
|
desc,
|
||||||
|
flags );
|
||||||
}
|
}
|
||||||
|
|
||||||
for( i=0; i<al_get_count( old_opt ); i++ )
|
for( i=0; i<old_opt.size(); i++ )
|
||||||
{
|
{
|
||||||
complete_add( cmd,
|
complete_add( cmd,
|
||||||
cmd_type,
|
cmd_type,
|
||||||
0,
|
0,
|
||||||
(wchar_t *)al_get(old_opt, i ),
|
old_opt.at(i).c_str(),
|
||||||
1,
|
1,
|
||||||
result_mode,
|
result_mode,
|
||||||
authorative,
|
|
||||||
condition,
|
condition,
|
||||||
comp,
|
comp,
|
||||||
desc );
|
desc,
|
||||||
|
flags );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( al_get_count( old_opt )+al_get_count( gnu_opt )+wcslen(short_opt) == 0 )
|
if( old_opt.size() == 0 && gnu_opt.size() == 0 && wcslen(short_opt) == 0 )
|
||||||
{
|
{
|
||||||
complete_add( cmd,
|
complete_add( cmd,
|
||||||
cmd_type,
|
cmd_type,
|
||||||
@@ -106,93 +106,105 @@ static void builtin_complete_add2( const wchar_t *cmd,
|
|||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
result_mode,
|
result_mode,
|
||||||
authorative,
|
|
||||||
condition,
|
condition,
|
||||||
comp,
|
comp,
|
||||||
desc );
|
desc,
|
||||||
|
flags );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Silly function
|
Silly function
|
||||||
*/
|
*/
|
||||||
static void builtin_complete_add( array_list_t *cmd,
|
static void builtin_complete_add( const wcstring_list_t &cmd,
|
||||||
array_list_t *path,
|
const wcstring_list_t &path,
|
||||||
const wchar_t *short_opt,
|
const wchar_t *short_opt,
|
||||||
array_list_t *gnu_opt,
|
wcstring_list_t &gnu_opt,
|
||||||
array_list_t *old_opt,
|
wcstring_list_t &old_opt,
|
||||||
int result_mode,
|
int result_mode,
|
||||||
int authorative,
|
int authoritative,
|
||||||
const wchar_t *condition,
|
const wchar_t *condition,
|
||||||
const wchar_t *comp,
|
const wchar_t *comp,
|
||||||
const wchar_t *desc )
|
const wchar_t *desc,
|
||||||
|
int flags )
|
||||||
{
|
{
|
||||||
int i;
|
for( size_t i=0; i<cmd.size(); i++ )
|
||||||
|
|
||||||
for( i=0; i<al_get_count( cmd ); i++ )
|
|
||||||
{
|
{
|
||||||
builtin_complete_add2( al_get( cmd, i ),
|
builtin_complete_add2( cmd.at(i).c_str(),
|
||||||
COMMAND,
|
COMMAND,
|
||||||
short_opt,
|
short_opt,
|
||||||
gnu_opt,
|
gnu_opt,
|
||||||
old_opt,
|
old_opt,
|
||||||
result_mode,
|
result_mode,
|
||||||
authorative,
|
|
||||||
condition,
|
condition,
|
||||||
comp,
|
comp,
|
||||||
desc );
|
desc,
|
||||||
|
flags );
|
||||||
|
|
||||||
|
if( authoritative != -1 )
|
||||||
|
{
|
||||||
|
complete_set_authoritative( cmd.at(i).c_str(),
|
||||||
|
COMMAND,
|
||||||
|
authoritative );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for( i=0; i<al_get_count( path ); i++ )
|
for( size_t i=0; i<path.size(); i++ )
|
||||||
{
|
{
|
||||||
builtin_complete_add2( al_get( path, i ),
|
builtin_complete_add2( path.at(i).c_str(),
|
||||||
PATH,
|
PATH,
|
||||||
short_opt,
|
short_opt,
|
||||||
gnu_opt,
|
gnu_opt,
|
||||||
old_opt,
|
old_opt,
|
||||||
result_mode,
|
result_mode,
|
||||||
authorative,
|
|
||||||
condition,
|
condition,
|
||||||
comp,
|
comp,
|
||||||
desc );
|
desc,
|
||||||
}
|
flags );
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
if( authoritative != -1 )
|
||||||
Silly function
|
{
|
||||||
*/
|
complete_set_authoritative( path.at(i).c_str(),
|
||||||
static void builtin_complete_remove3( wchar_t *cmd,
|
PATH,
|
||||||
int cmd_type,
|
authoritative );
|
||||||
wchar_t short_opt,
|
}
|
||||||
array_list_t *long_opt )
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for( i=0; i<al_get_count( long_opt ); i++ )
|
|
||||||
{
|
|
||||||
complete_remove( cmd,
|
|
||||||
cmd_type,
|
|
||||||
short_opt,
|
|
||||||
(wchar_t *)al_get( long_opt, i ) );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Silly function
|
Silly function
|
||||||
*/
|
*/
|
||||||
static void builtin_complete_remove2( wchar_t *cmd,
|
static void builtin_complete_remove3( const wchar_t *cmd,
|
||||||
|
int cmd_type,
|
||||||
|
wchar_t short_opt,
|
||||||
|
const wcstring_list_t &long_opt )
|
||||||
|
{
|
||||||
|
for( size_t i=0; i<long_opt.size(); i++ )
|
||||||
|
{
|
||||||
|
complete_remove( cmd,
|
||||||
|
cmd_type,
|
||||||
|
short_opt,
|
||||||
|
long_opt.at(i).c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Silly function
|
||||||
|
*/
|
||||||
|
static void builtin_complete_remove2( const wchar_t *cmd,
|
||||||
int cmd_type,
|
int cmd_type,
|
||||||
const wchar_t *short_opt,
|
const wchar_t *short_opt,
|
||||||
array_list_t *gnu_opt,
|
const wcstring_list_t &gnu_opt,
|
||||||
array_list_t *old_opt )
|
const wcstring_list_t &old_opt )
|
||||||
{
|
{
|
||||||
const wchar_t *s = (wchar_t *)short_opt;
|
const wchar_t *s = (wchar_t *)short_opt;
|
||||||
if( *s )
|
if( *s )
|
||||||
{
|
{
|
||||||
for( ; *s; s++ )
|
for( ; *s; s++ )
|
||||||
{
|
{
|
||||||
if( al_get_count( old_opt) + al_get_count( gnu_opt ) == 0 )
|
if( old_opt.size() == 0 && gnu_opt.size() == 0 )
|
||||||
{
|
{
|
||||||
complete_remove(cmd,
|
complete_remove(cmd,
|
||||||
cmd_type,
|
cmd_type,
|
||||||
@@ -232,27 +244,24 @@ static void builtin_complete_remove2( wchar_t *cmd,
|
|||||||
/**
|
/**
|
||||||
Silly function
|
Silly function
|
||||||
*/
|
*/
|
||||||
static void builtin_complete_remove( array_list_t *cmd,
|
static void builtin_complete_remove( const wcstring_list_t &cmd,
|
||||||
array_list_t *path,
|
const wcstring_list_t &path,
|
||||||
const wchar_t *short_opt,
|
const wchar_t *short_opt,
|
||||||
array_list_t *gnu_opt,
|
const wcstring_list_t &gnu_opt,
|
||||||
array_list_t *old_opt )
|
const wcstring_list_t &old_opt )
|
||||||
{
|
{
|
||||||
|
for( size_t i=0; i<cmd.size(); i++ )
|
||||||
int i;
|
|
||||||
|
|
||||||
for( i=0; i<al_get_count( cmd ); i++ )
|
|
||||||
{
|
{
|
||||||
builtin_complete_remove2( (wchar_t *)al_get( cmd, i ),
|
builtin_complete_remove2( cmd.at(i).c_str(),
|
||||||
COMMAND,
|
COMMAND,
|
||||||
short_opt,
|
short_opt,
|
||||||
gnu_opt,
|
gnu_opt,
|
||||||
old_opt );
|
old_opt );
|
||||||
}
|
}
|
||||||
|
|
||||||
for( i=0; i<al_get_count( path ); i++ )
|
for( size_t i=0; i<path.size(); i++ )
|
||||||
{
|
{
|
||||||
builtin_complete_remove2( (wchar_t *)al_get( path, i ),
|
builtin_complete_remove2( path.at(i).c_str(),
|
||||||
PATH,
|
PATH,
|
||||||
short_opt,
|
short_opt,
|
||||||
gnu_opt,
|
gnu_opt,
|
||||||
@@ -264,6 +273,7 @@ static void builtin_complete_remove( array_list_t *cmd,
|
|||||||
|
|
||||||
const wchar_t *builtin_complete_get_temporary_buffer()
|
const wchar_t *builtin_complete_get_temporary_buffer()
|
||||||
{
|
{
|
||||||
|
ASSERT_IS_MAIN_THREAD();
|
||||||
return temporary_buffer;
|
return temporary_buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,43 +282,35 @@ const wchar_t *builtin_complete_get_temporary_buffer()
|
|||||||
tab-completions. Calls the functions in complete.c for any heavy
|
tab-completions. Calls the functions in complete.c for any heavy
|
||||||
lifting. Defined in builtin_complete.c
|
lifting. Defined in builtin_complete.c
|
||||||
*/
|
*/
|
||||||
static int builtin_complete( wchar_t **argv )
|
static int builtin_complete( parser_t &parser, wchar_t **argv )
|
||||||
{
|
{
|
||||||
int res=0;
|
ASSERT_IS_MAIN_THREAD();
|
||||||
|
bool res=false;
|
||||||
int argc=0;
|
int argc=0;
|
||||||
int result_mode=SHARED;
|
int result_mode=SHARED;
|
||||||
int remove = 0;
|
int remove = 0;
|
||||||
int authorative = 1;
|
int authoritative = -1;
|
||||||
|
int flags = COMPLETE_AUTO_SPACE;
|
||||||
|
|
||||||
string_buffer_t short_opt;
|
wcstring short_opt;
|
||||||
array_list_t gnu_opt, old_opt;
|
wcstring_list_t gnu_opt, old_opt;
|
||||||
wchar_t *comp=L"", *desc=L"", *condition=L"";
|
const wchar_t *comp=L"", *desc=L"", *condition=L"";
|
||||||
|
|
||||||
wchar_t *do_complete = 0;
|
bool do_complete = false;
|
||||||
|
wcstring do_complete_param;
|
||||||
|
|
||||||
array_list_t cmd;
|
wcstring_list_t cmd;
|
||||||
array_list_t path;
|
wcstring_list_t path;
|
||||||
|
|
||||||
static int recursion_level=0;
|
static int recursion_level=0;
|
||||||
|
|
||||||
if( !is_interactive_session )
|
|
||||||
{
|
|
||||||
debug( 1, _(L"%ls: Command only available in interactive sessions"), argv[0] );
|
|
||||||
}
|
|
||||||
|
|
||||||
al_init( &cmd );
|
|
||||||
al_init( &path );
|
|
||||||
sb_init( &short_opt );
|
|
||||||
al_init( &gnu_opt );
|
|
||||||
al_init( &old_opt );
|
|
||||||
|
|
||||||
argc = builtin_count_args( argv );
|
argc = builtin_count_args( argv );
|
||||||
|
|
||||||
woptind=0;
|
woptind=0;
|
||||||
|
|
||||||
while( res == 0 )
|
while( ! res )
|
||||||
{
|
{
|
||||||
const static struct woption
|
static const struct woption
|
||||||
long_options[] =
|
long_options[] =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
@@ -356,7 +358,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 +387,7 @@ static int builtin_complete( wchar_t **argv )
|
|||||||
|
|
||||||
int opt = wgetopt_long( argc,
|
int opt = wgetopt_long( argc,
|
||||||
argv,
|
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,
|
long_options,
|
||||||
&opt_index );
|
&opt_index );
|
||||||
if( opt == -1 )
|
if( opt == -1 )
|
||||||
@@ -392,17 +398,14 @@ static int builtin_complete( wchar_t **argv )
|
|||||||
case 0:
|
case 0:
|
||||||
if(long_options[opt_index].flag != 0)
|
if(long_options[opt_index].flag != 0)
|
||||||
break;
|
break;
|
||||||
sb_printf( sb_err,
|
append_format(stderr_buffer,
|
||||||
BUILTIN_ERR_UNKNOWN,
|
BUILTIN_ERR_UNKNOWN,
|
||||||
argv[0],
|
argv[0],
|
||||||
long_options[opt_index].name );
|
long_options[opt_index].name );
|
||||||
sb_append( sb_err,
|
builtin_print_help( parser, argv[0], stderr_buffer );
|
||||||
parser_current_line() );
|
|
||||||
|
|
||||||
builtin_print_help( argv[0], sb_err );
|
|
||||||
|
|
||||||
|
|
||||||
res = 1;
|
res = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'x':
|
case 'x':
|
||||||
@@ -420,15 +423,18 @@ static int builtin_complete( wchar_t **argv )
|
|||||||
case 'p':
|
case 'p':
|
||||||
case 'c':
|
case 'c':
|
||||||
{
|
{
|
||||||
wchar_t *a = unescape( woptarg, 1);
|
wcstring tmp = woptarg;
|
||||||
if( a )
|
if (unescape_string(tmp, 1))
|
||||||
{
|
{
|
||||||
al_push( (opt=='p'?&path:&cmd), a );
|
if (opt=='p')
|
||||||
|
path.push_back(tmp);
|
||||||
|
else
|
||||||
|
cmd.push_back(tmp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sb_printf( sb_err, L"%ls: Invalid token '%ls'\n", argv[0], woptarg );
|
append_format(stderr_buffer, L"%ls: Invalid token '%ls'\n", argv[0], woptarg );
|
||||||
res = 1;
|
res = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -438,19 +444,23 @@ static int builtin_complete( wchar_t **argv )
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'u':
|
case 'u':
|
||||||
authorative=0;
|
authoritative=0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'A':
|
||||||
|
authoritative=1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
sb_append( &short_opt, woptarg );
|
short_opt.append(woptarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'l':
|
case 'l':
|
||||||
al_push( &gnu_opt, woptarg );
|
gnu_opt.push_back(woptarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'o':
|
case 'o':
|
||||||
al_push( &old_opt, woptarg );
|
old_opt.push_back(woptarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'a':
|
case 'a':
|
||||||
@@ -466,19 +476,17 @@ static int builtin_complete( wchar_t **argv )
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'C':
|
case 'C':
|
||||||
do_complete = woptarg?woptarg:reader_get_buffer();
|
do_complete = true;
|
||||||
|
do_complete_param = woptarg ? woptarg : reader_get_buffer();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'h':
|
case 'h':
|
||||||
builtin_print_help( argv[0], sb_out );
|
builtin_print_help( parser, argv[0], stdout_buffer );
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case '?':
|
case '?':
|
||||||
sb_append( sb_err,
|
builtin_unknown_option( parser, argv[0], argv[woptind-1] );
|
||||||
parser_current_line() );
|
res = true;
|
||||||
builtin_print_help( argv[0], sb_err );
|
|
||||||
|
|
||||||
res = 1;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -489,16 +497,16 @@ static int builtin_complete( wchar_t **argv )
|
|||||||
{
|
{
|
||||||
if( condition && wcslen( condition ) )
|
if( condition && wcslen( condition ) )
|
||||||
{
|
{
|
||||||
if( parser_test( condition, 0, 0, 0 ) )
|
if( parser.test( condition, 0, 0, 0 ) )
|
||||||
{
|
{
|
||||||
sb_printf( sb_err,
|
append_format(stderr_buffer,
|
||||||
L"%ls: Condition '%ls' contained a syntax error\n",
|
L"%ls: Condition '%ls' contained a syntax error\n",
|
||||||
argv[0],
|
argv[0],
|
||||||
condition );
|
condition );
|
||||||
|
|
||||||
parser_test( condition, 0, sb_err, argv[0] );
|
parser.test( condition, 0, &stderr_buffer, argv[0] );
|
||||||
|
|
||||||
res = 1;
|
res = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -507,16 +515,16 @@ static int builtin_complete( wchar_t **argv )
|
|||||||
{
|
{
|
||||||
if( comp && wcslen( comp ) )
|
if( comp && wcslen( comp ) )
|
||||||
{
|
{
|
||||||
if( parser_test_args( comp, 0, 0 ) )
|
if( parser.test_args( comp, 0, 0 ) )
|
||||||
{
|
{
|
||||||
sb_printf( sb_err,
|
append_format(stderr_buffer,
|
||||||
L"%ls: Completion '%ls' contained a syntax error\n",
|
L"%ls: Completion '%ls' contained a syntax error\n",
|
||||||
argv[0],
|
argv[0],
|
||||||
comp );
|
comp );
|
||||||
|
|
||||||
parser_test_args( comp, sb_err, argv[0] );
|
parser.test_args( comp, &stderr_buffer, argv[0] );
|
||||||
|
|
||||||
res = 1;
|
res = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -525,31 +533,46 @@ static int builtin_complete( wchar_t **argv )
|
|||||||
{
|
{
|
||||||
if( do_complete )
|
if( do_complete )
|
||||||
{
|
{
|
||||||
array_list_t comp;
|
const wchar_t *token;
|
||||||
int i;
|
|
||||||
|
|
||||||
|
parse_util_token_extent( do_complete_param.c_str(), do_complete_param.size(), &token, 0, 0, 0 );
|
||||||
|
|
||||||
const wchar_t *prev_temporary_buffer = temporary_buffer;
|
const wchar_t *prev_temporary_buffer = temporary_buffer;
|
||||||
temporary_buffer = do_complete;
|
temporary_buffer = do_complete_param.c_str();
|
||||||
|
|
||||||
if( recursion_level < 1 )
|
if( recursion_level < 1 )
|
||||||
{
|
{
|
||||||
recursion_level++;
|
recursion_level++;
|
||||||
|
|
||||||
|
std::vector<completion_t> comp;
|
||||||
|
complete( do_complete_param, comp, COMPLETE_DEFAULT );
|
||||||
|
|
||||||
al_init( &comp );
|
for( size_t i=0; i< comp.size() ; i++ )
|
||||||
|
|
||||||
complete( do_complete, &comp );
|
|
||||||
|
|
||||||
for( i=0; i<al_get_count( &comp ); i++ )
|
|
||||||
{
|
{
|
||||||
wchar_t *next = (wchar_t *)al_get( &comp, i );
|
const completion_t &next = comp.at( i );
|
||||||
wchar_t *sep = wcschr( next, COMPLETE_SEP );
|
|
||||||
if( sep )
|
const wchar_t *prepend;
|
||||||
*sep = L'\t';
|
|
||||||
sb_printf( sb_out, L"%ls\n", next );
|
if( next.flags & COMPLETE_NO_CASE )
|
||||||
|
{
|
||||||
|
prepend = L"";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
prepend = token;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if( !(next.description).empty() )
|
||||||
|
{
|
||||||
|
append_format(stdout_buffer, L"%ls%ls\t%ls\n", prepend, next.completion.c_str(), next.description.c_str() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
append_format(stdout_buffer, L"%ls%ls\n", prepend, next.completion.c_str() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
al_foreach( &comp, &free );
|
|
||||||
al_destroy( &comp );
|
|
||||||
recursion_level--;
|
recursion_level--;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -558,56 +581,46 @@ static int builtin_complete( wchar_t **argv )
|
|||||||
}
|
}
|
||||||
else if( woptind != argc )
|
else if( woptind != argc )
|
||||||
{
|
{
|
||||||
sb_printf( sb_err,
|
append_format(stderr_buffer,
|
||||||
_( L"%ls: Too many arguments\n" ),
|
_( L"%ls: Too many arguments\n" ),
|
||||||
argv[0] );
|
argv[0] );
|
||||||
sb_append( sb_err,
|
builtin_print_help( parser, argv[0], stderr_buffer );
|
||||||
parser_current_line() );
|
|
||||||
builtin_print_help( argv[0], sb_err );
|
|
||||||
|
|
||||||
res = 1;
|
res = true;
|
||||||
}
|
}
|
||||||
else if( (al_get_count( &cmd) == 0 ) && (al_get_count( &path) == 0 ) )
|
else if( cmd.empty() && path.empty() )
|
||||||
{
|
{
|
||||||
/* No arguments specified, meaning we print the definitions of
|
/* No arguments specified, meaning we print the definitions of
|
||||||
* all specified completions to stdout.*/
|
* all specified completions to stdout.*/
|
||||||
complete_print( sb_out );
|
complete_print( stdout_buffer );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( remove )
|
if( remove )
|
||||||
{
|
{
|
||||||
builtin_complete_remove( &cmd,
|
builtin_complete_remove( cmd,
|
||||||
&path,
|
path,
|
||||||
(wchar_t *)short_opt.buff,
|
short_opt.c_str(),
|
||||||
&gnu_opt,
|
gnu_opt,
|
||||||
&old_opt );
|
old_opt );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
builtin_complete_add( &cmd,
|
builtin_complete_add( cmd,
|
||||||
&path,
|
path,
|
||||||
(wchar_t *)short_opt.buff,
|
short_opt.c_str(),
|
||||||
&gnu_opt,
|
gnu_opt,
|
||||||
&old_opt,
|
old_opt,
|
||||||
result_mode,
|
result_mode,
|
||||||
authorative,
|
authoritative,
|
||||||
condition,
|
condition,
|
||||||
comp,
|
comp,
|
||||||
desc );
|
desc,
|
||||||
|
flags );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
al_foreach( &cmd, &free );
|
return res ? 1 : 0;
|
||||||
al_foreach( &path, &free );
|
|
||||||
|
|
||||||
al_destroy( &cmd );
|
|
||||||
al_destroy( &path );
|
|
||||||
sb_destroy( &short_opt );
|
|
||||||
al_destroy( &gnu_opt );
|
|
||||||
al_destroy( &old_opt );
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
@@ -1,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 );
|
|
||||||
@@ -43,7 +43,7 @@ enum
|
|||||||
/**
|
/**
|
||||||
Calculates the cpu usage (in percent) of the specified job.
|
Calculates the cpu usage (in percent) of the specified job.
|
||||||
*/
|
*/
|
||||||
static int cpu_use( job_t *j )
|
static int cpu_use( const job_t *j )
|
||||||
{
|
{
|
||||||
double u=0;
|
double u=0;
|
||||||
process_t *p;
|
process_t *p;
|
||||||
@@ -71,7 +71,7 @@ static int cpu_use( job_t *j )
|
|||||||
/**
|
/**
|
||||||
Print information about the specified job
|
Print information about the specified job
|
||||||
*/
|
*/
|
||||||
static void builtin_jobs_print( job_t *j, int mode, int header )
|
static void builtin_jobs_print( const job_t *j, int mode, int header )
|
||||||
{
|
{
|
||||||
process_t *p;
|
process_t *p;
|
||||||
switch( mode )
|
switch( mode )
|
||||||
@@ -84,24 +84,22 @@ static void builtin_jobs_print( job_t *j, int mode, int header )
|
|||||||
/*
|
/*
|
||||||
Print table header before first job
|
Print table header before first job
|
||||||
*/
|
*/
|
||||||
sb_append( sb_out, _( L"Job\tGroup\t" ));
|
stdout_buffer.append( _( L"Job\tGroup\t" ));
|
||||||
#ifdef HAVE__PROC_SELF_STAT
|
#ifdef HAVE__PROC_SELF_STAT
|
||||||
sb_append( sb_out, _( L"CPU\t" ) );
|
stdout_buffer.append( _( L"CPU\t" ) );
|
||||||
#endif
|
#endif
|
||||||
sb_append( sb_out, _( L"State\tCommand\n" ) );
|
stdout_buffer.append( _( L"State\tCommand\n" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
sb_printf( sb_out, L"%d\t%d\t", j->job_id, j->pgid );
|
append_format(stdout_buffer, L"%d\t%d\t", j->job_id, j->pgid );
|
||||||
|
|
||||||
#ifdef HAVE__PROC_SELF_STAT
|
#ifdef HAVE__PROC_SELF_STAT
|
||||||
sb_printf( sb_out, L"%d%%\t", cpu_use(j) );
|
append_format(stdout_buffer, L"%d%%\t", cpu_use(j) );
|
||||||
#endif
|
#endif
|
||||||
sb_append2( sb_out,
|
stdout_buffer.append(job_is_stopped(j)?_(L"stopped"):_(L"running"));
|
||||||
job_is_stopped(j)?_(L"stopped"):_(L"running"),
|
stdout_buffer.append(L"\t");
|
||||||
L"\t",
|
stdout_buffer.append(j->command_wcstr());
|
||||||
j->command,
|
stdout_buffer.append(L"\n");
|
||||||
L"\n",
|
|
||||||
(void *)0 );
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,9 +110,9 @@ static void builtin_jobs_print( job_t *j, int mode, int header )
|
|||||||
/*
|
/*
|
||||||
Print table header before first job
|
Print table header before first job
|
||||||
*/
|
*/
|
||||||
sb_append( sb_out, _( L"Group\n" ));
|
stdout_buffer.append( _( L"Group\n" ));
|
||||||
}
|
}
|
||||||
sb_printf( sb_out, L"%d\n", j->pgid );
|
append_format(stdout_buffer, L"%d\n", j->pgid );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,12 +123,12 @@ static void builtin_jobs_print( job_t *j, int mode, int header )
|
|||||||
/*
|
/*
|
||||||
Print table header before first job
|
Print table header before first job
|
||||||
*/
|
*/
|
||||||
sb_append( sb_out, _( L"Procces\n" ));
|
stdout_buffer.append( _( L"Procces\n" ));
|
||||||
}
|
}
|
||||||
|
|
||||||
for( p=j->first_process; p; p=p->next )
|
for( p=j->first_process; p; p=p->next )
|
||||||
{
|
{
|
||||||
sb_printf( sb_out, L"%d\n", p->pid );
|
append_format(stdout_buffer, L"%d\n", p->pid );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -142,12 +140,12 @@ static void builtin_jobs_print( job_t *j, int mode, int header )
|
|||||||
/*
|
/*
|
||||||
Print table header before first job
|
Print table header before first job
|
||||||
*/
|
*/
|
||||||
sb_append( sb_out, _( L"Command\n" ));
|
stdout_buffer.append( _( L"Command\n" ));
|
||||||
}
|
}
|
||||||
|
|
||||||
for( p=j->first_process; p; p=p->next )
|
for( p=j->first_process; p; p=p->next )
|
||||||
{
|
{
|
||||||
sb_printf( sb_out, L"%ls\n", p->argv[0] );
|
append_format(stdout_buffer, L"%ls\n", p->argv0() );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -160,20 +158,20 @@ static void builtin_jobs_print( job_t *j, int mode, int header )
|
|||||||
/**
|
/**
|
||||||
The jobs builtin. Used fopr printing running jobs. Defined in builtin_jobs.c.
|
The jobs builtin. Used fopr printing running jobs. Defined in builtin_jobs.c.
|
||||||
*/
|
*/
|
||||||
static int builtin_jobs( wchar_t **argv )
|
static int builtin_jobs( parser_t &parser, wchar_t **argv )
|
||||||
{
|
{
|
||||||
int argc=0;
|
int argc=0;
|
||||||
int found=0;
|
int found=0;
|
||||||
int mode=JOBS_DEFAULT;
|
int mode=JOBS_DEFAULT;
|
||||||
int print_last = 0;
|
int print_last = 0;
|
||||||
job_t *j;
|
const job_t *j;
|
||||||
|
|
||||||
argc = builtin_count_args( argv );
|
argc = builtin_count_args( argv );
|
||||||
woptind=0;
|
woptind=0;
|
||||||
|
|
||||||
while( 1 )
|
while( 1 )
|
||||||
{
|
{
|
||||||
const static struct woption
|
static const struct woption
|
||||||
long_options[] =
|
long_options[] =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
@@ -217,14 +215,12 @@ static int builtin_jobs( wchar_t **argv )
|
|||||||
case 0:
|
case 0:
|
||||||
if(long_options[opt_index].flag != 0)
|
if(long_options[opt_index].flag != 0)
|
||||||
break;
|
break;
|
||||||
sb_printf( sb_err,
|
append_format(stderr_buffer,
|
||||||
BUILTIN_ERR_UNKNOWN,
|
BUILTIN_ERR_UNKNOWN,
|
||||||
argv[0],
|
argv[0],
|
||||||
long_options[opt_index].name );
|
long_options[opt_index].name );
|
||||||
|
|
||||||
sb_append( sb_err,
|
builtin_print_help( parser, argv[0], stderr_buffer );
|
||||||
parser_current_line() );
|
|
||||||
builtin_print_help( argv[0], sb_err );
|
|
||||||
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@@ -249,12 +245,11 @@ static int builtin_jobs( wchar_t **argv )
|
|||||||
}
|
}
|
||||||
|
|
||||||
case 'h':
|
case 'h':
|
||||||
builtin_print_help( argv[0], sb_out );
|
builtin_print_help( parser, argv[0], stdout_buffer );
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case '?':
|
case '?':
|
||||||
builtin_print_help( argv[0], sb_err );
|
builtin_unknown_option( parser, argv[0], argv[woptind-1] );
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -274,8 +269,11 @@ static int builtin_jobs( wchar_t **argv )
|
|||||||
/*
|
/*
|
||||||
Ignore unconstructed jobs, i.e. ourself.
|
Ignore unconstructed jobs, i.e. ourself.
|
||||||
*/
|
*/
|
||||||
for( j=first_job; j; j=j->next )
|
job_iterator_t jobs;
|
||||||
|
const job_t *j;
|
||||||
|
while ((j = jobs.next()))
|
||||||
{
|
{
|
||||||
|
|
||||||
if( (j->flags & JOB_CONSTRUCTED) && !job_is_completed(j) )
|
if( (j->flags & JOB_CONSTRUCTED) && !job_is_completed(j) )
|
||||||
{
|
{
|
||||||
builtin_jobs_print( j, mode, !found );
|
builtin_jobs_print( j, mode, !found );
|
||||||
@@ -294,13 +292,13 @@ static int builtin_jobs( wchar_t **argv )
|
|||||||
|
|
||||||
for( i=woptind; i<argc; i++ )
|
for( i=woptind; i<argc; i++ )
|
||||||
{
|
{
|
||||||
long pid;
|
int pid;
|
||||||
wchar_t *end;
|
wchar_t *end;
|
||||||
errno=0;
|
errno=0;
|
||||||
pid=wcstol( argv[i], &end, 10 );
|
pid=fish_wcstoi( argv[i], &end, 10 );
|
||||||
if( errno || *end )
|
if( errno || *end )
|
||||||
{
|
{
|
||||||
sb_printf( sb_err,
|
append_format(stderr_buffer,
|
||||||
_( L"%ls: '%ls' is not a job\n" ),
|
_( L"%ls: '%ls' is not a job\n" ),
|
||||||
argv[0],
|
argv[0],
|
||||||
argv[i] );
|
argv[i] );
|
||||||
@@ -315,7 +313,7 @@ static int builtin_jobs( wchar_t **argv )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sb_printf( sb_err,
|
append_format(stderr_buffer,
|
||||||
_( L"%ls: No suitable job: %d\n" ),
|
_( L"%ls: No suitable job: %d\n" ),
|
||||||
argv[0],
|
argv[0],
|
||||||
pid );
|
pid );
|
||||||
@@ -325,8 +323,10 @@ static int builtin_jobs( wchar_t **argv )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for( j= first_job; j; j=j->next )
|
job_iterator_t jobs;
|
||||||
{
|
const job_t *j;
|
||||||
|
while ((j = jobs.next()))
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
Ignore unconstructed jobs, i.e. ourself.
|
Ignore unconstructed jobs, i.e. ourself.
|
||||||
*/
|
*/
|
||||||
@@ -341,7 +341,7 @@ static int builtin_jobs( wchar_t **argv )
|
|||||||
|
|
||||||
if( !found )
|
if( !found )
|
||||||
{
|
{
|
||||||
sb_printf( sb_out,
|
append_format(stdout_buffer,
|
||||||
_( L"%ls: There are no jobs\n" ),
|
_( L"%ls: There are no jobs\n" ),
|
||||||
argv[0] );
|
argv[0] );
|
||||||
}
|
}
|
||||||
835
builtin_set.c
835
builtin_set.c
@@ -1,835 +0,0 @@
|
|||||||
/** \file builtin_set.c Functions defining the set builtin
|
|
||||||
|
|
||||||
Functions used for implementing the set builtin.
|
|
||||||
|
|
||||||
*/
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <wchar.h>
|
|
||||||
#include <wctype.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <termios.h>
|
|
||||||
#include <signal.h>
|
|
||||||
|
|
||||||
#include "fallback.h"
|
|
||||||
#include "util.h"
|
|
||||||
|
|
||||||
#include "wutil.h"
|
|
||||||
#include "builtin.h"
|
|
||||||
#include "env.h"
|
|
||||||
#include "expand.h"
|
|
||||||
#include "common.h"
|
|
||||||
#include "wgetopt.h"
|
|
||||||
#include "proc.h"
|
|
||||||
#include "parser.h"
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Error message for invalid path operations
|
|
||||||
*/
|
|
||||||
#define BUILTIN_SET_PATH_ERROR L"%ls: Could not add component %ls to %ls.\n"
|
|
||||||
|
|
||||||
/**
|
|
||||||
Hint for invalid path operation with a colon
|
|
||||||
*/
|
|
||||||
#define BUILTIN_SET_PATH_HINT L"%ls: Did you mean 'set %ls $%ls %ls'?\n"
|
|
||||||
|
|
||||||
/**
|
|
||||||
Error for mismatch between index count and elements
|
|
||||||
*/
|
|
||||||
#define BUILTIN_SET_ARG_COUNT L"%ls: The number of variable indexes does not match the number of values\n"
|
|
||||||
|
|
||||||
/**
|
|
||||||
Test if the specified variable should be subject to path validation
|
|
||||||
*/
|
|
||||||
static int is_path_variable( const wchar_t *env )
|
|
||||||
{
|
|
||||||
return contains_str( env,
|
|
||||||
L"PATH",
|
|
||||||
L"CDPATH",
|
|
||||||
(void *)0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Call env_set. If this is a path variable, e.g. PATH, validate the
|
|
||||||
elements. On error, print a description of the problem to stderr.
|
|
||||||
*/
|
|
||||||
static int my_env_set( const wchar_t *key, array_list_t *val, int scope )
|
|
||||||
{
|
|
||||||
string_buffer_t sb;
|
|
||||||
int i;
|
|
||||||
int retcode = 0;
|
|
||||||
wchar_t *val_str=0;
|
|
||||||
|
|
||||||
if( is_path_variable( key ) )
|
|
||||||
{
|
|
||||||
int error = 0;
|
|
||||||
|
|
||||||
for( i=0; i<al_get_count( val ); i++ )
|
|
||||||
{
|
|
||||||
int show_perror = 0;
|
|
||||||
int show_hint = 0;
|
|
||||||
|
|
||||||
struct stat buff;
|
|
||||||
wchar_t *dir = (wchar_t *)al_get( val, i );
|
|
||||||
|
|
||||||
if( wstat( dir, &buff ) )
|
|
||||||
{
|
|
||||||
error = 1;
|
|
||||||
show_perror = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !( S_ISDIR(buff.st_mode) ) )
|
|
||||||
{
|
|
||||||
error = 1;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if( error )
|
|
||||||
{
|
|
||||||
wchar_t *colon;
|
|
||||||
|
|
||||||
sb_printf( sb_err,
|
|
||||||
_(BUILTIN_SET_PATH_ERROR),
|
|
||||||
L"set",
|
|
||||||
dir,
|
|
||||||
key );
|
|
||||||
|
|
||||||
colon = wcschr( dir, L':' );
|
|
||||||
|
|
||||||
if( colon && *(colon+1) )
|
|
||||||
{
|
|
||||||
show_hint = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if( show_perror )
|
|
||||||
{
|
|
||||||
builtin_wperror( L"set" );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( show_hint )
|
|
||||||
{
|
|
||||||
sb_printf( sb_err,
|
|
||||||
_(BUILTIN_SET_PATH_HINT),
|
|
||||||
L"set",
|
|
||||||
key,
|
|
||||||
key,
|
|
||||||
wcschr( dir, L':' )+1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if( error )
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if( error )
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
sb_init( &sb );
|
|
||||||
|
|
||||||
if( al_get_count( val ) )
|
|
||||||
{
|
|
||||||
for( i=0; i<al_get_count( val ); i++ )
|
|
||||||
{
|
|
||||||
sb_append( &sb, (wchar_t *)al_get( val, i ) );
|
|
||||||
if( i<al_get_count( val )-1 )
|
|
||||||
{
|
|
||||||
sb_append( &sb, ARRAY_SEP_STR );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val_str = (wchar_t *)sb.buff;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
switch( env_set( key, val_str, scope | ENV_USER ) )
|
|
||||||
{
|
|
||||||
case ENV_PERM:
|
|
||||||
{
|
|
||||||
sb_printf( sb_err, _(L"%ls: Tried to change the read-only variable '%ls'\n"), L"set", key );
|
|
||||||
retcode=1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case ENV_INVALID:
|
|
||||||
{
|
|
||||||
sb_printf( sb_err, _(L"%ls: Unknown error"), L"set" );
|
|
||||||
retcode=1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sb_destroy( &sb );
|
|
||||||
|
|
||||||
return retcode;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Extract indexes from a destination argument of the form name[index1 index2...]
|
|
||||||
|
|
||||||
\param indexes the list to insert the new indexes into
|
|
||||||
\param src the source string to parse
|
|
||||||
\param name the name of the element. Return null if the name in \c src does not match this name
|
|
||||||
\param var_count the number of elements in the array to parse.
|
|
||||||
|
|
||||||
\return the total number of indexes parsed, or -1 on error
|
|
||||||
*/
|
|
||||||
static int parse_index( array_list_t *indexes,
|
|
||||||
const wchar_t *src,
|
|
||||||
const wchar_t *name,
|
|
||||||
int var_count )
|
|
||||||
{
|
|
||||||
int len;
|
|
||||||
|
|
||||||
int count = 0;
|
|
||||||
const wchar_t *src_orig = src;
|
|
||||||
|
|
||||||
if (src == 0)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (*src != L'\0' && (iswalnum(*src) || *src == L'_'))
|
|
||||||
{
|
|
||||||
src++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*src != L'[')
|
|
||||||
{
|
|
||||||
sb_printf( sb_err, _(BUILTIN_SET_ARG_COUNT), L"set" );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
len = src-src_orig;
|
|
||||||
|
|
||||||
if( (wcsncmp( src_orig, name, len )!=0) || (wcslen(name) != (len)) )
|
|
||||||
{
|
|
||||||
sb_printf( sb_err,
|
|
||||||
_(L"%ls: Multiple variable names specified in single call (%ls and %.*ls)\n"),
|
|
||||||
L"set",
|
|
||||||
name,
|
|
||||||
len,
|
|
||||||
src_orig);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
src++;
|
|
||||||
|
|
||||||
while (iswspace(*src))
|
|
||||||
{
|
|
||||||
src++;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (*src != L']')
|
|
||||||
{
|
|
||||||
wchar_t *end;
|
|
||||||
long l_ind = wcstol(src, &end, 10);
|
|
||||||
|
|
||||||
if (end == src)
|
|
||||||
{
|
|
||||||
sb_printf(sb_err, _(L"%ls: Invalid index starting at '%ls'\n"), L"set", src);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( l_ind < 0 )
|
|
||||||
{
|
|
||||||
l_ind = var_count+l_ind+1;
|
|
||||||
}
|
|
||||||
|
|
||||||
al_push_long(indexes, l_ind);
|
|
||||||
src = end;
|
|
||||||
count++;
|
|
||||||
while (iswspace(*src)) src++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Update a list \c list by writing copies (using wcsdup) of the
|
|
||||||
values specified by \c values to the indexes specified by \c
|
|
||||||
indexes. The previous entries at the specidied position will be
|
|
||||||
free'd.
|
|
||||||
|
|
||||||
\return 0 if the operation was successfull, non-zero otherwise
|
|
||||||
*/
|
|
||||||
static int update_values( array_list_t *list,
|
|
||||||
array_list_t *indexes,
|
|
||||||
array_list_t *values )
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
/* Replace values where needed */
|
|
||||||
for( i = 0; i < al_get_count(indexes); i++ )
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
The '- 1' below is because the indices in fish are
|
|
||||||
one-based, but the array_lsit_t uses zero-based indices
|
|
||||||
*/
|
|
||||||
long ind = al_get_long(indexes, i) - 1;
|
|
||||||
void *new = (void *) al_get(values, i);
|
|
||||||
if( ind <= 0 )
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
free((void *) al_get(list, ind));
|
|
||||||
al_set(list, ind, new != 0 ? wcsdup(new) : wcsdup(L""));
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Return 1 if an array list of longs contains the specified
|
|
||||||
value, 0 otherwise
|
|
||||||
*/
|
|
||||||
static int al_contains_long( array_list_t *list,
|
|
||||||
long val)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < al_get_count(list); i++)
|
|
||||||
{
|
|
||||||
long current = al_get_long(list, i);
|
|
||||||
if( current != 0 && current == val )
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Erase from a list values at specified indexes
|
|
||||||
*/
|
|
||||||
static void erase_values(array_list_t *list, array_list_t *indexes)
|
|
||||||
{
|
|
||||||
long i;
|
|
||||||
array_list_t result;
|
|
||||||
|
|
||||||
al_init(&result);
|
|
||||||
|
|
||||||
for (i = 0; i < al_get_count(list); i++)
|
|
||||||
{
|
|
||||||
if (!al_contains_long(indexes, i + 1))
|
|
||||||
{
|
|
||||||
al_push(&result, al_get(list, i));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
free( (void *)al_get(list, i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
al_truncate(list,0);
|
|
||||||
al_push_all( list, &result );
|
|
||||||
al_destroy(&result);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Print the names of all environment variables in the scope, with or without values,
|
|
||||||
with or without escaping
|
|
||||||
*/
|
|
||||||
static void print_variables(int include_values, int esc, int scope)
|
|
||||||
{
|
|
||||||
array_list_t names;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
al_init( &names );
|
|
||||||
env_get_names( &names, scope );
|
|
||||||
|
|
||||||
sort_list( &names );
|
|
||||||
|
|
||||||
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, 0) : wcsdup(key);
|
|
||||||
|
|
||||||
sb_append(sb_out, e_key);
|
|
||||||
|
|
||||||
if( include_values )
|
|
||||||
{
|
|
||||||
wchar_t *value = env_get(key);
|
|
||||||
wchar_t *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_append2(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");
|
|
||||||
free(e_key);
|
|
||||||
}
|
|
||||||
al_destroy(&names);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
The set builtin. Creates, updates and erases environment variables
|
|
||||||
and environemnt variable arrays.
|
|
||||||
*/
|
|
||||||
static int builtin_set( wchar_t **argv )
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
Variables used for parsing the argument list
|
|
||||||
*/
|
|
||||||
const static struct woption
|
|
||||||
long_options[] =
|
|
||||||
{
|
|
||||||
{
|
|
||||||
L"export", no_argument, 0, 'x'
|
|
||||||
}
|
|
||||||
,
|
|
||||||
{
|
|
||||||
L"global", no_argument, 0, 'g'
|
|
||||||
}
|
|
||||||
,
|
|
||||||
{
|
|
||||||
L"local", no_argument, 0, 'l'
|
|
||||||
}
|
|
||||||
,
|
|
||||||
{
|
|
||||||
L"erase", no_argument, 0, 'e'
|
|
||||||
}
|
|
||||||
,
|
|
||||||
{
|
|
||||||
L"names", no_argument, 0, 'n'
|
|
||||||
}
|
|
||||||
,
|
|
||||||
{
|
|
||||||
L"unexport", no_argument, 0, 'u'
|
|
||||||
}
|
|
||||||
,
|
|
||||||
{
|
|
||||||
L"universal", no_argument, 0, 'U'
|
|
||||||
}
|
|
||||||
,
|
|
||||||
{
|
|
||||||
L"query", no_argument, 0, 'q'
|
|
||||||
}
|
|
||||||
,
|
|
||||||
{
|
|
||||||
L"help", no_argument, 0, 'h'
|
|
||||||
}
|
|
||||||
,
|
|
||||||
{
|
|
||||||
0, 0, 0, 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
const wchar_t *short_options = L"+xglenuUqh";
|
|
||||||
|
|
||||||
int argc = builtin_count_args(argv);
|
|
||||||
|
|
||||||
/*
|
|
||||||
Flags to set the work mode
|
|
||||||
*/
|
|
||||||
int local = 0, global = 0, export = 0;
|
|
||||||
int erase = 0, list = 0, unexport=0;
|
|
||||||
int universal = 0, query=0;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
Variables used for performing the actual work
|
|
||||||
*/
|
|
||||||
wchar_t *dest = 0;
|
|
||||||
int retcode=0;
|
|
||||||
int scope;
|
|
||||||
int slice=0;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
wchar_t *bad_char;
|
|
||||||
|
|
||||||
|
|
||||||
/* Parse options to obtain the requested operation and the modifiers */
|
|
||||||
woptind = 0;
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
int c = wgetopt_long(argc, argv, short_options, long_options, 0);
|
|
||||||
|
|
||||||
if (c == -1)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch(c)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'e':
|
|
||||||
erase = 1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'n':
|
|
||||||
list = 1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'x':
|
|
||||||
export = 1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'l':
|
|
||||||
local = 1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'g':
|
|
||||||
global = 1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'u':
|
|
||||||
unexport = 1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'U':
|
|
||||||
universal = 1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'q':
|
|
||||||
query = 1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'h':
|
|
||||||
builtin_print_help( argv[0], sb_out );
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
case '?':
|
|
||||||
builtin_print_help( argv[0], sb_err );
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Ok, all arguments have been parsed, let's validate them
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
If we are checking the existance of a variable (-q) we can not
|
|
||||||
also specify scope
|
|
||||||
*/
|
|
||||||
|
|
||||||
if( query && (erase || list || global || local || universal || export || unexport ) )
|
|
||||||
{
|
|
||||||
sb_printf(sb_err,
|
|
||||||
BUILTIN_ERR_COMBO2,
|
|
||||||
argv[0],
|
|
||||||
parser_current_line() );
|
|
||||||
|
|
||||||
builtin_print_help( argv[0], sb_err );
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* We can't both list and erase varaibles */
|
|
||||||
if( erase && list )
|
|
||||||
{
|
|
||||||
sb_printf(sb_err,
|
|
||||||
BUILTIN_ERR_COMBO2,
|
|
||||||
argv[0],
|
|
||||||
parser_current_line() );
|
|
||||||
|
|
||||||
builtin_print_help( argv[0], sb_err );
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Variables can only have one scope
|
|
||||||
*/
|
|
||||||
if( local + global + universal > 1 )
|
|
||||||
{
|
|
||||||
sb_printf( sb_err,
|
|
||||||
BUILTIN_ERR_GLOCAL,
|
|
||||||
argv[0],
|
|
||||||
parser_current_line() );
|
|
||||||
builtin_print_help( argv[0], sb_err );
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Variables can only have one export status
|
|
||||||
*/
|
|
||||||
if( export && unexport )
|
|
||||||
{
|
|
||||||
sb_printf( sb_err,
|
|
||||||
BUILTIN_ERR_EXPUNEXP,
|
|
||||||
argv[0],
|
|
||||||
parser_current_line() );
|
|
||||||
builtin_print_help( argv[0], sb_err );
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Calculate the scope value for variable assignement
|
|
||||||
*/
|
|
||||||
scope = (local ? ENV_LOCAL : 0) | (global ? ENV_GLOBAL : 0) | (export ? ENV_EXPORT : 0) | (unexport ? ENV_UNEXPORT : 0) | (universal ? ENV_UNIVERSAL:0) | ENV_USER;
|
|
||||||
|
|
||||||
if( query )
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
Query mode. Return the number of variables that do not exist
|
|
||||||
out of the specified variables.
|
|
||||||
*/
|
|
||||||
int i;
|
|
||||||
for( i=woptind; i<argc; i++ )
|
|
||||||
{
|
|
||||||
if( !env_exist( argv[i], scope ) )
|
|
||||||
{
|
|
||||||
retcode++;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
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 )
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
Print values of variables
|
|
||||||
*/
|
|
||||||
|
|
||||||
if( erase )
|
|
||||||
{
|
|
||||||
sb_printf( sb_err,
|
|
||||||
_(L"%ls: Erase needs a variable name\n%ls\n"),
|
|
||||||
argv[0],
|
|
||||||
parser_current_line() );
|
|
||||||
|
|
||||||
builtin_print_help( argv[0], sb_err );
|
|
||||||
retcode = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print_variables( 1, 1, scope );
|
|
||||||
}
|
|
||||||
|
|
||||||
return retcode;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !(dest = wcsdup(argv[woptind])))
|
|
||||||
{
|
|
||||||
DIE_MEM();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( wcschr( dest, L'[' ) )
|
|
||||||
{
|
|
||||||
slice = 1;
|
|
||||||
*wcschr( dest, L'[' )=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !wcslen( dest ) )
|
|
||||||
{
|
|
||||||
free( dest );
|
|
||||||
sb_printf( sb_err, BUILTIN_ERR_VARNAME_ZERO, argv[0] );
|
|
||||||
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 );
|
|
||||||
sb_printf( sb_err, _(L"%ls: Can not specify scope when erasing array slice\n"), argv[0] );
|
|
||||||
builtin_print_help( argv[0], sb_err );
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
set assignment can work in two modes, either using slices or
|
|
||||||
using the whole array. We detect which mode is used here.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if( slice )
|
|
||||||
{
|
|
||||||
|
|
||||||
/*
|
|
||||||
Slice mode
|
|
||||||
*/
|
|
||||||
int idx_count, val_count;
|
|
||||||
array_list_t values;
|
|
||||||
array_list_t indexes;
|
|
||||||
array_list_t result;
|
|
||||||
|
|
||||||
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 ) ) )
|
|
||||||
{
|
|
||||||
builtin_print_help( argv[0], sb_err );
|
|
||||||
retcode = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
val_count = argc-woptind-1;
|
|
||||||
idx_count = al_get_count( &indexes );
|
|
||||||
|
|
||||||
if( !erase )
|
|
||||||
{
|
|
||||||
if( val_count < idx_count )
|
|
||||||
{
|
|
||||||
sb_printf( sb_err, _(BUILTIN_SET_ARG_COUNT), argv[0] );
|
|
||||||
builtin_print_help( argv[0], sb_err );
|
|
||||||
retcode=1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if( val_count == idx_count )
|
|
||||||
{
|
|
||||||
woptind++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !retcode )
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
Slice indexes have been calculated, do the actual work
|
|
||||||
*/
|
|
||||||
|
|
||||||
if( erase )
|
|
||||||
{
|
|
||||||
erase_values(&result, &indexes);
|
|
||||||
my_env_set( dest, &result, scope);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
array_list_t value;
|
|
||||||
al_init(&value);
|
|
||||||
|
|
||||||
while( woptind < argc )
|
|
||||||
{
|
|
||||||
al_push(&value, argv[woptind++]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if( update_values( &result,
|
|
||||||
&indexes,
|
|
||||||
&value ) )
|
|
||||||
{
|
|
||||||
sb_printf( sb_err, L"%ls: ", argv[0] );
|
|
||||||
sb_printf( sb_err, ARRAY_BOUNDS_ERR );
|
|
||||||
sb_append( sb_err, L"\n" );
|
|
||||||
}
|
|
||||||
|
|
||||||
my_env_set(dest,
|
|
||||||
&result,
|
|
||||||
scope);
|
|
||||||
|
|
||||||
al_destroy( &value );
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
al_foreach( &result, &free );
|
|
||||||
al_destroy( &result );
|
|
||||||
|
|
||||||
al_destroy(&indexes);
|
|
||||||
al_destroy(&values);
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
woptind++;
|
|
||||||
|
|
||||||
/*
|
|
||||||
No slicing
|
|
||||||
*/
|
|
||||||
if( erase )
|
|
||||||
{
|
|
||||||
if( woptind != argc )
|
|
||||||
{
|
|
||||||
sb_printf( sb_err,
|
|
||||||
_(L"%ls: Values cannot be specfied with erase\n%ls\n"),
|
|
||||||
argv[0],
|
|
||||||
parser_current_line() );
|
|
||||||
builtin_print_help( argv[0], sb_err );
|
|
||||||
retcode=1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
retcode = env_remove( dest, scope );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
array_list_t val;
|
|
||||||
al_init( &val );
|
|
||||||
|
|
||||||
for( i=woptind; i<argc; i++ )
|
|
||||||
{
|
|
||||||
al_push( &val, argv[i] );
|
|
||||||
}
|
|
||||||
|
|
||||||
retcode = my_env_set( dest, &val, scope );
|
|
||||||
|
|
||||||
al_destroy( &val );
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
free( dest );
|
|
||||||
|
|
||||||
return retcode;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
836
builtin_set.cpp
Normal file
836
builtin_set.cpp
Normal file
@@ -0,0 +1,836 @@
|
|||||||
|
/** \file builtin_set.c Functions defining the set builtin
|
||||||
|
|
||||||
|
Functions used for implementing the set builtin.
|
||||||
|
|
||||||
|
*/
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <wchar.h>
|
||||||
|
#include <wctype.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <termios.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <vector>
|
||||||
|
#include <algorithm>
|
||||||
|
#include "fallback.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
#include "wutil.h"
|
||||||
|
#include "builtin.h"
|
||||||
|
#include "env.h"
|
||||||
|
#include "expand.h"
|
||||||
|
#include "common.h"
|
||||||
|
#include "wgetopt.h"
|
||||||
|
#include "proc.h"
|
||||||
|
#include "parser.h"
|
||||||
|
|
||||||
|
/* We know about these buffers */
|
||||||
|
extern wcstring stdout_buffer, stderr_buffer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Error message for invalid path operations
|
||||||
|
*/
|
||||||
|
#define BUILTIN_SET_PATH_ERROR L"%ls: Warning: path component %ls may not be valid in %ls.\n"
|
||||||
|
|
||||||
|
/**
|
||||||
|
Hint for invalid path operation with a colon
|
||||||
|
*/
|
||||||
|
#define BUILTIN_SET_PATH_HINT L"%ls: Did you mean 'set %ls $%ls %ls'?\n"
|
||||||
|
|
||||||
|
/**
|
||||||
|
Error for mismatch between index count and elements
|
||||||
|
*/
|
||||||
|
#define BUILTIN_SET_ARG_COUNT L"%ls: The number of variable indexes does not match the number of values\n"
|
||||||
|
|
||||||
|
/**
|
||||||
|
Test if the specified variable should be subject to path validation
|
||||||
|
*/
|
||||||
|
static int is_path_variable( const wchar_t *env )
|
||||||
|
{
|
||||||
|
return contains(env, L"PATH", L"CDPATH" );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Call env_set. If this is a path variable, e.g. PATH, validate the
|
||||||
|
elements. On error, print a description of the problem to stderr.
|
||||||
|
*/
|
||||||
|
static int my_env_set( const wchar_t *key, const wcstring_list_t &val, int scope )
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
int retcode = 0;
|
||||||
|
const wchar_t *val_str=NULL;
|
||||||
|
|
||||||
|
if( is_path_variable( key ) )
|
||||||
|
{
|
||||||
|
/* Fix for https://github.com/fish-shell/fish-shell/issues/199 . Return success if any path setting succeeds. */
|
||||||
|
bool any_success = false, any_error = false;
|
||||||
|
|
||||||
|
for( i=0; i< val.size() ; i++ )
|
||||||
|
{
|
||||||
|
bool show_perror = false;
|
||||||
|
int show_hint = 0;
|
||||||
|
bool error = false;
|
||||||
|
|
||||||
|
struct stat buff;
|
||||||
|
const wchar_t *dir = val[i].c_str();
|
||||||
|
|
||||||
|
if( wstat( dir, &buff ) )
|
||||||
|
{
|
||||||
|
error = true;
|
||||||
|
show_perror = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !( S_ISDIR(buff.st_mode) ) )
|
||||||
|
{
|
||||||
|
error = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !error )
|
||||||
|
{
|
||||||
|
any_success = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
any_error = true;
|
||||||
|
const wchar_t *colon;
|
||||||
|
append_format(stderr_buffer, _(BUILTIN_SET_PATH_ERROR), L"set", dir, key);
|
||||||
|
colon = wcschr( dir, L':' );
|
||||||
|
|
||||||
|
if( colon && *(colon+1) )
|
||||||
|
{
|
||||||
|
show_hint = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if( show_perror )
|
||||||
|
{
|
||||||
|
builtin_wperror( L"set" );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( show_hint )
|
||||||
|
{
|
||||||
|
append_format(stderr_buffer, _(BUILTIN_SET_PATH_HINT), L"set", key, key, wcschr( dir, L':' )+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fail at setting the path if we tried to set it to something non-empty, but it wound up empty. */
|
||||||
|
if( ! val.empty() && ! any_success )
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
wcstring sb;
|
||||||
|
if( val.size() )
|
||||||
|
{
|
||||||
|
for( i=0; i< val.size() ; i++ )
|
||||||
|
{
|
||||||
|
sb.append(val[i]);
|
||||||
|
if( i<val.size() - 1 )
|
||||||
|
{
|
||||||
|
sb.append( ARRAY_SEP_STR );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val_str = sb.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
switch( env_set( key, val_str, scope | ENV_USER ) )
|
||||||
|
{
|
||||||
|
case ENV_PERM:
|
||||||
|
{
|
||||||
|
append_format(stderr_buffer, _(L"%ls: Tried to change the read-only variable '%ls'\n"), L"set", key);
|
||||||
|
retcode=1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ENV_INVALID:
|
||||||
|
{
|
||||||
|
append_format(stderr_buffer, _(L"%ls: Unknown error"), L"set" );
|
||||||
|
retcode=1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return retcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Extract indexes from a destination argument of the form name[index1 index2...]
|
||||||
|
|
||||||
|
\param indexes the list to insert the new indexes into
|
||||||
|
\param src the source string to parse
|
||||||
|
\param name the name of the element. Return null if the name in \c src does not match this name
|
||||||
|
\param var_count the number of elements in the array to parse.
|
||||||
|
|
||||||
|
\return the total number of indexes parsed, or -1 on error
|
||||||
|
*/
|
||||||
|
static int parse_index( std::vector<long> &indexes,
|
||||||
|
const wchar_t *src,
|
||||||
|
const wchar_t *name,
|
||||||
|
size_t var_count )
|
||||||
|
{
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
const wchar_t *src_orig = src;
|
||||||
|
|
||||||
|
if (src == 0)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (*src != L'\0' && (iswalnum(*src) || *src == L'_'))
|
||||||
|
{
|
||||||
|
src++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*src != L'[')
|
||||||
|
{
|
||||||
|
append_format(stderr_buffer, _(BUILTIN_SET_ARG_COUNT), L"set" );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
len = src-src_orig;
|
||||||
|
|
||||||
|
if( (wcsncmp( src_orig, name, len )!=0) || (wcslen(name) != (len)) )
|
||||||
|
{
|
||||||
|
append_format(stderr_buffer,
|
||||||
|
_(L"%ls: Multiple variable names specified in single call (%ls and %.*ls)\n"),
|
||||||
|
L"set",
|
||||||
|
name,
|
||||||
|
len,
|
||||||
|
src_orig);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
src++;
|
||||||
|
|
||||||
|
while (iswspace(*src))
|
||||||
|
{
|
||||||
|
src++;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (*src != L']')
|
||||||
|
{
|
||||||
|
wchar_t *end;
|
||||||
|
|
||||||
|
long l_ind;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
|
||||||
|
l_ind = wcstol(src, &end, 10);
|
||||||
|
|
||||||
|
if( end==src || errno )
|
||||||
|
{
|
||||||
|
append_format(stderr_buffer, _(L"%ls: Invalid index starting at '%ls'\n"), L"set", src);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( l_ind < 0 )
|
||||||
|
{
|
||||||
|
l_ind = var_count+l_ind+1;
|
||||||
|
}
|
||||||
|
|
||||||
|
src = end;
|
||||||
|
if ( *src==L'.' && *(src+1)==L'.' ){
|
||||||
|
src+=2;
|
||||||
|
long l_ind2 = wcstol( src, &end, 10 );
|
||||||
|
if( end==src || errno )
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
src = end;
|
||||||
|
|
||||||
|
if( l_ind2 < 0 )
|
||||||
|
{
|
||||||
|
l_ind2 = var_count+l_ind2+1;
|
||||||
|
}
|
||||||
|
int direction = l_ind2<l_ind ? -1 : 1 ;
|
||||||
|
for (long jjj = l_ind; jjj*direction <= l_ind2*direction; jjj+=direction) {
|
||||||
|
// debug(0, L"Expand range [set]: %i\n", jjj);
|
||||||
|
indexes.push_back( jjj );
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
indexes.push_back( l_ind );
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
while (iswspace(*src)) src++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int update_values( wcstring_list_t &list,
|
||||||
|
std::vector<long> &indexes,
|
||||||
|
wcstring_list_t &values )
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
/* Replace values where needed */
|
||||||
|
for( i = 0; i < indexes.size(); i++ )
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
The '- 1' below is because the indices in fish are
|
||||||
|
one-based, but the vector uses zero-based indices
|
||||||
|
*/
|
||||||
|
long ind = indexes[i] - 1;
|
||||||
|
const wcstring newv = values[ i ];
|
||||||
|
if( ind < 0 )
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if ( (size_t)ind >= list.size() )
|
||||||
|
{
|
||||||
|
list.resize( ind+1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
// free((void *) al_get(list, ind));
|
||||||
|
list[ ind ] = newv;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Erase from a list of wcstring values at specified indexes
|
||||||
|
*/
|
||||||
|
static void erase_values(wcstring_list_t &list, const std::vector<long> &indexes)
|
||||||
|
{
|
||||||
|
// Make a set of indexes.
|
||||||
|
// This both sorts them into ascending order and removes duplicates.
|
||||||
|
const std::set<long> indexes_set(indexes.begin(), indexes.end());
|
||||||
|
|
||||||
|
// Now walk the set backwards, so we encounter larger indexes first, and remove elements at the given (1-based) indexes.
|
||||||
|
std::set<long>::const_reverse_iterator iter;
|
||||||
|
for (iter = indexes_set.rbegin(); iter != indexes_set.rend(); iter++) {
|
||||||
|
long val = *iter;
|
||||||
|
if (val > 0 && (size_t)val <= list.size()) {
|
||||||
|
// One-based indexing!
|
||||||
|
list.erase(list.begin() + val - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Print the names of all environment variables in the scope, with or without shortening,
|
||||||
|
with or without values, with or without escaping
|
||||||
|
*/
|
||||||
|
static void print_variables(int include_values, int esc, bool shorten_ok, int scope)
|
||||||
|
{
|
||||||
|
wcstring_list_t names = env_get_names(scope);
|
||||||
|
sort(names.begin(), names.end());
|
||||||
|
|
||||||
|
for( size_t i = 0; i < names.size(); i++ )
|
||||||
|
{
|
||||||
|
const wcstring key = names.at(i);
|
||||||
|
const wcstring e_key = escape_string(key, 0);
|
||||||
|
|
||||||
|
stdout_buffer.append(e_key);
|
||||||
|
|
||||||
|
if( include_values )
|
||||||
|
{
|
||||||
|
env_var_t value = env_get_string(key);
|
||||||
|
if( !value.missing() )
|
||||||
|
{
|
||||||
|
int shorten = 0;
|
||||||
|
|
||||||
|
if( shorten_ok && value.length() > 64 )
|
||||||
|
{
|
||||||
|
shorten = 1;
|
||||||
|
value.resize(60);
|
||||||
|
}
|
||||||
|
|
||||||
|
wcstring e_value = esc ? expand_escape_variable(value) : value;
|
||||||
|
|
||||||
|
stdout_buffer.append(L" ");
|
||||||
|
stdout_buffer.append(e_value);
|
||||||
|
|
||||||
|
if( shorten )
|
||||||
|
{
|
||||||
|
stdout_buffer.append(L"\u2026");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stdout_buffer.append(L"\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
The set builtin. Creates, updates and erases environment variables
|
||||||
|
and environemnt variable arrays.
|
||||||
|
*/
|
||||||
|
static int builtin_set( parser_t &parser, wchar_t **argv )
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
Variables used for parsing the argument list
|
||||||
|
*/
|
||||||
|
static const struct woption
|
||||||
|
long_options[] =
|
||||||
|
{
|
||||||
|
{
|
||||||
|
L"export", no_argument, 0, 'x'
|
||||||
|
}
|
||||||
|
,
|
||||||
|
{
|
||||||
|
L"global", no_argument, 0, 'g'
|
||||||
|
}
|
||||||
|
,
|
||||||
|
{
|
||||||
|
L"local", no_argument, 0, 'l'
|
||||||
|
}
|
||||||
|
,
|
||||||
|
{
|
||||||
|
L"erase", no_argument, 0, 'e'
|
||||||
|
}
|
||||||
|
,
|
||||||
|
{
|
||||||
|
L"names", no_argument, 0, 'n'
|
||||||
|
}
|
||||||
|
,
|
||||||
|
{
|
||||||
|
L"unexport", no_argument, 0, 'u'
|
||||||
|
}
|
||||||
|
,
|
||||||
|
{
|
||||||
|
L"universal", no_argument, 0, 'U'
|
||||||
|
}
|
||||||
|
,
|
||||||
|
{
|
||||||
|
L"long", no_argument, 0, 'L'
|
||||||
|
}
|
||||||
|
,
|
||||||
|
{
|
||||||
|
L"query", no_argument, 0, 'q'
|
||||||
|
}
|
||||||
|
,
|
||||||
|
{
|
||||||
|
L"help", no_argument, 0, 'h'
|
||||||
|
}
|
||||||
|
,
|
||||||
|
{
|
||||||
|
0, 0, 0, 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
|
const wchar_t *short_options = L"+xglenuULqh";
|
||||||
|
|
||||||
|
int argc = builtin_count_args(argv);
|
||||||
|
|
||||||
|
/*
|
||||||
|
Flags to set the work mode
|
||||||
|
*/
|
||||||
|
int local = 0, global = 0, exportv = 0;
|
||||||
|
int erase = 0, list = 0, unexport=0;
|
||||||
|
int universal = 0, query=0;
|
||||||
|
bool shorten_ok = true;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Variables used for performing the actual work
|
||||||
|
*/
|
||||||
|
wchar_t *dest = 0;
|
||||||
|
int retcode=0;
|
||||||
|
int scope;
|
||||||
|
int slice=0;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
wchar_t *bad_char;
|
||||||
|
|
||||||
|
|
||||||
|
/* Parse options to obtain the requested operation and the modifiers */
|
||||||
|
woptind = 0;
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
int c = wgetopt_long(argc, argv, short_options, long_options, 0);
|
||||||
|
|
||||||
|
if (c == -1)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(c)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'e':
|
||||||
|
erase = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'n':
|
||||||
|
list = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'x':
|
||||||
|
exportv = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'l':
|
||||||
|
local = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'g':
|
||||||
|
global = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'u':
|
||||||
|
unexport = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'U':
|
||||||
|
universal = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'L':
|
||||||
|
shorten_ok = false;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'q':
|
||||||
|
query = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'h':
|
||||||
|
builtin_print_help( parser, argv[0], stdout_buffer );
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
case '?':
|
||||||
|
builtin_unknown_option( parser, argv[0], argv[woptind-1] );
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Ok, all arguments have been parsed, let's validate them
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
If we are checking the existance of a variable (-q) we can not
|
||||||
|
also specify scope
|
||||||
|
*/
|
||||||
|
|
||||||
|
if( query && (erase || list) )
|
||||||
|
{
|
||||||
|
append_format(stderr_buffer,
|
||||||
|
BUILTIN_ERR_COMBO,
|
||||||
|
argv[0] );
|
||||||
|
|
||||||
|
builtin_print_help( parser, argv[0], stderr_buffer );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* We can't both list and erase varaibles */
|
||||||
|
if( erase && list )
|
||||||
|
{
|
||||||
|
append_format(stderr_buffer,
|
||||||
|
BUILTIN_ERR_COMBO,
|
||||||
|
argv[0] );
|
||||||
|
|
||||||
|
builtin_print_help( parser, argv[0], stderr_buffer );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Variables can only have one scope
|
||||||
|
*/
|
||||||
|
if( local + global + universal > 1 )
|
||||||
|
{
|
||||||
|
append_format(stderr_buffer,
|
||||||
|
BUILTIN_ERR_GLOCAL,
|
||||||
|
argv[0] );
|
||||||
|
builtin_print_help( parser, argv[0], stderr_buffer );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Variables can only have one export status
|
||||||
|
*/
|
||||||
|
if( exportv && unexport )
|
||||||
|
{
|
||||||
|
append_format(stderr_buffer,
|
||||||
|
BUILTIN_ERR_EXPUNEXP,
|
||||||
|
argv[0] );
|
||||||
|
builtin_print_help( parser, argv[0], stderr_buffer );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Calculate the scope value for variable assignement
|
||||||
|
*/
|
||||||
|
scope = (local ? ENV_LOCAL : 0) | (global ? ENV_GLOBAL : 0) | (exportv ? ENV_EXPORT : 0) | (unexport ? ENV_UNEXPORT : 0) | (universal ? ENV_UNIVERSAL:0) | ENV_USER;
|
||||||
|
|
||||||
|
if( query )
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Query mode. Return the number of variables that do not exist
|
||||||
|
out of the specified variables.
|
||||||
|
*/
|
||||||
|
int i;
|
||||||
|
for( i=woptind; i<argc; i++ )
|
||||||
|
{
|
||||||
|
wchar_t *arg = argv[i];
|
||||||
|
int slice=0;
|
||||||
|
|
||||||
|
if( !(dest = wcsdup(arg)))
|
||||||
|
{
|
||||||
|
DIE_MEM();
|
||||||
|
}
|
||||||
|
|
||||||
|
if( wcschr( dest, L'[' ) )
|
||||||
|
{
|
||||||
|
slice = 1;
|
||||||
|
*wcschr( dest, L'[' )=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( slice )
|
||||||
|
{
|
||||||
|
std::vector<long> indexes;
|
||||||
|
wcstring_list_t result;
|
||||||
|
size_t j;
|
||||||
|
|
||||||
|
env_var_t dest_str = env_get_string(dest);
|
||||||
|
if (! dest_str.missing())
|
||||||
|
tokenize_variable_array( dest_str, result );
|
||||||
|
|
||||||
|
if( !parse_index( indexes, arg, dest, result.size() ) )
|
||||||
|
{
|
||||||
|
builtin_print_help( parser, argv[0], stderr_buffer );
|
||||||
|
retcode = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
for( j=0; j < indexes.size() ; j++ )
|
||||||
|
{
|
||||||
|
long idx = indexes[j];
|
||||||
|
if( idx < 1 || (size_t)idx > result.size() )
|
||||||
|
{
|
||||||
|
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, shorten_ok, scope);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( woptind == argc )
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Print values of variables
|
||||||
|
*/
|
||||||
|
|
||||||
|
if( erase )
|
||||||
|
{
|
||||||
|
append_format(stderr_buffer,
|
||||||
|
_(L"%ls: Erase needs a variable name\n"),
|
||||||
|
argv[0] );
|
||||||
|
|
||||||
|
builtin_print_help( parser, argv[0], stderr_buffer );
|
||||||
|
retcode = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print_variables( 1, 1, shorten_ok, scope );
|
||||||
|
}
|
||||||
|
|
||||||
|
return retcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !(dest = wcsdup(argv[woptind])))
|
||||||
|
{
|
||||||
|
DIE_MEM();
|
||||||
|
}
|
||||||
|
|
||||||
|
if( wcschr( dest, L'[' ) )
|
||||||
|
{
|
||||||
|
slice = 1;
|
||||||
|
*wcschr( dest, L'[' )=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !wcslen( dest ) )
|
||||||
|
{
|
||||||
|
free( dest );
|
||||||
|
append_format(stderr_buffer, BUILTIN_ERR_VARNAME_ZERO, argv[0] );
|
||||||
|
builtin_print_help( parser, argv[0], stderr_buffer );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( (bad_char = wcsvarname( dest ) ) )
|
||||||
|
{
|
||||||
|
append_format(stderr_buffer, BUILTIN_ERR_VARCHAR, argv[0], *bad_char );
|
||||||
|
builtin_print_help( parser, argv[0], stderr_buffer );
|
||||||
|
free( dest );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( slice && erase && (scope != ENV_USER) )
|
||||||
|
{
|
||||||
|
free( dest );
|
||||||
|
append_format(stderr_buffer, _(L"%ls: Can not specify scope when erasing array slice\n"), argv[0] );
|
||||||
|
builtin_print_help( parser, argv[0], stderr_buffer );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
set assignment can work in two modes, either using slices or
|
||||||
|
using the whole array. We detect which mode is used here.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if( slice )
|
||||||
|
{
|
||||||
|
|
||||||
|
/*
|
||||||
|
Slice mode
|
||||||
|
*/
|
||||||
|
size_t idx_count, val_count;
|
||||||
|
wcstring_list_t values;
|
||||||
|
std::vector<long> indexes;
|
||||||
|
wcstring_list_t result;
|
||||||
|
|
||||||
|
const env_var_t dest_str = env_get_string(dest);
|
||||||
|
if (! dest_str.missing())
|
||||||
|
tokenize_variable_array( dest_str, result );
|
||||||
|
|
||||||
|
for( ; woptind<argc; woptind++ )
|
||||||
|
{
|
||||||
|
if( !parse_index( indexes, argv[woptind], dest, result.size() ) )
|
||||||
|
{
|
||||||
|
builtin_print_help( parser, argv[0], stderr_buffer );
|
||||||
|
retcode = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
val_count = argc-woptind-1;
|
||||||
|
idx_count = indexes.size();
|
||||||
|
|
||||||
|
if( !erase )
|
||||||
|
{
|
||||||
|
if( val_count < idx_count )
|
||||||
|
{
|
||||||
|
append_format(stderr_buffer, _(BUILTIN_SET_ARG_COUNT), argv[0] );
|
||||||
|
builtin_print_help( parser, argv[0], stderr_buffer );
|
||||||
|
retcode=1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if( val_count == idx_count )
|
||||||
|
{
|
||||||
|
woptind++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !retcode )
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Slice indexes have been calculated, do the actual work
|
||||||
|
*/
|
||||||
|
|
||||||
|
if( erase )
|
||||||
|
{
|
||||||
|
erase_values(result, indexes);
|
||||||
|
my_env_set( dest, result, scope);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wcstring_list_t value;
|
||||||
|
// al_init(&value);
|
||||||
|
|
||||||
|
while( woptind < argc )
|
||||||
|
{
|
||||||
|
value.push_back( argv[woptind++] );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( update_values( result,
|
||||||
|
indexes,
|
||||||
|
value ) )
|
||||||
|
{
|
||||||
|
append_format(stderr_buffer, L"%ls: ", argv[0] );
|
||||||
|
append_format(stderr_buffer, ARRAY_BOUNDS_ERR );
|
||||||
|
stderr_buffer.push_back(L'\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
my_env_set(dest, result, scope);
|
||||||
|
|
||||||
|
// al_destroy( &value );
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// al_foreach( &result, &free );
|
||||||
|
// al_destroy( &result );
|
||||||
|
|
||||||
|
// al_destroy(&indexes);
|
||||||
|
// al_destroy(&values);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
woptind++;
|
||||||
|
|
||||||
|
/*
|
||||||
|
No slicing
|
||||||
|
*/
|
||||||
|
if( erase )
|
||||||
|
{
|
||||||
|
if( woptind != argc )
|
||||||
|
{
|
||||||
|
append_format(stderr_buffer,
|
||||||
|
_(L"%ls: Values cannot be specfied with erase\n"),
|
||||||
|
argv[0] );
|
||||||
|
builtin_print_help( parser, argv[0], stderr_buffer );
|
||||||
|
retcode=1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
retcode = env_remove( dest, scope );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wcstring_list_t val;
|
||||||
|
for( i=woptind; i<argc; i++ )
|
||||||
|
val.push_back(argv[i]);
|
||||||
|
retcode = my_env_set( dest, val, scope );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
free( dest );
|
||||||
|
|
||||||
|
return retcode;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
745
builtin_test.cpp
Normal file
745
builtin_test.cpp
Normal file
@@ -0,0 +1,745 @@
|
|||||||
|
/** \file builtin_test.cpp Functions defining the test builtin
|
||||||
|
|
||||||
|
Functions used for implementing the test builtin.
|
||||||
|
Implemented from scratch (yes, really) by way of IEEE 1003.1 as reference.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "common.h"
|
||||||
|
#include "builtin.h"
|
||||||
|
#include "wutil.h"
|
||||||
|
#include "proc.h"
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
|
||||||
|
enum {
|
||||||
|
BUILTIN_TEST_SUCCESS = STATUS_BUILTIN_OK,
|
||||||
|
BUILTIN_TEST_FAIL = STATUS_BUILTIN_ERROR
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
int builtin_test( parser_t &parser, wchar_t **argv );
|
||||||
|
|
||||||
|
static const wchar_t * const condstr[] = {
|
||||||
|
L"!", L"&&", L"||", L"==", L"!=", L"<", L">", L"-nt", L"-ot", L"-ef", L"-eq",
|
||||||
|
L"-ne", L"-lt", L"-gt", L"-le", L"-ge", L"=~"
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace test_expressions {
|
||||||
|
|
||||||
|
enum token_t {
|
||||||
|
test_unknown, // arbitrary string
|
||||||
|
|
||||||
|
test_bang, // "!", inverts sense
|
||||||
|
|
||||||
|
test_filetype_b, // "-b", for block special files
|
||||||
|
test_filetype_c, // "-c" for character special files
|
||||||
|
test_filetype_d, // "-d" for directories
|
||||||
|
test_filetype_e, // "-e" for files that exist
|
||||||
|
test_filetype_f, // "-f" for for regular files
|
||||||
|
test_filetype_g, // "-g" for set-group-id
|
||||||
|
test_filetype_h, // "-h" for symbolic links
|
||||||
|
test_filetype_L, // "-L", same as -h
|
||||||
|
test_filetype_p, // "-p", for FIFO
|
||||||
|
test_filetype_S, // "-S", socket
|
||||||
|
|
||||||
|
test_filesize_s, // "-s", size greater than zero
|
||||||
|
|
||||||
|
test_filedesc_t, // "-t", whether the fd is associated with a terminal
|
||||||
|
|
||||||
|
test_fileperm_r, // "-r", read permission
|
||||||
|
test_fileperm_u, // "-u", whether file is setuid
|
||||||
|
test_fileperm_w, // "-w", whether file write permission is allowed
|
||||||
|
test_fileperm_x, // "-x", whether file execute/search is allowed
|
||||||
|
|
||||||
|
test_string_n, // "-n", non-empty string
|
||||||
|
test_string_z, // "-z", true if length of string is 0
|
||||||
|
test_string_equal, // "=", true if strings are identical
|
||||||
|
test_string_not_equal, // "!=", true if strings are not identical
|
||||||
|
|
||||||
|
test_number_equal, // "-eq", true if numbers are equal
|
||||||
|
test_number_not_equal, // "-ne", true if numbers are not equal
|
||||||
|
test_number_greater, // "-gt", true if first number is larger than second
|
||||||
|
test_number_greater_equal, // "-ge", true if first number is at least second
|
||||||
|
test_number_lesser, // "-lt", true if first number is smaller than second
|
||||||
|
test_number_lesser_equal, // "-le", true if first number is at most second
|
||||||
|
|
||||||
|
test_combine_and, // "-a", true if left and right are both true
|
||||||
|
test_combine_or, // "-o", true if either left or right is true
|
||||||
|
|
||||||
|
test_paren_open, // "(", open paren
|
||||||
|
test_paren_close, // ")", close paren
|
||||||
|
};
|
||||||
|
|
||||||
|
static bool binary_primary_evaluate(test_expressions::token_t token, const wcstring &left, const wcstring &right, wcstring_list_t &errors);
|
||||||
|
static bool unary_primary_evaluate(test_expressions::token_t token, const wcstring &arg, wcstring_list_t &errors);
|
||||||
|
|
||||||
|
|
||||||
|
enum {
|
||||||
|
UNARY_PRIMARY = 1 << 0,
|
||||||
|
BINARY_PRIMARY = 1 << 1
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct token_info_t { token_t tok; const wchar_t *string; unsigned int flags; } token_infos[] =
|
||||||
|
{
|
||||||
|
{test_unknown, L"", 0},
|
||||||
|
{test_bang, L"!", 0},
|
||||||
|
{test_filetype_b, L"-b", UNARY_PRIMARY},
|
||||||
|
{test_filetype_c, L"-c", UNARY_PRIMARY},
|
||||||
|
{test_filetype_d, L"-d", UNARY_PRIMARY},
|
||||||
|
{test_filetype_e, L"-e", UNARY_PRIMARY},
|
||||||
|
{test_filetype_f, L"-f", UNARY_PRIMARY},
|
||||||
|
{test_filetype_g, L"-g", UNARY_PRIMARY},
|
||||||
|
{test_filetype_h, L"-h", UNARY_PRIMARY},
|
||||||
|
{test_filetype_L, L"-L", UNARY_PRIMARY},
|
||||||
|
{test_filetype_p, L"-p", UNARY_PRIMARY},
|
||||||
|
{test_filetype_S, L"-S", UNARY_PRIMARY},
|
||||||
|
{test_filesize_s, L"-s", UNARY_PRIMARY},
|
||||||
|
{test_filedesc_t, L"-t", UNARY_PRIMARY},
|
||||||
|
{test_fileperm_r, L"-r", UNARY_PRIMARY},
|
||||||
|
{test_fileperm_u, L"-u", UNARY_PRIMARY},
|
||||||
|
{test_fileperm_w, L"-w", UNARY_PRIMARY},
|
||||||
|
{test_fileperm_x, L"-x", UNARY_PRIMARY},
|
||||||
|
{test_string_n, L"-n", UNARY_PRIMARY},
|
||||||
|
{test_string_z, L"-z", UNARY_PRIMARY},
|
||||||
|
{test_string_equal, L"=", BINARY_PRIMARY},
|
||||||
|
{test_string_not_equal, L"!=", BINARY_PRIMARY},
|
||||||
|
{test_number_equal, L"-eq", BINARY_PRIMARY},
|
||||||
|
{test_number_not_equal, L"-ne", BINARY_PRIMARY},
|
||||||
|
{test_number_greater, L"-gt", BINARY_PRIMARY},
|
||||||
|
{test_number_greater_equal, L"-ge", BINARY_PRIMARY},
|
||||||
|
{test_number_lesser, L"-lt", BINARY_PRIMARY},
|
||||||
|
{test_number_lesser_equal, L"-le", BINARY_PRIMARY},
|
||||||
|
{test_combine_and, L"-a", 0},
|
||||||
|
{test_combine_or, L"-o", 0},
|
||||||
|
{test_paren_open, L"(", 0},
|
||||||
|
{test_paren_close, L")", 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
const token_info_t *token_for_string(const wcstring &str) {
|
||||||
|
for (size_t i=0; i < sizeof token_infos / sizeof *token_infos; i++) {
|
||||||
|
if (str == token_infos[i].string) {
|
||||||
|
return &token_infos[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return &token_infos[0]; //unknown
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Grammar.
|
||||||
|
|
||||||
|
<expr> = <combining_expr>
|
||||||
|
|
||||||
|
<combining_expr> = <unary_expr> and/or <combining_expr> |
|
||||||
|
<unary_expr>
|
||||||
|
|
||||||
|
<unary_expr> = bang <unary_expr> |
|
||||||
|
<primary>
|
||||||
|
|
||||||
|
<primary> = <unary_primary> arg |
|
||||||
|
arg <binary_primary> arg |
|
||||||
|
'(' <expr> ')'
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
class expression;
|
||||||
|
class test_parser {
|
||||||
|
private:
|
||||||
|
wcstring_list_t strings;
|
||||||
|
wcstring_list_t errors;
|
||||||
|
|
||||||
|
expression *error(const wchar_t *fmt, ...);
|
||||||
|
void add_error(const wchar_t *fmt, ...);
|
||||||
|
|
||||||
|
const wcstring &arg(unsigned int idx) { return strings.at(idx); }
|
||||||
|
|
||||||
|
public:
|
||||||
|
test_parser(const wcstring_list_t &val) : strings(val)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
expression *parse_expression(unsigned int start, unsigned int end);
|
||||||
|
expression *parse_combining_expression(unsigned int start, unsigned int end);
|
||||||
|
expression *parse_unary_expression(unsigned int start, unsigned int end);
|
||||||
|
|
||||||
|
expression *parse_primary(unsigned int start, unsigned int end);
|
||||||
|
expression *parse_parenthentical(unsigned int start, unsigned int end);
|
||||||
|
expression *parse_unary_primary(unsigned int start, unsigned int end);
|
||||||
|
expression *parse_binary_primary(unsigned int start, unsigned int end);
|
||||||
|
expression *parse_just_a_string(unsigned int start, unsigned int end);
|
||||||
|
|
||||||
|
static expression *parse_args(const wcstring_list_t &args, wcstring &err);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct range_t {
|
||||||
|
unsigned int start;
|
||||||
|
unsigned int end;
|
||||||
|
|
||||||
|
range_t(unsigned s, unsigned e) : start(s), end(e) { }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* Base class for expressions */
|
||||||
|
class expression {
|
||||||
|
protected:
|
||||||
|
expression(token_t what, range_t where) : token(what), range(where) { }
|
||||||
|
|
||||||
|
public:
|
||||||
|
const token_t token;
|
||||||
|
range_t range;
|
||||||
|
|
||||||
|
virtual ~expression() { }
|
||||||
|
|
||||||
|
// evaluate returns true if the expression is true (i.e. BUILTIN_TEST_SUCCESS)
|
||||||
|
virtual bool evaluate(wcstring_list_t &errors) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::auto_ptr<expression> expr_ref_t;
|
||||||
|
|
||||||
|
/* Single argument like -n foo or "just a string" */
|
||||||
|
class unary_primary : public expression {
|
||||||
|
public:
|
||||||
|
wcstring arg;
|
||||||
|
unary_primary(token_t tok, range_t where, const wcstring &what) : expression(tok, where), arg(what) { }
|
||||||
|
bool evaluate(wcstring_list_t &errors);
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Two argument primary like foo != bar */
|
||||||
|
class binary_primary : public expression {
|
||||||
|
public:
|
||||||
|
wcstring arg_left;
|
||||||
|
wcstring arg_right;
|
||||||
|
|
||||||
|
binary_primary(token_t tok, range_t where, const wcstring &left, const wcstring &right) : expression(tok, where), arg_left(left), arg_right(right)
|
||||||
|
{ }
|
||||||
|
bool evaluate(wcstring_list_t &errors);
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Unary operator like bang */
|
||||||
|
class unary_operator : public expression {
|
||||||
|
public:
|
||||||
|
expr_ref_t subject;
|
||||||
|
unary_operator(token_t tok, range_t where, expr_ref_t &exp) : expression(tok, where), subject(exp) { }
|
||||||
|
bool evaluate(wcstring_list_t &errors);
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Combining expression. Contains a list of AND or OR expressions. It takes more than two so that we don't have to worry about precedence in the parser. */
|
||||||
|
class combining_expression : public expression {
|
||||||
|
public:
|
||||||
|
const std::vector<expression *> subjects;
|
||||||
|
const std::vector<token_t> combiners;
|
||||||
|
|
||||||
|
combining_expression(token_t tok, range_t where, const std::vector<expression *> &exprs, const std::vector<token_t> &combs) : expression(tok, where), subjects(exprs), combiners(combs)
|
||||||
|
{
|
||||||
|
/* We should have one more subject than combiner */
|
||||||
|
assert(subjects.size() == combiners.size() + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* We are responsible for destroying our expressions */
|
||||||
|
virtual ~combining_expression() {
|
||||||
|
for (size_t i=0; i < subjects.size(); i++) {
|
||||||
|
delete subjects[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool evaluate(wcstring_list_t &errors);
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Parenthetical expression */
|
||||||
|
class parenthetical_expression : public expression {
|
||||||
|
public:
|
||||||
|
expr_ref_t contents;
|
||||||
|
parenthetical_expression(token_t tok, range_t where, expr_ref_t &expr) : expression(tok, where), contents(expr) { }
|
||||||
|
|
||||||
|
virtual bool evaluate(wcstring_list_t &errors);
|
||||||
|
};
|
||||||
|
|
||||||
|
void test_parser::add_error(const wchar_t *fmt, ...) {
|
||||||
|
assert(fmt != NULL);
|
||||||
|
va_list va;
|
||||||
|
va_start(va, fmt);
|
||||||
|
this->errors.push_back(vformat_string(fmt, va));
|
||||||
|
va_end(va);
|
||||||
|
}
|
||||||
|
|
||||||
|
expression *test_parser::error(const wchar_t *fmt, ...) {
|
||||||
|
assert(fmt != NULL);
|
||||||
|
va_list va;
|
||||||
|
va_start(va, fmt);
|
||||||
|
this->errors.push_back(vformat_string(fmt, va));
|
||||||
|
va_end(va);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
expression *test_parser::parse_unary_expression(unsigned int start, unsigned int end) {
|
||||||
|
if (start >= end) {
|
||||||
|
return error(L"Missing argument at index %u", start);
|
||||||
|
}
|
||||||
|
token_t tok = token_for_string(arg(start))->tok;
|
||||||
|
if (tok == test_bang) {
|
||||||
|
expr_ref_t subject(parse_unary_expression(start + 1, end));
|
||||||
|
if (subject.get()) {
|
||||||
|
return new unary_operator(tok, range_t(start, subject->range.end), subject);
|
||||||
|
} else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return parse_primary(start, end);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Parse a combining expression (AND, OR) */
|
||||||
|
expression *test_parser::parse_combining_expression(unsigned int start, unsigned int end) {
|
||||||
|
if (start >= end)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
std::vector<expression *> subjects;
|
||||||
|
std::vector<token_t> combiners;
|
||||||
|
unsigned int idx = start;
|
||||||
|
|
||||||
|
while (idx < end) {
|
||||||
|
|
||||||
|
if (! subjects.empty()) {
|
||||||
|
/* This is not the first expression, so we expect a combiner. */
|
||||||
|
token_t combiner = token_for_string(arg(idx))->tok;
|
||||||
|
if (combiner != test_combine_and && combiner != test_combine_or) {
|
||||||
|
/* Not a combiner, we're done */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
combiners.push_back(combiner);
|
||||||
|
idx++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Parse another expression */
|
||||||
|
expression *expr = parse_unary_expression(idx, end);
|
||||||
|
if (! expr) {
|
||||||
|
add_error(L"Missing argument at index %u", idx);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Go to the end of this expression */
|
||||||
|
idx = expr->range.end;
|
||||||
|
subjects.push_back(expr);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! subjects.empty()) {
|
||||||
|
/* Our new expression takes ownership of all expressions we created. The token we pass is irrelevant. */
|
||||||
|
return new combining_expression(test_combine_and, range_t(start, idx), subjects, combiners);
|
||||||
|
} else {
|
||||||
|
/* No subjects */
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
expression *test_parser::parse_unary_primary(unsigned int start, unsigned int end) {
|
||||||
|
/* We need two arguments */
|
||||||
|
if (start >= end) {
|
||||||
|
return error(L"Missing argument at index %u", start);
|
||||||
|
}
|
||||||
|
if (start + 1 >= end) {
|
||||||
|
return error(L"Missing argument at index %u", start + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* All our unary primaries are prefix, so the operator is at start. */
|
||||||
|
const token_info_t *info = token_for_string(arg(start));
|
||||||
|
if (! (info->flags & UNARY_PRIMARY))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return new unary_primary(info->tok, range_t(start, start + 2), arg(start + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
expression *test_parser::parse_just_a_string(unsigned int start, unsigned int end) {
|
||||||
|
/* Handle a string as a unary primary that is not a token of any other type.
|
||||||
|
e.g. 'test foo -a bar' should evaluate to true
|
||||||
|
We handle this with a unary primary of test_string_n
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* We need one arguments */
|
||||||
|
if (start >= end) {
|
||||||
|
return error(L"Missing argument at index %u", start);
|
||||||
|
}
|
||||||
|
|
||||||
|
const token_info_t *info = token_for_string(arg(start));
|
||||||
|
if (info->tok != test_unknown) {
|
||||||
|
return error(L"Unexpected argument type at index %u", start);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This is hackish; a nicer way to implement this would be with a "just a string" expression type */
|
||||||
|
return new unary_primary(test_string_n, range_t(start, start + 1), arg(start));
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
expression *test_parser::parse_unary_primary(unsigned int start, unsigned int end) {
|
||||||
|
/* We need either one or two arguments */
|
||||||
|
if (start >= end) {
|
||||||
|
return error(L"Missing argument at index %u", start);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The index of the argument to the unary primary */
|
||||||
|
unsigned int arg_idx;
|
||||||
|
|
||||||
|
/* All our unary primaries are prefix, so any operator is at start. But it also may just be a string, with no operator. */
|
||||||
|
const token_info_t *info = token_for_string(arg(start));
|
||||||
|
if (info->flags & UNARY_PRIMARY) {
|
||||||
|
/* We have an operator. Skip the operator argument */
|
||||||
|
arg_idx = start + 1;
|
||||||
|
|
||||||
|
/* We have some freedom here...do we allow other tokens for the argument to operate on?
|
||||||
|
For example, should 'test -n =' work? I say yes. So no typechecking on the next token. */
|
||||||
|
|
||||||
|
} else if (info->tok == test_unknown) {
|
||||||
|
/* "Just a string. */
|
||||||
|
arg_idx = start;
|
||||||
|
} else {
|
||||||
|
/* Here we don't allow arbitrary tokens as "just a string." I.e. 'test = -a =' should have a parse error. We could relax this at some point. */
|
||||||
|
return error(L"Parse error at argument index %u", start);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Verify we have the argument we want, i.e. test -n should fail to parse */
|
||||||
|
if (arg_idx >= end) {
|
||||||
|
return error(L"Missing argument at index %u", arg_idx);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new unary_primary(info->tok, range_t(start, arg_idx + 1), arg(arg_idx));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
expression *test_parser::parse_binary_primary(unsigned int start, unsigned int end) {
|
||||||
|
/* We need three arguments */
|
||||||
|
for (unsigned int idx = start; idx < start + 3; idx++) {
|
||||||
|
if (idx >= end) {
|
||||||
|
return error(L"Missing argument at index %u", idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* All our binary primaries are infix, so the operator is at start + 1. */
|
||||||
|
const token_info_t *info = token_for_string(arg(start + 1));
|
||||||
|
if (! (info->flags & BINARY_PRIMARY))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return new binary_primary(info->tok, range_t(start, start + 3), arg(start), arg(start + 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
expression *test_parser::parse_parenthentical(unsigned int start, unsigned int end) {
|
||||||
|
/* We need at least three arguments: open paren, argument, close paren */
|
||||||
|
if (start + 3 >= end)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* Must start with an open expression */
|
||||||
|
const token_info_t *open_paren = token_for_string(arg(start));
|
||||||
|
if (open_paren->tok != test_paren_open)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* Parse a subexpression */
|
||||||
|
expression *subexr_ptr = parse_expression(start + 1, end);
|
||||||
|
if (! subexr_ptr)
|
||||||
|
return NULL;
|
||||||
|
expr_ref_t subexpr(subexr_ptr);
|
||||||
|
|
||||||
|
/* Parse a close paren */
|
||||||
|
unsigned close_index = subexpr->range.end;
|
||||||
|
assert(close_index <= end);
|
||||||
|
if (close_index == end) {
|
||||||
|
return error(L"Missing close paren at index %u", close_index);
|
||||||
|
}
|
||||||
|
const token_info_t *close_paren = token_for_string(arg(close_index));
|
||||||
|
if (close_paren->tok != test_paren_close) {
|
||||||
|
return error(L"Expected close paren at index %u", close_index);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Success */
|
||||||
|
return new parenthetical_expression(test_paren_open, range_t(start, close_index+1), subexpr);
|
||||||
|
}
|
||||||
|
|
||||||
|
expression *test_parser::parse_primary(unsigned int start, unsigned int end) {
|
||||||
|
if (start >= end) {
|
||||||
|
return error(L"Missing argument at index %u", start);
|
||||||
|
}
|
||||||
|
|
||||||
|
expression *expr = NULL;
|
||||||
|
if (! expr) expr = parse_parenthentical(start, end);
|
||||||
|
if (! expr) expr = parse_unary_primary(start, end);
|
||||||
|
if (! expr) expr = parse_binary_primary(start, end);
|
||||||
|
if (! expr) expr = parse_just_a_string(start, end);
|
||||||
|
return expr;
|
||||||
|
}
|
||||||
|
|
||||||
|
expression *test_parser::parse_expression(unsigned int start, unsigned int end) {
|
||||||
|
if (start >= end) {
|
||||||
|
return error(L"Missing argument at index %u", start);
|
||||||
|
}
|
||||||
|
|
||||||
|
return parse_combining_expression(start, end);
|
||||||
|
}
|
||||||
|
|
||||||
|
expression *test_parser::parse_args(const wcstring_list_t &args, wcstring &err) {
|
||||||
|
/* Empty list and one-arg list should be handled by caller */
|
||||||
|
assert(args.size() > 1);
|
||||||
|
|
||||||
|
test_parser parser(args);
|
||||||
|
expression *result = parser.parse_expression(0, (unsigned int)args.size());
|
||||||
|
|
||||||
|
/* Handle errors */
|
||||||
|
bool errored = false;
|
||||||
|
for (size_t i = 0; i < parser.errors.size(); i++) {
|
||||||
|
err.append(L"test: ");
|
||||||
|
err.append(parser.errors.at(i));
|
||||||
|
err.push_back(L'\n');
|
||||||
|
errored = true;
|
||||||
|
// For now we only show the first error
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! errored && result) {
|
||||||
|
/* It's also an error if there are any unused arguments. This is not detected by parse_expression() */
|
||||||
|
assert(result->range.end <= args.size());
|
||||||
|
if (result->range.end < args.size()) {
|
||||||
|
append_format(err, L"test: unexpected argument at index %lu: '%ls'\n", (unsigned long)result->range.end, args.at(result->range.end).c_str());
|
||||||
|
delete result;
|
||||||
|
result = NULL;
|
||||||
|
errored = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool unary_primary::evaluate(wcstring_list_t &errors) {
|
||||||
|
return unary_primary_evaluate(token, arg, errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool binary_primary::evaluate(wcstring_list_t &errors) {
|
||||||
|
return binary_primary_evaluate(token, arg_left, arg_right, errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool unary_operator::evaluate(wcstring_list_t &errors) {
|
||||||
|
switch (token) {
|
||||||
|
case test_bang:
|
||||||
|
assert(subject.get());
|
||||||
|
return ! subject->evaluate(errors);
|
||||||
|
default:
|
||||||
|
errors.push_back(format_string(L"Unknown token type in %s", __func__));
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool combining_expression::evaluate(wcstring_list_t &errors) {
|
||||||
|
switch (token) {
|
||||||
|
case test_combine_and:
|
||||||
|
case test_combine_or:
|
||||||
|
{
|
||||||
|
/* One-element case */
|
||||||
|
if (subjects.size() == 1)
|
||||||
|
return subjects.at(0)->evaluate(errors);
|
||||||
|
|
||||||
|
/* Evaluate our lists, remembering that AND has higher precedence than OR. We can visualize this as a sequence of OR expressions of AND expressions. */
|
||||||
|
assert(combiners.size() + 1 == subjects.size());
|
||||||
|
assert(! subjects.empty());
|
||||||
|
|
||||||
|
size_t idx = 0, max = subjects.size();
|
||||||
|
bool or_result = false;
|
||||||
|
while (idx < max) {
|
||||||
|
if (or_result) {
|
||||||
|
/* Short circuit */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Evaluate a stream of AND starting at given subject index. It may only have one element. */
|
||||||
|
bool and_result = true;
|
||||||
|
for (; idx < max; idx++) {
|
||||||
|
/* Evaluate it, short-circuiting */
|
||||||
|
and_result = and_result && subjects.at(idx)->evaluate(errors);
|
||||||
|
|
||||||
|
/* If the combiner at this index (which corresponding to how we combine with the next subject) is not AND, then exit the loop */
|
||||||
|
if (idx + 1 < max && combiners.at(idx) != test_combine_and) {
|
||||||
|
idx++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* OR it in */
|
||||||
|
or_result = or_result || and_result;
|
||||||
|
}
|
||||||
|
return or_result;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
errors.push_back(format_string(L"Unknown token type in %s", __func__));
|
||||||
|
return BUILTIN_TEST_FAIL;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool parenthetical_expression::evaluate(wcstring_list_t &errors) {
|
||||||
|
return contents->evaluate(errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* IEEE 1003.1 says nothing about what it means for two strings to be "algebraically equal". For example, should we interpret 0x10 as 0, 10, or 16? Here we use only base 10 and use wcstoll, which allows for leading + and -, and leading whitespace. This matches bash. */
|
||||||
|
static bool parse_number(const wcstring &arg, long long *out) {
|
||||||
|
const wchar_t *str = arg.c_str();
|
||||||
|
wchar_t *endptr = NULL;
|
||||||
|
*out = wcstoll(str, &endptr, 10);
|
||||||
|
return endptr && *endptr == L'\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool binary_primary_evaluate(test_expressions::token_t token, const wcstring &left, const wcstring &right, wcstring_list_t &errors) {
|
||||||
|
using namespace test_expressions;
|
||||||
|
long long left_num, right_num;
|
||||||
|
switch (token) {
|
||||||
|
case test_string_equal:
|
||||||
|
return left == right;
|
||||||
|
|
||||||
|
case test_string_not_equal:
|
||||||
|
return left != right;
|
||||||
|
|
||||||
|
case test_number_equal:
|
||||||
|
return parse_number(left, &left_num) && parse_number(right, &right_num) && left_num == right_num;
|
||||||
|
|
||||||
|
case test_number_not_equal:
|
||||||
|
return parse_number(left, &left_num) && parse_number(right, &right_num) && left_num != right_num;
|
||||||
|
|
||||||
|
case test_number_greater:
|
||||||
|
return parse_number(left, &left_num) && parse_number(right, &right_num) && left_num > right_num;
|
||||||
|
|
||||||
|
case test_number_greater_equal:
|
||||||
|
return parse_number(left, &left_num) && parse_number(right, &right_num) && left_num >= right_num;
|
||||||
|
|
||||||
|
case test_number_lesser:
|
||||||
|
return parse_number(left, &left_num) && parse_number(right, &right_num) && left_num < right_num;
|
||||||
|
|
||||||
|
case test_number_lesser_equal:
|
||||||
|
return parse_number(left, &left_num) && parse_number(right, &right_num) && left_num <= right_num;
|
||||||
|
|
||||||
|
default:
|
||||||
|
errors.push_back(format_string(L"Unknown token type in %s", __func__));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static bool unary_primary_evaluate(test_expressions::token_t token, const wcstring &arg, wcstring_list_t &errors) {
|
||||||
|
using namespace test_expressions;
|
||||||
|
struct stat buf;
|
||||||
|
long long num;
|
||||||
|
switch (token) {
|
||||||
|
case test_filetype_b: // "-b", for block special files
|
||||||
|
return !wstat(arg, &buf) && S_ISBLK(buf.st_mode);
|
||||||
|
|
||||||
|
case test_filetype_c: // "-c" for character special files
|
||||||
|
return !wstat(arg, &buf) && S_ISCHR(buf.st_mode);
|
||||||
|
|
||||||
|
case test_filetype_d: // "-d" for directories
|
||||||
|
return !wstat(arg, &buf) && S_ISDIR(buf.st_mode);
|
||||||
|
|
||||||
|
case test_filetype_e: // "-e" for files that exist
|
||||||
|
return !wstat(arg, &buf);
|
||||||
|
|
||||||
|
case test_filetype_f: // "-f" for for regular files
|
||||||
|
return !wstat(arg, &buf) && S_ISREG(buf.st_mode);
|
||||||
|
|
||||||
|
case test_filetype_g: // "-g" for set-group-id
|
||||||
|
return !wstat(arg, &buf) && (S_ISGID & buf.st_mode);
|
||||||
|
|
||||||
|
case test_filetype_h: // "-h" for symbolic links
|
||||||
|
case test_filetype_L: // "-L", same as -h
|
||||||
|
return !lwstat(arg, &buf) && S_ISLNK(buf.st_mode);
|
||||||
|
|
||||||
|
case test_filetype_p: // "-p", for FIFO
|
||||||
|
return !wstat(arg, &buf) && S_ISFIFO(buf.st_mode);
|
||||||
|
|
||||||
|
case test_filetype_S: // "-S", socket
|
||||||
|
return !wstat(arg, &buf) && S_ISSOCK(buf.st_mode);
|
||||||
|
|
||||||
|
case test_filesize_s: // "-s", size greater than zero
|
||||||
|
return !wstat(arg, &buf) && buf.st_size > 0;
|
||||||
|
|
||||||
|
case test_filedesc_t: // "-t", whether the fd is associated with a terminal
|
||||||
|
return parse_number(arg, &num) && num == (int)num && isatty((int)num);
|
||||||
|
|
||||||
|
case test_fileperm_r: // "-r", read permission
|
||||||
|
return !waccess(arg, R_OK);
|
||||||
|
|
||||||
|
case test_fileperm_u: // "-u", whether file is setuid
|
||||||
|
return !wstat(arg, &buf) && (S_ISUID & buf.st_mode);
|
||||||
|
|
||||||
|
case test_fileperm_w: // "-w", whether file write permission is allowed
|
||||||
|
return !waccess(arg, W_OK);
|
||||||
|
|
||||||
|
case test_fileperm_x: // "-x", whether file execute/search is allowed
|
||||||
|
return !waccess(arg, X_OK);
|
||||||
|
|
||||||
|
case test_string_n: // "-n", non-empty string
|
||||||
|
return ! arg.empty();
|
||||||
|
|
||||||
|
case test_string_z: // "-z", true if length of string is 0
|
||||||
|
return arg.empty();
|
||||||
|
|
||||||
|
default:
|
||||||
|
errors.push_back(format_string(L"Unknown token type in %s", __func__));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Evaluate a conditional expression given the arguments.
|
||||||
|
* If fromtest is set, the caller is the test or [ builtin;
|
||||||
|
* with the pointer giving the name of the command.
|
||||||
|
* for POSIX conformance this supports a more limited range
|
||||||
|
* of functionality.
|
||||||
|
*
|
||||||
|
* Return status is the final shell status, i.e. 0 for true,
|
||||||
|
* 1 for false and 2 for error.
|
||||||
|
*/
|
||||||
|
int builtin_test( parser_t &parser, wchar_t **argv )
|
||||||
|
{
|
||||||
|
using namespace test_expressions;
|
||||||
|
|
||||||
|
/* The first argument should be the name of the command ('test') */
|
||||||
|
if (! argv[0])
|
||||||
|
return BUILTIN_TEST_FAIL;
|
||||||
|
|
||||||
|
size_t argc = 0;
|
||||||
|
while (argv[argc + 1])
|
||||||
|
argc++;
|
||||||
|
const wcstring_list_t args(argv + 1, argv + 1 + argc);
|
||||||
|
|
||||||
|
if (argc == 0) {
|
||||||
|
// Per 1003.1, exit false
|
||||||
|
return BUILTIN_TEST_FAIL;
|
||||||
|
} else if (argc == 1) {
|
||||||
|
// Per 1003.1, exit true if the arg is non-empty
|
||||||
|
return args.at(0).empty() ? BUILTIN_TEST_FAIL : BUILTIN_TEST_SUCCESS;
|
||||||
|
} else {
|
||||||
|
// Try parsing. If expr is not nil, we are responsible for deleting it.
|
||||||
|
wcstring err;
|
||||||
|
expression *expr = test_parser::parse_args(args, err);
|
||||||
|
if (! expr) {
|
||||||
|
#if 0
|
||||||
|
printf("Oops! test was given args:\n");
|
||||||
|
for (size_t i=0; i < argc; i++) {
|
||||||
|
printf("\t%ls\n", args.at(i).c_str());
|
||||||
|
}
|
||||||
|
printf("and returned parse error: %ls\n", err.c_str());
|
||||||
|
#endif
|
||||||
|
builtin_show_error(err);
|
||||||
|
return BUILTIN_TEST_FAIL;
|
||||||
|
} else {
|
||||||
|
wcstring_list_t eval_errors;
|
||||||
|
bool result = expr->evaluate(eval_errors);
|
||||||
|
if (! eval_errors.empty()) {
|
||||||
|
printf("test returned eval errors:\n");
|
||||||
|
for (size_t i=0; i < eval_errors.size(); i++) {
|
||||||
|
printf("\t%ls\n", eval_errors.at(i).c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delete expr;
|
||||||
|
return result ? BUILTIN_TEST_SUCCESS : BUILTIN_TEST_FAIL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
@@ -49,7 +49,7 @@ struct resource_t
|
|||||||
/**
|
/**
|
||||||
Array of resource_t structs, describing all known resource types.
|
Array of resource_t structs, describing all known resource types.
|
||||||
*/
|
*/
|
||||||
const static struct resource_t resource_arr[] =
|
static const struct resource_t resource_arr[] =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
RLIMIT_CORE, L"Maximum size of core files created", L'c', 1024
|
RLIMIT_CORE, L"Maximum size of core files created", L'c', 1024
|
||||||
@@ -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 )
|
static rlim_t get( int resource, int hard )
|
||||||
{
|
{
|
||||||
@@ -142,9 +144,9 @@ static void print( int resource, int hard )
|
|||||||
rlim_t l = get( resource, hard );
|
rlim_t l = get( resource, hard );
|
||||||
|
|
||||||
if( l == RLIM_INFINITY )
|
if( l == RLIM_INFINITY )
|
||||||
sb_append( sb_out, L"unlimited\n" );
|
stdout_buffer.append( L"unlimited\n" );
|
||||||
else
|
else
|
||||||
sb_printf( sb_out, L"%d\n", l );
|
append_format(stdout_buffer, L"%d\n", l / get_multiplier( resource ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,9 +170,9 @@ static void print_all( int hard )
|
|||||||
getrlimit( resource_arr[i].resource, &ls );
|
getrlimit( resource_arr[i].resource, &ls );
|
||||||
l = hard ? ls.rlim_max:ls.rlim_cur;
|
l = hard ? ls.rlim_max:ls.rlim_cur;
|
||||||
|
|
||||||
wchar_t *unit = ((resource_arr[i].resource==RLIMIT_CPU)?L"(seconds, ":(get_multiplier(resource_arr[i].resource)==1?L"(":L"(kB, "));
|
const wchar_t *unit = ((resource_arr[i].resource==RLIMIT_CPU)?L"(seconds, ":(get_multiplier(resource_arr[i].resource)==1?L"(":L"(kB, "));
|
||||||
|
|
||||||
sb_printf( sb_out,
|
append_format(stdout_buffer,
|
||||||
L"%-*ls %10ls-%lc) ",
|
L"%-*ls %10ls-%lc) ",
|
||||||
w,
|
w,
|
||||||
resource_arr[i].desc,
|
resource_arr[i].desc,
|
||||||
@@ -178,10 +180,15 @@ static void print_all( int hard )
|
|||||||
resource_arr[i].switch_char);
|
resource_arr[i].switch_char);
|
||||||
|
|
||||||
if( l == RLIM_INFINITY )
|
if( l == RLIM_INFINITY )
|
||||||
sb_append( sb_out, L"unlimited\n" );
|
{
|
||||||
|
stdout_buffer.append( L"unlimited\n" );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
sb_printf( sb_out, L"%d\n", l );
|
{
|
||||||
|
append_format(stdout_buffer, 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 )
|
static int set( int resource, int hard, int soft, rlim_t value )
|
||||||
{
|
{
|
||||||
struct rlimit ls;
|
struct rlimit ls;
|
||||||
getrlimit( resource, &ls );
|
getrlimit( resource, &ls );
|
||||||
if( value != RLIM_INFINITY )
|
|
||||||
value *= get_multiplier( resource );
|
|
||||||
|
|
||||||
if( hard )
|
if( hard )
|
||||||
{
|
{
|
||||||
@@ -233,7 +240,7 @@ static int set( int resource, int hard, int soft, rlim_t value )
|
|||||||
if( setrlimit( resource, &ls ) )
|
if( setrlimit( resource, &ls ) )
|
||||||
{
|
{
|
||||||
if( errno == EPERM )
|
if( errno == EPERM )
|
||||||
sb_printf( sb_err, L"ulimit: Permission denied when changing resource of type '%ls'\n", get_desc( resource ) );
|
append_format(stderr_buffer, L"ulimit: Permission denied when changing resource of type '%ls'\n", get_desc( resource ) );
|
||||||
else
|
else
|
||||||
builtin_wperror( L"ulimit" );
|
builtin_wperror( L"ulimit" );
|
||||||
return 1;
|
return 1;
|
||||||
@@ -241,27 +248,11 @@ static int set( int resource, int hard, int soft, rlim_t value )
|
|||||||
return 0;
|
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
|
The ulimit builtin, used for setting resource limits. Defined in
|
||||||
builtin_ulimit.c.
|
builtin_ulimit.c.
|
||||||
*/
|
*/
|
||||||
static int builtin_ulimit( wchar_t ** argv )
|
static int builtin_ulimit( parser_t &parser, wchar_t ** argv )
|
||||||
{
|
{
|
||||||
int hard=0;
|
int hard=0;
|
||||||
int soft=0;
|
int soft=0;
|
||||||
@@ -275,7 +266,7 @@ static int builtin_ulimit( wchar_t ** argv )
|
|||||||
|
|
||||||
while( 1 )
|
while( 1 )
|
||||||
{
|
{
|
||||||
const static struct woption
|
static const struct woption
|
||||||
long_options[] =
|
long_options[] =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
@@ -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,
|
int opt = wgetopt_long( argc,
|
||||||
argv,
|
argv,
|
||||||
L"aHScdflmnptuvh",
|
L"aHScdflmnstuvh",
|
||||||
long_options,
|
long_options,
|
||||||
&opt_index );
|
&opt_index );
|
||||||
if( opt == -1 )
|
if( opt == -1 )
|
||||||
@@ -356,11 +347,11 @@ static int builtin_ulimit( wchar_t ** argv )
|
|||||||
case 0:
|
case 0:
|
||||||
if(long_options[opt_index].flag != 0)
|
if(long_options[opt_index].flag != 0)
|
||||||
break;
|
break;
|
||||||
sb_printf( sb_err,
|
append_format(stderr_buffer,
|
||||||
BUILTIN_ERR_UNKNOWN,
|
BUILTIN_ERR_UNKNOWN,
|
||||||
argv[0],
|
argv[0],
|
||||||
long_options[opt_index].name );
|
long_options[opt_index].name );
|
||||||
builtin_print_help( argv[0], sb_err );
|
builtin_print_help( parser, argv[0], stderr_buffer );
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
@@ -424,32 +415,43 @@ static int builtin_ulimit( wchar_t ** argv )
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
case L'h':
|
case L'h':
|
||||||
builtin_print_help( argv[0], sb_out );
|
builtin_print_help( parser, argv[0], stdout_buffer );
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case L'?':
|
case L'?':
|
||||||
builtin_print_help( argv[0], sb_err );
|
builtin_unknown_option( parser, argv[0], argv[woptind-1] );
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( report_all )
|
||||||
|
{
|
||||||
|
if( argc - woptind == 0 )
|
||||||
|
{
|
||||||
|
print_all( hard );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
stderr_buffer.append(argv[0]);
|
||||||
|
stderr_buffer.append(L": Too many arguments\n");
|
||||||
|
builtin_print_help( parser, argv[0], stderr_buffer );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
switch( argc - woptind )
|
switch( argc - woptind )
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
Show current limit value
|
Show current limit value
|
||||||
*/
|
*/
|
||||||
if( report_all )
|
print( what, hard );
|
||||||
{
|
|
||||||
print_all( hard );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print( what, hard );
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@@ -457,7 +459,7 @@ static int builtin_ulimit( wchar_t ** argv )
|
|||||||
*/
|
*/
|
||||||
rlim_t new_limit;
|
rlim_t new_limit;
|
||||||
wchar_t *end;
|
wchar_t *end;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Set both hard and soft limits if nothing else was specified
|
Set both hard and soft limits if nothing else was specified
|
||||||
*/
|
*/
|
||||||
@@ -466,7 +468,6 @@ static int builtin_ulimit( wchar_t ** argv )
|
|||||||
hard=soft=1;
|
hard=soft=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if( wcscasecmp( argv[woptind], L"unlimited" )==0)
|
if( wcscasecmp( argv[woptind], L"unlimited" )==0)
|
||||||
{
|
{
|
||||||
new_limit = RLIM_INFINITY;
|
new_limit = RLIM_INFINITY;
|
||||||
@@ -485,37 +486,27 @@ static int builtin_ulimit( wchar_t ** argv )
|
|||||||
new_limit = wcstol( argv[woptind], &end, 10 );
|
new_limit = wcstol( argv[woptind], &end, 10 );
|
||||||
if( errno || *end )
|
if( errno || *end )
|
||||||
{
|
{
|
||||||
sb_printf( sb_err,
|
append_format(stderr_buffer,
|
||||||
L"%ls: Invalid limit '%ls'\n",
|
L"%ls: Invalid limit '%ls'\n",
|
||||||
argv[0],
|
argv[0],
|
||||||
argv[woptind] );
|
argv[woptind] );
|
||||||
builtin_print_help( argv[0], sb_err );
|
builtin_print_help( parser, argv[0], stderr_buffer );
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
new_limit *= get_multiplier( what );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( report_all )
|
return set( what, hard, soft, new_limit );
|
||||||
{
|
|
||||||
return set_all( hard, soft, new_limit );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return set( what, hard, soft, new_limit );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
sb_append2( sb_err,
|
{
|
||||||
argv[0],
|
stderr_buffer.append(argv[0]);
|
||||||
L": Too many arguments\n",
|
stderr_buffer.append(L": Too many arguments\n");
|
||||||
(void *)0 );
|
builtin_print_help( parser, argv[0], stderr_buffer );
|
||||||
builtin_print_help( argv[0], sb_err );
|
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
266
color.cpp
Normal file
266
color.cpp
Normal file
@@ -0,0 +1,266 @@
|
|||||||
|
/** \file color.cpp Color class implementation
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "color.h"
|
||||||
|
#include "fallback.h"
|
||||||
|
|
||||||
|
bool rgb_color_t::try_parse_special(const wcstring &special) {
|
||||||
|
bzero(&data, sizeof data);
|
||||||
|
const wchar_t *name = special.c_str();
|
||||||
|
if (! wcscasecmp(name, L"normal")) {
|
||||||
|
this->type = type_normal;
|
||||||
|
} else if (! wcscasecmp(name, L"reset")) {
|
||||||
|
this->type = type_reset;
|
||||||
|
} else if (! wcscasecmp(name, L"ignore")) {
|
||||||
|
this->type = type_ignore;
|
||||||
|
} else {
|
||||||
|
this->type = type_none;
|
||||||
|
}
|
||||||
|
return this->type != type_none;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int parse_hex_digit(wchar_t x) {
|
||||||
|
switch (x) {
|
||||||
|
case L'0': return 0x0;
|
||||||
|
case L'1': return 0x1;
|
||||||
|
case L'2': return 0x2;
|
||||||
|
case L'3': return 0x3;
|
||||||
|
case L'4': return 0x4;
|
||||||
|
case L'5': return 0x5;
|
||||||
|
case L'6': return 0x6;
|
||||||
|
case L'7': return 0x7;
|
||||||
|
case L'8': return 0x8;
|
||||||
|
case L'9': return 0x9;
|
||||||
|
case L'a':case L'A': return 0xA;
|
||||||
|
case L'b':case L'B': return 0xB;
|
||||||
|
case L'c':case L'C': return 0xC;
|
||||||
|
case L'd':case L'D': return 0xD;
|
||||||
|
case L'e':case L'E': return 0xE;
|
||||||
|
case L'f':case L'F': return 0xF;
|
||||||
|
default: return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static unsigned long squared_difference(long p1, long p2)
|
||||||
|
{
|
||||||
|
unsigned long diff = (unsigned long)labs(p1 - p2);
|
||||||
|
return diff * diff;
|
||||||
|
}
|
||||||
|
|
||||||
|
static unsigned char convert_color(const unsigned char rgb[3], const uint32_t *colors, size_t color_count) {
|
||||||
|
long r = rgb[0], g = rgb[1], b = rgb[2];
|
||||||
|
unsigned long best_distance = (unsigned long)(-1);
|
||||||
|
unsigned char best_index = (unsigned char)(-1);
|
||||||
|
for (unsigned char idx = 0; idx < color_count; idx++) {
|
||||||
|
uint32_t color = colors[idx];
|
||||||
|
long test_r = (color >> 16) & 0xFF, test_g = (color >> 8) & 0xFF, test_b = (color >> 0) & 0xFF;
|
||||||
|
unsigned long distance = squared_difference(r, test_r) + squared_difference(g, test_g) + squared_difference(b, test_b);
|
||||||
|
if (distance <= best_distance) {
|
||||||
|
best_index = idx;
|
||||||
|
best_distance = distance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return best_index;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool rgb_color_t::try_parse_rgb(const wcstring &name) {
|
||||||
|
bzero(&data, sizeof data);
|
||||||
|
/* We support the following style of rgb formats (case insensitive):
|
||||||
|
#FA3
|
||||||
|
#F3A035
|
||||||
|
FA3
|
||||||
|
F3A035
|
||||||
|
*/
|
||||||
|
|
||||||
|
size_t digit_idx = 0, len = name.size();
|
||||||
|
|
||||||
|
/* Skip any leading # */
|
||||||
|
if (len > 0 && name.at(0) == L'#')
|
||||||
|
digit_idx++;
|
||||||
|
|
||||||
|
bool success = false;
|
||||||
|
size_t i;
|
||||||
|
if (len - digit_idx == 3) {
|
||||||
|
// type FA3
|
||||||
|
for (i=0; i < 3; i++) {
|
||||||
|
int val = parse_hex_digit(name.at(digit_idx++));
|
||||||
|
if (val < 0) break;
|
||||||
|
data.rgb[i] = val*16+val;
|
||||||
|
}
|
||||||
|
success = (i == 3);
|
||||||
|
} else if (len - digit_idx == 6) {
|
||||||
|
// type F3A035
|
||||||
|
for (i=0; i < 3; i++) {
|
||||||
|
int hi = parse_hex_digit(name.at(digit_idx++));
|
||||||
|
int lo = parse_hex_digit(name.at(digit_idx++));
|
||||||
|
if (lo < 0 || hi < 0) break;
|
||||||
|
data.rgb[i] = hi*16+lo;
|
||||||
|
}
|
||||||
|
success = (i == 3);
|
||||||
|
}
|
||||||
|
if (success) {
|
||||||
|
this->type = type_rgb;
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct named_color_t {
|
||||||
|
const wchar_t * name;
|
||||||
|
unsigned char idx;
|
||||||
|
unsigned char rgb[3];
|
||||||
|
};
|
||||||
|
|
||||||
|
static const named_color_t named_colors[11] = {
|
||||||
|
{L"black", 0, {0, 0, 0}},
|
||||||
|
{L"red", 1, {0xFF, 0, 0}},
|
||||||
|
{L"green", 2, {0, 0xFF, 0}},
|
||||||
|
{L"brown", 3, {0x72, 0x50, 0}},
|
||||||
|
{L"yellow", 3, {0xFF, 0xFF, 0}},
|
||||||
|
{L"blue", 4, {0, 0, 0xFF}},
|
||||||
|
{L"magenta", 5, {0xFF, 0, 0xFF}},
|
||||||
|
{L"purple", 5, {0xFF, 0, 0xFF}},
|
||||||
|
{L"cyan", 6, {0, 0xFF, 0xFF}},
|
||||||
|
{L"white", 7, {0xFF, 0xFF, 0xFF}},
|
||||||
|
{L"normal", 8, {0xFF, 0xFF, 0XFF}}
|
||||||
|
};
|
||||||
|
|
||||||
|
bool rgb_color_t::try_parse_named(const wcstring &str) {
|
||||||
|
bzero(&data, sizeof data);
|
||||||
|
size_t max = sizeof named_colors / sizeof *named_colors;
|
||||||
|
for (size_t idx=0; idx < max; idx++) {
|
||||||
|
if (0 == wcscasecmp(str.c_str(), named_colors[idx].name)) {
|
||||||
|
data.name_idx = named_colors[idx].idx;
|
||||||
|
this->type = type_named;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const wchar_t *name_for_color_idx(unsigned char idx) {
|
||||||
|
size_t max = sizeof named_colors / sizeof *named_colors;
|
||||||
|
for (size_t i=0; i < max; i++) {
|
||||||
|
if (named_colors[i].idx == idx) {
|
||||||
|
return named_colors[i].name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return L"unknown";
|
||||||
|
}
|
||||||
|
|
||||||
|
rgb_color_t::rgb_color_t(unsigned char t, unsigned char i) : type(t), flags(), data() {
|
||||||
|
data.name_idx = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
rgb_color_t rgb_color_t::normal() { return rgb_color_t(type_normal); }
|
||||||
|
rgb_color_t rgb_color_t::reset() { return rgb_color_t(type_reset); }
|
||||||
|
rgb_color_t rgb_color_t::ignore() { return rgb_color_t(type_ignore); }
|
||||||
|
rgb_color_t rgb_color_t::none() { return rgb_color_t(type_none); }
|
||||||
|
rgb_color_t rgb_color_t::white() { return rgb_color_t(type_named, 7); }
|
||||||
|
rgb_color_t rgb_color_t::black() { return rgb_color_t(type_named, 0); }
|
||||||
|
|
||||||
|
static unsigned char term8_color_for_rgb(const unsigned char rgb[3]) {
|
||||||
|
const uint32_t kColors[] = {
|
||||||
|
0x000000, //Black
|
||||||
|
0xFF0000, //Red
|
||||||
|
0x00FF00, //Green
|
||||||
|
0xFFFF00, //Yellow
|
||||||
|
0x0000FF, //Blue
|
||||||
|
0xFF00FF, //Magenta
|
||||||
|
0x00FFFF, //Cyan
|
||||||
|
0xFFFFFF, //White
|
||||||
|
};
|
||||||
|
return convert_color(rgb, kColors, sizeof kColors / sizeof *kColors);
|
||||||
|
}
|
||||||
|
|
||||||
|
static unsigned char term256_color_for_rgb(const unsigned char rgb[3]) {
|
||||||
|
const uint32_t kColors[240] = {
|
||||||
|
0x000000, 0x00005f, 0x000087, 0x0000af, 0x0000d7, 0x0000ff, 0x005f00, 0x005f5f,
|
||||||
|
0x005f87, 0x005faf, 0x005fd7, 0x005fff, 0x008700, 0x00875f, 0x008787, 0x0087af,
|
||||||
|
0x0087d7, 0x0087ff, 0x00af00, 0x00af5f, 0x00af87, 0x00afaf, 0x00afd7, 0x00afff,
|
||||||
|
0x00d700, 0x00d75f, 0x00d787, 0x00d7af, 0x00d7d7, 0x00d7ff, 0x00ff00, 0x00ff5f,
|
||||||
|
0x00ff87, 0x00ffaf, 0x00ffd7, 0x00ffff, 0x5f0000, 0x5f005f, 0x5f0087, 0x5f00af,
|
||||||
|
0x5f00d7, 0x5f00ff, 0x5f5f00, 0x5f5f5f, 0x5f5f87, 0x5f5faf, 0x5f5fd7, 0x5f5fff,
|
||||||
|
0x5f8700, 0x5f875f, 0x5f8787, 0x5f87af, 0x5f87d7, 0x5f87ff, 0x5faf00, 0x5faf5f,
|
||||||
|
0x5faf87, 0x5fafaf, 0x5fafd7, 0x5fafff, 0x5fd700, 0x5fd75f, 0x5fd787, 0x5fd7af,
|
||||||
|
0x5fd7d7, 0x5fd7ff, 0x5fff00, 0x5fff5f, 0x5fff87, 0x5fffaf, 0x5fffd7, 0x5fffff,
|
||||||
|
0x870000, 0x87005f, 0x870087, 0x8700af, 0x8700d7, 0x8700ff, 0x875f00, 0x875f5f,
|
||||||
|
0x875f87, 0x875faf, 0x875fd7, 0x875fff, 0x878700, 0x87875f, 0x878787, 0x8787af,
|
||||||
|
0x8787d7, 0x8787ff, 0x87af00, 0x87af5f, 0x87af87, 0x87afaf, 0x87afd7, 0x87afff,
|
||||||
|
0x87d700, 0x87d75f, 0x87d787, 0x87d7af, 0x87d7d7, 0x87d7ff, 0x87ff00, 0x87ff5f,
|
||||||
|
0x87ff87, 0x87ffaf, 0x87ffd7, 0x87ffff, 0xaf0000, 0xaf005f, 0xaf0087, 0xaf00af,
|
||||||
|
0xaf00d7, 0xaf00ff, 0xaf5f00, 0xaf5f5f, 0xaf5f87, 0xaf5faf, 0xaf5fd7, 0xaf5fff,
|
||||||
|
0xaf8700, 0xaf875f, 0xaf8787, 0xaf87af, 0xaf87d7, 0xaf87ff, 0xafaf00, 0xafaf5f,
|
||||||
|
0xafaf87, 0xafafaf, 0xafafd7, 0xafafff, 0xafd700, 0xafd75f, 0xafd787, 0xafd7af,
|
||||||
|
0xafd7d7, 0xafd7ff, 0xafff00, 0xafff5f, 0xafff87, 0xafffaf, 0xafffd7, 0xafffff,
|
||||||
|
0xd70000, 0xd7005f, 0xd70087, 0xd700af, 0xd700d7, 0xd700ff, 0xd75f00, 0xd75f5f,
|
||||||
|
0xd75f87, 0xd75faf, 0xd75fd7, 0xd75fff, 0xd78700, 0xd7875f, 0xd78787, 0xd787af,
|
||||||
|
0xd787d7, 0xd787ff, 0xd7af00, 0xd7af5f, 0xd7af87, 0xd7afaf, 0xd7afd7, 0xd7afff,
|
||||||
|
0xd7d700, 0xd7d75f, 0xd7d787, 0xd7d7af, 0xd7d7d7, 0xd7d7ff, 0xd7ff00, 0xd7ff5f,
|
||||||
|
0xd7ff87, 0xd7ffaf, 0xd7ffd7, 0xd7ffff, 0xff0000, 0xff005f, 0xff0087, 0xff00af,
|
||||||
|
0xff00d7, 0xff00ff, 0xff5f00, 0xff5f5f, 0xff5f87, 0xff5faf, 0xff5fd7, 0xff5fff,
|
||||||
|
0xff8700, 0xff875f, 0xff8787, 0xff87af, 0xff87d7, 0xff87ff, 0xffaf00, 0xffaf5f,
|
||||||
|
0xffaf87, 0xffafaf, 0xffafd7, 0xffafff, 0xffd700, 0xffd75f, 0xffd787, 0xffd7af,
|
||||||
|
0xffd7d7, 0xffd7ff, 0xffff00, 0xffff5f, 0xffff87, 0xffffaf, 0xffffd7, 0xffffff,
|
||||||
|
0x080808, 0x121212, 0x1c1c1c, 0x262626, 0x303030, 0x3a3a3a, 0x444444, 0x4e4e4e,
|
||||||
|
0x585858, 0x626262, 0x6c6c6c, 0x767676, 0x808080, 0x8a8a8a, 0x949494, 0x9e9e9e,
|
||||||
|
0xa8a8a8, 0xb2b2b2, 0xbcbcbc, 0xc6c6c6, 0xd0d0d0, 0xdadada, 0xe4e4e4, 0xeeeeee
|
||||||
|
};
|
||||||
|
return 16 + convert_color(rgb, kColors, sizeof kColors / sizeof *kColors);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char rgb_color_t::to_term256_index() const {
|
||||||
|
assert(type == type_rgb);
|
||||||
|
return term256_color_for_rgb(data.rgb);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char rgb_color_t::to_name_index() const {
|
||||||
|
assert(type == type_named || type == type_rgb);
|
||||||
|
if (type == type_named) {
|
||||||
|
return data.name_idx;
|
||||||
|
} else if (type == type_rgb) {
|
||||||
|
return term8_color_for_rgb(data.rgb);
|
||||||
|
} else {
|
||||||
|
/* This is an error */
|
||||||
|
return (unsigned char)(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void rgb_color_t::parse(const wcstring &str) {
|
||||||
|
bool success = false;
|
||||||
|
if (! success) success = try_parse_special(str);
|
||||||
|
if (! success) success = try_parse_named(str);
|
||||||
|
if (! success) success = try_parse_rgb(str);
|
||||||
|
if (! success) {
|
||||||
|
bzero(this->data.rgb, sizeof this->data.rgb);
|
||||||
|
this->type = type_none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rgb_color_t::rgb_color_t(const wcstring &str) {
|
||||||
|
this->parse(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
rgb_color_t::rgb_color_t(const std::string &str) {
|
||||||
|
this->parse(str2wcstring(str));
|
||||||
|
}
|
||||||
|
|
||||||
|
wcstring rgb_color_t::description() const {
|
||||||
|
switch (type) {
|
||||||
|
case type_none:
|
||||||
|
return L"none";
|
||||||
|
case type_named:
|
||||||
|
return format_string(L"named(%d: %ls)", (int)data.name_idx, name_for_color_idx(data.name_idx));
|
||||||
|
case type_rgb:
|
||||||
|
return format_string(L"rgb(0x%02x%02x%02x)", data.rgb[0], data.rgb[1], data.rgb[2]);
|
||||||
|
case type_reset:
|
||||||
|
return L"reset";
|
||||||
|
case type_normal:
|
||||||
|
return L"normal";
|
||||||
|
case type_ignore:
|
||||||
|
return L"ignore";
|
||||||
|
default:
|
||||||
|
abort();
|
||||||
|
return L"";
|
||||||
|
}
|
||||||
|
}
|
||||||
133
color.h
Normal file
133
color.h
Normal file
@@ -0,0 +1,133 @@
|
|||||||
|
/** \file color.h Color class.
|
||||||
|
*/
|
||||||
|
#ifndef FISH_COLOR_H
|
||||||
|
#define FISH_COLOR_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <cstddef>
|
||||||
|
#include "config.h"
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* A type that represents a color. We work hard to keep it at a size of 4 bytes. */
|
||||||
|
class rgb_color_t {
|
||||||
|
|
||||||
|
/* Types */
|
||||||
|
enum {
|
||||||
|
type_none,
|
||||||
|
type_named,
|
||||||
|
type_rgb,
|
||||||
|
type_normal,
|
||||||
|
type_reset,
|
||||||
|
type_ignore
|
||||||
|
};
|
||||||
|
unsigned char type:4;
|
||||||
|
|
||||||
|
/* Flags */
|
||||||
|
enum {
|
||||||
|
flag_bold = 1 << 0,
|
||||||
|
flag_underline = 1 << 1
|
||||||
|
};
|
||||||
|
unsigned char flags:4;
|
||||||
|
|
||||||
|
union {
|
||||||
|
unsigned char name_idx; //0-10
|
||||||
|
unsigned char rgb[3];
|
||||||
|
} data;
|
||||||
|
|
||||||
|
/** Try parsing a special color name like "normal" */
|
||||||
|
bool try_parse_special(const wcstring &str);
|
||||||
|
|
||||||
|
/** Try parsing an rgb color like "#F0A030" */
|
||||||
|
bool try_parse_rgb(const wcstring &str);
|
||||||
|
|
||||||
|
/** Try parsing an explicit color name like "magenta" */
|
||||||
|
bool try_parse_named(const wcstring &str);
|
||||||
|
|
||||||
|
/* Parsing entry point */
|
||||||
|
void parse(const wcstring &str);
|
||||||
|
|
||||||
|
/** Private constructor */
|
||||||
|
explicit rgb_color_t(unsigned char t, unsigned char i=0);
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
/** Default constructor of type none */
|
||||||
|
explicit rgb_color_t() : type(type_none), flags(), data() {}
|
||||||
|
|
||||||
|
/** Parse a color from a string */
|
||||||
|
explicit rgb_color_t(const wcstring &str);
|
||||||
|
explicit rgb_color_t(const std::string &str);
|
||||||
|
|
||||||
|
/** Returns white */
|
||||||
|
static rgb_color_t white();
|
||||||
|
|
||||||
|
/** Returns black */
|
||||||
|
static rgb_color_t black();
|
||||||
|
|
||||||
|
/** Returns the reset special color */
|
||||||
|
static rgb_color_t reset();
|
||||||
|
|
||||||
|
/** Returns the normal special color */
|
||||||
|
static rgb_color_t normal();
|
||||||
|
|
||||||
|
/** Returns the ignore special color */
|
||||||
|
static rgb_color_t ignore();
|
||||||
|
|
||||||
|
/** Returns the none special color */
|
||||||
|
static rgb_color_t none();
|
||||||
|
|
||||||
|
/** Returns whether the color is the ignore special color */
|
||||||
|
bool is_ignore(void) const { return type == type_ignore; }
|
||||||
|
|
||||||
|
/** Returns whether the color is the normal special color */
|
||||||
|
bool is_normal(void) const { return type == type_normal; }
|
||||||
|
|
||||||
|
/** Returns whether the color is the reset special color */
|
||||||
|
bool is_reset(void) const { return type == type_reset; }
|
||||||
|
|
||||||
|
/** Returns whether the color is the none special color */
|
||||||
|
bool is_none(void) const { return type == type_none; }
|
||||||
|
|
||||||
|
/** Returns whether the color is a named color (like "magenta") */
|
||||||
|
bool is_named(void) const { return type == type_named; }
|
||||||
|
|
||||||
|
/** Returns whether the color is specified via RGB components */
|
||||||
|
bool is_rgb(void) const { return type == type_rgb; }
|
||||||
|
|
||||||
|
/** Returns whether the color is special, that is, not rgb or named */
|
||||||
|
bool is_special(void) const { return type != type_named && type != type_rgb; }
|
||||||
|
|
||||||
|
/** Returns a description of the color */
|
||||||
|
wcstring description() const;
|
||||||
|
|
||||||
|
/** Returns the name index for the given color. Requires that the color be named or RGB. */
|
||||||
|
unsigned char to_name_index() const;
|
||||||
|
|
||||||
|
/** Returns the term256 index for the given color. Requires that the color be named or RGB. */
|
||||||
|
unsigned char to_term256_index() const;
|
||||||
|
|
||||||
|
/** Returns whether the color is bold */
|
||||||
|
bool is_bold() const { return flags & flag_bold; }
|
||||||
|
|
||||||
|
/** Set whether the color is bold */
|
||||||
|
void set_bold(bool x) { if (x) flags |= flag_bold; else flags &= ~flag_bold; }
|
||||||
|
|
||||||
|
/** Returns whether the color is underlined */
|
||||||
|
bool is_underline() const { return !! (flags & flag_underline); }
|
||||||
|
|
||||||
|
/** Set whether the color is underlined */
|
||||||
|
void set_underline(bool x) { if (x) flags |= flag_underline; else flags &= ~flag_underline; }
|
||||||
|
|
||||||
|
/** Compare two colors for equality */
|
||||||
|
bool operator==(const rgb_color_t &other) const {
|
||||||
|
return type == other.type && ! memcmp(&data, &other.data, sizeof data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Compare two colors for inequality */
|
||||||
|
bool operator!=(const rgb_color_t &other) const {
|
||||||
|
return !(*this == other);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
2035
common.cpp
Normal file
2035
common.cpp
Normal file
File diff suppressed because it is too large
Load Diff
549
common.h
549
common.h
@@ -12,9 +12,22 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
|
#include <string>
|
||||||
|
#include <sstream>
|
||||||
|
#include <vector>
|
||||||
|
#include <pthread.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <assert.h>
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
class completion_t;
|
||||||
|
|
||||||
|
/* Common string type */
|
||||||
|
typedef std::wstring wcstring;
|
||||||
|
typedef std::vector<wcstring> wcstring_list_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Maximum number of bytes used by a single utf-8 character
|
Maximum number of bytes used by a single utf-8 character
|
||||||
*/
|
*/
|
||||||
@@ -40,6 +53,37 @@
|
|||||||
*/
|
*/
|
||||||
#define BYTE_MAX 0xffu
|
#define BYTE_MAX 0xffu
|
||||||
|
|
||||||
|
/**
|
||||||
|
Escape special fish syntax characters like the semicolon
|
||||||
|
*/
|
||||||
|
#define UNESCAPE_SPECIAL 1
|
||||||
|
|
||||||
|
/**
|
||||||
|
Allow incomplete escape sequences
|
||||||
|
*/
|
||||||
|
#define UNESCAPE_INCOMPLETE 2
|
||||||
|
|
||||||
|
/* Flags for the escape() and escape_string() functions */
|
||||||
|
enum {
|
||||||
|
/** Escape all characters, including magic characters like the semicolon */
|
||||||
|
ESCAPE_ALL = 1 << 0,
|
||||||
|
|
||||||
|
/** Do not try to use 'simplified' quoted escapes, and do not use empty quotes as the empty string */
|
||||||
|
ESCAPE_NO_QUOTED = 1 << 1,
|
||||||
|
|
||||||
|
/** Do not escape tildes */
|
||||||
|
ESCAPE_NO_TILDE = 1 << 2
|
||||||
|
};
|
||||||
|
typedef unsigned int escape_flags_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Helper macro for errors
|
||||||
|
*/
|
||||||
|
#define VOMIT_ON_FAILURE(a) do { if (0 != (a)) { int err = errno; fprintf(stderr, "%s failed on line %d in file %s: %d (%s)\n", #a, __LINE__, __FILE__, err, strerror(err)); abort(); }} while (0)
|
||||||
|
|
||||||
|
/** Exits without invoking destructors (via _exit), useful for code after fork. */
|
||||||
|
void exit_without_destructors(int code) __attribute__ ((noreturn));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Save the shell mode on startup so we can restore them on exit
|
Save the shell mode on startup so we can restore them on exit
|
||||||
*/
|
*/
|
||||||
@@ -66,101 +110,97 @@ extern char *profile;
|
|||||||
Name of the current program. Should be set at startup. Used by the
|
Name of the current program. Should be set at startup. Used by the
|
||||||
debug function.
|
debug function.
|
||||||
*/
|
*/
|
||||||
extern wchar_t *program_name;
|
extern const wchar_t *program_name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This macro is used to check that an input argument is not null. It
|
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
|
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
|
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) ) \
|
if( !(arg) ) \
|
||||||
{ \
|
{ \
|
||||||
debug( 1, \
|
debug( 0, \
|
||||||
_( L"function %s called with null value for argument %s. " \
|
"function %s called with null value for argument %s. ", \
|
||||||
L"This is a bug. " \
|
|
||||||
L"If you can reproduce it, please send a bug report to %s." ), \
|
|
||||||
__func__, \
|
__func__, \
|
||||||
#arg, \
|
#arg ); \
|
||||||
PACKAGE_BUGREPORT ); \
|
bugreport(); \
|
||||||
|
show_stackframe(); \
|
||||||
return retval; \
|
return retval; \
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Exit program at once, leaving an error message about running out of memory
|
Pause for input, then exit the program. If supported, print a backtrace first.
|
||||||
|
*/
|
||||||
|
#define FATAL_EXIT() \
|
||||||
|
{ \
|
||||||
|
char exit_read_buff; \
|
||||||
|
show_stackframe(); \
|
||||||
|
read( 0, &exit_read_buff, 1 ); \
|
||||||
|
exit_without_destructors( 1 ); \
|
||||||
|
} \
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Exit program at once, leaving an error message about running out of memory.
|
||||||
*/
|
*/
|
||||||
#define DIE_MEM() \
|
#define DIE_MEM() \
|
||||||
{ \
|
{ \
|
||||||
fwprintf( stderr, \
|
fwprintf( stderr, \
|
||||||
L"fish: Out of memory on line %d of file %s, shutting down fish\n", \
|
L"fish: Out of memory on line %ld of file %s, shutting down fish\n", \
|
||||||
__LINE__, \
|
(long)__LINE__, \
|
||||||
__FILE__ ); \
|
__FILE__ ); \
|
||||||
exit(1); \
|
FATAL_EXIT(); \
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Cause fish to crash. This should only be usd for debugging.
|
Check if signals are blocked. If so, print an error message and
|
||||||
|
return from the function performing this check.
|
||||||
*/
|
*/
|
||||||
#define CRASH() \
|
#define CHECK_BLOCK( retval ) \
|
||||||
{ \
|
|
||||||
int *n = 0; \
|
|
||||||
*n = 1; \
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Check if signals are blocked
|
|
||||||
*/
|
|
||||||
#define CHECK_BLOCK( retval ) \
|
|
||||||
if( signal_is_blocked() ) \
|
if( signal_is_blocked() ) \
|
||||||
{ \
|
{ \
|
||||||
debug( 0, \
|
debug( 0, \
|
||||||
L"function %s called while blocking signals. " \
|
"function %s called while blocking signals. ", \
|
||||||
L"This is a bug. " \
|
__func__); \
|
||||||
L"If you can reproduce it, please send a bug report to %s.", \
|
bugreport(); \
|
||||||
__func__, \
|
show_stackframe(); \
|
||||||
PACKAGE_BUGREPORT ); \
|
return retval; \
|
||||||
return retval; \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Shorthand for wgettext call
|
Shorthand for wgettext call
|
||||||
*/
|
*/
|
||||||
#define _(wstr) wgettext(wstr)
|
#define _(wstr) wgettext((const wchar_t *)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
|
#define N_(wstr) wstr
|
||||||
|
|
||||||
|
/**
|
||||||
|
Check if the specified string element is a part of the specified string list
|
||||||
|
*/
|
||||||
|
#define contains( str,... ) contains_internal( str, __VA_ARGS__, NULL )
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Take an array_list_t containing wide strings and converts them to a
|
Print a stack trace to stderr
|
||||||
single null-terminated wchar_t **. The array is allocated using
|
|
||||||
halloc, and uses the \c context parameter as context. If \c context
|
|
||||||
is not noll, all elements of the \c array_list_t are also
|
|
||||||
registered to \c context using \c halloc_register().
|
|
||||||
*/
|
*/
|
||||||
wchar_t **list_to_char_arr( array_list_t *l );
|
void show_stackframe();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Read a line from the stream f into the buffer buff of length len. If
|
Read a line from the stream f into the string. Returns
|
||||||
buff is to small, it will be reallocated, and both buff and len will
|
the number of bytes read or -1 on failiure.
|
||||||
be updated to reflect this. Returns the number of bytes read or -1
|
|
||||||
on failiure.
|
|
||||||
|
|
||||||
If the carriage return character is encountered, it is
|
If the carriage return character is encountered, it is
|
||||||
ignored. fgetws() considers the line to end if reading the file
|
ignored. fgetws() considers the line to end if reading the file
|
||||||
results in either a newline (L'\n') character, the null (L'\\0')
|
results in either a newline (L'\n') character, the null (L'\\0')
|
||||||
character or the end of file (WEOF) character.
|
character or the end of file (WEOF) character.
|
||||||
*/
|
*/
|
||||||
int fgetws2( wchar_t **buff, int *len, FILE *f );
|
int fgetws2(wcstring *s, FILE *f);
|
||||||
|
|
||||||
/**
|
|
||||||
Sorts an array_list of wide strings according to the
|
|
||||||
wcsfilecmp-function from the util library
|
|
||||||
*/
|
|
||||||
void sort_list( array_list_t *comp );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns a newly allocated wide character string equivalent of the
|
Returns a newly allocated wide character string equivalent of the
|
||||||
@@ -171,6 +211,16 @@ void sort_list( array_list_t *comp );
|
|||||||
*/
|
*/
|
||||||
wchar_t *str2wcs( const char *in );
|
wchar_t *str2wcs( const char *in );
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns a newly allocated wide character string equivalent of the
|
||||||
|
specified multibyte character string
|
||||||
|
|
||||||
|
This function encodes illegal character sequences in a reversible
|
||||||
|
way using the private use area.
|
||||||
|
*/
|
||||||
|
wcstring str2wcstring( const char *in );
|
||||||
|
wcstring str2wcstring( const std::string &in );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Converts the narrow character string \c in into it's wide
|
Converts the narrow character string \c in into it's wide
|
||||||
equivalent, stored in \c out. \c out must have enough space to fit
|
equivalent, stored in \c out. \c out must have enough space to fit
|
||||||
@@ -189,6 +239,35 @@ wchar_t *str2wcs_internal( const char *in, wchar_t *out );
|
|||||||
way using the private use area.
|
way using the private use area.
|
||||||
*/
|
*/
|
||||||
char *wcs2str( const wchar_t *in );
|
char *wcs2str( const wchar_t *in );
|
||||||
|
std::string wcs2string(const wcstring &input);
|
||||||
|
|
||||||
|
/** Test if a string prefixes another. Returns true if a is a prefix of b */
|
||||||
|
bool string_prefixes_string(const wcstring &proposed_prefix, const wcstring &value);
|
||||||
|
bool string_prefixes_string(const wchar_t *proposed_prefix, const wcstring &value);
|
||||||
|
|
||||||
|
/** Test if a string is a suffix of another */
|
||||||
|
bool string_suffixes_string(const wcstring &proposed_suffix, const wcstring &value);
|
||||||
|
bool string_suffixes_string(const wchar_t *proposed_suffix, const wcstring &value);
|
||||||
|
|
||||||
|
|
||||||
|
/** Test if a string prefixes another without regard to case. Returns true if a is a prefix of b */
|
||||||
|
bool string_prefixes_string_case_insensitive(const wcstring &proposed_prefix, const wcstring &value);
|
||||||
|
|
||||||
|
/** Test if a list contains a string using a linear search. */
|
||||||
|
bool list_contains_string(const wcstring_list_t &list, const wcstring &str);
|
||||||
|
|
||||||
|
|
||||||
|
void assert_is_main_thread(const char *who);
|
||||||
|
#define ASSERT_IS_MAIN_THREAD_TRAMPOLINE(x) assert_is_main_thread(x)
|
||||||
|
#define ASSERT_IS_MAIN_THREAD() ASSERT_IS_MAIN_THREAD_TRAMPOLINE(__FUNCTION__)
|
||||||
|
|
||||||
|
void assert_is_background_thread(const char *who);
|
||||||
|
#define ASSERT_IS_BACKGROUND_THREAD_TRAMPOLINE(x) assert_is_background_thread(x)
|
||||||
|
#define ASSERT_IS_BACKGROUND_THREAD() ASSERT_IS_BACKGROUND_THREAD_TRAMPOLINE(__FUNCTION__)
|
||||||
|
|
||||||
|
/* Useful macro for asserting that a lock is locked. This doesn't check whether this thread locked it, which it would be nice if it did, but here it is anyways. */
|
||||||
|
void assert_is_locked(void *mutex, const char *who, const char *caller);
|
||||||
|
#define ASSERT_IS_LOCKED(x) assert_is_locked((void *)(&x), #x, __FUNCTION__)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Converts the wide character string \c in into it's narrow
|
Converts the wide character string \c in into it's narrow
|
||||||
@@ -200,33 +279,244 @@ char *wcs2str( const wchar_t *in );
|
|||||||
*/
|
*/
|
||||||
char *wcs2str_internal( const wchar_t *in, char *out );
|
char *wcs2str_internal( const wchar_t *in, char *out );
|
||||||
|
|
||||||
|
/** Format the specified size (in bytes, kilobytes, etc.) into the specified stringbuffer. */
|
||||||
|
wcstring format_size(long long sz);
|
||||||
|
|
||||||
|
/** Version of format_size that does not allocate memory. */
|
||||||
|
void format_size_safe(char buff[128], unsigned long long sz);
|
||||||
|
|
||||||
|
/** Our crappier versions of debug which is guaranteed to not allocate any memory, or do anything other than call write(). This is useful after a call to fork() with threads. */
|
||||||
|
void debug_safe(int level, const char *msg, const char *param1 = NULL, const char *param2 = NULL, const char *param3 = NULL, const char *param4 = NULL, const char *param5 = NULL, const char *param6 = NULL, const char *param7 = NULL, const char *param8 = NULL, const char *param9 = NULL, const char *param10 = NULL, const char *param11 = NULL, const char *param12 = NULL);
|
||||||
|
|
||||||
|
/** Writes out a long safely */
|
||||||
|
void format_long_safe(char buff[128], long val);
|
||||||
|
void format_long_safe(wchar_t buff[128], long val);
|
||||||
|
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
T from_string(const wcstring &x) {
|
||||||
|
T result;
|
||||||
|
std::wstringstream stream(x);
|
||||||
|
stream >> result;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
T from_string(const std::string &x) {
|
||||||
|
T result = T();
|
||||||
|
std::stringstream stream(x);
|
||||||
|
stream >> result;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
wcstring to_string(const T &x) {
|
||||||
|
std::wstringstream stream;
|
||||||
|
stream << x;
|
||||||
|
return stream.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* wstringstream is a huge memory pig. Let's provide some specializations where we can. */
|
||||||
|
template<>
|
||||||
|
inline wcstring to_string(const long &x) {
|
||||||
|
wchar_t buff[128];
|
||||||
|
format_long_safe(buff, x);
|
||||||
|
return wcstring(buff);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline bool from_string(const std::string &x) {
|
||||||
|
return ! x.empty() && strchr("YTyt1", x.at(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline bool from_string(const wcstring &x) {
|
||||||
|
return ! x.empty() && wcschr(L"YTyt1", x.at(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline wcstring to_string(const int &x) {
|
||||||
|
return to_string(static_cast<long>(x));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Helper class for managing a null-terminated array of null-terminated strings (of some char type) */
|
||||||
|
template <typename CharType_t>
|
||||||
|
class null_terminated_array_t {
|
||||||
|
CharType_t **array;
|
||||||
|
|
||||||
|
typedef std::basic_string<CharType_t> string_t;
|
||||||
|
typedef std::vector<string_t> string_list_t;
|
||||||
|
|
||||||
|
void swap(null_terminated_array_t<CharType_t> &him) { std::swap(array, him.array); }
|
||||||
|
|
||||||
|
/* Silly function to get the length of a null terminated array of...something */
|
||||||
|
template <typename T>
|
||||||
|
static size_t count_not_null(const T *arr) {
|
||||||
|
size_t len;
|
||||||
|
for (len=0; arr[len] != T(0); len++)
|
||||||
|
;
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t size() const {
|
||||||
|
return count_not_null(array);
|
||||||
|
}
|
||||||
|
|
||||||
|
void free(void) {
|
||||||
|
if (array != NULL) {
|
||||||
|
for (size_t i = 0; array[i] != NULL; i++) {
|
||||||
|
delete [] array[i];
|
||||||
|
}
|
||||||
|
delete [] array;
|
||||||
|
array = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
null_terminated_array_t() : array(NULL) { }
|
||||||
|
null_terminated_array_t(const string_list_t &argv) : array(NULL) { this->set(argv); }
|
||||||
|
~null_terminated_array_t() { this->free(); }
|
||||||
|
|
||||||
|
/** operator=. Notice the pass-by-value parameter. */
|
||||||
|
null_terminated_array_t& operator=(null_terminated_array_t rhs) {
|
||||||
|
if (this != &rhs)
|
||||||
|
this->swap(rhs);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Copy constructor. */
|
||||||
|
null_terminated_array_t(const null_terminated_array_t &him) : array(NULL) {
|
||||||
|
this->set(him.array);
|
||||||
|
}
|
||||||
|
|
||||||
|
void set(const string_list_t &argv) {
|
||||||
|
/* Get rid of the old argv */
|
||||||
|
this->free();
|
||||||
|
|
||||||
|
/* Allocate our null-terminated array of null-terminated strings */
|
||||||
|
size_t i, count = argv.size();
|
||||||
|
this->array = new CharType_t * [count + 1];
|
||||||
|
for (i=0; i < count; i++) {
|
||||||
|
const string_t &str = argv.at(i);
|
||||||
|
this->array[i] = new CharType_t [1 + str.size()];
|
||||||
|
std::copy(str.begin(), str.end(), this->array[i]);
|
||||||
|
this->array[i][str.size()] = CharType_t(0);
|
||||||
|
}
|
||||||
|
this->array[count] = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void set(const CharType_t * const *new_array) {
|
||||||
|
if (new_array == array)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Get rid of the old argv */
|
||||||
|
this->free();
|
||||||
|
|
||||||
|
/* Copy the new one */
|
||||||
|
if (new_array) {
|
||||||
|
size_t i, count = count_not_null(new_array);
|
||||||
|
this->array = new CharType_t * [count + 1];
|
||||||
|
for (i=0; i < count; i++) {
|
||||||
|
size_t len = count_not_null(new_array[i]);
|
||||||
|
this->array[i] = new CharType_t [1 + len];
|
||||||
|
std::copy(new_array[i], new_array[i] + len, this->array[i]);
|
||||||
|
this->array[i][len] = CharType_t(0);
|
||||||
|
}
|
||||||
|
this->array[count] = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CharType_t **get() { return array; }
|
||||||
|
const CharType_t * const *get() const { return array; }
|
||||||
|
|
||||||
|
string_list_t to_list() const {
|
||||||
|
string_list_t lst;
|
||||||
|
if (array != NULL) {
|
||||||
|
size_t count = this->size();
|
||||||
|
lst.reserve(count);
|
||||||
|
lst.insert(lst.end(), array, array + count);
|
||||||
|
}
|
||||||
|
return lst;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Helper function to convert from a null_terminated_array_t<wchar_t> to a null_terminated_array_t<char_t> */
|
||||||
|
null_terminated_array_t<char> convert_wide_array_to_narrow(const null_terminated_array_t<wchar_t> &arr);
|
||||||
|
|
||||||
|
/* Helper class to cache a narrow version of a wcstring in a malloc'd buffer, so that we can read it after fork() */
|
||||||
|
class narrow_string_rep_t {
|
||||||
|
private:
|
||||||
|
const char *str;
|
||||||
|
|
||||||
|
/* No copying */
|
||||||
|
narrow_string_rep_t &operator=(const narrow_string_rep_t &);
|
||||||
|
narrow_string_rep_t(const narrow_string_rep_t &x);
|
||||||
|
|
||||||
|
public:
|
||||||
|
~narrow_string_rep_t() {
|
||||||
|
free((void *)str);
|
||||||
|
}
|
||||||
|
|
||||||
|
narrow_string_rep_t() : str(NULL) {}
|
||||||
|
|
||||||
|
void set(const wcstring &s) {
|
||||||
|
free((void *)str);
|
||||||
|
str = wcs2str(s.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *get() const {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
bool is_forked_child();
|
||||||
|
|
||||||
|
/* Basic scoped lock class */
|
||||||
|
class scoped_lock {
|
||||||
|
pthread_mutex_t *lock_obj;
|
||||||
|
bool locked;
|
||||||
|
|
||||||
|
/* No copying */
|
||||||
|
scoped_lock &operator=(const scoped_lock &);
|
||||||
|
scoped_lock(const scoped_lock &);
|
||||||
|
|
||||||
|
public:
|
||||||
|
void lock(void);
|
||||||
|
void unlock(void);
|
||||||
|
scoped_lock(pthread_mutex_t &mutex);
|
||||||
|
~scoped_lock();
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Wrapper around wcstok */
|
||||||
|
class wcstokenizer {
|
||||||
|
wchar_t *buffer, *str, *state;
|
||||||
|
const wcstring sep;
|
||||||
|
|
||||||
|
/* No copying */
|
||||||
|
wcstokenizer &operator=(const wcstokenizer &);
|
||||||
|
wcstokenizer(const wcstokenizer &);
|
||||||
|
|
||||||
|
public:
|
||||||
|
wcstokenizer(const wcstring &s, const wcstring &separator);
|
||||||
|
bool next(wcstring &result);
|
||||||
|
~wcstokenizer();
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Appends a path component, with a / if necessary
|
||||||
|
*/
|
||||||
|
void append_path_component(wcstring &path, const wcstring &component);
|
||||||
|
|
||||||
|
wcstring format_string(const wchar_t *format, ...);
|
||||||
|
wcstring vformat_string(const wchar_t *format, va_list va_orig);
|
||||||
|
void append_format(wcstring &str, const wchar_t *format, ...);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns a newly allocated wide character string array equivalent of
|
Returns a newly allocated wide character string array equivalent of
|
||||||
the specified multibyte character string array
|
the specified multibyte character string array
|
||||||
*/
|
*/
|
||||||
char **wcsv2strv( const wchar_t **in );
|
char **wcsv2strv( const wchar_t * const *in );
|
||||||
|
|
||||||
/**
|
|
||||||
Returns a newly allocated multibyte character string array equivalent of the specified wide character string array
|
|
||||||
*/
|
|
||||||
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.
|
|
||||||
*/
|
|
||||||
__sentinel wchar_t *wcsdupcat2( const wchar_t *a, ... );
|
|
||||||
|
|
||||||
/**
|
|
||||||
Test if the given string is a valid variable name
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Test if the given string is a valid variable name.
|
Test if the given string is a valid variable name.
|
||||||
@@ -243,7 +533,7 @@ wchar_t *wcsvarname( const wchar_t *str );
|
|||||||
\return null if this is a valid name, and a pointer to the first invalid character otherwise
|
\return null if this is a valid name, and a pointer to the first invalid character otherwise
|
||||||
*/
|
*/
|
||||||
|
|
||||||
wchar_t *wcsfuncname( const wchar_t *str );
|
const wchar_t *wcsfuncname( const wchar_t *str );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Test if the given string is valid in a variable name
|
Test if the given string is valid in a variable name
|
||||||
@@ -284,28 +574,46 @@ void error_reset();
|
|||||||
the user is using a Unicode character set, and if so, use the
|
the user is using a Unicode character set, and if so, use the
|
||||||
unicode ellipsis character as ellipsis, instead of '$'.
|
unicode ellipsis character as ellipsis, instead of '$'.
|
||||||
*/
|
*/
|
||||||
const wchar_t *wsetlocale( int category, const wchar_t *locale );
|
wcstring wsetlocale( int category, const wchar_t *locale );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Checks if \c needle is included in the list of strings specified. A warning is printed if needle is zero.
|
Checks if \c needle is included in the list of strings specified. A warning is printed if needle is zero.
|
||||||
|
|
||||||
\param needle the string to search for in the list
|
\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
|
||||||
*/
|
*/
|
||||||
__sentinel int contains_str( const wchar_t *needle, ... );
|
__sentinel bool contains_internal( const wchar_t *needle, ... );
|
||||||
|
__sentinel bool contains_internal( const wcstring &needle, ... );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Call read while blocking the SIGCHLD signal. Should only be called
|
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);
|
long 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, const char *buff, size_t count);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Loop a read request while failiure is non-critical. Return -1 and set errno
|
||||||
|
in case of critical error.
|
||||||
|
*/
|
||||||
|
ssize_t read_loop(int fd, void *buff, size_t count);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Issue a debug message with printf-style string formating and
|
Issue a debug message with printf-style string formating and
|
||||||
automatic line breaking. The string will begin with the string \c
|
automatic line breaking. The string will begin with the string \c
|
||||||
program_name, followed by a colon and a whitespace.
|
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 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.
|
\param msg the message format string.
|
||||||
@@ -316,6 +624,7 @@ int read_blocked(int fd, void *buf, size_t count);
|
|||||||
|
|
||||||
will print the string 'fish: Pi = 3.141', given that debug_level is 1 or higher, and that program_name is 'fish'.
|
will print the string 'fish: Pi = 3.141', given that debug_level is 1 or higher, and that program_name is 'fish'.
|
||||||
*/
|
*/
|
||||||
|
void debug( int level, const char *msg, ... );
|
||||||
void debug( int level, const wchar_t *msg, ... );
|
void debug( int level, const wchar_t *msg, ... );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -327,7 +636,8 @@ void debug( int level, const wchar_t *msg, ... );
|
|||||||
\return The escaped string, or 0 if there is not enough memory
|
\return The escaped string, or 0 if there is not enough memory
|
||||||
*/
|
*/
|
||||||
|
|
||||||
wchar_t *escape( const wchar_t *in, int escape_all );
|
wchar_t *escape( const wchar_t *in, escape_flags_t flags );
|
||||||
|
wcstring escape_string( const wcstring &in, escape_flags_t flags );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Expand backslashed escapes and substitute them with their unescaped
|
Expand backslashed escapes and substitute them with their unescaped
|
||||||
@@ -343,29 +653,22 @@ wchar_t *escape( const wchar_t *in, int escape_all );
|
|||||||
wchar_t *unescape( const wchar_t * in,
|
wchar_t *unescape( const wchar_t * in,
|
||||||
int escape_special );
|
int escape_special );
|
||||||
|
|
||||||
/**
|
bool unescape_string( wcstring &str,
|
||||||
Attempt to acquire a lock based on a lockfile, waiting LOCKPOLLINTERVAL
|
int escape_special );
|
||||||
milliseconds between polls and timing out after timeout seconds,
|
|
||||||
thereafter forcibly attempting to obtain the lock if force is non-zero.
|
|
||||||
Returns 1 on success, 0 on failure.
|
|
||||||
To release the lock the lockfile must be unlinked.
|
|
||||||
A unique temporary file named by appending characters to the lockfile name
|
|
||||||
is used; any pre-existing file of the same name is subject to deletion.
|
|
||||||
*/
|
|
||||||
int acquire_lock_file( const char *lockfile, const int timeout, int force );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the width of the terminal window, so that not all
|
Returns the width of the terminal window, so that not all
|
||||||
functions that use these values continually have to keep track of
|
functions that use these values continually have to keep track of
|
||||||
it.
|
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();
|
int common_get_width();
|
||||||
/**
|
/**
|
||||||
Returns the height of the terminal window, so that not all
|
Returns the height of the terminal window, so that not all
|
||||||
functions that use these values continually have to keep track of
|
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.
|
Only works if common_handle_winch is registered to handle winch signals.
|
||||||
*/
|
*/
|
||||||
@@ -382,25 +685,63 @@ void common_handle_winch( int signal );
|
|||||||
Write paragraph of output to the specified stringbuffer, and redo
|
Write paragraph of output to the specified stringbuffer, and redo
|
||||||
the linebreaks to fit the current screen.
|
the linebreaks to fit the current screen.
|
||||||
*/
|
*/
|
||||||
void write_screen( const wchar_t *msg, string_buffer_t *buff );
|
void write_screen( const wcstring &msg, wcstring &buff );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Tokenize the specified string into the specified array_list_t.
|
Tokenize the specified string into the specified wcstring_list_t.
|
||||||
Each new element is allocated using malloc and must be freed by the
|
|
||||||
caller.
|
|
||||||
|
|
||||||
\param val the input string. The contents of this string is not changed.
|
\param val the input string. The contents of this string is not changed.
|
||||||
\param out the list in which to place the elements.
|
\param out the list in which to place the elements.
|
||||||
*/
|
*/
|
||||||
void tokenize_variable_array( const wchar_t *val, array_list_t *out );
|
void tokenize_variable_array( const wcstring &val, wcstring_list_t &out);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Make sure the specified direcotry exists. If no, try to create it.
|
Make sure the specified direcotry exists. If needed, try to create
|
||||||
|
it and any currently not existing parent directories..
|
||||||
|
|
||||||
\return 0 if the directory exists, -1 otherwise.
|
\return 0 if, at the time of function return the directory exists, -1 otherwise.
|
||||||
*/
|
*/
|
||||||
int create_directory( wchar_t *d );
|
int create_directory( const wcstring &d );
|
||||||
|
|
||||||
|
/**
|
||||||
|
Print a short message about how to file a bug report to stderr
|
||||||
|
*/
|
||||||
|
void bugreport();
|
||||||
|
|
||||||
|
/**
|
||||||
|
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();
|
||||||
|
|
||||||
|
/**
|
||||||
|
Call the following function early in main to set the main thread.
|
||||||
|
This is our replacement for pthread_main_np().
|
||||||
|
*/
|
||||||
|
void set_main_thread();
|
||||||
|
bool is_main_thread();
|
||||||
|
|
||||||
|
/** Configures thread assertions for testing */
|
||||||
|
void configure_thread_assertions_for_testing();
|
||||||
|
|
||||||
|
/** Set up a guard to complain if we try to do certain things (like take a lock) after calling fork */
|
||||||
|
void setup_fork_guards(void);
|
||||||
|
|
||||||
|
/** Save the value of tcgetpgrp so we can restore it on exit */
|
||||||
|
void save_term_foreground_process_group(void);
|
||||||
|
void restore_term_foreground_process_group(void);
|
||||||
|
|
||||||
|
/** Return whether we are the child of a fork */
|
||||||
|
bool is_forked_child(void);
|
||||||
|
void assert_is_not_forked_child(const char *who);
|
||||||
|
#define ASSERT_IS_NOT_FORKED_CHILD_TRAMPOLINE(x) assert_is_not_forked_child(x)
|
||||||
|
#define ASSERT_IS_NOT_FORKED_CHILD() ASSERT_IS_NOT_FORKED_CHILD_TRAMPOLINE(__FUNCTION__)
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
__attribute__((noinline)) void debug_thread_error(void);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
2257
complete.c
2257
complete.c
File diff suppressed because it is too large
Load Diff
2034
complete.cpp
Normal file
2034
complete.cpp
Normal file
File diff suppressed because it is too large
Load Diff
191
complete.h
191
complete.h
@@ -12,10 +12,11 @@
|
|||||||
*/
|
*/
|
||||||
#define FISH_COMPLETE_H
|
#define FISH_COMPLETE_H
|
||||||
|
|
||||||
|
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "common.h"
|
||||||
/**
|
/**
|
||||||
Use all completions
|
Use all completions
|
||||||
*/
|
*/
|
||||||
@@ -66,16 +67,103 @@
|
|||||||
*/
|
*/
|
||||||
#define PROG_COMPLETE_SEP L'\t'
|
#define PROG_COMPLETE_SEP L'\t'
|
||||||
|
|
||||||
/**
|
enum {
|
||||||
Terminator for completions sent to the fish_pager
|
/**
|
||||||
*/
|
Do not insert space afterwards if this is the only completion. (The
|
||||||
#define COMPLETE_TERMINATOR L'\006'
|
default is to try insert a space)
|
||||||
|
*/
|
||||||
|
COMPLETE_NO_SPACE = 1 << 0,
|
||||||
|
|
||||||
|
/**
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
COMPLETE_NO_CASE = 1 << 1,
|
||||||
|
|
||||||
|
/**
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
COMPLETE_WHOLE_ARGUMENT = 1 << 2,
|
||||||
|
|
||||||
|
/**
|
||||||
|
This completion may or may not want a space at the end - guess by
|
||||||
|
checking the last character of the completion.
|
||||||
|
*/
|
||||||
|
COMPLETE_AUTO_SPACE = 1 << 3,
|
||||||
|
|
||||||
|
/**
|
||||||
|
This completion should be inserted as-is, without escaping.
|
||||||
|
*/
|
||||||
|
COMPLETE_DONT_ESCAPE = 1 << 4
|
||||||
|
};
|
||||||
|
typedef int complete_flags_t;
|
||||||
|
|
||||||
|
|
||||||
|
class completion_t
|
||||||
|
{
|
||||||
|
|
||||||
|
private:
|
||||||
|
/* No public default constructor */
|
||||||
|
completion_t();
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
The completion string
|
||||||
|
*/
|
||||||
|
wcstring completion;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The description for this completion
|
||||||
|
*/
|
||||||
|
wcstring 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;
|
||||||
|
|
||||||
|
bool is_case_insensitive() const { return !! (flags & COMPLETE_NO_CASE); }
|
||||||
|
|
||||||
|
/* Construction. Note: defining these so that they are not inlined reduces the executable size. */
|
||||||
|
completion_t(const wcstring &comp, const wcstring &desc = L"", int flags_val = 0);
|
||||||
|
completion_t(const completion_t &);
|
||||||
|
completion_t &operator=(const completion_t &);
|
||||||
|
|
||||||
|
/* The following are needed for sorting and uniquing completions */
|
||||||
|
bool operator < (const completion_t& rhs) const;
|
||||||
|
bool operator == (const completion_t& rhs) const;
|
||||||
|
bool operator != (const completion_t& rhs) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum complete_type_t {
|
||||||
|
COMPLETE_DEFAULT,
|
||||||
|
COMPLETE_AUTOSUGGEST
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Given a list of completions, returns a list of their completion fields */
|
||||||
|
wcstring_list_t completions_to_wcstring_list( const std::vector<completion_t> &completions );
|
||||||
|
|
||||||
|
/** Sorts a list of completions */
|
||||||
|
void sort_completions( std::vector<completion_t> &completions);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
Add a completion.
|
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:
|
Examples:
|
||||||
|
|
||||||
@@ -109,71 +197,60 @@
|
|||||||
file completion is not performed.
|
file completion is not performed.
|
||||||
\param comp A space separated list of completions which may contain subshells.
|
\param comp A space separated list of completions which may contain subshells.
|
||||||
\param desc A description of the completion.
|
\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 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,
|
void complete_add( const wchar_t *cmd,
|
||||||
int cmd_type,
|
bool cmd_is_path,
|
||||||
wchar_t short_opt,
|
wchar_t short_opt,
|
||||||
const wchar_t *long_opt,
|
const wchar_t *long_opt,
|
||||||
int long_mode,
|
int long_mode,
|
||||||
int result_mode,
|
int result_mode,
|
||||||
int authorative,
|
const wchar_t *condition,
|
||||||
const wchar_t *condition,
|
const wchar_t *comp,
|
||||||
const wchar_t *comp,
|
const wchar_t *desc,
|
||||||
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, bool cmd_type, bool authoritative );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Remove a previously defined completion
|
Remove a previously defined completion
|
||||||
*/
|
*/
|
||||||
void complete_remove( const wchar_t *cmd,
|
void complete_remove( const wchar_t *cmd,
|
||||||
int cmd_type,
|
bool cmd_is_path,
|
||||||
wchar_t short_opt,
|
wchar_t short_opt,
|
||||||
const wchar_t *long_opt );
|
const wchar_t *long_opt );
|
||||||
|
|
||||||
|
|
||||||
|
/** Find all completions of the command cmd, insert them into out. If to_load is not NULL, append all commands that we would autoload, but did not (presumably because this is not the main thread) */
|
||||||
|
void complete( const wcstring &cmd, std::vector<completion_t> &comp, complete_type_t type, wcstring_list_t *to_load = NULL );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Find all completions of the command cmd, insert them into out. The
|
Print a list of all current completions into the string.
|
||||||
caller must free the variables returned in out. The results are
|
|
||||||
returned in the array_list_t 'out', in the format of wide character
|
|
||||||
strings, with each element consisting of a suggested completion and
|
|
||||||
a description of what kind of object this completion represents,
|
|
||||||
separated by a separator of type COMPLETE_SEP.
|
|
||||||
|
|
||||||
Values returned by this function should be freed by the caller.
|
\param out The string to write completions to
|
||||||
*/
|
*/
|
||||||
void complete( const wchar_t *cmd, array_list_t *out );
|
void complete_print( wcstring &out );
|
||||||
|
|
||||||
/**
|
|
||||||
Print a list of all current completions into the string_buffer_t.
|
|
||||||
|
|
||||||
\param out The string_buffer_t to write completions to
|
|
||||||
*/
|
|
||||||
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
|
Tests if the specified option is defined for the specified command
|
||||||
*/
|
*/
|
||||||
int complete_is_valid_option( const wchar_t *str,
|
int complete_is_valid_option( const wcstring &str,
|
||||||
const wchar_t *opt,
|
const wcstring &opt,
|
||||||
array_list_t *errors );
|
wcstring_list_t *inErrorsOrNull,
|
||||||
|
bool allow_autoload );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Tests if the specified argument is valid for the specified option
|
Tests if the specified argument is valid for the specified option
|
||||||
and command
|
and command
|
||||||
*/
|
*/
|
||||||
int complete_is_valid_argument( const wchar_t *str,
|
bool complete_is_valid_argument( const wcstring &str,
|
||||||
const wchar_t *opt,
|
const wcstring &opt,
|
||||||
const wchar_t *arg );
|
const wcstring &arg );
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -185,6 +262,18 @@ int complete_is_valid_argument( const wchar_t *str,
|
|||||||
\param cmd the command for which to load command-specific completions
|
\param cmd the command for which to load command-specific completions
|
||||||
\param reload should the commands completions be reloaded, even if they where previously loaded. (This is set to true on actual completions, so that changed completion are updated in running shells)
|
\param reload should the commands completions be reloaded, even if they where previously loaded. (This is set to true on actual completions, so that changed completion are updated in running shells)
|
||||||
*/
|
*/
|
||||||
void complete_load( const wchar_t *cmd, int reload );
|
void complete_load( const wcstring &cmd, bool reload );
|
||||||
|
|
||||||
|
/**
|
||||||
|
Create a new completion entry
|
||||||
|
|
||||||
|
\param completions The array of completions to append to
|
||||||
|
\param comp The completion string
|
||||||
|
\param desc The description of the completion
|
||||||
|
\param flags completion flags
|
||||||
|
|
||||||
|
*/
|
||||||
|
void append_completion(std::vector<completion_t> &completions, const wcstring &comp, const wcstring &desc = L"", int flags = 0);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
457
configure.ac
457
configure.ac
@@ -9,7 +9,36 @@
|
|||||||
# configure the build process.
|
# configure the build process.
|
||||||
#
|
#
|
||||||
|
|
||||||
AC_INIT(fish,1.22.0,fish-users@lists.sf.net)
|
AC_INIT(fish,2.0.0,fish-users@lists.sf.net)
|
||||||
|
|
||||||
|
#
|
||||||
|
# preserve configure arguments for xsel
|
||||||
|
#
|
||||||
|
|
||||||
|
conf_arg=$@
|
||||||
|
|
||||||
|
#
|
||||||
|
# List of output variables produced by this configure script
|
||||||
|
#
|
||||||
|
|
||||||
|
AC_SUBST(docdir)
|
||||||
|
AC_SUBST(HAVE_GETTEXT)
|
||||||
|
AC_SUBST(LDFLAGS_FISH)
|
||||||
|
AC_SUBST(LIBS_FISH)
|
||||||
|
AC_SUBST(LIBS_FISH_INDENT)
|
||||||
|
AC_SUBST(LIBS_FISH_PAGER)
|
||||||
|
AC_SUBST(LIBS_FISHD)
|
||||||
|
AC_SUBST(LIBS_MIMEDB)
|
||||||
|
AC_SUBST(LIBS_SET_COLOR)
|
||||||
|
AC_SUBST(localedir)
|
||||||
|
AC_SUBST(optbindirs)
|
||||||
|
AC_SUBST(prefix)
|
||||||
|
AC_SUBST(SEQ_FALLBACK)
|
||||||
|
AC_SUBST(XSEL)
|
||||||
|
AC_SUBST(XSEL_MAN)
|
||||||
|
AC_SUBST(XSEL_BIN)
|
||||||
|
AC_SUBST(XSEL_MAN_PATH)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -33,7 +62,7 @@ if test configure -ot configure.ac; then
|
|||||||
fi
|
fi
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
AC_MSG_ERROR(
|
AC_MSG_ERROR(
|
||||||
[cannot find the autoconf program in your path.
|
[cannot find the autoconf program in your path.
|
||||||
This program needs to be run whenever the configure.ac file is modified.
|
This program needs to be run whenever the configure.ac file is modified.
|
||||||
Please install it and try again.]
|
Please install it and try again.]
|
||||||
@@ -58,11 +87,11 @@ if test ! -f ./config.h.in -o config.h.in -ot configure.ac; then
|
|||||||
AC_MSG_NOTICE([running autoheader])
|
AC_MSG_NOTICE([running autoheader])
|
||||||
autoheader || exit 1
|
autoheader || exit 1
|
||||||
else
|
else
|
||||||
AC_MSG_ERROR(
|
AC_MSG_ERROR(
|
||||||
[cannot find the autoheader program in your path.
|
[cannot find the autoheader program in your path.
|
||||||
This program needs to be run whenever the configure.ac file is modified.
|
This program needs to be run whenever the configure.ac file is modified.
|
||||||
Please install it and try again.]
|
Please install it and try again.]
|
||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
AC_MSG_RESULT([no])
|
AC_MSG_RESULT([no])
|
||||||
@@ -77,24 +106,25 @@ fi
|
|||||||
# This mostly helps OS X users, since fink usually installs out of
|
# This mostly helps OS X users, since fink usually installs out of
|
||||||
# tree and doesn't update CFLAGS.
|
# tree and doesn't update CFLAGS.
|
||||||
#
|
#
|
||||||
|
# It also helps FreeBSD which puts libiconv in /usr/local/lib
|
||||||
|
|
||||||
for i in /usr/pkg /sw /opt /opt/local; do
|
for i in /usr/pkg /sw /opt /opt/local /usr/local; do
|
||||||
|
|
||||||
AC_MSG_CHECKING([for $i/include include directory])
|
AC_MSG_CHECKING([for $i/include include directory])
|
||||||
if test -d $i/include; then
|
if test -d $i/include; then
|
||||||
AC_MSG_RESULT(yes)
|
AC_MSG_RESULT(yes)
|
||||||
CPPFLAGS="$CPPFLAGS -I$i/include/"
|
CXXFLAGS="$CXXFLAGS -I$i/include/"
|
||||||
CFLAGS="$CFLAGS -I$i/include/"
|
CFLAGS="$CFLAGS -I$i/include/"
|
||||||
else
|
else
|
||||||
AC_MSG_RESULT(no)
|
AC_MSG_RESULT(no)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
AC_MSG_CHECKING([for $i/lib library directory])
|
AC_MSG_CHECKING([for $i/lib library directory])
|
||||||
if test -d $i/lib; then
|
if test -d $i/lib; then
|
||||||
AC_MSG_RESULT(yes)
|
AC_MSG_RESULT(yes)
|
||||||
LDFLAGS="$LDFLAGS -L$i/lib/ -R$i/lib/"
|
LDFLAGS="$LDFLAGS -L$i/lib/ -Wl,-rpath,$i/lib/"
|
||||||
else
|
else
|
||||||
AC_MSG_RESULT(no)
|
AC_MSG_RESULT(no)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
AC_MSG_CHECKING([for $i/bin command directory])
|
AC_MSG_CHECKING([for $i/bin command directory])
|
||||||
@@ -102,16 +132,14 @@ for i in /usr/pkg /sw /opt /opt/local; do
|
|||||||
AC_MSG_RESULT(yes)
|
AC_MSG_RESULT(yes)
|
||||||
optbindirs="$optbindirs $i/bin"
|
optbindirs="$optbindirs $i/bin"
|
||||||
else
|
else
|
||||||
AC_MSG_RESULT(no)
|
AC_MSG_RESULT(no)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
AC_SUBST( optbindirs, $optbindirs )
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Tell autoconf to create config.h header
|
# Tell autoconf to create config.h header
|
||||||
#
|
#
|
||||||
AC_CONFIG_HEADERS(config.h)
|
AC_CONFIG_HEADERS(config.h)
|
||||||
|
|
||||||
@@ -125,8 +153,8 @@ AH_BOTTOM([#if __GNUC__ >= 3
|
|||||||
#define __warn_unused __attribute__ ((warn_unused_result))
|
#define __warn_unused __attribute__ ((warn_unused_result))
|
||||||
#define __sentinel __attribute__ ((sentinel))
|
#define __sentinel __attribute__ ((sentinel))
|
||||||
#else
|
#else
|
||||||
#define __warn_unused
|
#define __warn_unused
|
||||||
#define __sentinel
|
#define __sentinel
|
||||||
#endif])
|
#endif])
|
||||||
|
|
||||||
|
|
||||||
@@ -134,11 +162,10 @@ AH_BOTTOM([#if __GNUC__ >= 3
|
|||||||
# Set up various programs needed for install
|
# Set up various programs needed for install
|
||||||
#
|
#
|
||||||
|
|
||||||
AC_PROG_CC
|
AC_PROG_CXX([g++ c++])
|
||||||
AC_PROG_CPP
|
AC_PROG_CPP
|
||||||
AC_PROG_INSTALL
|
AC_PROG_INSTALL
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Check for seq command. If missing, make sure fallback shellscript
|
# Check for seq command. If missing, make sure fallback shellscript
|
||||||
# implementation is installed.
|
# implementation is installed.
|
||||||
@@ -147,76 +174,85 @@ AC_PROG_INSTALL
|
|||||||
AC_CHECK_PROG( SEQ_FALLBACK, seq, [ ], [seq])
|
AC_CHECK_PROG( SEQ_FALLBACK, seq, [ ], [seq])
|
||||||
|
|
||||||
|
|
||||||
#
|
if test "$SEQ_FALLBACK"; then
|
||||||
# Optionally drop xsel command
|
|
||||||
#
|
|
||||||
|
|
||||||
AC_ARG_WITH(
|
#
|
||||||
xsel,
|
# We already have seq. Check if the seq version is installed by an
|
||||||
AC_HELP_STRING(
|
# earlier fish version. If it is, we'll replace it.
|
||||||
[--without-xsel],
|
#
|
||||||
[do not build the xsel program needed for X clipboard integration]
|
|
||||||
),
|
|
||||||
[xsel=$withval],
|
|
||||||
[xsel=with_xsel]
|
|
||||||
)
|
|
||||||
|
|
||||||
if [[ "$xsel" = "with_xsel" ]]; then
|
file=`which seq`
|
||||||
AC_SUBST( XSEL,[xsel-0.9.6/xsel])
|
if test -f "$file"; then
|
||||||
AC_SUBST( XSEL_MAN,[xsel.1x])
|
|
||||||
AC_SUBST( XSEL_MAN_PATH,[xsel-0.9.6/xsel.1x])
|
AC_MSG_CHECKING([if seq comes from a previous fish version])
|
||||||
else
|
shebang=`grep "\(^#!/.*/fish\|^#!/usr/bin/env fish\)" $file`
|
||||||
AC_SUBST( XSEL,[ ])
|
|
||||||
AC_SUBST( XSEL_MAN,[ ])
|
if test "$shebang"; then
|
||||||
AC_SUBST( XSEL_MAN_PATH,[ ])
|
SEQ_FALLBACK=seq
|
||||||
|
AC_MSG_RESULT(yes, replace it)
|
||||||
|
else
|
||||||
|
AC_MSG_RESULT(no, keep it)
|
||||||
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Test if the compiler accepts the -std=c99 flag. If so, using it
|
# Optionally drop xsel command
|
||||||
# increases the odds of correct compilation, since we want to use the
|
|
||||||
# *wprintf functions, which where defined in C99.
|
|
||||||
#
|
#
|
||||||
|
|
||||||
XCFLAGS="$CFLAGS"
|
AC_ARG_WITH(
|
||||||
CFLAGS="$CFLAGS -std=c99"
|
xsel,
|
||||||
XCPPFLAGS="$CPPFLAGS"
|
AC_HELP_STRING(
|
||||||
CPPFLAGS="$CPPFLAGS -std=c99"
|
[--without-xsel],
|
||||||
AC_MSG_CHECKING(if -std=c99 works)
|
[do not build the xsel program needed for X clipboard integration.
|
||||||
|
If build xsel, it will be configured with the same options as fish.]
|
||||||
AC_CACHE_VAL(
|
),
|
||||||
local_cv_has__std_c99,
|
[xsel=$withval],
|
||||||
[
|
[xsel=with_xsel]
|
||||||
AC_TRY_RUN(
|
|
||||||
[
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
],
|
|
||||||
local_cv_has__std_c99=yes,
|
|
||||||
local_cv_has__std_c99=no,
|
|
||||||
)
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
AC_MSG_RESULT($local_cv_has__std_c99)
|
if [[ "$xsel" = "with_xsel" ]]; then
|
||||||
case x$local_cv_has__std_c99 in
|
XSEL=xsel-1.2.0
|
||||||
xno)
|
XSEL_BIN=$XSEL/xsel
|
||||||
CFLAGS="$XCFLAGS"
|
XSEL_MAN=xsel.1x
|
||||||
CPPFLAGS="$XCPPFLAGS" ;;
|
XSEL_MAN_PATH=$XSEL/xsel.1x
|
||||||
esac
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Optionally drop gettext support
|
||||||
|
#
|
||||||
|
|
||||||
|
AC_ARG_WITH(
|
||||||
|
gettext,
|
||||||
|
AC_HELP_STRING(
|
||||||
|
[--without-gettext],
|
||||||
|
[do not translate messages, even if gettext is available]
|
||||||
|
),
|
||||||
|
[local_gettext=$withval],
|
||||||
|
[local_gettext=yes]
|
||||||
|
)
|
||||||
|
|
||||||
|
if test x$local_gettext != xno; then
|
||||||
|
AC_DEFINE([USE_GETTEXT],[1],[Perform string translations with gettext])
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Try to enable large file support. This will make sure that on systems
|
||||||
|
# where off_t can be either 32 or 64 bit, the latter size is used. On
|
||||||
|
# other systems, this should do nothing. (Hopefully)
|
||||||
|
#
|
||||||
|
|
||||||
|
CXXFLAGS="$CXXFLAGS -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64"
|
||||||
|
|
||||||
#
|
#
|
||||||
# If we are using gcc, set some flags that increase the odds of the
|
# If we are using gcc, set some flags that increase the odds of the
|
||||||
# compiler producing a working binary...
|
# compiler producing a working binary...
|
||||||
#
|
#
|
||||||
|
|
||||||
if test "$CC" = gcc; then
|
if test "$GCC" = yes; then
|
||||||
|
|
||||||
#
|
#
|
||||||
# -fno-optimize-sibling-calls seems to work around a bug where
|
# -fno-optimize-sibling-calls seems to work around a bug where
|
||||||
@@ -228,14 +264,21 @@ if test "$CC" = gcc; then
|
|||||||
# bug has been verified to not exist on Linux using GCC 3.3.3.
|
# bug has been verified to not exist on Linux using GCC 3.3.3.
|
||||||
#
|
#
|
||||||
|
|
||||||
CFLAGS="$CFLAGS -fno-optimize-sibling-calls"
|
CXXFLAGS="$CXXFLAGS -fno-optimize-sibling-calls"
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# -Wall is there to keep me on my toes
|
# -Wall is there to keep me on my toes
|
||||||
#
|
#
|
||||||
|
|
||||||
CFLAGS="$CFLAGS -Wall"
|
# Some day...
|
||||||
|
CXXFLAGS="$CXXFLAGS -Wall"
|
||||||
|
|
||||||
|
#
|
||||||
|
# This is needed in order to get the really cool backtraces
|
||||||
|
#
|
||||||
|
|
||||||
|
LDFLAGS_FISH="$LDFLAGS_FISH -rdynamic"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -262,9 +305,9 @@ AC_RUN_IFELSE(
|
|||||||
return STATUS;
|
return STATUS;
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
[glibc=yes],
|
[glibc=yes],
|
||||||
[glibc=no]
|
[glibc=no]
|
||||||
)
|
)
|
||||||
|
|
||||||
if test "$glibc" = yes; then
|
if test "$glibc" = yes; then
|
||||||
@@ -297,7 +340,7 @@ fi
|
|||||||
AC_CANONICAL_TARGET
|
AC_CANONICAL_TARGET
|
||||||
|
|
||||||
if test $target_cpu = powerpc; then
|
if test $target_cpu = powerpc; then
|
||||||
AC_DEFINE([TPUTS_KLUDGE],[1],[Evil kludge to get Power based machines to work])
|
AC_DEFINE([TPUTS_KLUDGE],[1],[Evil kludge to get Power based machines to work])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
@@ -307,7 +350,7 @@ fi
|
|||||||
|
|
||||||
AC_MSG_CHECKING([if we are under Solaris])
|
AC_MSG_CHECKING([if we are under Solaris])
|
||||||
case $target_os in
|
case $target_os in
|
||||||
solaris*)
|
solaris*)
|
||||||
AC_DEFINE( __EXTENSIONS__, 1, [Macro to enable additional prototypes under Solaris])
|
AC_DEFINE( __EXTENSIONS__, 1, [Macro to enable additional prototypes under Solaris])
|
||||||
AC_MSG_RESULT(yes)
|
AC_MSG_RESULT(yes)
|
||||||
;;
|
;;
|
||||||
@@ -316,6 +359,34 @@ case $target_os in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
# Check for Solaris curses tputs having fixed length parameter list.
|
||||||
|
AC_MSG_CHECKING([if we are using non varargs tparm.])
|
||||||
|
AC_COMPILE_IFELSE(
|
||||||
|
[
|
||||||
|
AC_LANG_PROGRAM(
|
||||||
|
[
|
||||||
|
#include <curses.h>
|
||||||
|
#include <term.h>
|
||||||
|
],
|
||||||
|
[
|
||||||
|
tparm( "" );
|
||||||
|
]
|
||||||
|
)
|
||||||
|
],
|
||||||
|
[tparm_solaris_kludge=no],
|
||||||
|
[tparm_solaris_kludge=yes]
|
||||||
|
)
|
||||||
|
if test "x$tparm_solaris_kludge" = "xyes"; then
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
AC_DEFINE(
|
||||||
|
[TPARM_SOLARIS_KLUDGE],
|
||||||
|
[1],
|
||||||
|
[Define to 1 if tparm accepts a fixed amount of paramters.]
|
||||||
|
)
|
||||||
|
else
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# BSD-specific flags go here
|
# BSD-specific flags go here
|
||||||
@@ -323,7 +394,7 @@ esac
|
|||||||
|
|
||||||
AC_MSG_CHECKING([if we are under BSD])
|
AC_MSG_CHECKING([if we are under BSD])
|
||||||
case $target_os in
|
case $target_os in
|
||||||
*bsd*)
|
*bsd*)
|
||||||
AC_DEFINE( __BSD_VISIBLE, 1, [Macro to enable additional prototypes under BSD])
|
AC_DEFINE( __BSD_VISIBLE, 1, [Macro to enable additional prototypes under BSD])
|
||||||
AC_DEFINE( _NETBSD_SOURCE, 1, [Macro to enable additional prototypes under BSD])
|
AC_DEFINE( _NETBSD_SOURCE, 1, [Macro to enable additional prototypes under BSD])
|
||||||
AC_MSG_RESULT(yes)
|
AC_MSG_RESULT(yes)
|
||||||
@@ -342,10 +413,7 @@ esac
|
|||||||
#
|
#
|
||||||
|
|
||||||
if [[ "$prefix" = NONE ]]; then
|
if [[ "$prefix" = NONE ]]; then
|
||||||
export prefix=/usr/local
|
prefix=/usr/local
|
||||||
AC_SUBST( prefix, /usr/local)
|
|
||||||
else
|
|
||||||
AC_SUBST( prefix, [$prefix])
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
@@ -357,9 +425,9 @@ fi
|
|||||||
AC_ARG_VAR( [docdir], [Documentation direcotry] )
|
AC_ARG_VAR( [docdir], [Documentation direcotry] )
|
||||||
|
|
||||||
if test -z $docdir; then
|
if test -z $docdir; then
|
||||||
AC_SUBST(docdir, [$datadir/doc/fish] )
|
docdir=$datadir/doc/fish
|
||||||
else
|
else
|
||||||
AC_SUBST(docdir, [$docdir])
|
docdir=$docdir
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
@@ -368,7 +436,7 @@ fi
|
|||||||
# installed.
|
# installed.
|
||||||
#
|
#
|
||||||
|
|
||||||
AC_SUBST( [localedir], [$datadir/locale])
|
localedir=$datadir/locale
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -385,38 +453,126 @@ AC_CHECK_FILES([/proc/self/stat])
|
|||||||
#
|
#
|
||||||
|
|
||||||
AC_DEFINE(
|
AC_DEFINE(
|
||||||
[HAVE_TRANSLATE_H],
|
[HAVE_TRANSLATE_H],
|
||||||
[1],
|
[1],
|
||||||
[Define to 1 if the wgettext function should be used for translating strings.]
|
[Define to 1 if the wgettext function should be used for translating strings.]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Check presense of various libraries
|
# Check presense of various libraries. This is done on a per-binary
|
||||||
|
# level, since including various extra libraries in all binaries only
|
||||||
|
# because thay are used by some of them can cause extra bloat and
|
||||||
|
# slower compiles when developing fish.
|
||||||
#
|
#
|
||||||
|
|
||||||
AC_SEARCH_LIBS( gettext, intl,,)
|
# Check for os dependant libraries for all binaries.
|
||||||
|
LIBS_COMMON=$LIBS
|
||||||
|
LIBS=""
|
||||||
AC_SEARCH_LIBS( connect, socket, , [AC_MSG_ERROR([Cannot find the socket library, needed to build this package.] )] )
|
AC_SEARCH_LIBS( connect, socket, , [AC_MSG_ERROR([Cannot find the socket library, needed to build this package.] )] )
|
||||||
AC_SEARCH_LIBS( nanosleep, rt, , [AC_MSG_ERROR([Cannot find the rt library, needed to build this package.] )] )
|
AC_SEARCH_LIBS( nanosleep, rt, , [AC_MSG_ERROR([Cannot find the rt library, needed to build this package.] )] )
|
||||||
|
AC_SEARCH_LIBS( pthread_create, pthread, , [AC_MSG_ERROR([Cannot find the pthread library, needed to build this package.] )] )
|
||||||
AC_SEARCH_LIBS( setupterm, [ncurses curses], , [AC_MSG_ERROR([Could not find a curses implementation, needed to build fish])] )
|
AC_SEARCH_LIBS( setupterm, [ncurses curses], , [AC_MSG_ERROR([Could not find a curses implementation, needed to build fish])] )
|
||||||
|
AC_SEARCH_LIBS( [nan], [m], [AC_DEFINE( [HAVE_NAN], [1], [Define to 1 if you have the nan function])] )
|
||||||
|
LIBS_SHARED=$LIBS
|
||||||
|
LIBS=$LIBS_COMMON
|
||||||
|
|
||||||
|
#
|
||||||
|
# Check for libraries needed by fish.
|
||||||
|
#
|
||||||
|
|
||||||
|
LIBS_COMMON=$LIBS
|
||||||
|
LIBS="$LIBS_SHARED"
|
||||||
|
if test x$local_gettext != xno; then
|
||||||
|
AC_SEARCH_LIBS( gettext, intl,,)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check for libiconv_open if we can't find iconv_open. Silly OS X does
|
||||||
|
# weird macro magic for the sole purpose of amusing me.
|
||||||
|
AC_SEARCH_LIBS( iconv_open, iconv, , [AC_SEARCH_LIBS( libiconv_open, iconv, , [AC_MSG_ERROR([Could not find an iconv implementation, needed to build fish])] )] )
|
||||||
|
|
||||||
|
LIBS_FISH=$LIBS
|
||||||
|
LIBS=$LIBS_COMMON
|
||||||
|
|
||||||
|
#
|
||||||
|
# Check for libraries needed by fish_indent.
|
||||||
|
#
|
||||||
|
|
||||||
|
LIBS_COMMON=$LIBS
|
||||||
|
LIBS="$LIBS_SHARED"
|
||||||
|
if test x$local_gettext != xno; then
|
||||||
|
AC_SEARCH_LIBS( gettext, intl,,)
|
||||||
|
fi
|
||||||
|
LIBS_FISH_INDENT=$LIBS
|
||||||
|
LIBS=$LIBS_COMMON
|
||||||
|
|
||||||
|
#
|
||||||
|
# Check for libraries needed by fish_pager.
|
||||||
|
#
|
||||||
|
|
||||||
|
LIBS_COMMON=$LIBS
|
||||||
|
LIBS="$LIBS_SHARED"
|
||||||
|
if test x$local_gettext != xno; then
|
||||||
|
AC_SEARCH_LIBS( gettext, intl,,)
|
||||||
|
fi
|
||||||
|
AC_SEARCH_LIBS( iconv_open, iconv, , [AC_SEARCH_LIBS( libiconv_open, iconv, , [AC_MSG_ERROR([Could not find an iconv implementation, needed to build fish])] )] )
|
||||||
|
LIBS_FISH_PAGER=$LIBS
|
||||||
|
LIBS=$LIBS_COMMON
|
||||||
|
|
||||||
|
#
|
||||||
|
# Check for libraries needed by fishd.
|
||||||
|
#
|
||||||
|
|
||||||
|
LIBS_COMMON=$LIBS
|
||||||
|
LIBS="$LIBS_SHARED"
|
||||||
|
if test x$local_gettext != xno; then
|
||||||
|
AC_SEARCH_LIBS( gettext, intl,,)
|
||||||
|
fi
|
||||||
|
AC_SEARCH_LIBS( iconv_open, iconv, , [AC_SEARCH_LIBS( libiconv_open, iconv, , [AC_MSG_ERROR([Could not find an iconv implementation, needed to build fish])] )] )
|
||||||
|
LIBS_FISHD=$LIBS
|
||||||
|
LIBS=$LIBS_COMMON
|
||||||
|
|
||||||
|
#
|
||||||
|
# Check for libraries needed by mimedb.
|
||||||
|
#
|
||||||
|
|
||||||
|
LIBS_COMMON=$LIBS
|
||||||
|
LIBS="$LIBS_SHARED"
|
||||||
|
if test x$local_gettext != xno; then
|
||||||
|
AC_SEARCH_LIBS( gettext, intl,,)
|
||||||
|
fi
|
||||||
|
LIBS_MIMEDB=$LIBS
|
||||||
|
LIBS=$LIBS_COMMON
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Check for libraries needed by set_color
|
||||||
|
#
|
||||||
|
|
||||||
|
LIBS_COMMON=$LIBS
|
||||||
|
LIBS="$LIBS_SHARED"
|
||||||
|
if test x$local_gettext != xno; then
|
||||||
|
AC_SEARCH_LIBS( gettext, intl,,)
|
||||||
|
fi
|
||||||
|
LIBS_SET_COLOR=$LIBS
|
||||||
|
LIBS=$LIBS_COMMON
|
||||||
|
|
||||||
#
|
#
|
||||||
# Check presense of various header files
|
# Check presense of various header files
|
||||||
#
|
#
|
||||||
|
|
||||||
AC_CHECK_HEADERS([getopt.h termio.h sys/resource.h term.h ncurses/term.h libintl.h ncurses.h curses.h stropts.h siginfo.h sys/select.h sys/ioctl.h sys/termios.h])
|
AC_CHECK_HEADERS([getopt.h termio.h sys/resource.h term.h ncurses/term.h ncurses.h curses.h stropts.h siginfo.h sys/select.h sys/ioctl.h sys/termios.h libintl.h execinfo.h spawn.h])
|
||||||
|
|
||||||
AC_CHECK_HEADER(
|
AC_CHECK_HEADER(
|
||||||
[regex.h],
|
[regex.h],
|
||||||
[
|
[
|
||||||
AC_DEFINE(
|
AC_DEFINE(
|
||||||
[HAVE_REGEX_H],
|
[HAVE_REGEX_H],
|
||||||
[1],
|
[1],
|
||||||
[Define to 1 if you have the <regex.h> header file.]
|
[Define to 1 if you have the <regex.h> header file.]
|
||||||
)],
|
)
|
||||||
[AC_MSG_ERROR([Could not find the header regex.h, needed to build fish])
|
],
|
||||||
]
|
[AC_MSG_ERROR([Could not find the header regex.h, needed to build fish])]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -424,7 +580,7 @@ AC_CHECK_HEADER(
|
|||||||
# On some platforms (Solaris 10) adding -std=c99 in turn requires that
|
# On some platforms (Solaris 10) adding -std=c99 in turn requires that
|
||||||
# _POSIX_C_SOURCE be defined to 200112L otherwise several
|
# _POSIX_C_SOURCE be defined to 200112L otherwise several
|
||||||
# POSIX-specific, non-ISO-C99 types/prototypes are made unavailable
|
# POSIX-specific, non-ISO-C99 types/prototypes are made unavailable
|
||||||
# e.g. siginfo_t. Defining _XOPEN_SOURCE to 600 is compatible with
|
# e.g. siginfo_t. Defining _XOPEN_SOURCE to 600 is compatible with
|
||||||
# the _POSIX_C_SOURCE value and provides a little assurance that
|
# the _POSIX_C_SOURCE value and provides a little assurance that
|
||||||
# extension functions' prototypes are available, e.g. killpg().
|
# extension functions' prototypes are available, e.g. killpg().
|
||||||
#
|
#
|
||||||
@@ -449,7 +605,7 @@ AC_CHECK_HEADER(
|
|||||||
# conditional definition of __EXTENSIONS__, to avoid redundant tests.
|
# conditional definition of __EXTENSIONS__, to avoid redundant tests.
|
||||||
#
|
#
|
||||||
|
|
||||||
XCFLAGS="$CFLAGS"
|
XCFLAGS="$CXXFLAGS"
|
||||||
|
|
||||||
echo Checking how to use -D_XOPEN_SOURCE=600 and -D_POSIX_C_SOURCE=200112L...
|
echo Checking how to use -D_XOPEN_SOURCE=600 and -D_POSIX_C_SOURCE=200112L...
|
||||||
local_found_posix_switch=no
|
local_found_posix_switch=no
|
||||||
@@ -499,20 +655,20 @@ for i in "" "-D_POSIX_C_SOURCE=200112L" "-D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=2
|
|||||||
[
|
[
|
||||||
/* Avert high-level optimisation, by making the program's
|
/* Avert high-level optimisation, by making the program's
|
||||||
* return value depend on all tested identifiers. */
|
* return value depend on all tested identifiers. */
|
||||||
int ret = 0;
|
long ret = 0;
|
||||||
/* POSIX only: might be unhidden by _POSIX_C_SOURCE. */
|
/* POSIX only: might be unhidden by _POSIX_C_SOURCE. */
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
sigset_t ss;
|
sigset_t ss;
|
||||||
siginfo_t info;
|
siginfo_t info;
|
||||||
ret += (int)(void *)&info + kill( 0, 0 ) +
|
ret += (long)(void *)&info + kill( 0, 0 ) +
|
||||||
sigaction( 0, &sa, 0 ) + sigemptyset( &ss );
|
sigaction( 0, &sa, 0 ) + sigemptyset( &ss );
|
||||||
/* Extended-POSIX: might be unhidden by _XOPEN_SOURCE. */
|
/* Extended-POSIX: might be unhidden by _XOPEN_SOURCE. */
|
||||||
ret += killpg( 0, 0 );
|
ret += killpg( 0, 0 );
|
||||||
/* Non-standard: might be hidden by the macros. */
|
/* Non-standard: might be hidden by the macros. */
|
||||||
{
|
{
|
||||||
struct winsize termsize;
|
struct winsize termsize;
|
||||||
ret += (int)(void *)&termsize;
|
ret += (long)(void *)&termsize;
|
||||||
ret += SIGWINCH + TIOCGWINSZ + SIGIO;
|
ret += SIGWINCH + TIOCGWINSZ + SIGIO;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
@@ -546,17 +702,19 @@ fi
|
|||||||
# Check for presense of various functions used by fish
|
# Check for presense of various functions used by fish
|
||||||
#
|
#
|
||||||
|
|
||||||
AC_CHECK_FUNCS( gettext wcsdup wcsndup wcslen wcscasecmp wcsncasecmp fwprintf )
|
AC_CHECK_FUNCS( wcsdup wcsndup wcslen wcscasecmp wcsncasecmp fwprintf )
|
||||||
AC_CHECK_FUNCS( futimes wcwidth wcswidth wcstok fputwc fgetwc )
|
AC_CHECK_FUNCS( futimes wcwidth wcswidth wcstok fputwc fgetwc )
|
||||||
AC_CHECK_FUNCS( wcstol dcgettext wcslcat wcslcpy lrand48_r killpg)
|
AC_CHECK_FUNCS( wcstol wcslcat wcslcpy lrand48_r killpg gettext )
|
||||||
|
AC_CHECK_FUNCS( dcgettext backtrace backtrace_symbols sysconf )
|
||||||
|
|
||||||
#
|
#
|
||||||
# The Makefile also needs to know if we have gettext, so it knows if
|
# The Makefile also needs to know if we have gettext, so it knows if
|
||||||
# the translations should be installed.
|
# the translations should be installed.
|
||||||
#
|
#
|
||||||
|
|
||||||
AC_CHECK_FUNC( gettext, AC_SUBST( HAVE_GETTEXT, 1 ), AC_SUBST( HAVE_GETTEXT, 0 ) )
|
if test x$local_gettext != xno; then
|
||||||
|
AC_CHECK_FUNC( gettext, HAVE_GETTEXT=1, HAVE_GETTEXT=0 )
|
||||||
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
# Here follows a list of small programs used to test for various
|
# Here follows a list of small programs used to test for various
|
||||||
@@ -578,22 +736,22 @@ AC_RUN_IFELSE(
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
int status;
|
int status;
|
||||||
char *res;
|
char *res;
|
||||||
res = realpath( "somefile", 0 );
|
res = realpath( "somefile", 0 );
|
||||||
status = !(res != 0 || errno == ENOENT);
|
status = !(res != 0 || errno == ENOENT);
|
||||||
exit( status );
|
exit( status );
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
[have_realpath_null=yes],
|
[have_realpath_null=yes],
|
||||||
[have_realpath_null=no]
|
[have_realpath_null=no]
|
||||||
)
|
)
|
||||||
|
|
||||||
if test "$have_realpath_null" = yes; then
|
if test "$have_realpath_null" = yes; then
|
||||||
AC_MSG_RESULT(yes)
|
AC_MSG_RESULT(yes)
|
||||||
AC_DEFINE(
|
AC_DEFINE(
|
||||||
[HAVE_REALPATH_NULL],
|
[HAVE_REALPATH_NULL],
|
||||||
[1],
|
[1],
|
||||||
[Define to 1 if realpath accepts null for its second argument.]
|
[Define to 1 if realpath accepts null for its second argument.]
|
||||||
)
|
)
|
||||||
@@ -620,15 +778,15 @@ AC_LINK_IFELSE(
|
|||||||
#endif
|
#endif
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
struct winsize termsize = {0};
|
struct winsize termsize = {0};
|
||||||
TIOCGWINSZ;
|
TIOCGWINSZ;
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
AC_MSG_RESULT(yes);
|
AC_MSG_RESULT(yes);
|
||||||
AC_DEFINE([HAVE_WINSIZE], [1], [Define to 1 if the winsize struct and TIOCGWINSZ macro exist])
|
AC_DEFINE([HAVE_WINSIZE], [1], [Define to 1 if the winsize struct and TIOCGWINSZ macro exist])
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
AC_MSG_RESULT(no)
|
AC_MSG_RESULT(no)
|
||||||
]
|
]
|
||||||
@@ -658,13 +816,13 @@ if test "$ac_cv_func_fwprintf" = yes; then
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
AC_MSG_RESULT(no)
|
AC_MSG_RESULT(no)
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
AC_MSG_RESULT([yes])
|
AC_MSG_RESULT([yes])
|
||||||
AC_DEFINE([HAVE_BROKEN_FWPRINTF], [1], [Define to 1 one if the implemented fwprintf is broken])
|
AC_DEFINE([HAVE_BROKEN_FWPRINTF], [1], [Define to 1 one if the implemented fwprintf is broken])
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
fi
|
fi
|
||||||
@@ -680,21 +838,46 @@ AC_TRY_LINK(
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
extern int _nl_msg_cat_cntr;
|
extern int _nl_msg_cat_cntr;
|
||||||
int tmp = _nl_msg_cat_cntr;
|
int tmp = _nl_msg_cat_cntr;
|
||||||
exit(tmp);
|
exit(tmp);
|
||||||
],
|
],
|
||||||
have__nl_msg_cat_cntr=yes,
|
have__nl_msg_cat_cntr=yes,
|
||||||
have__nl_msg_cat_cntr=no
|
have__nl_msg_cat_cntr=no
|
||||||
)
|
)
|
||||||
if test "$have__nl_msg_cat_cntr" = yes; then
|
if test "$have__nl_msg_cat_cntr" = yes; then
|
||||||
AC_MSG_RESULT(yes)
|
AC_MSG_RESULT(yes)
|
||||||
AC_DEFINE(
|
AC_DEFINE(
|
||||||
[HAVE__NL_MSG_CAT_CNTR],
|
[HAVE__NL_MSG_CAT_CNTR],
|
||||||
[1],
|
[1],
|
||||||
[Define to 1 if the _nl_msg_cat_cntr symbol is exported.]
|
[Define to 1 if the _nl_msg_cat_cntr symbol is exported.]
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
AC_MSG_RESULT(no)
|
AC_MSG_RESULT(no)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check for __environ symbol
|
||||||
|
AC_MSG_CHECKING([for __environ symbol])
|
||||||
|
AC_TRY_LINK(
|
||||||
|
[
|
||||||
|
#include <unistd.h>
|
||||||
|
],
|
||||||
|
[
|
||||||
|
extern char **__environ;
|
||||||
|
char **tmp = __environ;
|
||||||
|
exit(tmp!=0);
|
||||||
|
],
|
||||||
|
have___environ=yes,
|
||||||
|
have___environ=no
|
||||||
|
)
|
||||||
|
if test "$have___environ" = yes; then
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
AC_DEFINE(
|
||||||
|
[HAVE___ENVIRON],
|
||||||
|
[1],
|
||||||
|
[Define to 1 if the __environ symbol is exported.]
|
||||||
|
)
|
||||||
|
else
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if getopt_long exists and works
|
# Check if getopt_long exists and works
|
||||||
@@ -709,28 +892,28 @@ AC_TRY_LINK(
|
|||||||
static struct option
|
static struct option
|
||||||
long_options[] =
|
long_options[] =
|
||||||
{
|
{
|
||||||
0, 0, 0, 0
|
0, 0, 0, 0
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
int opt = getopt_long( 0,
|
int opt = getopt_long( 0,
|
||||||
0,
|
|
||||||
0,
|
0,
|
||||||
long_options,
|
0,
|
||||||
|
long_options,
|
||||||
0 );
|
0 );
|
||||||
|
|
||||||
],
|
],
|
||||||
have_working_getopt_long=yes,
|
have_working_getopt_long=yes,
|
||||||
have_working_getopt_long=no
|
have_working_getopt_long=no
|
||||||
)
|
)
|
||||||
if test "$have_working_getopt_long" = yes; then
|
if test "$have_working_getopt_long" = yes; then
|
||||||
AC_MSG_RESULT(yes)
|
AC_MSG_RESULT(yes)
|
||||||
AC_DEFINE(
|
AC_DEFINE(
|
||||||
[HAVE_WORKING_GETOPT_LONG],
|
[HAVE_WORKING_GETOPT_LONG],
|
||||||
[1],
|
[1],
|
||||||
[Define to 1 if getopt_long exists and works.]
|
[Define to 1 if getopt_long exists and works.]
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
AC_MSG_RESULT(no)
|
AC_MSG_RESULT(no)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if del_curterm is broken - in that case we redefine
|
# Check if del_curterm is broken - in that case we redefine
|
||||||
@@ -752,7 +935,7 @@ case $target_os in
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
# Tell the world what we know
|
# Tell the world what we know
|
||||||
AC_CONFIG_FILES([Makefile fish.spec doc_src/Doxyfile seq])
|
AC_CONFIG_FILES([Makefile fish.spec Doxyfile.help seq])
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
|
||||||
if test ! x$local_found_posix_switch = xyes; then
|
if test ! x$local_found_posix_switch = xyes; then
|
||||||
@@ -760,6 +943,12 @@ if test ! x$local_found_posix_switch = xyes; then
|
|||||||
echo "Some fish features may be disabled."
|
echo "Some fish features may be disabled."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ "$xsel" = "with_xsel" ]]; then
|
||||||
|
echo "Now configure xsel with $conf_arg"
|
||||||
|
rm -rf $XSEL
|
||||||
|
tar xf $XSEL.tar.gz
|
||||||
|
cd $XSEL && ./configure $conf_arg
|
||||||
|
fi
|
||||||
echo "fish is now configured."
|
echo "fish is now configured."
|
||||||
echo "Use 'make' and 'make install' to build and install fish."
|
echo "Use 'make' and 'make install' to build and install fish."
|
||||||
|
|
||||||
|
|||||||
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.
|
||||||
@@ -10,10 +10,14 @@ status (as set by the last previous command) is 0.
|
|||||||
|
|
||||||
The and command does not change the current exit status.
|
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
|
\subsection and-example Example
|
||||||
|
|
||||||
The following code runs the \c make command to build a program, if the
|
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
|
<tt>make clean</tt> is run, which removes the files created by the
|
||||||
build process
|
build process
|
||||||
|
|
||||||
|
|||||||
@@ -23,11 +23,11 @@ scope, they will be automatically deleted when the block ends.
|
|||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
begin
|
begin
|
||||||
set -x PIRATE Yarrr
|
set -l PIRATE Yarrr
|
||||||
...
|
...
|
||||||
end
|
end
|
||||||
# This will not output anything, since PIRATE went out of scope at the end of
|
# This will not output anything, since the PIRATE variable went out
|
||||||
# the block and was killed
|
# of scope at the end of the block
|
||||||
echo $PIRATE
|
echo $PIRATE
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ In the following code, all output is redirected to the file out.html.
|
|||||||
begin
|
begin
|
||||||
echo $xml_header
|
echo $xml_header
|
||||||
echo $html_header
|
echo $html_header
|
||||||
if test -e $file
|
if test -e $file
|
||||||
...
|
...
|
||||||
end
|
end
|
||||||
...
|
...
|
||||||
|
|||||||
@@ -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
|
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.
|
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
|
\subsection bg-example Example
|
||||||
|
|
||||||
|
|||||||
@@ -1,23 +1,63 @@
|
|||||||
\section bind bind - handle key bindings
|
\section bind bind - handle fish key bindings
|
||||||
|
|
||||||
\subsection bind-synopsis Synopsis
|
\subsection bind-synopsis Synopsis
|
||||||
<tt>bind [OPTIONS] [BINDINGS...]</tt>
|
<tt>bind [OPTIONS] SEQUENCE COMMAND</tt>
|
||||||
|
|
||||||
The <tt>bind</tt> builtin causes fish to add the readline style bindings specified by BINDINGS to the list of key bindings, as if they appeared in your <tt>~/.fish_inputrc</tt> file.
|
|
||||||
|
|
||||||
For more information on the syntax keyboard bindings, use <tt>man
|
|
||||||
readline</tt> to access the readline documentation. The availiable commands
|
|
||||||
are listed in the <a href="index.html#editor">Command Line Editor</a> section
|
|
||||||
of the fish manual - but you may also use any fish command! To write such
|
|
||||||
commands, see the <a href="#commandline">commandline</a> builtin. It's good
|
|
||||||
practice to put the code into a <tt><a href="#function">function</a> -b</tt>
|
|
||||||
and bind to the function name.
|
|
||||||
|
|
||||||
\subsection bind-description Description
|
\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.
|
||||||
|
|
||||||
|
If you want to autoload bindings each time you start shell, you should
|
||||||
|
define them inside fish_user_key_bindings function.
|
||||||
|
|
||||||
|
- <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
|
\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
|
|
||||||
|
|||||||
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.
|
||||||
|
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
- <tt>-n</tt> or <tt>--names</tt> List the names of all defined builtins
|
- <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
|
\subsection builtin-example Example
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ regular wildcard expansion using filenames.
|
|||||||
|
|
||||||
Note that fish does not fall through on case statements. Though the
|
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
|
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
|
Also note that command substitutions in a case statement will be
|
||||||
evaluated even if it's body is not taken. This may seem
|
evaluated even if it's body is not taken. This may seem
|
||||||
|
|||||||
@@ -4,11 +4,11 @@
|
|||||||
<tt>command COMMANDNAME [OPTIONS...]</tt>
|
<tt>command COMMANDNAME [OPTIONS...]</tt>
|
||||||
|
|
||||||
\subsection command-description Description
|
\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
|
\subsection command-example Example
|
||||||
|
|
||||||
|
|
||||||
<tt>command ls</tt>
|
<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.
|
||||||
|
|||||||
@@ -7,20 +7,22 @@
|
|||||||
|
|
||||||
|
|
||||||
- \c CMD is the new value of the commandline. If unspecified, the
|
- \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
|
The following switches change what the commandline builtin does
|
||||||
|
|
||||||
- \c -C or \c --cursor set or get the current cursor position, not
|
- \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
|
the contents of the buffer. If no argument is given, the current
|
||||||
cursor position is printed, otherwise the argument is interpreted
|
cursor position is printed, otherwise the argument is interpreted
|
||||||
as the new cursor position.
|
as the new cursor position.
|
||||||
- \c -f or \c --function inject readline functions into the
|
- \c -f or \c --function inject readline functions into the
|
||||||
reader. This option can not be combined with any other option. It
|
reader. This option can not be combined with any other option. It
|
||||||
will cause any additional arguments to be interpreted as readline
|
will cause any additional arguments to be interpreted as readline
|
||||||
functions, and these functions will be injected into the reader, so
|
functions, and these functions will be injected into the reader, so
|
||||||
that they will be returned to the reader before any additional
|
that they will be returned to the reader before any additional
|
||||||
actual keypresses are read.
|
actual key presses are read.
|
||||||
|
|
||||||
|
|
||||||
The following switches change the way \c commandline updates the
|
The following switches change the way \c commandline updates the
|
||||||
@@ -39,10 +41,10 @@ or updated
|
|||||||
- \c -b or \c --current-buffer select the entire buffer (default)
|
- \c -b or \c --current-buffer select the entire buffer (default)
|
||||||
- \c -j or \c --current-job select the current job
|
- \c -j or \c --current-job select the current job
|
||||||
- \c -p or \c --current-process select the current process
|
- \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
|
The following switch changes the way \c commandline prints the current
|
||||||
commandline buffer
|
commandline buffer
|
||||||
|
|
||||||
- \c -c or \c --cut-at-cursor only print selection up until the
|
- \c -c or \c --cut-at-cursor only print selection up until the
|
||||||
current cursor position
|
current cursor position
|
||||||
|
|||||||
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@
|
||||||
|
|
||||||
|
*/
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
\subsection complete-description Description
|
\subsection complete-description Description
|
||||||
|
|
||||||
For an introduction to how to specify completions, see the section <a
|
For an introduction to how to specify completions, see the section <a
|
||||||
href='index.html#completions-own'>Writing your own completions</a> of
|
href='index.html#completion-own'>Writing your own completions</a> of
|
||||||
the fish manual.
|
the fish manual.
|
||||||
|
|
||||||
- <tt>COMMAND</tt> is the name of the command for which to add a completion
|
- <tt>COMMAND</tt> is the name of the command for which to add a completion
|
||||||
@@ -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>-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>-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>-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>
|
- <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
|
Command specific tab-completions in \c fish are based on the notion
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
\subsection contains-description Description
|
\subsection contains-description Description
|
||||||
|
|
||||||
|
- \c -i or \c --index print the the word index
|
||||||
- \c -h or \c --help display this message
|
- \c -h or \c --help display this message
|
||||||
|
|
||||||
Test if the set VALUES contains the string KEY. Return status is 0 if
|
Test if the set VALUES contains the string KEY. Return status is 0 if
|
||||||
|
|||||||
@@ -5,17 +5,18 @@
|
|||||||
|
|
||||||
\subsection count-description Description
|
\subsection count-description Description
|
||||||
|
|
||||||
<tt>count</tt> prints the number of arguments that were passed to
|
The <tt>count</tt> builtin prints the number of arguments that were
|
||||||
it. This is usually used to find out how many elements an environment
|
passed to it. This is usually used to find out how many elements an
|
||||||
variable array contains, but this is not the only potential usage for
|
environment variable array contains, but this is not the only
|
||||||
the count command.
|
potential usage for the count command.
|
||||||
|
|
||||||
The count command does not accept any options, not even '-h'. This way
|
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
|
the user does not have to worry about an array containing elements
|
||||||
such as dashes. \c fish performs a special check when invoking the
|
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
|
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
|
Count exits with a non-zero exit status if no arguments where passed
|
||||||
to it, with zero otherwise.
|
to it, with zero otherwise.
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ design fish. The fish design has three high level goals. These are:
|
|||||||
|
|
||||||
-# Everything that can be done in other shell languages should be
|
-# Everything that can be done in other shell languages should be
|
||||||
possible to do in fish, though fish may rely on external commands in
|
possible to do in fish, though fish may rely on external commands in
|
||||||
doing so.
|
doing so.
|
||||||
-# Fish should be user friendly, but not at the expense of expressiveness.
|
-# 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.
|
Most tradeoffs between power and ease of use can be avoided with careful design.
|
||||||
-# Whenever possible without breaking the above goals, fish should
|
-# Whenever possible without breaking the above goals, fish should
|
||||||
follow the Posix syntax.
|
follow the Posix syntax.
|
||||||
@@ -33,7 +33,7 @@ program harder to maintain and update.
|
|||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
- Here documents are too similar to using echo inside of a pipeline.
|
- 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.
|
- 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.
|
- 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 \$''.
|
- The many Posix quoting styles are silly, especially \$''.
|
||||||
|
|
||||||
@@ -57,14 +57,14 @@ take the whole system down.
|
|||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
- Builtin commands should only be created when it cannot be
|
- Builtin commands should only be created when it cannot be
|
||||||
avoided. \c echo, \c kill, \c printf and \c time are among the commands
|
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
|
that fish does not implement internally since they can be provided as
|
||||||
external commands. Several other commands that are commonly implemented
|
external commands. Several other commands that are commonly implemented
|
||||||
as builtins and can not be implemented as external commands,
|
as builtins and can not be implemented as external commands,
|
||||||
including \c type, \c vared, \c pushd and \c popd are implemented as shellscript
|
including \c type, \c vared, \c pushd and \c popd are implemented as shellscript
|
||||||
functions in fish.
|
functions in fish.
|
||||||
- Mathematical calculations, regex matching, generating lists of numbers
|
- Mathematical calculations, regex matching, generating lists of numbers
|
||||||
and many other funtions can easily be done in external programs. They
|
and many other funtions can easily be done in external programs. They
|
||||||
should not be supported internally by the shell.
|
should not be supported internally by the shell.
|
||||||
|
|
||||||
The law of minimalism does not imply that a large feature set is
|
The law of minimalism does not imply that a large feature set is
|
||||||
@@ -122,8 +122,8 @@ 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.
|
- 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.
|
- 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
|
- 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
|
- All blocks end with the \c end builtin.
|
||||||
|
|
||||||
\section disc The law of discoverability
|
\section disc The law of discoverability
|
||||||
|
|
||||||
@@ -147,7 +147,7 @@ until the next time she/he uses the same program.
|
|||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
- Everything should be tab-completable, and every tab completion should have a description
|
- 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.
|
- 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 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.
|
- 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.
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
\subsection dirh-synopsis Synopsis
|
\subsection dirh-synopsis Synopsis
|
||||||
<tt>dirh</tt>
|
<tt>dirh</tt>
|
||||||
|
|
||||||
\subsection dirh-description Description
|
\subsection dirh-description Description
|
||||||
<tt>dirh</tt> prints the current directory history. The current position in the
|
<tt>dirh</tt> prints the current directory history. The current position in the
|
||||||
history is highlighted using <tt>$fish_color_history_current</tt>.
|
history is highlighted using <tt>$fish_color_history_current</tt>.
|
||||||
|
|||||||
@@ -3,5 +3,5 @@
|
|||||||
\subsection dirs-synopsis Synopsis
|
\subsection dirs-synopsis Synopsis
|
||||||
<tt>dirs</tt>
|
<tt>dirs</tt>
|
||||||
|
|
||||||
\subsection dirs-description Description
|
\subsection dirs-description Description
|
||||||
<tt>dirs</tt> prints the current directory stack.
|
<tt>dirs</tt> prints the current directory stack.
|
||||||
|
|||||||
16
doc_src/echo.txt
Normal file
16
doc_src/echo.txt
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
\section echo echo - display a line of text
|
||||||
|
|
||||||
|
\subsection echo-synopsis Synopsis
|
||||||
|
<tt>echo [STRING]</tt>
|
||||||
|
|
||||||
|
\subsection echo-description Description
|
||||||
|
|
||||||
|
Display a line of text.
|
||||||
|
|
||||||
|
- \c -n, \c Do not output a newline
|
||||||
|
- \c -s, \c Do not separate arguments with spaces
|
||||||
|
- \c -h, \c --help Display this help
|
||||||
|
|
||||||
|
\subsection echo-example Example
|
||||||
|
|
||||||
|
<tt>echo 'Hello World'</tt> Print hello world to stdout
|
||||||
@@ -13,5 +13,5 @@ status is 0, the commands COMMANDS_TRUE will execute. If it is not 0 and
|
|||||||
|
|
||||||
The command <tt>if test -f foo.txt; echo foo.txt exists; else; echo foo.txt does not exist; end</tt>
|
The command <tt>if test -f foo.txt; echo foo.txt exists; else; echo foo.txt does not exist; end</tt>
|
||||||
will print <tt>foo.txt exists</tt> if the file foo.txt
|
will print <tt>foo.txt exists</tt> if the file foo.txt
|
||||||
exists and is a regular file, otherwise it will print
|
exists and is a regular file, otherwise it will print
|
||||||
<tt>foo.txt does not exist</tt>.
|
<tt>foo.txt does not exist</tt>.
|
||||||
|
|||||||
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,10 +1,10 @@
|
|||||||
\section eval eval - eval the specified commands
|
\section eval eval - evaluate the specified commands
|
||||||
|
|
||||||
\subsection eval-synopsis Synopsis
|
\subsection eval-synopsis Synopsis
|
||||||
<tt>eval [COMMANDS...]</tt>
|
<tt>eval [COMMANDS...]</tt>
|
||||||
|
|
||||||
\subsection eval-description Description
|
\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
|
\subsection eval-example Example
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
- <a href='#faq-default'>How do I make fish my default shell?</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-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-greeting'>How do I change the greeting message?</a>
|
||||||
|
- <a href='#faq-history'>Why doesn't history substitution ("!$" etc.) work?</a>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
@@ -32,7 +33,7 @@ parent is ~. This issue is not possible to fix without either making
|
|||||||
every single command into a builtin, breaking Unix semantics or
|
every single command into a builtin, breaking Unix semantics or
|
||||||
implementing kludges in every single command.
|
implementing kludges in every single command.
|
||||||
|
|
||||||
This issue can also be seen when doing IO redirection.
|
This issue can also be seen when doing IO redirection.
|
||||||
|
|
||||||
Another related issue is that many programs that operate on recursive
|
Another related issue is that many programs that operate on recursive
|
||||||
directory trees, like the find command, silently ignore symlinked
|
directory trees, like the find command, silently ignore symlinked
|
||||||
@@ -55,9 +56,9 @@ feature, write <code>set CDPATH .</code> on the commandline.
|
|||||||
|
|
||||||
If fish is unable to locate a command with a given name, fish will
|
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
|
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
|
assumed that you want to change working directory. For example, the
|
||||||
fastest way to switch to your home directory is to simply type
|
fastest way to switch to your home directory is to simply press
|
||||||
<code>~</code>.
|
<code>~</code> and enter.
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
@@ -71,6 +72,8 @@ in a nonstandard location. Please contact the <a
|
|||||||
href='mailto:fish-users@lists.sf.net'>fish mailing list</a>, and
|
href='mailto:fish-users@lists.sf.net'>fish mailing list</a>, and
|
||||||
hopefully this can be resolved.
|
hopefully this can be resolved.
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
\section faq-default How do I make fish my default shell?
|
\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
|
If you installed fish manually (e.g. by compiling it, not by using a
|
||||||
@@ -78,6 +81,23 @@ package manager), you first need to add fish to the list of shells by
|
|||||||
executing the following command (assuming you installed fish in
|
executing the following command (assuming you installed fish in
|
||||||
/usr/local) as root:
|
/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?
|
\section faq-titlebar I'm seeing weird output before each prompt when using screen. What's wrong?
|
||||||
|
|
||||||
Quick answer:
|
Quick answer:
|
||||||
@@ -85,7 +105,7 @@ Quick answer:
|
|||||||
Run the following command in fish:
|
Run the following command in fish:
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
echo function fish_title;end ~/.config/fish/config.fish
|
echo 'function fish_title;end' > ~/.config/fish/config.fish
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
Problem solved!
|
Problem solved!
|
||||||
@@ -106,21 +126,6 @@ Note that fish has a default titlebar message, which will be used if
|
|||||||
the fish_title function is undefined. So simply unsetting the
|
the fish_title function is undefined. So simply unsetting the
|
||||||
fish_title function will not work.
|
fish_title function will not work.
|
||||||
|
|
||||||
|
|
||||||
<code>echo /usr/local/bin/fish >>/etc/shells</code>
|
|
||||||
|
|
||||||
If you installed a prepackaged version of fish, the package manager
|
|
||||||
should have already done this for you.
|
|
||||||
|
|
||||||
In order to change your default shell, type:
|
|
||||||
|
|
||||||
<code>chsh -s /usr/bin/fish</code>
|
|
||||||
|
|
||||||
You may need to adjust the above path to e.g. /usr/local/bin/fish.
|
|
||||||
|
|
||||||
You will need to log out and back in again for the change to take
|
|
||||||
effect.
|
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
\section faq-greeting How do I change the greeting message?
|
\section faq-greeting How do I change the greeting message?
|
||||||
@@ -132,5 +137,25 @@ the greeting use:
|
|||||||
set fish_greeting
|
set fish_greeting
|
||||||
</pre>
|
</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
|
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.
|
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
|
\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@ )
|
|
||||||
@@ -5,7 +5,9 @@ fish [-h] [-v] [-c command] [FILE [ARGUMENTS...]]
|
|||||||
|
|
||||||
\subsection fish-description Description
|
\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.
|
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>-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>-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.
|
||||||
@@ -16,3 +18,6 @@ A commandline shell written mainly with interactive use in mind. The full manual
|
|||||||
- <code>-p</code> or <code>--profile=PROFILE_FILE</code> when fish exits, output timing information on all executed commands to the specified file
|
- <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
|
- <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.
|
||||||
|
|||||||
5
doc_src/fish_config.txt
Normal file
5
doc_src/fish_config.txt
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
\section fish_config fish_config - Start up the web-based configuration interface
|
||||||
|
|
||||||
|
\subsection fish_config-description Description
|
||||||
|
|
||||||
|
This command starts up the web-based configuration interface, which allows you to edit your colors and view your functions, variables, and history.
|
||||||
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 prettifier
|
||||||
|
|
||||||
|
\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
|
||||||
|
|
||||||
26
doc_src/fish_prompt.txt
Normal file
26
doc_src/fish_prompt.txt
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
\section fish_prompt fish_prompt - define the apperance of the command line prompt
|
||||||
|
|
||||||
|
\subsection fish_prompt-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.
|
||||||
|
|
||||||
|
Please keep in mind that the function is executed by <a
|
||||||
|
href='index.html#expand-command-substitution'>command substitution</a>, and so the exit status of commands within fish_prompt will not modify the <a href="index.html#variables-status">$status</a> seen outside of fish_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>
|
||||||
|
|
||||||
23
doc_src/fish_right_prompt.txt
Normal file
23
doc_src/fish_right_prompt.txt
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
\section fish_right_prompt fish_right_prompt - define the apperance of the right-side command line prompt
|
||||||
|
|
||||||
|
\subsection fish_right_prompt-synopsis Synopsis
|
||||||
|
<pre>function fish_right_prompt
|
||||||
|
...
|
||||||
|
end</pre>
|
||||||
|
|
||||||
|
\subsection fish_right_prompt-description Description
|
||||||
|
|
||||||
|
\c fish_right_prompt is similar to \c fish_prompt, except that it appears on the right side of the terminal window.
|
||||||
|
|
||||||
|
Multiple lines are not supported in \c fish_right_prompt.
|
||||||
|
|
||||||
|
\subsection fish_prompt-example Example
|
||||||
|
|
||||||
|
A simple right prompt:
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
function fish_right_prompt -d "Write out the right prompt"
|
||||||
|
date "+%m/%d/%y"
|
||||||
|
end
|
||||||
|
</pre>
|
||||||
|
|
||||||
6
doc_src/fish_update_completions.txt
Normal file
6
doc_src/fish_update_completions.txt
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
\section fish_update_completions fish_update_completions - Update man-page completions
|
||||||
|
|
||||||
|
\subsection fish_update_completions-description Description
|
||||||
|
|
||||||
|
This command parses your installed man pages and writes completion files to the fish config directory. This does not overwrite custom completions.
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ not be executed at all.
|
|||||||
|
|
||||||
\subsection for-example Example
|
\subsection for-example Example
|
||||||
|
|
||||||
The command
|
The command
|
||||||
|
|
||||||
<tt>for i in foo bar baz; echo $i; end</tt>
|
<tt>for i in foo bar baz; echo $i; end</tt>
|
||||||
|
|
||||||
@@ -21,5 +21,5 @@ would output:
|
|||||||
foo
|
foo
|
||||||
bar
|
bar
|
||||||
baz
|
baz
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
|||||||
14
doc_src/funced.txt
Normal file
14
doc_src/funced.txt
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
\section funced funced - edit a function interactively
|
||||||
|
|
||||||
|
\subsection funced-synopsis Synopsis
|
||||||
|
<code>funced [OPTIONS] NAME</code>
|
||||||
|
|
||||||
|
\subsection funced-description Description
|
||||||
|
|
||||||
|
Use the funced command to 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 definition will be shown in your editor or on the command line.
|
||||||
|
|
||||||
|
By default, funced edits functions using the text editor in your $EDITOR variable, if set; otherwise it uses the built-in editor.
|
||||||
|
|
||||||
|
- <code>-e command</code> or <code>--editor command</code> Open the function body inside the text editor given by the command (for example, "vi"). The command 'fish' will use the built-in editor.
|
||||||
|
- <code>-i</code> or <code>--interactive</code> Open function body in built-in editor.
|
||||||
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.
|
||||||
|
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
\subsection function-description Description
|
\subsection function-description Description
|
||||||
|
|
||||||
- <code>-d DESCRIPTION</code> or \c --description=DESCRIPTION is a description of what the function does, suitable as a completion description
|
- <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>-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>-p PID</code> or <code> --on-process-exit PID</code> tells fish to run this function when the fish child process with process id PID exits
|
||||||
- <code>-s</code> or <code>--on-signal SIGSPEC</code> tells fish to run this function when the signal SIGSPEC is delivered. SIGSPEC can be a signal number, or the signal name, such as SIGHUP (or just HUP)
|
- <code>-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)
|
||||||
@@ -26,6 +27,11 @@ will write <code>hello</code> whenever the user enters \c hi.
|
|||||||
If the user enters any additional arguments after the function, they
|
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.
|
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
|
\subsection function-example Example
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
This builtin command is used to print or erase functions.
|
This builtin command is used to print or erase functions.
|
||||||
|
|
||||||
- <code>-a</code> or <code>--all</code> list all functions, even those whose name start with an underscore.
|
- <code>-a</code> or <code>--all</code> list all functions, even those whose name start with an underscore.
|
||||||
|
- <code>-c OLDNAME NEWNAME</code> or <code>--copy OLDNAME NEWNAME</code> creates a new function named NEWNAME, using the definition of the OLDNAME function.
|
||||||
- <code>-d DESCRIPTION</code> or <code>--description=DESCRIPTION</code> change the description of this function
|
- <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>-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>-h</code> or <code>--help</code> display a help message and exit
|
||||||
@@ -17,11 +18,14 @@ This builtin command is used to print or erase functions.
|
|||||||
The default behavior of \c functions when called with no arguments,
|
The default behavior of \c functions when called with no arguments,
|
||||||
is to print the names and definitions of all defined functions. If any
|
is to print the names and definitions of all defined functions. If any
|
||||||
non-switch parameters are given, only the definition of the specified
|
non-switch parameters are given, only the definition of the specified
|
||||||
functions are printed.
|
functions are printed.
|
||||||
|
|
||||||
Automatically loaded functions can not be removed using functions
|
Automatically loaded functions can not be removed using functions
|
||||||
-e. Either remove the definition file or change the
|
-e. Either remove the definition file or change the
|
||||||
$fish_function_path variable to remove autoloaded functions.
|
$fish_function_path variable to remove autoloaded functions.
|
||||||
|
|
||||||
|
Function copies, created with -c, will not have any event/signal/on-exit
|
||||||
|
notifications that the original may have had.
|
||||||
|
|
||||||
The exit status of the functions builtin is the number functions
|
The exit status of the functions builtin is the number functions
|
||||||
specified in the argument list that do not exist.
|
specified in the argument list that do not exist.
|
||||||
|
|||||||
36
doc_src/history.txt
Normal file
36
doc_src/history.txt
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
\section history history - Show and manipulate user's command history
|
||||||
|
|
||||||
|
\subsection history-synopsis Synopsis
|
||||||
|
<pre>
|
||||||
|
history (--save | --clear)
|
||||||
|
history (--search | --delete ) (--prefix "prefix string" | --contains "search string")
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
\subsection history-description Description
|
||||||
|
|
||||||
|
history is used to list, search and delete user's command history
|
||||||
|
|
||||||
|
\subsection history-examples Example
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
history --save
|
||||||
|
Save all changes in history file
|
||||||
|
|
||||||
|
history --clear
|
||||||
|
Delete all history items
|
||||||
|
|
||||||
|
history --search --contains "foo"
|
||||||
|
Searches commands containing "foo" string
|
||||||
|
|
||||||
|
history --search --prefix "foo"
|
||||||
|
Searches for commands with prefix "foo"
|
||||||
|
|
||||||
|
history --delete --contains "foo"
|
||||||
|
Interactively delete commands containing string "foo"
|
||||||
|
|
||||||
|
history --delete --prefix "foo"
|
||||||
|
Interactively delete commands with prefix "foo"
|
||||||
|
|
||||||
|
history --delete "foo"
|
||||||
|
Delete command "foo" from history
|
||||||
|
</pre>
|
||||||
@@ -1,23 +1,36 @@
|
|||||||
\section if if - conditionally execute a command
|
\section if if - conditionally execute a command
|
||||||
|
|
||||||
\subsection if-synopsis Synopsis
|
\subsection if-synopsis Synopsis
|
||||||
<tt>if CONDITION; COMMANDS_TRUE...; [else; COMMANDS_FALSE...;] end</tt>
|
<tt>if CONDITION; COMMANDS_TRUE...; [else if CONDITION2; COMMANDS_TRUE2...;] [else; COMMANDS_FALSE...;] end</tt>
|
||||||
|
|
||||||
\subsection if-description Description
|
\subsection if-description Description
|
||||||
<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>if</tt> will execute the command CONDITION. If the condition's
|
||||||
<tt>else</tt> is given, COMMANDS_FALSE will be executed. Hint: use
|
exit status is 0, the commands COMMANDS_TRUE will execute. If the
|
||||||
<a href="#begin"><tt>begin; ...; end</tt></a> for complex conditions.
|
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
|
\subsection if-example Example
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
if test -f foo.txt
|
if test -f foo.txt
|
||||||
echo foo.txt exists
|
echo foo.txt exists
|
||||||
|
else if test -f bar.txt
|
||||||
|
echo bar.txt exists
|
||||||
else
|
else
|
||||||
echo foo.txt does not exist
|
echo foo.txt and bar.txt do not exist
|
||||||
end
|
end
|
||||||
</pre>
|
</pre>will print <tt>foo.txt exists</tt> if the file foo.txt
|
||||||
will print <tt>foo.txt exists</tt> if the file foo.txt
|
exists and is a regular file, otherwise it will print
|
||||||
exists and is a regular file, otherwise it will print
|
<tt>bar.txt exists</tt> if the file bar.txt exists
|
||||||
<tt>foo.txt does not exist</tt>.
|
and is a regular file, otherwise it will print
|
||||||
|
<tt>foo.txt and bar.txt do not exist</tt>.
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
|||||||
\section isatty isatty - test if the specidied file descriptor is a tty
|
\section isatty isatty - test if the specified file descriptor is a tty
|
||||||
|
|
||||||
\subsection isatty-synopsis Synopsis
|
\subsection isatty-synopsis Synopsis
|
||||||
<tt>isatty [FILE DESCRIPTOR]</tt>
|
<tt>isatty [FILE DESCRIPTOR]</tt>
|
||||||
|
|||||||
@@ -1,28 +1,11 @@
|
|||||||
/** \page license Licenses
|
/** \page license Licenses
|
||||||
|
|
||||||
Fish Copyright (C) 2005 Axel Liljencrantz. Fish is released under the
|
<h2>License for fish</h2>
|
||||||
GNU General Public License, version 2. The license agreement is
|
|
||||||
|
Fish Copyright (C) 2005-2009 Axel Liljencrantz. Fish is released under
|
||||||
|
the GNU General Public License, version 2. The license agreement is
|
||||||
included below.
|
included below.
|
||||||
|
|
||||||
Fish contains code under the BSD license, namely versions of the
|
|
||||||
two functions strlcat and strlcpy, modified for use with wide
|
|
||||||
character strings. This code is copyrighted by Todd C. Miller. The
|
|
||||||
license agreement is included below.
|
|
||||||
|
|
||||||
The XSel command, written and copyrighted by Conrad Parker, is
|
|
||||||
distributed together with, and used by fish. It is released under the MIT
|
|
||||||
license. The license agreement is included below.
|
|
||||||
|
|
||||||
The xdgmime library, written and copyrighted by Red Hat, Inc, is used
|
|
||||||
by the mimedb command, which is a part of fish. It is released under
|
|
||||||
the LGPL. The license agreement is included below.
|
|
||||||
|
|
||||||
Fish contains code from the glibc library, namely the wcstok
|
|
||||||
function. This code is licensed under the LGPL. The license agreement
|
|
||||||
is included below.
|
|
||||||
|
|
||||||
|
|
||||||
<HR>
|
|
||||||
|
|
||||||
<H2><A NAME="SEC1" HREF="gpl.html#TOC1">GNU GENERAL PUBLIC LICENSE</A></H2>
|
<H2><A NAME="SEC1" HREF="gpl.html#TOC1">GNU GENERAL PUBLIC LICENSE</A></H2>
|
||||||
<P>
|
<P>
|
||||||
@@ -31,7 +14,7 @@ Version 2, June 1991
|
|||||||
</P>
|
</P>
|
||||||
|
|
||||||
<PRE>
|
<PRE>
|
||||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
@@ -464,7 +447,7 @@ PERFORMANCE OF THIS SOFTWARE.
|
|||||||
<h2>License for XSel</h2>
|
<h2>License for XSel</h2>
|
||||||
|
|
||||||
The XSel command, written and copyrighted by Conrad Parker, is
|
The XSel command, written and copyrighted by Conrad Parker, is
|
||||||
distributed together with \c fish.
|
distributed together with \c fish.
|
||||||
|
|
||||||
|
|
||||||
It is Copyright (C) 2001 Conrad Parker <conrad@vergenet.net>
|
It is Copyright (C) 2001 Conrad Parker <conrad@vergenet.net>
|
||||||
@@ -480,6 +463,18 @@ without express or implied warranty.
|
|||||||
|
|
||||||
<HR>
|
<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>
|
<H2><A NAME="SEC1" HREF="#TOC1">GNU LESSER GENERAL PUBLIC LICENSE</A></H2>
|
||||||
|
|
||||||
<P>
|
<P>
|
||||||
@@ -807,7 +802,7 @@ of these things:
|
|||||||
that the user who changes the contents of definitions files in the
|
that the user who changes the contents of definitions files in the
|
||||||
Library will not necessarily be able to recompile the application
|
Library will not necessarily be able to recompile the application
|
||||||
to use the modified definitions.)
|
to use the modified definitions.)
|
||||||
|
|
||||||
<LI><STRONG>b)</STRONG> Use a suitable shared library mechanism for linking with the
|
<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
|
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,
|
copy of the library already present on the user's computer system,
|
||||||
|
|||||||
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.
|
||||||
|
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
\subsection mimedb-description Description
|
\subsection mimedb-description Description
|
||||||
|
|
||||||
- \c FILES is a list of files to analyse
|
- \c FILES is a list of files to analyse
|
||||||
- \c -t, \c --input-file-data the specified files type should be determined both by their filename and by their contents (Default)
|
- \c -t, \c --input-file-data the specified files type should be determined both by their filename and by their contents (Default)
|
||||||
- \c -f, \c --input-filename the specified files type should be determined by their filename
|
- \c -f, \c --input-filename the specified files type should be determined by their filename
|
||||||
- \c -i, \c --input-mime the arguments are not files but mimetypes
|
- \c -i, \c --input-mime the arguments are not files but mimetypes
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
The mimedb command is used to query the mimetype database and the
|
The mimedb command is used to query the mimetype database and the
|
||||||
.desktop files installed on the system in order to find information on
|
.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
|
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
|
is. mimedb can also be used to launch the default action for this
|
||||||
file.
|
file.
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
\subsection not-description Description
|
\subsection not-description Description
|
||||||
|
|
||||||
The \c not builtin is used to negate the exit status of another command.
|
The \c not builtin is used to negate the exit status of another command.
|
||||||
|
|
||||||
\subsection not-example Example
|
\subsection not-example Example
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +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
|
\subsection open-synopsis Synopsis
|
||||||
<tt>open FILES...</tt>
|
<tt>open FILES...</tt>
|
||||||
|
|
||||||
\subsection open-description Description
|
\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
|
\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.
|
||||||
|
|||||||
@@ -10,10 +10,14 @@ status (as set by the last previous command) is not 0.
|
|||||||
|
|
||||||
The or command does not change the current exit status.
|
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
|
\subsection or-example Example
|
||||||
|
|
||||||
The following code runs the \c make command to build a program, if the
|
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
|
<tt>make clean</tt> is run, which removes the files created by the
|
||||||
build process
|
build process
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
\subsection popd-synopsis Synopsis
|
\subsection popd-synopsis Synopsis
|
||||||
<tt>popd</tt>
|
<tt>popd</tt>
|
||||||
|
|
||||||
\subsection popd-description Description
|
\subsection popd-description Description
|
||||||
<tt>popd</tt> removes the top directory from the directory stack and
|
<tt>popd</tt> removes the top directory from the directory stack and
|
||||||
cd's to the new top directory.
|
cd's to the new top directory.
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
\section prevd prevd - move backward through direcotry history
|
\section prevd prevd - move backward through directory history
|
||||||
|
|
||||||
\subsection prevd-synopsis Synopsis
|
\subsection prevd-synopsis Synopsis
|
||||||
<tt>prevd [-l | --list] [pos]</tt>
|
<tt>prevd [-l | --list] [pos]</tt>
|
||||||
|
|
||||||
\subsection prevd-description Description <tt>prevd</tt> moves
|
\subsection prevd-description Description
|
||||||
backwards <tt>pos</tt> positions in the history of visited
|
|
||||||
directories; if the beginning of the history has been hit, a warning
|
<tt>prevd</tt> moves backwards <tt>pos</tt> positions in the history
|
||||||
is printed. If the <code>-l</code> or <code>--list</code> flag is
|
of visited directories; if the beginning of the history has been hit,
|
||||||
specified, the current history is also displayed.
|
a warning is printed. If the <code>-l</code> or <code>--list</code>
|
||||||
|
flag is specified, the current history is also displayed.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
\section psub psub - perform process substitution
|
\section psub psub - perform process substitution
|
||||||
|
|
||||||
\subsection psub-synopsis Synopsis
|
\subsection psub-synopsis Synopsis
|
||||||
<tt>COMMAND1 (COMMAND2|psub) </tt>
|
<tt>COMMAND1 (COMMAND2|psub [-f]) </tt>
|
||||||
|
|
||||||
\subsection psub-description Description
|
\subsection psub-description Description
|
||||||
|
|
||||||
@@ -14,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
|
program. The psub shellscript function, which when combined with a
|
||||||
regular command substitution provides the same functionality.
|
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
|
\subsection psub-example Example
|
||||||
|
|
||||||
<tt>diff (sort a.txt|psub) (sort b.txt|psub)</tt> shows the difference
|
<tt>diff (sort a.txt|psub) (sort b.txt|psub)</tt> shows the difference
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
\subsection pushd-synopsis Synopsis
|
\subsection pushd-synopsis Synopsis
|
||||||
<tt>pushd [DIRECTORY]</tt>
|
<tt>pushd [DIRECTORY]</tt>
|
||||||
|
|
||||||
\subsection pushd-description Description
|
\subsection pushd-description Description
|
||||||
The <tt>pushd</tt> function adds DIRECTORY to the top of the directory stack
|
The <tt>pushd</tt> function adds DIRECTORY to the top of the directory stack
|
||||||
and makes it the current directory. Use <tt>popd</tt> to pop it off and and
|
and makes it the current directory. Use <tt>popd</tt> to pop it off and and
|
||||||
return to the original directory.
|
return to the original directory.
|
||||||
|
|||||||
8
doc_src/pwd.txt
Normal file
8
doc_src/pwd.txt
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
\section pwd pwd - returns the current directory
|
||||||
|
|
||||||
|
\subsection pwd-synopsis Synopsis
|
||||||
|
<tt>pwd</tt>
|
||||||
|
|
||||||
|
\subsection pwd-description Description
|
||||||
|
|
||||||
|
Returns the current directory. Note that fish always resolves symbolic links in the current directory path.
|
||||||
@@ -21,4 +21,4 @@ for i in (seq (random) -1 1)
|
|||||||
echo $i
|
echo $i
|
||||||
sleep
|
sleep
|
||||||
end
|
end
|
||||||
</pre>
|
</pre>
|
||||||
|
|||||||
@@ -6,12 +6,14 @@
|
|||||||
\subsection read-description Description
|
\subsection read-description Description
|
||||||
|
|
||||||
The <tt>read</tt> builtin causes fish to read one line from standard
|
The <tt>read</tt> builtin causes fish to read one line from standard
|
||||||
input and store the result in one or more environment variables.
|
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>-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>-g</tt> or <tt>--global</tt> specifies that the variables will be made global.
|
||||||
|
- <tt>-l</tt> or <tt>--local</tt> specifies that the variables will be made local.
|
||||||
|
- <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>.
|
- <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>--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>-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
|
- <code>-x</code> or <code>--export</code> causes the specified environment variable to be exported to child processes
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
\subsection return-synopsis Synopsis
|
\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
|
\subsection return-description Description
|
||||||
|
|
||||||
The \c return builtin is used to halt a currently running function. It
|
The \c return builtin is used to halt a currently running function. It
|
||||||
is usually added inside of a conditional block such as an <a
|
is usually added inside of a conditional block such as an <a
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ the last index of an array.
|
|||||||
The scoping rules when creating or updating a variable are:
|
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 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.
|
-# 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
|
The exporting rules when creating or updating a variable are identical
|
||||||
@@ -51,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 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 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.
|
In query mode, the scope to be examined can be specified.
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,11 @@
|
|||||||
|
|
||||||
Change the foreground and/or background color of the terminal.
|
Change the foreground and/or background color of the terminal.
|
||||||
COLOR is one of black, red, green, brown, yellow, blue, magenta,
|
COLOR is one of black, red, green, brown, yellow, blue, magenta,
|
||||||
purple, cyan, white and normal.
|
purple, cyan, white and normal.
|
||||||
|
|
||||||
|
If your terminal supports term256 (modern xterms and OS X Lion),
|
||||||
|
you can specify an RGB value with three or six hex digits, such
|
||||||
|
as A0FF33 or f2f. fish will choose the closest supported color.
|
||||||
|
|
||||||
- \c -b, \c --background Set the background color
|
- \c -b, \c --background Set the background color
|
||||||
- \c -c, \c --print-colors Prints a list of all valid color names
|
- \c -c, \c --print-colors Prints a list of all valid color names
|
||||||
@@ -28,3 +32,9 @@ result in a white font color.
|
|||||||
Not all terminal emulators support all these features. This is not a
|
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,19 +1,28 @@
|
|||||||
\section source . - evaluate contents of file.
|
\section source . - evaluate contents of file.
|
||||||
|
|
||||||
\subsection source-synopsis Synopsis
|
\subsection source-synopsis Synopsis
|
||||||
<tt>. FILENAME</tt>
|
<tt>. FILENAME [ARGUMENTS...]</tt>
|
||||||
|
|
||||||
\subsection source-description Description
|
\subsection source-description Description
|
||||||
|
|
||||||
Evaluates the commands of the specified file in the current
|
Evaluates the commands of the specified file in the current
|
||||||
shell. This is different from starting a new process to perform the
|
shell. This is different from starting a new process to perform the
|
||||||
commands (i.e. <tt>fish < FILENAME</tt>) since the commands will be
|
commands (i.e. <tt>fish < FILENAME</tt>) since the commands will be
|
||||||
evaluated by the current shell, which means that changes in
|
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
|
\subsection source-example Example
|
||||||
|
|
||||||
<tt>. ~/.fish</tt>
|
<tt>. ~/.config/fish/config.fish</tt>
|
||||||
|
|
||||||
causes fish to reread its initialization file.
|
causes fish to reread its initialization file.
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user