mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-31 12:56:10 +01:00
Compare commits
986
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7d5bc63209 | ||
|
|
18d96317a1 | ||
|
|
68a0a8fbec | ||
|
|
43837e2288 | ||
|
|
62d02dc863 | ||
|
|
909c082ec1 | ||
|
|
86c7ef7872 | ||
|
|
ac88a0a707 | ||
|
|
e0fb848ab2 | ||
|
|
5c2f5d6243 | ||
|
|
2bc4e74f3a | ||
|
|
4026f294fb | ||
|
|
0b909877cf | ||
|
|
37cdba40e6 | ||
|
|
22381f1a11 | ||
|
|
727591c126 | ||
|
|
f1b796bf01 | ||
|
|
710115ffa2 | ||
|
|
563546642e | ||
|
|
2b17a020b8 | ||
|
|
d9fe40cfe2 | ||
|
|
034d80aacc | ||
|
|
1dc8e58608 | ||
|
|
7d32c7e4a6 | ||
|
|
5e3690f270 | ||
|
|
b5ee61fc4c | ||
|
|
649a01d8d4 | ||
|
|
253df96c73 | ||
|
|
d1b07af47c | ||
|
|
f4a0789aad | ||
|
|
e7a3173a83 | ||
|
|
9545a56c96 | ||
|
|
0b449c2699 | ||
|
|
10522f2e51 | ||
|
|
f191ebcf55 | ||
|
|
7efb0443a1 | ||
|
|
0acc63cefc | ||
|
|
341e0586b4 | ||
|
|
881ae9a56f | ||
|
|
26434e889b | ||
|
|
736fc9be30 | ||
|
|
e1ea49a732 | ||
|
|
f8feb060cf | ||
|
|
3b234f84b6 | ||
|
|
e554ada9f5 | ||
|
|
11c84bd2a0 | ||
|
|
f3e00f04a7 | ||
|
|
01df96a90a | ||
|
|
0d7c5d3598 | ||
|
|
014c4b26f8 | ||
|
|
eabad3cb57 | ||
|
|
4c6b5a04e3 | ||
|
|
87ec7a3156 | ||
|
|
80eae1f0ad | ||
|
|
039547dbca | ||
|
|
c826cdb249 | ||
|
|
3cd4a69c91 | ||
|
|
0f591ffd30 | ||
|
|
98ff43f8ad | ||
|
|
c93d632184 | ||
|
|
39b71d2b18 | ||
|
|
e2b02502ce | ||
|
|
997b18fff2 | ||
|
|
b4b269d04b | ||
|
|
8d7717c8f8 | ||
|
|
2ddeca5af8 | ||
|
|
fbfa3f052c | ||
|
|
abfb961fad | ||
|
|
16e6e7379a | ||
|
|
118f3eb101 | ||
|
|
96aace0670 | ||
|
|
77a5659f07 | ||
|
|
9bec5b4849 | ||
|
|
dcbeae29d4 | ||
|
|
b4d3679465 | ||
|
|
06e3a92959 | ||
|
|
ae577b4100 | ||
|
|
3e9ac6c2f7 | ||
|
|
a470520b27 | ||
|
|
21be3f39bf | ||
|
|
56ed46a4de | ||
|
|
09bed63737 | ||
|
|
6b69b77bb0 | ||
|
|
9d0e40e914 | ||
|
|
f00fa6d98b | ||
|
|
ad5c494342 | ||
|
|
e2345374a7 | ||
|
|
cb71be7a4b | ||
|
|
d29d80199c | ||
|
|
c9d6f50827 | ||
|
|
0f2d75a949 | ||
|
|
7d111a9847 | ||
|
|
b9f8d5948d | ||
|
|
021890eb4e | ||
|
|
df24b68717 | ||
|
|
366205f667 | ||
|
|
037532d2d9 | ||
|
|
fd512253f3 | ||
|
|
02d6988fe0 | ||
|
|
5ecb043295 | ||
|
|
cee17461ed | ||
|
|
a17f66db29 | ||
|
|
10f6e8c649 | ||
|
|
c55fa51a43 | ||
|
|
a550f7f356 | ||
|
|
86b99f13a2 | ||
|
|
3eaf155c95 | ||
|
|
38d3020be4 | ||
|
|
cd741eae0a | ||
|
|
bc8c7cefd4 | ||
|
|
3862c067d2 | ||
|
|
bcd1db1348 | ||
|
|
1e984d2a60 | ||
|
|
0fbbdc1de2 | ||
|
|
326ab7dbb1 | ||
|
|
705e27f151 | ||
|
|
bbef2e163d | ||
|
|
4cb5ea0648 | ||
|
|
d32fdf350a | ||
|
|
145fa4bcc8 | ||
|
|
6a2638324e | ||
|
|
89800c9b01 | ||
|
|
622906f1f3 | ||
|
|
be94235213 | ||
|
|
1bed24fbfc | ||
|
|
e1b4b68e63 | ||
|
|
6506718d4f | ||
|
|
8857adacf4 | ||
|
|
91b0a912c7 | ||
|
|
d2188905ba | ||
|
|
14db04edce | ||
|
|
7b0c18a9e0 | ||
|
|
6e20fbb752 | ||
|
|
20d2fd5f04 | ||
|
|
665e307511 | ||
|
|
8c82ecd75f | ||
|
|
2c9291c6d5 | ||
|
|
4a3cc125bd | ||
|
|
11942be157 | ||
|
|
6d7a1ca174 | ||
|
|
ee0c53086c | ||
|
|
1c53544c52 | ||
|
|
480fadb7b1 | ||
|
|
c39e106692 | ||
|
|
0f6ef27384 | ||
|
|
859f01321a | ||
|
|
84b47b0830 | ||
|
|
2c1218d904 | ||
|
|
37c9115227 | ||
|
|
3a96f13943 | ||
|
|
06ef838c9a | ||
|
|
96af8ca352 | ||
|
|
66717bdf0f | ||
|
|
f973bff275 | ||
|
|
f3bd8f3189 | ||
|
|
61c70187d6 | ||
|
|
b6f58c8d70 | ||
|
|
1eee4d5ac7 | ||
|
|
4a8984e082 | ||
|
|
c31ceffe07 | ||
|
|
ba91099bd3 | ||
|
|
e4a480ece8 | ||
|
|
9b59f30765 | ||
|
|
1695353f62 | ||
|
|
b842f47f5c | ||
|
|
246eb89cb8 | ||
|
|
6a74cae102 | ||
|
|
f0db17addb | ||
|
|
f32edd72b7 | ||
|
|
100bfcd1a9 | ||
|
|
e647b9b1e2 | ||
|
|
258c91a9a8 | ||
|
|
b1dd2deb2b | ||
|
|
6c18e2687a | ||
|
|
ff2355e11f | ||
|
|
dd2945ee27 | ||
|
|
917964aa9d | ||
|
|
2c6f262b2d | ||
|
|
35b672cbbe | ||
|
|
f9498d3b9e | ||
|
|
c467132cb1 | ||
|
|
55b3d7e976 | ||
|
|
e9df0e9107 | ||
|
|
1752c99f31 | ||
|
|
f4f0aa9cd1 | ||
|
|
28d8877972 | ||
|
|
3572adb867 | ||
|
|
ebc9e121e2 | ||
|
|
4325a53a13 | ||
|
|
3daf4d6ef1 | ||
|
|
53de306886 | ||
|
|
97548cbaa9 | ||
|
|
038d4d9e5c | ||
|
|
bd9966eef7 | ||
|
|
8e57c3cfe9 | ||
|
|
4e13174564 | ||
|
|
f58825edc0 | ||
|
|
6aa216abc5 | ||
|
|
3aa267a213 | ||
|
|
5b27174689 | ||
|
|
159298ed57 | ||
|
|
d9faeb23db | ||
|
|
c0aa8f3a98 | ||
|
|
e8db720003 | ||
|
|
7ef062dd03 | ||
|
|
09dbd3b14f | ||
|
|
caf3a087b5 | ||
|
|
de5fea70d1 | ||
|
|
55663c360a | ||
|
|
41726a2e21 | ||
|
|
b7c875d82a | ||
|
|
eee9007e1f | ||
|
|
22da2d1b3c | ||
|
|
d6df6e2659 | ||
|
|
66079f4d83 | ||
|
|
a410b1371a | ||
|
|
a42d47530f | ||
|
|
bc8118e19d | ||
|
|
54074ba978 | ||
|
|
d3688b48bb | ||
|
|
4c018912a9 | ||
|
|
9ea9730dfa | ||
|
|
75b2fa00c2 | ||
|
|
08c1ba9c19 | ||
|
|
3f986a9508 | ||
|
|
bd311b45dc | ||
|
|
9185dcabf5 | ||
|
|
8789a3976e | ||
|
|
c7f6239892 | ||
|
|
d09e917d3d | ||
|
|
7255f7f01f | ||
|
|
01f8a8b2ec | ||
|
|
601c33b80f | ||
|
|
8aef5981c0 | ||
|
|
8c561b8cc3 | ||
|
|
3460818194 | ||
|
|
f8bc8ec409 | ||
|
|
e0f6361748 | ||
|
|
893abf9888 | ||
|
|
5ebd407bca | ||
|
|
0b82ab5ebc | ||
|
|
152472d957 | ||
|
|
3d71b01065 | ||
|
|
e816850295 | ||
|
|
fb24796b58 | ||
|
|
7aac573a14 | ||
|
|
3f3cb126c4 | ||
|
|
b7a1b6a176 | ||
|
|
f7bade96a9 | ||
|
|
71ed8ca70b | ||
|
|
eb5d8b1314 | ||
|
|
dcd98572fd | ||
|
|
d5eb10d4fc | ||
|
|
93defd8682 | ||
|
|
b2bacd00f5 | ||
|
|
3850f7b9d7 | ||
|
|
8813f2eb10 | ||
|
|
cad25b5062 | ||
|
|
1a01aa5b43 | ||
|
|
50239d81eb | ||
|
|
055c7b64eb | ||
|
|
ab7919da83 | ||
|
|
b32dbf8423 | ||
|
|
2a70a80fac | ||
|
|
4bd668b383 | ||
|
|
c7a1738c94 | ||
|
|
77fc9f9396 | ||
|
|
2a835e8424 | ||
|
|
a98770255e | ||
|
|
a84e239788 | ||
|
|
56ec22cf65 | ||
|
|
ce88eae706 | ||
|
|
f13ad78dcd | ||
|
|
569e0d7f3c | ||
|
|
ace69c98df | ||
|
|
cc76f06685 | ||
|
|
23b30a5917 | ||
|
|
ea3c68ab01 | ||
|
|
c3dda797a1 | ||
|
|
6813e0318b | ||
|
|
3f43094c5f | ||
|
|
738be7ff05 | ||
|
|
e3a6e5a327 | ||
|
|
3ce8c2d66a | ||
|
|
55a27f6ecd | ||
|
|
a77b9f2d3f | ||
|
|
2d11746790 | ||
|
|
400e4f66e2 | ||
|
|
abf2253635 | ||
|
|
75ed5dcc5c | ||
|
|
4f5bf5d6d3 | ||
|
|
14dec6302e | ||
|
|
61bfe792ed | ||
|
|
374bb95f89 | ||
|
|
91e1a5025c | ||
|
|
d3c0a5eb42 | ||
|
|
1c757fb757 | ||
|
|
20092ff107 | ||
|
|
c4bf962ea2 | ||
|
|
a1755a6851 | ||
|
|
b7b4bf1425 | ||
|
|
0497cf6ccd | ||
|
|
35a0fe04ef | ||
|
|
9f90cb462d | ||
|
|
3b2580e8d8 | ||
|
|
266ba32995 | ||
|
|
c103f2bf23 | ||
|
|
b475649b62 | ||
|
|
3ee7fb9e9b | ||
|
|
094b31bc72 | ||
|
|
0b7a86ba45 | ||
|
|
713ffef6ab | ||
|
|
3349930f4c | ||
|
|
f827afa7e7 | ||
|
|
824368768d | ||
|
|
fce7e6f534 | ||
|
|
299e6dd0f7 | ||
|
|
44687310e1 | ||
|
|
7917974044 | ||
|
|
0d13835831 | ||
|
|
afcaad2532 | ||
|
|
0815d30b9f | ||
|
|
e354c6fc0b | ||
|
|
9b27d8b934 | ||
|
|
bfd6029615 | ||
|
|
3a04ce0179 | ||
|
|
ab3558402c | ||
|
|
4550b0c06d | ||
|
|
5e7b94c16a | ||
|
|
d99452b672 | ||
|
|
579ff8dba6 | ||
|
|
dee37f52de | ||
|
|
fb23fbac0d | ||
|
|
d4f61155bf | ||
|
|
f3145b18e5 | ||
|
|
f9d30c6106 | ||
|
|
67737a3703 | ||
|
|
6da4c5d94a | ||
|
|
52d0c84baa | ||
|
|
f2d4589a8e | ||
|
|
8503fab82c | ||
|
|
5cc704a2b9 | ||
|
|
10f1f49952 | ||
|
|
1f61e6a8de | ||
|
|
d7cb927423 | ||
|
|
c64eb155c5 | ||
|
|
818b76dca4 | ||
|
|
8ba9a8277a | ||
|
|
c76d93d537 | ||
|
|
ebb7e2f798 | ||
|
|
6834d5c4af | ||
|
|
03429c1bb6 | ||
|
|
6fe698c3ca | ||
|
|
6567782c34 | ||
|
|
8767eb4ee6 | ||
|
|
f508faf974 | ||
|
|
55a408a913 | ||
|
|
c714364bf4 | ||
|
|
966b8fcfc3 | ||
|
|
1c68c2b2cb | ||
|
|
77dbc216d6 | ||
|
|
60e87e827a | ||
|
|
78c04ea9a5 | ||
|
|
5c22470396 | ||
|
|
442a034ab0 | ||
|
|
7449021331 | ||
|
|
f64b373013 | ||
|
|
f03949e349 | ||
|
|
af88c09155 | ||
|
|
8e1b66ae74 | ||
|
|
6a7d026980 | ||
|
|
6e7e727660 | ||
|
|
19e3e2ff25 | ||
|
|
7398989f81 | ||
|
|
c0144b8dcb | ||
|
|
55ee423324 | ||
|
|
00e5ed0584 | ||
|
|
b17cbfa587 | ||
|
|
137319041b | ||
|
|
9d693d3457 | ||
|
|
3fcc1612e6 | ||
|
|
fd2abeee06 | ||
|
|
cfdd60be45 | ||
|
|
52011e008e | ||
|
|
27306130d8 | ||
|
|
d4e4d3a724 | ||
|
|
a85266ac8e | ||
|
|
0f3db5354d | ||
|
|
b288519a3b | ||
|
|
7c4488b70a | ||
|
|
e23f4b7279 | ||
|
|
9f2e387eca | ||
|
|
6e77b86ce2 | ||
|
|
d3cfc4cf46 | ||
|
|
9bd8f2d4b4 | ||
|
|
8dcad812ce | ||
|
|
735a1ab7d5 | ||
|
|
0beeeb3440 | ||
|
|
9cebedd66b | ||
|
|
7f0e5599d8 | ||
|
|
e1dc2b78f0 | ||
|
|
ceb18ab0f5 | ||
|
|
1cada36c56 | ||
|
|
73d4073137 | ||
|
|
7c3566be9f | ||
|
|
9637e5f688 | ||
|
|
b6c8ec6096 | ||
|
|
cbb344d6d6 | ||
|
|
c355670229 | ||
|
|
002d6f2455 | ||
|
|
e6b2ae4638 | ||
|
|
1b2c889e00 | ||
|
|
473b8522dd | ||
|
|
f0d8aa68bd | ||
|
|
ef1059a64e | ||
|
|
5de07a177a | ||
|
|
c2ce8018e4 | ||
|
|
84eb730aec | ||
|
|
5c03781863 | ||
|
|
5e5ed8f948 | ||
|
|
4243c8ac8f | ||
|
|
0073d44add | ||
|
|
c985376284 | ||
|
|
1ef681d32d | ||
|
|
b383708ec3 | ||
|
|
7b6927aac0 | ||
|
|
0338784d5d | ||
|
|
5a490f9a9a | ||
|
|
1ccde44a16 | ||
|
|
ef5c33cb93 | ||
|
|
c838baec19 | ||
|
|
ea5b15849b | ||
|
|
bad07f937a | ||
|
|
3b376d0478 | ||
|
|
10f048a7b4 | ||
|
|
8c7580241e | ||
|
|
50405dc2d6 | ||
|
|
df924d72db | ||
|
|
da637a8791 | ||
|
|
0647794dd1 | ||
|
|
9382f4409c | ||
|
|
65bba05fcc | ||
|
|
ce7c71931c | ||
|
|
2df6b9f88a | ||
|
|
9ea8028ff4 | ||
|
|
45325d7b91 | ||
|
|
697c38e52c | ||
|
|
d1f833b568 | ||
|
|
2381d88084 | ||
|
|
f66270acfb | ||
|
|
4d042c9d8b | ||
|
|
0d1bc927b1 | ||
|
|
7e955da543 | ||
|
|
1c22ec3f1f | ||
|
|
40d3441ba5 | ||
|
|
1f0a929314 | ||
|
|
a000a1155c | ||
|
|
2319d8d62b | ||
|
|
e8e6fe203e | ||
|
|
f550457f2e | ||
|
|
4148f241b1 | ||
|
|
ae8bd88a6e | ||
|
|
516807fb91 | ||
|
|
b87265eb3b | ||
|
|
8165daa6b8 | ||
|
|
585a11b37a | ||
|
|
e92188b4c7 | ||
|
|
4ef5177d18 | ||
|
|
f6af5de691 | ||
|
|
e0cfaf398a | ||
|
|
e8a404ed89 | ||
|
|
a3eae6b2e5 | ||
|
|
099870f366 | ||
|
|
b47975d1ae | ||
|
|
cb949d9472 | ||
|
|
e26cad8b90 | ||
|
|
e6449073ea | ||
|
|
65de826f7a | ||
|
|
2fd585f0ae | ||
|
|
22454bd776 | ||
|
|
183cefca97 | ||
|
|
6fc4d230ec | ||
|
|
879c4c23c8 | ||
|
|
63365483db | ||
|
|
c27b88c784 | ||
|
|
72d36c9ceb | ||
|
|
3288a4d803 | ||
|
|
3e1cf3ca51 | ||
|
|
82e47923d6 | ||
|
|
3976147b35 | ||
|
|
caa62c0e0d | ||
|
|
68e65c4a0c | ||
|
|
c42be62cde | ||
|
|
864cea0b1d | ||
|
|
173860d382 | ||
|
|
4df0a4835c | ||
|
|
504384b90f | ||
|
|
41e37dd0c0 | ||
|
|
05b305feee | ||
|
|
84253df1c9 | ||
|
|
4a7a8ecf99 | ||
|
|
b378bc813d | ||
|
|
154425bc36 | ||
|
|
5e0e27483e | ||
|
|
621071fdae | ||
|
|
825535ae02 | ||
|
|
231666d419 | ||
|
|
8ea1b170a4 | ||
|
|
2491fcd123 | ||
|
|
1d2e203758 | ||
|
|
2c107ed769 | ||
|
|
e431bc73f9 | ||
|
|
893101bc06 | ||
|
|
d51b8c0f06 | ||
|
|
fce352de6e | ||
|
|
78fc1cff98 | ||
|
|
3a3b50cbe6 | ||
|
|
1d5a72e2bb | ||
|
|
3e821f41a9 | ||
|
|
302f36a3be | ||
|
|
a633a565e4 | ||
|
|
1c877ab24b | ||
|
|
348a782a99 | ||
|
|
f102ba214b | ||
|
|
6360b2b95c | ||
|
|
e3380831aa | ||
|
|
ca9047f101 | ||
|
|
bb6f685be0 | ||
|
|
a705529fd6 | ||
|
|
ddd3c7e90b | ||
|
|
adb722de3a | ||
|
|
2ca61fc79a | ||
|
|
cc7cba7a7c | ||
|
|
eb49bf350f | ||
|
|
4e917b201a | ||
|
|
5f7643cd64 | ||
|
|
e08b9eb2dc | ||
|
|
1cdca79d6b | ||
|
|
0fbf048a71 | ||
|
|
f24f873d37 | ||
|
|
16bdbd2613 | ||
|
|
c25dd826c8 | ||
|
|
facf36bbb1 | ||
|
|
241f9df57c | ||
|
|
1faeb4ee90 | ||
|
|
2fd867102c | ||
|
|
27d9ff5af0 | ||
|
|
ac70628eeb | ||
|
|
6a858cb676 | ||
|
|
84012a0d99 | ||
|
|
2d936868bd | ||
|
|
fca314d159 | ||
|
|
27b6f02dba | ||
|
|
1dcddbc473 | ||
|
|
2d4618ec28 | ||
|
|
9591b8104b | ||
|
|
986ed32207 | ||
|
|
33ecb0955c | ||
|
|
d670700247 | ||
|
|
b67739b62d | ||
|
|
04b4508f97 | ||
|
|
bf97ca1417 | ||
|
|
99ab062b9d | ||
|
|
296326a3ba | ||
|
|
b338c46775 | ||
|
|
9049958242 | ||
|
|
9a1bdebc18 | ||
|
|
7182dfc269 | ||
|
|
5fc63c802c | ||
|
|
cd4d880cc9 | ||
|
|
4f63a7efef | ||
|
|
a8c3477e21 | ||
|
|
aa9dbec26b | ||
|
|
bd323137f8 | ||
|
|
4db4a2640f | ||
|
|
403e724619 | ||
|
|
c11262004d | ||
|
|
5e523b2b3e | ||
|
|
05205c4621 | ||
|
|
34547fdc5e | ||
|
|
2e077bab76 | ||
|
|
56e5055f75 | ||
|
|
df51fa9b6b | ||
|
|
9c9f814d37 | ||
|
|
0f6afc7bc7 | ||
|
|
fe513d0e21 | ||
|
|
9d03ad9aaf | ||
|
|
38f87826ed | ||
|
|
43da46a08f | ||
|
|
1e00230d2f | ||
|
|
6d3cd09423 | ||
|
|
c8697a811b | ||
|
|
109c80fb73 | ||
|
|
d1719bf6e9 | ||
|
|
a350b08936 | ||
|
|
f3b7228434 | ||
|
|
b65601bc12 | ||
|
|
f0a1add67a | ||
|
|
1fd3ede1b6 | ||
|
|
ff997a9a34 | ||
|
|
2e81d62ff5 | ||
|
|
e7862b327f | ||
|
|
9527f33ecb | ||
|
|
4fd361af66 | ||
|
|
93e8564ab4 | ||
|
|
5b48dfe193 | ||
|
|
b058d7bdf2 | ||
|
|
1b703e998a | ||
|
|
5d25136190 | ||
|
|
53f1b2476b | ||
|
|
caf1396611 | ||
|
|
e7a6e480af | ||
|
|
19c5ed5a6a | ||
|
|
db1382652e | ||
|
|
685867d16d | ||
|
|
99ee25ffe9 | ||
|
|
347dc175e9 | ||
|
|
209b920d67 | ||
|
|
1a44bfc42e | ||
|
|
c0d3bc09e4 | ||
|
|
106240e3f7 | ||
|
|
b9a85c25dc | ||
|
|
3a362ccc9e | ||
|
|
85aed53917 | ||
|
|
92e5fa5527 | ||
|
|
a1535419ab | ||
|
|
7febae28eb | ||
|
|
ae635f086a | ||
|
|
91d8bea2b4 | ||
|
|
42db7aed42 | ||
|
|
2f77ab6502 | ||
|
|
c9ffe36ff1 | ||
|
|
e807048905 | ||
|
|
aedb7baab2 | ||
|
|
90d2573693 | ||
|
|
addf28cd86 | ||
|
|
8d7ce752d9 | ||
|
|
2dcd742972 | ||
|
|
100659ff9a | ||
|
|
f7cf6d689a | ||
|
|
11e28cdaef | ||
|
|
e93a0bdc0b | ||
|
|
cad5aacadc | ||
|
|
b1cbdf0c18 | ||
|
|
5f7bf11316 | ||
|
|
0d46dccf32 | ||
|
|
dbabd4cc00 | ||
|
|
062085c94e | ||
|
|
0ab23daa07 | ||
|
|
35db198509 | ||
|
|
10d5e2fb12 | ||
|
|
b287b9bd37 | ||
|
|
efd218930a | ||
|
|
bc68954fe2 | ||
|
|
9df3cfb0ca | ||
|
|
43fc07cf06 | ||
|
|
d39851d816 | ||
|
|
210b8f077d | ||
|
|
c4bffcd1a0 | ||
|
|
135d445ab0 | ||
|
|
432d73e704 | ||
|
|
a088b43887 | ||
|
|
67198a155e | ||
|
|
f24de6a5ed | ||
|
|
24874397ad | ||
|
|
e042507974 | ||
|
|
17e04d3c90 | ||
|
|
b2fa2d5306 | ||
|
|
9fc78878ce | ||
|
|
b7f51c9af9 | ||
|
|
aeec054b18 | ||
|
|
c032bc5dc0 | ||
|
|
8dda57f9de | ||
|
|
308a970667 | ||
|
|
a1fa4fcd75 | ||
|
|
9d860f5bb7 | ||
|
|
e3554945b2 | ||
|
|
4b18eee29c | ||
|
|
9f2f526b88 | ||
|
|
a4708f4d1a | ||
|
|
737f4fee17 | ||
|
|
aa56f2678b | ||
|
|
e6cef3534e | ||
|
|
1bba747548 | ||
|
|
0e0fc4595e | ||
|
|
5ccdb7a972 | ||
|
|
cb66f283ad | ||
|
|
38f3284a6c | ||
|
|
825d32569d | ||
|
|
e9168671e8 | ||
|
|
11311ed73d | ||
|
|
0c0e72adac | ||
|
|
f1155463d4 | ||
|
|
8d3d480083 | ||
|
|
b9b099bf1d | ||
|
|
fce4961c9c | ||
|
|
e3cd60c3de | ||
|
|
9fde0e72d4 | ||
|
|
8617cb2c24 | ||
|
|
8d48711fd4 | ||
|
|
e1fd416643 | ||
|
|
3f7a65b366 | ||
|
|
6d322ad7e1 | ||
|
|
c8758d0039 | ||
|
|
3542422e3d | ||
|
|
123da19b12 | ||
|
|
e9ebf8eb7d | ||
|
|
f43bd7b4d2 | ||
|
|
5a0c30d610 | ||
|
|
31c546bc29 | ||
|
|
489e451968 | ||
|
|
dd09aa5456 | ||
|
|
2adfc151a2 | ||
|
|
a6f3515189 | ||
|
|
af380b74f2 | ||
|
|
a021136dc3 | ||
|
|
2bfe6ab8ea | ||
|
|
149d9d2f65 | ||
|
|
27c7e4ebd4 | ||
|
|
a226707c69 | ||
|
|
25232cd6bb | ||
|
|
b5164068f2 | ||
|
|
633e6eb0ca | ||
|
|
6649904d4a | ||
|
|
5b81c62157 | ||
|
|
74c965153c | ||
|
|
de63909242 | ||
|
|
e960d42a8a | ||
|
|
3e504b9b71 | ||
|
|
d7cd68d5bd | ||
|
|
7b288f8ec1 | ||
|
|
f1307896ba | ||
|
|
b2e58f96e2 | ||
|
|
79c3fe9c36 | ||
|
|
a084711d1d | ||
|
|
d4b967978c | ||
|
|
3799c13ebe | ||
|
|
90cf12172a | ||
|
|
fa535f40f6 | ||
|
|
16be8bb080 | ||
|
|
14c9db2333 | ||
|
|
49c2d376ba | ||
|
|
f614684df9 | ||
|
|
df654026c1 | ||
|
|
cefd31e793 | ||
|
|
3951d2bcfe | ||
|
|
5c1185f039 | ||
|
|
0f08a5c030 | ||
|
|
795ce3d60a | ||
|
|
11a3379d96 | ||
|
|
649ccfd7ce | ||
|
|
62db771a46 | ||
|
|
03fb078160 | ||
|
|
1decb43aa4 | ||
|
|
741e910e63 | ||
|
|
83e8ea0efd | ||
|
|
1ed85dd535 | ||
|
|
5da6d41447 | ||
|
|
b6479dc164 | ||
|
|
4a85dbd565 | ||
|
|
aa80f8ef64 | ||
|
|
c8526ac4f4 | ||
|
|
d85757e98e | ||
|
|
65a7929557 | ||
|
|
d1a10d3f4d | ||
|
|
b0d3556c67 | ||
|
|
900fcbced8 | ||
|
|
c062ce53ea | ||
|
|
f92d074d99 | ||
|
|
2644760f2a | ||
|
|
2869283261 | ||
|
|
688d93796a | ||
|
|
70ddb5cb3a | ||
|
|
5218dd0490 | ||
|
|
8c8d52967a | ||
|
|
b4eb1d7e16 | ||
|
|
b696ae0ab3 | ||
|
|
e5eba3d02c | ||
|
|
b2a85d3b36 | ||
|
|
da570ec817 | ||
|
|
1dfadcb55c | ||
|
|
6ffb3668e2 | ||
|
|
bb083b0861 | ||
|
|
769ed4163b | ||
|
|
2586fcc3fc | ||
|
|
644d3210fd | ||
|
|
633ef477fc | ||
|
|
7c78559d2a | ||
|
|
f40f2866ed | ||
|
|
332e536558 | ||
|
|
dfcf67535d | ||
|
|
796cf9e3b0 | ||
|
|
e0dc1266b5 | ||
|
|
82064108c9 | ||
|
|
088d3798db | ||
|
|
240b159e39 | ||
|
|
251a872d87 | ||
|
|
1f70bfa6c1 | ||
|
|
1a18ddc2c1 | ||
|
|
49354c11f8 | ||
|
|
7bc437b766 | ||
|
|
b722322149 | ||
|
|
180ec55d00 | ||
|
|
e7e717302b | ||
|
|
ec6570ae27 | ||
|
|
c50b59cfd4 | ||
|
|
f845468336 | ||
|
|
84118b4a67 | ||
|
|
7463ff9638 | ||
|
|
ad1ab15643 | ||
|
|
c24ffeaa86 | ||
|
|
cff46f0369 | ||
|
|
09a0fd2c7f | ||
|
|
f83d7042a4 | ||
|
|
7b7892c9f2 | ||
|
|
2c8c4cd9bd | ||
|
|
d95143ef70 | ||
|
|
c479292e0d | ||
|
|
47823d3ae0 | ||
|
|
a914c0fb94 | ||
|
|
58b7db9c06 | ||
|
|
c7d3ae317d | ||
|
|
f9ed6e2725 | ||
|
|
89daf6f74f | ||
|
|
82b93f1cb8 | ||
|
|
b6ab1280e3 | ||
|
|
81e53a70fd | ||
|
|
8eb0068059 | ||
|
|
dc25010335 | ||
|
|
c4c15d6b25 | ||
|
|
07ff5741ec | ||
|
|
1cbe338fc6 | ||
|
|
e0de049a3f | ||
|
|
425a0f35cd | ||
|
|
851945cca8 | ||
|
|
5653f265b4 | ||
|
|
8bb702e4e6 | ||
|
|
5729c7ba22 | ||
|
|
15584c518d | ||
|
|
899c049301 | ||
|
|
ed5c02ac20 | ||
|
|
5d2e8742ae | ||
|
|
13b5076385 | ||
|
|
31ec2688de | ||
|
|
5e7c263236 | ||
|
|
0361811fe1 | ||
|
|
e7d59e3da1 | ||
|
|
0d0e00416e | ||
|
|
b8ff51406b | ||
|
|
db3d8728cb | ||
|
|
f6f3450a5b | ||
|
|
524be82e34 | ||
|
|
de9b8f6cdc | ||
|
|
2ff7b2f394 | ||
|
|
eee1d1571b | ||
|
|
356222102f | ||
|
|
c88db0b678 | ||
|
|
48a98e81c3 | ||
|
|
337f1a976b | ||
|
|
90f4c3cc05 | ||
|
|
2e9ec0111b | ||
|
|
a0a5a0dad3 | ||
|
|
0ad249d7cc | ||
|
|
1606ccf916 | ||
|
|
64ea785090 | ||
|
|
d6c0e4b600 | ||
|
|
e1a33e2336 | ||
|
|
04af6ed94e | ||
|
|
1582395f0b | ||
|
|
b4496ff7ee | ||
|
|
3dd96312b5 | ||
|
|
bf5957fd3e | ||
|
|
88766ede49 | ||
|
|
35df281094 | ||
|
|
1ab33f8e20 | ||
|
|
18041f3f95 | ||
|
|
9d6e763640 | ||
|
|
56b18b7ac8 | ||
|
|
40e581795d | ||
|
|
c82eea9ff6 | ||
|
|
3ae2eac9fe | ||
|
|
225bbc38ae | ||
|
|
74064d0748 | ||
|
|
75c4a1878e | ||
|
|
bfa060ab71 | ||
|
|
552976d192 | ||
|
|
66f7fe0bc7 | ||
|
|
2010fec15b | ||
|
|
92a9d33730 | ||
|
|
6beb55de6a | ||
|
|
c577339cff | ||
|
|
f2965d526c | ||
|
|
637fe16fbd | ||
|
|
24ff2a5122 | ||
|
|
3c36c65426 | ||
|
|
ebf7769062 | ||
|
|
212afa835f | ||
|
|
44cf633b58 | ||
|
|
78616dddd3 | ||
|
|
225f32d2f8 | ||
|
|
335d670aff | ||
|
|
a4cb90da94 | ||
|
|
45476447b6 | ||
|
|
0826505bf8 | ||
|
|
b3d654a271 | ||
|
|
85ef821111 | ||
|
|
51566c9268 | ||
|
|
200c9f95df | ||
|
|
f1091a5ae3 | ||
|
|
b6bf791ca7 | ||
|
|
0ad0944e23 | ||
|
|
466e7ecd48 | ||
|
|
539f5f9799 | ||
|
|
bb71e47610 | ||
|
|
2dbdf8c5c1 | ||
|
|
b418fc45b7 | ||
|
|
923e20bb7c | ||
|
|
6f13dc731a | ||
|
|
c68f59fe5b | ||
|
|
5acbaaeaf7 | ||
|
|
ce3d979327 | ||
|
|
af4db9e6ef | ||
|
|
b934713b98 | ||
|
|
02dcd7df67 | ||
|
|
c70f2b8b3b | ||
|
|
79d5d70c1f | ||
|
|
2270af8f3e | ||
|
|
e66140568c | ||
|
|
30611a5e6f | ||
|
|
4f0d5731de | ||
|
|
dc3490b876 | ||
|
|
ecae0546d3 | ||
|
|
3394c4cea5 | ||
|
|
ef99cb34f9 | ||
|
|
02e3c43b23 | ||
|
|
8002ec65e5 | ||
|
|
289348adea | ||
|
|
5f57307856 | ||
|
|
bc23b345b5 | ||
|
|
265bebf9de | ||
|
|
7a80ed4361 | ||
|
|
640918e8b0 | ||
|
|
80e8491772 | ||
|
|
1ed3ad4009 | ||
|
|
8b22f6dc66 | ||
|
|
49588b7ed1 | ||
|
|
ee469172e3 | ||
|
|
c20ad688cb | ||
|
|
8ca3ddb8dc | ||
|
|
59971fec63 | ||
|
|
ad831d544c | ||
|
|
de4b832e80 | ||
|
|
4736edcbe3 | ||
|
|
3e9b06ba6d | ||
|
|
d9e9925880 | ||
|
|
c1c40e6370 | ||
|
|
c1e5098c6a | ||
|
|
270c0eb0ce | ||
|
|
174ef11047 | ||
|
|
3ea56be9b2 | ||
|
|
9cc64d62f1 | ||
|
|
0d63067a5a | ||
|
|
272ca57822 | ||
|
|
8bbd88f7a4 | ||
|
|
7720af6a8c | ||
|
|
0f4a34026d | ||
|
|
d0e0f2a284 | ||
|
|
f17ea500f8 | ||
|
|
3221318663 | ||
|
|
f4c0272f9d | ||
|
|
d657c1d143 | ||
|
|
51870dccc1 | ||
|
|
a1831593d3 | ||
|
|
8a47d763a5 | ||
|
|
defaaa0b9b | ||
|
|
62d7a685fe | ||
|
|
a9dc8e21ec | ||
|
|
3005967e0e | ||
|
|
96358fc6af | ||
|
|
6a8f6c1df4 | ||
|
|
a60572f6a5 | ||
|
|
46c6266b40 | ||
|
|
a98269f0eb | ||
|
|
75cc813f6c | ||
|
|
69a4e11c89 | ||
|
|
40dfd7de5c |
No files matched your search
@@ -30,9 +30,7 @@
|
||||
# tree. This makefile executes a child make process, forcing it to use
|
||||
# the mk files from the source tree which are supposed to DTRT.
|
||||
#
|
||||
# The user-driven targets (as listed above) are implemented in Makefile.inc0
|
||||
# and the private targets are in Makefile.inc1. These are kept separate
|
||||
# to help the bootstrap build from aout to elf format.
|
||||
# The user-driven targets (as listed above) are implemented in Makefile.inc1.
|
||||
#
|
||||
# If you want to build your system from source be sure that /usr/obj has
|
||||
# at least 400MB of diskspace available.
|
||||
@@ -65,6 +63,11 @@
|
||||
# release of 4.0. You have exactly one major release to move entirely
|
||||
# to elf.
|
||||
#
|
||||
# If TARGET_ARCH=arch (e.g. alpha) is specified you can
|
||||
# cross build world for other architectures using the buildworld target,
|
||||
# and once the world is built you can cross build a kernel using the
|
||||
# buildkernel target.
|
||||
#
|
||||
# ----------------------------------------------------------------------------
|
||||
#
|
||||
# Upgrading an i386 system from a.out to elf format
|
||||
@@ -93,11 +96,19 @@
|
||||
# Define the user-driven targets. These are listed here in alphabetical
|
||||
# order, but that's not important.
|
||||
#
|
||||
TGTS= afterdistribute all all-man buildkernel buildworld checkdpadd clean \
|
||||
cleandepend cleandir depend distribute everything hierarchy includes \
|
||||
install installcheck installkernel installmost installworld kernel \
|
||||
libraries lint maninstall mk most obj objlink regress \
|
||||
reinstallkernel rerelease tags update
|
||||
TGTS= all all-man buildkernel buildworld checkdpadd clean \
|
||||
cleandepend cleandir depend distribute distributeworld everything \
|
||||
hierarchy install installcheck installkernel \
|
||||
reinstallkernel installmost installworld libraries lint maninstall \
|
||||
mk most obj objlink regress rerelease tags update
|
||||
|
||||
BITGTS= files includes
|
||||
BITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
|
||||
|
||||
.ORDER: buildworld installworld
|
||||
.ORDER: buildworld distributeworld
|
||||
.ORDER: buildkernel installkernel
|
||||
.ORDER: buildkernel reinstallkernel
|
||||
|
||||
PATH= /sbin:/bin:/usr/sbin:/usr/bin
|
||||
MAKE= PATH=${PATH} make -m ${.CURDIR}/share/mk -f Makefile.inc1
|
||||
@@ -105,7 +116,7 @@ MAKE= PATH=${PATH} make -m ${.CURDIR}/share/mk -f Makefile.inc1
|
||||
#
|
||||
# Handle the user-driven targets, using the source relative mk files.
|
||||
#
|
||||
${TGTS}: upgrade_checks
|
||||
${TGTS} ${BITGTS}: upgrade_checks
|
||||
@cd ${.CURDIR}; \
|
||||
${MAKE} ${.TARGET}
|
||||
|
||||
@@ -144,6 +155,13 @@ world: upgrade_checks
|
||||
@printf ">>> ${OBJFORMAT} make world completed on `LC_ALL=C date`\n (started ${STARTTIME})\n"
|
||||
@echo "--------------------------------------------------------------"
|
||||
|
||||
#
|
||||
# kernel
|
||||
#
|
||||
# Short hand for `make buildkernel installkernel'
|
||||
#
|
||||
kernel: buildkernel installkernel
|
||||
|
||||
#
|
||||
# Perform a few tests to determine if the installed tools are adequate
|
||||
# for building the world. These are for older systems (prior to 2.2.5).
|
||||
@@ -154,15 +172,26 @@ world: upgrade_checks
|
||||
#
|
||||
upgrade_checks:
|
||||
@cd ${.CURDIR}; \
|
||||
if ! make -m ${.CURDIR}/share/mk test > /dev/null 2>&1; then \
|
||||
make make; \
|
||||
fi
|
||||
if ! make -m ${.CURDIR}/share/mk -Dnotdef test >/dev/null 2>&1; then \
|
||||
make make; \
|
||||
fi
|
||||
@cd ${.CURDIR}; \
|
||||
if make -V .CURDIR:C/.// 2>&1 >/dev/null | \
|
||||
grep -q "Unknown modifier 'C'"; then \
|
||||
make make; \
|
||||
fi
|
||||
|
||||
#
|
||||
# A simple test target used as part of the test to see if make supports
|
||||
# the -m argument.
|
||||
# the -m argument. Also test that make will only evaluate a conditional
|
||||
# as far as is necessary to determine its value.
|
||||
#
|
||||
test:
|
||||
.if defined(notdef)
|
||||
.undef notdef
|
||||
.if defined(notdef) && ${notdef:U}
|
||||
.endif
|
||||
.endif
|
||||
|
||||
#
|
||||
# Upgrade the installed make to the current version using the installed
|
||||
|
||||
+164
-217
@@ -76,6 +76,9 @@ SUBDIR+= libexec
|
||||
.if exists(${.CURDIR}/sbin)
|
||||
SUBDIR+= sbin
|
||||
.endif
|
||||
.if exists(${.CURDIR}/secure) && !defined(NOCRYPT) && !defined(NOSECURE)
|
||||
SUBDIR+= secure
|
||||
.endif
|
||||
.if exists(${.CURDIR}/share) && !defined(NOSHARE)
|
||||
SUBDIR+= share
|
||||
.endif
|
||||
@@ -88,9 +91,6 @@ SUBDIR+= usr.bin
|
||||
.if exists(${.CURDIR}/usr.sbin)
|
||||
SUBDIR+= usr.sbin
|
||||
.endif
|
||||
.if exists(${.CURDIR}/secure) && !defined(NOCRYPT) && !defined(NOSECURE)
|
||||
SUBDIR+= secure
|
||||
.endif
|
||||
|
||||
# etc must be last for "distribute" to work
|
||||
.if exists(${.CURDIR}/etc)
|
||||
@@ -107,6 +107,10 @@ SUBDIR+= ${_DIR}
|
||||
.endfor
|
||||
.endif
|
||||
|
||||
.if defined(SUBDIR_OVERRIDE)
|
||||
SUBDIR= ${SUBDIR_OVERRIDE}
|
||||
.endif
|
||||
|
||||
.if defined(NOCLEANDIR)
|
||||
CLEANDIR= clean cleandepend
|
||||
.else
|
||||
@@ -121,17 +125,21 @@ SUPFLAGS+= -h ${SUPHOST}
|
||||
|
||||
MAKEOBJDIRPREFIX?= /usr/obj
|
||||
TARGET_ARCH?= ${MACHINE_ARCH}
|
||||
.if ${TARGET_ARCH} == ${MACHINE_ARCH}
|
||||
TARGET?= ${MACHINE}
|
||||
.else
|
||||
TARGET?= ${TARGET_ARCH}
|
||||
.endif
|
||||
.if make(buildworld)
|
||||
BUILD_ARCH!= sysctl -n hw.machine_arch
|
||||
.if ${MACHINE_ARCH} != ${BUILD_ARCH}
|
||||
.error To cross-build, set TARGET_ARCH.
|
||||
.endif
|
||||
.endif
|
||||
.if ${MACHINE_ARCH} == ${TARGET_ARCH}
|
||||
.if ${MACHINE} == ${TARGET}
|
||||
OBJTREE= ${MAKEOBJDIRPREFIX}
|
||||
.else
|
||||
OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET_ARCH}
|
||||
OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}
|
||||
.endif
|
||||
WORLDTMP= ${OBJTREE}${.CURDIR}/${MACHINE_ARCH}
|
||||
# /usr/games added for fortune which depend on strfile
|
||||
@@ -179,7 +187,8 @@ BMAKEENV= MAKEOBJDIRPREFIX=${WORLDTMP} \
|
||||
DESTDIR= \
|
||||
INSTALL="sh ${.CURDIR}/tools/install.sh"
|
||||
BMAKE= ${BMAKEENV} ${MAKE} -f Makefile.inc1 -DBOOTSTRAPPING \
|
||||
-DNOHTML -DNOINFO -DNOMAN -DNOPIC -DNOPROFILE -DNOSHARED
|
||||
-DNOHTML -DNOINFO -DNOMAN -DNOPIC -DNOPROFILE -DNOSHARED \
|
||||
-DNO_WERROR
|
||||
|
||||
# build-tool stage
|
||||
TMAKEENV= MAKEOBJDIRPREFIX=${OBJTREE} \
|
||||
@@ -225,8 +234,8 @@ USRDIRS= usr/bin usr/lib/compat/aout usr/games usr/libdata/ldscripts \
|
||||
usr/share/groff_font/devutf8 \
|
||||
usr/share/tmac/mdoc usr/share/tmac/mm
|
||||
|
||||
INCDIRS= arpa g++/std isc objc protocols readline rpc rpcsvc openssl \
|
||||
security ss
|
||||
INCDIRS= arpa dev fs g++/std isc isofs libmilter objc openssl \
|
||||
protocols readline rpc rpcsvc security ufs
|
||||
|
||||
#
|
||||
# buildworld
|
||||
@@ -234,13 +243,17 @@ INCDIRS= arpa g++/std isc objc protocols readline rpc rpcsvc openssl \
|
||||
# Attempt to rebuild the entire system, with reasonable chance of
|
||||
# success, regardless of how old your existing system is.
|
||||
#
|
||||
buildworld:
|
||||
_worldtmp:
|
||||
@echo
|
||||
@echo "--------------------------------------------------------------"
|
||||
@echo ">>> Rebuilding the temporary build tree"
|
||||
@echo "--------------------------------------------------------------"
|
||||
.if !defined(NOCLEAN)
|
||||
rm -rf ${WORLDTMP}
|
||||
.else
|
||||
# XXX - These two can depend on any header file.
|
||||
rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
|
||||
rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
|
||||
.endif
|
||||
.for _dir in ${USRDIRS}
|
||||
mkdir -p ${WORLDTMP}/${_dir}
|
||||
@@ -249,11 +262,13 @@ buildworld:
|
||||
mkdir -p ${WORLDTMP}/usr/include/${_dir}
|
||||
.endfor
|
||||
ln -sf ${.CURDIR}/sys ${WORLDTMP}
|
||||
_bootstrap-tools:
|
||||
@echo
|
||||
@echo "--------------------------------------------------------------"
|
||||
@echo ">>> stage 1: bootstrap tools"
|
||||
@echo "--------------------------------------------------------------"
|
||||
cd ${.CURDIR}; ${BMAKE} bootstrap-tools
|
||||
_cleanobj:
|
||||
.if !defined(NOCLEAN)
|
||||
@echo
|
||||
@echo "--------------------------------------------------------------"
|
||||
@@ -261,47 +276,62 @@ buildworld:
|
||||
@echo "--------------------------------------------------------------"
|
||||
cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
|
||||
.endif
|
||||
_obj:
|
||||
@echo
|
||||
@echo "--------------------------------------------------------------"
|
||||
@echo ">>> stage 2: rebuilding the object tree"
|
||||
@echo "--------------------------------------------------------------"
|
||||
cd ${.CURDIR}; ${WMAKE} par-obj
|
||||
_build-tools:
|
||||
@echo
|
||||
@echo "--------------------------------------------------------------"
|
||||
@echo ">>> stage 2: build tools"
|
||||
@echo "--------------------------------------------------------------"
|
||||
cd ${.CURDIR}; ${TMAKE} build-tools
|
||||
_cross-tools:
|
||||
@echo
|
||||
@echo "--------------------------------------------------------------"
|
||||
@echo ">>> stage 3: cross tools"
|
||||
@echo "--------------------------------------------------------------"
|
||||
cd ${.CURDIR}; ${XMAKE} cross-tools
|
||||
_includes:
|
||||
@echo
|
||||
@echo "--------------------------------------------------------------"
|
||||
@echo ">>> stage 4: populating ${WORLDTMP}/usr/include"
|
||||
@echo "--------------------------------------------------------------"
|
||||
cd ${.CURDIR}; ${WMAKE} SHARED=copies includes
|
||||
cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
|
||||
_libraries:
|
||||
@echo
|
||||
@echo "--------------------------------------------------------------"
|
||||
@echo ">>> stage 4: building libraries"
|
||||
@echo "--------------------------------------------------------------"
|
||||
cd ${.CURDIR}; ${WMAKE} -DNOHTML -DNOINFO -DNOMAN -DNOFSCHG libraries
|
||||
_depend:
|
||||
@echo
|
||||
@echo "--------------------------------------------------------------"
|
||||
@echo ">>> stage 4: make dependencies"
|
||||
@echo "--------------------------------------------------------------"
|
||||
cd ${.CURDIR}; ${WMAKE} par-depend
|
||||
everything:
|
||||
@echo
|
||||
@echo "--------------------------------------------------------------"
|
||||
@echo ">>> stage 4: building everything.."
|
||||
@echo "--------------------------------------------------------------"
|
||||
cd ${.CURDIR}; ${WMAKE} all
|
||||
|
||||
everything:
|
||||
@echo "--------------------------------------------------------------"
|
||||
@echo ">>> Building everything.."
|
||||
@echo "--------------------------------------------------------------"
|
||||
cd ${.CURDIR}; ${WMAKE} all
|
||||
|
||||
WMAKE_TGTS=
|
||||
.if !defined(SUBDIR_OVERRIDE)
|
||||
WMAKE_TGTS+= _worldtmp _bootstrap-tools
|
||||
.endif
|
||||
WMAKE_TGTS+= _cleanobj _obj _build-tools
|
||||
.if !defined(SUBDIR_OVERRIDE)
|
||||
WMAKE_TGTS+= _cross-tools
|
||||
.endif
|
||||
WMAKE_TGTS+= _includes _libraries _depend everything
|
||||
|
||||
buildworld: ${WMAKE_TGTS}
|
||||
.ORDER: ${WMAKE_TGTS}
|
||||
|
||||
#
|
||||
# installcheck
|
||||
@@ -320,19 +350,23 @@ installcheck:
|
||||
fi
|
||||
.endif
|
||||
|
||||
#
|
||||
# distributeworld
|
||||
#
|
||||
# Distributes everything compiled by a `buildworld'.
|
||||
#
|
||||
# installworld
|
||||
#
|
||||
# Installs everything compiled by a 'buildworld'.
|
||||
#
|
||||
installworld: installcheck
|
||||
distributeworld installworld: installcheck
|
||||
mkdir -p ${INSTALLTMP}
|
||||
for prog in [ awk cat chflags chmod chown date echo egrep find grep \
|
||||
ln make makewhatis mtree mv perl rm sed sh sysctl \
|
||||
ln make makewhatis mtree mv perl pwd_mkdb rm sed sh sysctl \
|
||||
test true uname wc zic; do \
|
||||
cp `which $$prog` ${INSTALLTMP}; \
|
||||
done
|
||||
cd ${.CURDIR}; ${IMAKE} reinstall
|
||||
cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
|
||||
rm -rf ${INSTALLTMP}
|
||||
|
||||
#
|
||||
@@ -352,7 +386,7 @@ reinstall:
|
||||
@echo ">>> Installing everything.."
|
||||
@echo "--------------------------------------------------------------"
|
||||
cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
|
||||
.if !defined(NOMAN)
|
||||
.if !defined(NOMAN) && !defined(NO_MAKEDB_RUN)
|
||||
@echo
|
||||
@echo "--------------------------------------------------------------"
|
||||
@echo ">>> Rebuilding man page indices"
|
||||
@@ -360,14 +394,11 @@ reinstall:
|
||||
cd ${.CURDIR}/share/man; ${MAKE} makedb
|
||||
.endif
|
||||
|
||||
#
|
||||
# distribworld
|
||||
#
|
||||
# Front-end to distribute to make sure the search path contains
|
||||
# the object directory. Needed for miniperl.
|
||||
#
|
||||
distribworld:
|
||||
cd ${.CURDIR}; PATH=${TMPPATH} ${MAKE} -f Makefile.inc1 distribute
|
||||
redistribute:
|
||||
@echo "--------------------------------------------------------------"
|
||||
@echo ">>> Distributing everything.."
|
||||
@echo "--------------------------------------------------------------"
|
||||
cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
|
||||
|
||||
#
|
||||
# buildkernel and installkernel
|
||||
@@ -391,13 +422,6 @@ KERNCONF?= GENERIC
|
||||
.endif
|
||||
INSTKERNNAME?= kernel
|
||||
|
||||
# The only exotic TARGET_ARCH/TARGET combination valid at this
|
||||
# time is i386/pc98. In all other cases set TARGET equal to
|
||||
# TARGET_ARCH.
|
||||
.if ${TARGET_ARCH} != "i386" || ${TARGET} != "pc98"
|
||||
TARGET= ${TARGET_ARCH}
|
||||
.endif
|
||||
|
||||
KRNLSRCDIR= ${.CURDIR}/sys
|
||||
KRNLCONFDIR= ${KRNLSRCDIR}/${TARGET}/conf
|
||||
KRNLOBJDIR= ${OBJTREE}${KRNLSRCDIR}
|
||||
@@ -442,17 +466,16 @@ buildkernel:
|
||||
config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} ${_kernel}
|
||||
.endif
|
||||
.if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
|
||||
.if defined(MODULES_WITH_WORLD) || defined(NO_MODULES) || !exists(${KRNLSRCDIR}/modules)
|
||||
cd ${KRNLOBJDIR}/${_kernel}; \
|
||||
${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} clean
|
||||
.else
|
||||
${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} -DNO_MODULES clean
|
||||
.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KRNLSRCDIR}/modules)
|
||||
cd ${KRNLOBJDIR}/${_kernel}; \
|
||||
${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} clean cleandir
|
||||
${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} cleandir
|
||||
.endif
|
||||
.endif
|
||||
cd ${KRNLOBJDIR}/${_kernel}; \
|
||||
MAKESRCPATH=${KRNLSRCDIR}/dev/aic7xxx/aicasm \
|
||||
${MAKE} -f ${KRNLSRCDIR}/dev/aic7xxx/aicasm/Makefile
|
||||
MAKESRCPATH=${KRNLSRCDIR}/dev/aic7xxx/aicasm \
|
||||
${MAKE} -DBOOTSTRAPPING -f ${KRNLSRCDIR}/dev/aic7xxx/aicasm/Makefile
|
||||
.if !defined(NO_KERNELDEPEND)
|
||||
cd ${KRNLOBJDIR}/${_kernel}; \
|
||||
${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} depend
|
||||
@@ -469,19 +492,9 @@ buildkernel:
|
||||
#
|
||||
# Install the kernel defined by INSTALLKERNEL
|
||||
#
|
||||
installkernel:
|
||||
installkernel reinstallkernel:
|
||||
cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
|
||||
${CROSSENV} ${MAKE} KERNEL=${INSTKERNNAME} install
|
||||
reinstallkernel:
|
||||
cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
|
||||
${CROSSENV} ${MAKE} KERNEL=${INSTKERNNAME} reinstall
|
||||
|
||||
#
|
||||
# kernel
|
||||
#
|
||||
# Short hand for `make buildkernel installkernel'
|
||||
#
|
||||
kernel: buildkernel installkernel
|
||||
${CROSSENV} ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel$//}
|
||||
|
||||
#
|
||||
# update
|
||||
@@ -526,14 +539,9 @@ most:
|
||||
@echo "--------------------------------------------------------------"
|
||||
@echo ">>> Building programs only"
|
||||
@echo "--------------------------------------------------------------"
|
||||
cd ${.CURDIR}/bin; ${MAKE} all
|
||||
cd ${.CURDIR}/sbin; ${MAKE} all
|
||||
cd ${.CURDIR}/libexec; ${MAKE} all
|
||||
cd ${.CURDIR}/usr.bin; ${MAKE} all
|
||||
cd ${.CURDIR}/usr.sbin; ${MAKE} all
|
||||
cd ${.CURDIR}/gnu/libexec; ${MAKE} all
|
||||
cd ${.CURDIR}/gnu/usr.bin; ${MAKE} all
|
||||
cd ${.CURDIR}/gnu/usr.sbin; ${MAKE} all
|
||||
.for _dir in bin sbin libexec usr.bin usr.sbin gnu/libexec gnu/usr.bin gnu/usr.sbin
|
||||
cd ${.CURDIR}/${_dir}; ${MAKE} DIRPRFX=${_dir}/ all
|
||||
.endfor
|
||||
|
||||
#
|
||||
# installmost
|
||||
@@ -545,14 +553,9 @@ installmost:
|
||||
@echo "--------------------------------------------------------------"
|
||||
@echo ">>> Installing programs only"
|
||||
@echo "--------------------------------------------------------------"
|
||||
cd ${.CURDIR}/bin; ${MAKE} install
|
||||
cd ${.CURDIR}/sbin; ${MAKE} install
|
||||
cd ${.CURDIR}/libexec; ${MAKE} install
|
||||
cd ${.CURDIR}/usr.bin; ${MAKE} install
|
||||
cd ${.CURDIR}/usr.sbin; ${MAKE} install
|
||||
cd ${.CURDIR}/gnu/libexec; ${MAKE} install
|
||||
cd ${.CURDIR}/gnu/usr.bin; ${MAKE} install
|
||||
cd ${.CURDIR}/gnu/usr.sbin; ${MAKE} install
|
||||
.for _dir in bin sbin libexec usr.bin usr.sbin gnu/libexec gnu/usr.bin gnu/usr.sbin
|
||||
cd ${.CURDIR}/${_dir}; ${MAKE} DIRPRFX=${_dir}/ install
|
||||
.endfor
|
||||
|
||||
#
|
||||
# ------------------------------------------------------------------------
|
||||
@@ -573,14 +576,16 @@ _strfile= games/fortune/strfile
|
||||
.endif
|
||||
|
||||
bootstrap-tools:
|
||||
.for _tool in ${_strfile} usr.bin/yacc usr.bin/colldef usr.bin/xinstall \
|
||||
.for _tool in ${_strfile} usr.bin/yacc usr.bin/colldef \
|
||||
usr.bin/uudecode usr.bin/xinstall \
|
||||
usr.sbin/config \
|
||||
gnu/usr.bin/gperf gnu/usr.bin/groff gnu/usr.bin/texinfo
|
||||
cd ${.CURDIR}/${_tool}; \
|
||||
${MAKE} obj; \
|
||||
${MAKE} depend; \
|
||||
${MAKE} all; \
|
||||
${MAKE} DESTDIR=${MAKEOBJDIRPREFIX} install
|
||||
${ECHODIR} "===> ${_tool}"; \
|
||||
cd ${.CURDIR}/${_tool}; \
|
||||
${MAKE} DIRPRFX=${_tool}/ obj; \
|
||||
${MAKE} DIRPRFX=${_tool}/ depend; \
|
||||
${MAKE} DIRPRFX=${_tool}/ all; \
|
||||
${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
|
||||
.endfor
|
||||
|
||||
#
|
||||
@@ -609,13 +614,20 @@ _libroken4= kerberosIV/lib/libroken
|
||||
|
||||
.if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
|
||||
!defined(NOCRYPT) && defined(MAKE_KERBEROS5)
|
||||
_libkrb5= kerberos5/lib/libasn1 kerberos5/lib/libhdb kerberos5/lib/libsl
|
||||
_libkrb5= kerberos5/lib/libroken kerberos5/lib/libvers \
|
||||
kerberos5/lib/libasn1 kerberos5/lib/libhdb kerberos5/lib/libsl
|
||||
.endif
|
||||
|
||||
.if defined(RELEASEDIR)
|
||||
_sysinstall= release/sysinstall
|
||||
.endif
|
||||
|
||||
build-tools:
|
||||
.for _tool in bin/csh bin/sh ${_games} gnu/usr.bin/cc/cc_tools ${_fortran} \
|
||||
${_perl} ${_libroken4} ${_libkrb5} lib/libncurses ${_share} usr.bin/file
|
||||
cd ${.CURDIR}/${_tool}; ${MAKE} build-tools
|
||||
${_perl} ${_libroken4} ${_libkrb5} lib/libncurses ${_share} \
|
||||
usr.bin/awk usr.bin/file ${_sysinstall}
|
||||
${ECHODIR} "===> ${_tool}"; \
|
||||
cd ${.CURDIR}/${_tool}; ${MAKE} DIRPRFX=${_tool}/ build-tools
|
||||
.endfor
|
||||
|
||||
#
|
||||
@@ -630,13 +642,15 @@ _btxld= usr.sbin/btxld
|
||||
.endif
|
||||
|
||||
cross-tools:
|
||||
.for _tool in ${_btxld} ${_elf2exe} usr.bin/genassym \
|
||||
usr.bin/gensetdefs gnu/usr.bin/binutils usr.bin/objformat gnu/usr.bin/cc
|
||||
cd ${.CURDIR}/${_tool}; \
|
||||
${MAKE} obj; \
|
||||
${MAKE} depend; \
|
||||
${MAKE} all; \
|
||||
${MAKE} DESTDIR=${MAKEOBJDIRPREFIX} install
|
||||
.for _tool in ${_btxld} ${_elf2exe} usr.bin/genassym usr.bin/gensetdefs \
|
||||
gnu/usr.bin/binutils usr.bin/objformat usr.sbin/crunch/crunchide \
|
||||
gnu/usr.bin/cc
|
||||
${ECHODIR} "===> ${_tool}"; \
|
||||
cd ${.CURDIR}/${_tool}; \
|
||||
${MAKE} DIRPRFX=${_tool}/ obj; \
|
||||
${MAKE} DIRPRFX=${_tool}/ depend; \
|
||||
${MAKE} DIRPRFX=${_tool}/ all; \
|
||||
${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
|
||||
.endfor
|
||||
|
||||
#
|
||||
@@ -645,163 +659,96 @@ cross-tools:
|
||||
hierarchy:
|
||||
cd ${.CURDIR}/etc; ${MAKE} distrib-dirs
|
||||
|
||||
#
|
||||
# includes - possibly generate and install the include files.
|
||||
#
|
||||
includes:
|
||||
cd ${.CURDIR}/include; ${MAKE} -B all install
|
||||
cd ${.CURDIR}/gnu/include; ${MAKE} install
|
||||
cd ${.CURDIR}/gnu/lib/libmp; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/gnu/lib/libobjc; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/gnu/lib/libreadline/readline; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/gnu/lib/libregex; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/gnu/lib/libstdc++; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/gnu/lib/libdialog; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/gnu/lib/libgmp; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/gnu/usr.bin/cc/cc1plus; ${MAKE} beforeinstall
|
||||
.if exists(${.CURDIR}/secure) && !defined(NOCRYPT) && !defined(NOSECURE)
|
||||
.if exists(${.CURDIR}/secure/lib/libcrypto)
|
||||
cd ${.CURDIR}/secure/lib/libcrypto; ${MAKE} beforeinstall
|
||||
.endif
|
||||
.if exists(${.CURDIR}/secure/lib/libssl)
|
||||
cd ${.CURDIR}/secure/lib/libssl; ${MAKE} beforeinstall
|
||||
.endif
|
||||
.endif
|
||||
.if exists(${.CURDIR}/kerberosIV) && !defined(NOCRYPT) && \
|
||||
defined(MAKE_KERBEROS4)
|
||||
cd ${.CURDIR}/kerberosIV/lib/libacl; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/kerberosIV/lib/libkadm; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/kerberosIV/lib/libkafs; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/kerberosIV/lib/libkdb; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/kerberosIV/lib/libkrb; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/kerberosIV/lib/libtelnet; ${MAKE} beforeinstall
|
||||
.elif exists(${.CURDIR}/secure) && !defined(NOCRYPT) && !defined(NOSECURE)
|
||||
cd ${.CURDIR}/secure/lib/libtelnet; ${MAKE} beforeinstall
|
||||
.else
|
||||
cd ${.CURDIR}/lib/libtelnet; ${MAKE} beforeinstall
|
||||
.endif
|
||||
.if exists(${.CURDIR}/kerberos5) && !defined(NOCRYPT) && \
|
||||
defined(MAKE_KERBEROS5)
|
||||
cd ${.CURDIR}/kerberos5/lib/libasn1; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/kerberos5/lib/libhdb; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/kerberos5/lib/libkadm5clnt; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/kerberos5/lib/libkadm5srv; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/kerberos5/lib/libkafs5; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/kerberos5/lib/libkrb5; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/kerberos5/lib/libsl; ${MAKE} beforeinstall
|
||||
.endif
|
||||
.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH})
|
||||
cd ${.CURDIR}/lib/csu/${MACHINE_ARCH}; ${MAKE} beforeinstall
|
||||
.endif
|
||||
cd ${.CURDIR}/gnu/lib/csu; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libalias; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libatm; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libdevstat; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libc; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libcalendar; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libcam; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libdisk; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libedit; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libfetch; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libftpio; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libkvm; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libmd; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/msun; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libncp; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libncurses; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libnetgraph; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libopie; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libpam/libpam; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libpcap; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libradius; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/librpcsvc; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libskey; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libstand; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libtacplus; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libcom_err; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libusbhid; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libutil; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libvgl; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libwrap; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libz; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/usr.bin/lex; ${MAKE} beforeinstall
|
||||
|
||||
#
|
||||
# libraries - build all libraries, and install them under ${DESTDIR}.
|
||||
#
|
||||
# The following dependencies exist between the libraries:
|
||||
# The list of libraries with dependents (${_prebuild_libs}) and their
|
||||
# interdependencies (__L) are built automatically by the
|
||||
# ${.CURDIR}/tools/make_libdeps.sh script.
|
||||
#
|
||||
# lib*: csu libgcc_pic
|
||||
# libatm: libmd
|
||||
# libcrypt: libmd
|
||||
# libdialog: libncurses
|
||||
# libedit: libncurses
|
||||
# libg++: msun
|
||||
# libkrb: libcrypt
|
||||
# libopie: libmd
|
||||
# libpam: libcom_err libcrypt libcrypto libkrb libopie libradius \
|
||||
# libskey libtacplus libutil libz libssh
|
||||
# libradius: libmd
|
||||
# libreadline: libncurses
|
||||
# libskey: libcrypt libmd
|
||||
# libssh: libcrypto libz
|
||||
# libstc++: msun
|
||||
# libtacplus: libmd
|
||||
libraries:
|
||||
cd ${.CURDIR}; \
|
||||
${MAKE} -f Makefile.inc1 _startup_libs; \
|
||||
${MAKE} -f Makefile.inc1 _prebuild_libs; \
|
||||
${MAKE} -f Makefile.inc1 _generic_libs;
|
||||
|
||||
# These dependencies are not automatically generated:
|
||||
#
|
||||
# Across directories this comes down to (rougly):
|
||||
# gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
|
||||
# shared libraries for ELF.
|
||||
#
|
||||
# gnu/lib: lib/msun lib/libncurses
|
||||
# kerberosIV/lib kerberos5/lib: lib/libcrypt
|
||||
# lib/libpam: secure/lib/libcrypto kerberosIV/lib/libkrb \
|
||||
# secure/lib/libssh lib/libz
|
||||
# secure/lib: secure/lib/libcrypto lib/libmd lib/libz
|
||||
#
|
||||
.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}.pcc)
|
||||
_csu= lib/csu/${MACHINE_ARCH}.pcc
|
||||
.elif ${MACHINE_ARCH} == "i386" && ${OBJFORMAT} == "elf"
|
||||
_csu= lib/csu/i386-elf
|
||||
_startup_libs= gnu/lib/csu gnu/lib/libgcc
|
||||
.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-${OBJFORMAT})
|
||||
_startup_libs+= lib/csu/${MACHINE_ARCH}-${OBJFORMAT}
|
||||
.else
|
||||
_csu= lib/csu/${MACHINE_ARCH}
|
||||
_startup_libs+= lib/csu/${MACHINE_ARCH}
|
||||
.endif
|
||||
|
||||
.if exists(${.CURDIR}/secure) && !defined(NOCRYPT) && !defined(NOSECURE)
|
||||
_secure_lib= secure/lib
|
||||
.if exists(${.CURDIR}/secure/lib/libcrypto)
|
||||
_libcrypto= secure/lib/libcrypto
|
||||
.endif
|
||||
.endif
|
||||
_prebuild_libs=
|
||||
|
||||
.if !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
|
||||
_kerberosIV_lib= kerberosIV/lib
|
||||
_generic_libs= gnu/lib
|
||||
|
||||
.if !defined(NOPERL)
|
||||
_generic_libs+= gnu/usr.bin/perl/libperl
|
||||
.endif
|
||||
|
||||
.if !defined(NOCRYPT) && defined(MAKE_KERBEROS5)
|
||||
_kerberos5_lib= kerberos5/lib
|
||||
_prebuild_libs+= kerberos5/lib/libasn1
|
||||
_prebuild_libs+= kerberos5/lib/libgssapi
|
||||
_prebuild_libs+= kerberos5/lib/libkrb5
|
||||
_prebuild_libs+= kerberos5/lib/libroken
|
||||
_generic_libs+= kerberos5/lib
|
||||
.endif
|
||||
|
||||
.if !defined(NOPERL)
|
||||
_libperl= gnu/usr.bin/perl/libperl
|
||||
.if !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
|
||||
_prebuild_libs+= kerberosIV/lib/libkrb
|
||||
kerberosIV/lib/libkrb__L: lib/libcrypt__L
|
||||
_generic_libs+= kerberosIV/lib
|
||||
.endif
|
||||
|
||||
_prebuild_libs+= lib/libcom_err lib/libcrypt lib/libmd \
|
||||
lib/libncurses lib/libopie lib/libradius lib/libskey \
|
||||
lib/libtacplus lib/libutil \
|
||||
lib/libz lib/msun
|
||||
|
||||
lib/libopie__L lib/libradius__L lib/libtacplus__L: lib/libmd__L
|
||||
lib/libskey__L: lib/libcrypt__L lib/libmd__L
|
||||
|
||||
_generic_libs+= lib
|
||||
|
||||
.if !defined(NOCRYPT) && !defined(NOSECURE)
|
||||
.if !defined(NO_OPENSSL)
|
||||
_prebuild_libs+= secure/lib/libcrypto
|
||||
.if !defined(NO_OPENSSH)
|
||||
_prebuild_libs+= secure/lib/libssh
|
||||
secure/lib/libssh__L: secure/lib/libcrypto__L lib/libz__L
|
||||
.endif
|
||||
.endif
|
||||
_generic_libs+= secure/lib
|
||||
.endif
|
||||
|
||||
_generic_libs+= usr.bin/lex/lib
|
||||
|
||||
.if ${MACHINE_ARCH} == "i386"
|
||||
_libkeycap= usr.sbin/pcvt/keycap
|
||||
_generic_libs+= usr.sbin/pcvt/keycap
|
||||
.endif
|
||||
|
||||
libraries:
|
||||
.for _lib in ${_csu} gnu/lib/csu gnu/lib/libgcc lib/libmd lib/libcrypt \
|
||||
lib/libz ${_libcrypto} ${_secure_lib} ${_kerberosIV_lib} \
|
||||
${_kerberos5_lib} lib/libcom_err lib/msun lib/libncurses \
|
||||
lib/libopie lib/libradius lib/libskey lib/libtacplus lib/libutil \
|
||||
lib gnu/lib ${_libperl} usr.bin/lex/lib ${_libkeycap}
|
||||
.for _lib in ${_startup_libs} ${_prebuild_libs} ${_generic_libs}
|
||||
${_lib}__L: .PHONY
|
||||
.if exists(${.CURDIR}/${_lib})
|
||||
cd ${.CURDIR}/${_lib}; \
|
||||
${MAKE} depend; \
|
||||
${MAKE} all; \
|
||||
${MAKE} install
|
||||
${ECHODIR} "===> ${_lib}"; \
|
||||
cd ${.CURDIR}/${_lib}; \
|
||||
${MAKE} DIRPRFX=${_lib}/ depend; \
|
||||
${MAKE} DIRPRFX=${_lib}/ all; \
|
||||
${MAKE} DIRPRFX=${_lib}/ install
|
||||
.endif
|
||||
.endfor
|
||||
|
||||
.for __target in clean cleandepend cleandir depend obj
|
||||
_startup_libs: ${_startup_libs:S/$/__L/}
|
||||
_prebuild_libs: ${_prebuild_libs:S/$/__L/}
|
||||
_generic_libs: ${_generic_libs:S/$/__L/}
|
||||
|
||||
.for __target in clean cleandepend cleandir depend includes obj
|
||||
.for entry in ${SUBDIR}
|
||||
${entry}.${__target}__D: .PHONY
|
||||
@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
|
||||
|
||||
@@ -8,6 +8,20 @@ A reverse chronology since 4.0 was released is included, followed by
|
||||
the common items quick how-tos, followed by entries for versions of
|
||||
-current prior to 4.0 Release.
|
||||
|
||||
20020807:
|
||||
COPY is being deprecated. The 20020703 change was reverted, as
|
||||
it causes far more pain than was expected, and to always compare
|
||||
before installing, please use INSTALL="install -C" again. The
|
||||
-C option is now silently ignored when used with the -d option.
|
||||
|
||||
20020704:
|
||||
OpenSSH has been upgraded to 3.4p1 and fully PAMified. Note
|
||||
that the protocol version now defaults to 2 rather than 1,
|
||||
which means clients might get warnings about unknown host keys
|
||||
their hostfiles only list the ssh1 RSA key. See ssh_config(5)
|
||||
and sshd_config(5) for more information on configuring ssh and
|
||||
sshd.
|
||||
|
||||
20020703:
|
||||
The install(1) utility no longer allows the -d and -C options
|
||||
to be specified together. "INSTALL=install -C" in make.conf
|
||||
@@ -45,7 +59,9 @@ the common items quick how-tos, followed by entries for versions of
|
||||
are very benign, some of them have created a bit of a stir.
|
||||
Use the new version of mergemaster to update /etc, either by
|
||||
updating /etc after installworld, or by doing:
|
||||
cd /usr/src/usr.sbin/mergemaster; make all install [clean]
|
||||
cd /usr/src/usr.sbin/mergemaster; make all install
|
||||
before you run installworld.
|
||||
|
||||
Then use the new -C option to double-check your rc.conf settings.
|
||||
You should also double-check settings in [defaults/]rc.conf,
|
||||
syslog.conf, newsyslog.conf, and anything else important
|
||||
@@ -81,7 +97,7 @@ the common items quick how-tos, followed by entries for versions of
|
||||
'mergemaster -p' will do this. You may need to install
|
||||
mergemaster before this will work if you are updating from a
|
||||
very old version of stable. This can be done with:
|
||||
cd /usr/src/usr.sbin/mergemaster; make all install [clean]
|
||||
cd /usr/src/usr.sbin/mergemaster; make all install
|
||||
|
||||
20020325:
|
||||
sendmail 8.12.2 has been imported. The sendmail binary is no
|
||||
|
||||
+19
-19
@@ -83,19 +83,19 @@ Do not display a diagnostic message if
|
||||
.Nm
|
||||
could not modify the mode for
|
||||
.Va file .
|
||||
.It Fl h
|
||||
If the file is a symbolic link, change the mode of the link itself
|
||||
rather than the file that the link points to.
|
||||
.It Fl v
|
||||
Cause
|
||||
.Nm
|
||||
to be verbose, showing files as the mode is modified.
|
||||
to be verbose, showing filenames as the mode is modified.
|
||||
If the
|
||||
.Fl v
|
||||
flag is specified more than once, the old and new modes of the file
|
||||
will also be printed, in both octal and symbolic notation.
|
||||
.El
|
||||
.Pp
|
||||
Symbolic links do not have modes, so unless the
|
||||
.Fl H
|
||||
or
|
||||
.Fl L
|
||||
option is set,
|
||||
.Nm
|
||||
on a symbolic link always succeeds and has no effect.
|
||||
The
|
||||
.Fl H ,
|
||||
.Fl L
|
||||
@@ -130,37 +130,37 @@ and the
|
||||
option to
|
||||
.Xr mount 8 .
|
||||
.It Li 2000
|
||||
(the set-group-ID-on-execution bit) Executable files with this bit set
|
||||
(the set-group-ID-on-execution bit) Executable files with this bit set
|
||||
will run with effective gid set to the gid of the file owner.
|
||||
.It Li 1000
|
||||
(the sticky bit)
|
||||
When set on a directory, unprivileged users can delete and rename
|
||||
only those files in the directory that are owned by them, regardless of
|
||||
the permissions on the directory. Under
|
||||
.Fx ,
|
||||
the sticky bit is
|
||||
ignored for executable files and may only be set for directories (see
|
||||
.Xr sticky 8 ) .
|
||||
See
|
||||
.Xr chmod 2
|
||||
and
|
||||
.Xr sticky 8 .
|
||||
.It Li 0400
|
||||
Allow read by owner.
|
||||
.It Li 0200
|
||||
Allow write by owner.
|
||||
.It Li 0100
|
||||
For files, allow execution by owner. For directories, allow the owner to
|
||||
For files, allow execution by owner.
|
||||
For directories, allow the owner to
|
||||
search in the directory.
|
||||
.It Li 0040
|
||||
Allow read by group members.
|
||||
.It Li 0020
|
||||
Allow write by group members.
|
||||
.It Li 0010
|
||||
For files, allow execution by group members. For directories, allow
|
||||
For files, allow execution by group members.
|
||||
For directories, allow
|
||||
group members to search in the directory.
|
||||
.It Li 0004
|
||||
Allow read by others.
|
||||
.It Li 0002
|
||||
Allow write by others.
|
||||
.It Li 0001
|
||||
For files, allow execution by others. For directories allow others to
|
||||
For files, allow execution by others.
|
||||
For directories allow others to
|
||||
search in the directory.
|
||||
.El
|
||||
.Pp
|
||||
|
||||
+19
-4
@@ -35,7 +35,7 @@
|
||||
.\" @(#)cp.1 8.3 (Berkeley) 4/18/94
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd April 18, 1994
|
||||
.Dd August 10, 2002
|
||||
.Dt CP 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@@ -47,7 +47,7 @@
|
||||
.Fl R
|
||||
.Op Fl H | Fl L | Fl P
|
||||
.Oc
|
||||
.Op Fl f | i
|
||||
.Op Fl f | i | n
|
||||
.Op Fl pv
|
||||
.Ar source_file target_file
|
||||
.Nm
|
||||
@@ -55,7 +55,7 @@
|
||||
.Fl R
|
||||
.Op Fl H | Fl L | Fl P
|
||||
.Oc
|
||||
.Op Fl f | i
|
||||
.Op Fl f | i | n
|
||||
.Op Fl pv
|
||||
.Ar source_file ... target_directory
|
||||
.Sh DESCRIPTION
|
||||
@@ -121,6 +121,8 @@ regardless of its permissions.
|
||||
.Fl f
|
||||
option overrides any previous
|
||||
.Fl i
|
||||
or
|
||||
.Fl n
|
||||
options.)
|
||||
.It Fl i
|
||||
Cause
|
||||
@@ -136,6 +138,17 @@ the file copy is attempted.
|
||||
.Fl i
|
||||
option overrides any previous
|
||||
.Fl f
|
||||
or
|
||||
.Fl n
|
||||
options.)
|
||||
.It Fl n
|
||||
Do not overwrite an existing file.
|
||||
(The
|
||||
.Fl n
|
||||
option overrides any previous
|
||||
.Fl f
|
||||
or
|
||||
.Fl i
|
||||
options.)
|
||||
.It Fl p
|
||||
Cause
|
||||
@@ -226,7 +239,9 @@ or fifo's.
|
||||
.Pp
|
||||
The
|
||||
.Fl v
|
||||
option is non-standard and its use in scripts is not recommended.
|
||||
and
|
||||
.Fl n
|
||||
options are non-standard and their use in scripts is not recommended.
|
||||
.Sh SEE ALSO
|
||||
.Xr mv 1 ,
|
||||
.Xr rcp 1 ,
|
||||
|
||||
+12
-7
@@ -84,7 +84,7 @@ static const char rcsid[] =
|
||||
|
||||
PATH_T to = { to.p_path, "", "" };
|
||||
|
||||
int Rflag, iflag, pflag, rflag, fflag, vflag;
|
||||
int Rflag, fflag, iflag, nflag, pflag, rflag, vflag;
|
||||
|
||||
enum op { FILE_TO_FILE, FILE_TO_DIR, DIR_TO_DNE };
|
||||
|
||||
@@ -102,7 +102,7 @@ main(argc, argv)
|
||||
char *target;
|
||||
|
||||
Hflag = Lflag = Pflag = 0;
|
||||
while ((ch = getopt(argc, argv, "HLPRfiprv")) != -1)
|
||||
while ((ch = getopt(argc, argv, "HLPRfinprv")) != -1)
|
||||
switch (ch) {
|
||||
case 'H':
|
||||
Hflag = 1;
|
||||
@@ -121,11 +121,15 @@ main(argc, argv)
|
||||
break;
|
||||
case 'f':
|
||||
fflag = 1;
|
||||
iflag = 0;
|
||||
iflag = nflag = 0;
|
||||
break;
|
||||
case 'i':
|
||||
iflag = 1;
|
||||
fflag = 0;
|
||||
fflag = nflag = 0;
|
||||
break;
|
||||
case 'n':
|
||||
nflag = 1;
|
||||
fflag = iflag = 0;
|
||||
break;
|
||||
case 'p':
|
||||
pflag = 1;
|
||||
@@ -346,9 +350,10 @@ copy(argv, type, fts_options)
|
||||
* honour setuid, setgid and sticky bits, but we
|
||||
* normally want to preserve them on directories.
|
||||
*/
|
||||
if (pflag)
|
||||
rval = setfile(curr->fts_statp, 0);
|
||||
else {
|
||||
if (pflag) {
|
||||
if (setfile(curr->fts_statp, 0))
|
||||
rval = 1;
|
||||
} else {
|
||||
mode = curr->fts_statp->st_mode;
|
||||
if ((mode & (S_ISUID | S_ISGID | S_ISTXT)) ||
|
||||
((mode | S_IRWXU) & mask) != (mode & mask))
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ typedef struct {
|
||||
} PATH_T;
|
||||
|
||||
extern PATH_T to;
|
||||
extern int iflag, pflag, fflag, vflag;
|
||||
extern int fflag, iflag, nflag, pflag, vflag;
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
|
||||
+7
-3
@@ -88,7 +88,11 @@ copy_file(entp, dne)
|
||||
*/
|
||||
if (!dne) {
|
||||
#define YESNO "(y/n [n]) "
|
||||
if (iflag) {
|
||||
if (nflag) {
|
||||
if (vflag)
|
||||
printf("%s not overwritten\n", to.p_path);
|
||||
return (0);
|
||||
} else if (iflag) {
|
||||
(void)fprintf(stderr, "overwrite %s? %s",
|
||||
to.p_path, YESNO);
|
||||
checkch = ch = getchar();
|
||||
@@ -312,7 +316,7 @@ usage()
|
||||
{
|
||||
|
||||
(void)fprintf(stderr, "%s\n%s\n",
|
||||
"usage: cp [-R [-H | -L | -P]] [-f | -i] [-pv] src target",
|
||||
" cp [-R [-H | -L | -P]] [-f | -i] [-pv] src1 ... srcN directory");
|
||||
"usage: cp [-R [-H | -L | -P]] [-f | -i | -n] [-pv] src target",
|
||||
" cp [-R [-H | -L | -P]] [-f | -i | -n] [-pv] src1 ... srcN directory");
|
||||
exit(EX_USAGE);
|
||||
}
|
||||
@@ -13,5 +13,3 @@ CLEANFILES+= tcsh.cat tcsh.msg
|
||||
all: tcsh.cat
|
||||
|
||||
tcsh.cat: tcsh.msg
|
||||
|
||||
distribute:
|
||||
@@ -10,7 +10,7 @@ tcsh.msg: set[0-9]*
|
||||
${BASESRC}/${NL}/set[0-9][0-9] > ${.TARGET}
|
||||
|
||||
install:
|
||||
${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
tcsh.cat ${DESTDIR}${NLSDIR}/${DL}/tcsh.cat
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
@@ -11,7 +11,7 @@ tcsh.msg: set[0-9]*
|
||||
${BASESRC}/${NL}/set[0-9][0-9] > ${.TARGET}
|
||||
|
||||
install:
|
||||
${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
tcsh.cat ${DESTDIR}${NLSDIR}/${DL}/tcsh.cat
|
||||
.for i in ${LL}
|
||||
ln -fs ../${DL}/tcsh.cat ${DESTDIR}${NLSDIR}/$i/tcsh.cat
|
||||
|
||||
@@ -13,7 +13,7 @@ tcsh.msg: set[0-9]*
|
||||
${BASESRC}/${NL}/set[0-9][0-9] > ${.TARGET}
|
||||
|
||||
install:
|
||||
${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
tcsh.cat ${DESTDIR}${NLSDIR}/${DL}/tcsh.cat
|
||||
.for i in ${LL}
|
||||
ln -fs ../${DL}/tcsh.cat ${DESTDIR}${NLSDIR}/$i/tcsh.cat
|
||||
|
||||
@@ -12,7 +12,7 @@ tcsh.msg: set[0-9]*
|
||||
${BASESRC}/${NL}/set[0-9][0-9] > ${.TARGET}
|
||||
|
||||
install:
|
||||
${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
tcsh.cat ${DESTDIR}${NLSDIR}/${DL}/tcsh.cat
|
||||
.for i in ${LL}
|
||||
ln -fs ../${DL}/tcsh.cat ${DESTDIR}${NLSDIR}/$i/tcsh.cat
|
||||
|
||||
@@ -10,7 +10,7 @@ tcsh.msg: set[0-9]*
|
||||
${BASESRC}/${NL}/set[0-9][0-9] > ${.TARGET}
|
||||
|
||||
install:
|
||||
${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
tcsh.cat ${DESTDIR}${NLSDIR}/${DL}/tcsh.cat
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
@@ -11,7 +11,7 @@ tcsh.msg: set[0-9]*
|
||||
${BASESRC}/${NL}/set[0-9][0-9] > ${.TARGET}
|
||||
|
||||
install:
|
||||
${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
tcsh.cat ${DESTDIR}${NLSDIR}/${DL}/tcsh.cat
|
||||
.for i in ${LL}
|
||||
ln -fs ../${DL}/tcsh.cat ${DESTDIR}${NLSDIR}/$i/tcsh.cat
|
||||
|
||||
@@ -10,7 +10,7 @@ tcsh.msg: set[0-9]*
|
||||
${BASESRC}/${NL}/set[0-9][0-9] > ${.TARGET}
|
||||
|
||||
install:
|
||||
${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
tcsh.cat ${DESTDIR}${NLSDIR}/${DL}/tcsh.cat
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
@@ -10,7 +10,7 @@ tcsh.msg: set[0-9]*
|
||||
${BASESRC}/${NL}/set[0-9][0-9] > ${.TARGET}
|
||||
|
||||
install:
|
||||
${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
tcsh.cat ${DESTDIR}${NLSDIR}/${DL}/tcsh.cat
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
@@ -11,7 +11,7 @@ tcsh.msg: set[0-9]*
|
||||
${BASESRC}/${NL}/set[0-9][0-9] > ${.TARGET}
|
||||
|
||||
install:
|
||||
${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
tcsh.cat ${DESTDIR}${NLSDIR}/${DL}/tcsh.cat
|
||||
.for i in ${LL}
|
||||
ln -fs ../${DL}/tcsh.cat ${DESTDIR}${NLSDIR}/$i/tcsh.cat
|
||||
|
||||
@@ -10,7 +10,7 @@ tcsh.msg: set[0-9]*
|
||||
${BASESRC}/${NL}/set[0-9][0-9] > ${.TARGET}
|
||||
|
||||
install:
|
||||
${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
tcsh.cat ${DESTDIR}${NLSDIR}/${DL}/tcsh.cat
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
+1
-2
@@ -57,8 +57,7 @@ displays the number of complete and partial input and output blocks
|
||||
and truncated input records to the standard error output.
|
||||
.Pp
|
||||
The following operands are available:
|
||||
.\" XXX
|
||||
.Bl -tag -width of=file
|
||||
.Bl -tag -width ".Cm of Ns = Ns Ar file"
|
||||
.It Cm bs Ns = Ns Ar n
|
||||
Set both input and output block size to
|
||||
.Ar n
|
||||
|
||||
+126
-55
@@ -12,7 +12,6 @@
|
||||
.Op Fl sx
|
||||
.Op Fl p Ar string
|
||||
.Op Ar file
|
||||
.LP
|
||||
.Nm red
|
||||
.Op Fl
|
||||
.Op Fl sx
|
||||
@@ -32,7 +31,7 @@ mode, in which the only difference is that the editor restricts the
|
||||
use of filenames which start with
|
||||
.Ql \&!
|
||||
(interpreted as shell commands by
|
||||
.Nm ed )
|
||||
.Nm )
|
||||
or contain a
|
||||
.Ql \&/ .
|
||||
Note that editing outside of the current directory is only prohibited
|
||||
@@ -53,7 +52,7 @@ Changes are made to this copy and not directly to
|
||||
itself.
|
||||
Upon quitting
|
||||
.Nm ,
|
||||
any changes not explicitly saved with a
|
||||
any changes not explicitly saved with a
|
||||
.Em w
|
||||
command are lost.
|
||||
.Pp
|
||||
@@ -88,11 +87,13 @@ When an input command, such as
|
||||
.Em c
|
||||
(change), is given,
|
||||
.Nm
|
||||
enters input mode. This is the primary means
|
||||
enters input mode.
|
||||
This is the primary means
|
||||
of adding text to a file.
|
||||
In this mode, no commands are available;
|
||||
instead, the standard input is written
|
||||
directly to the editor buffer. Lines consist of text up to and
|
||||
directly to the editor buffer.
|
||||
Lines consist of text up to and
|
||||
including a
|
||||
.Em newline
|
||||
character.
|
||||
@@ -110,7 +111,8 @@ command deletes lines; the
|
||||
.Em m
|
||||
command moves lines, and so on.
|
||||
It is possible to modify only a portion of a line by means of replacement,
|
||||
as in the example above. However even here, the
|
||||
as in the example above.
|
||||
However even here, the
|
||||
.Em s
|
||||
command is applied to whole lines at a time.
|
||||
.Pp
|
||||
@@ -128,7 +130,8 @@ commands have the structure:
|
||||
.Sm on
|
||||
.Pp
|
||||
The address(es) indicate the line or range of lines to be affected by the
|
||||
command. If fewer addresses are given than the command accepts, then
|
||||
command.
|
||||
If fewer addresses are given than the command accepts, then
|
||||
default addresses are supplied.
|
||||
.Sh OPTIONS
|
||||
The following options are available:
|
||||
@@ -144,14 +147,17 @@ Prompt for an encryption key to be used in subsequent reads and writes
|
||||
.Em x
|
||||
command).
|
||||
.It Fl p Ar string
|
||||
Specify a command prompt. This may be toggled on and off with the
|
||||
Specify a command prompt.
|
||||
This may be toggled on and off with the
|
||||
.Em P
|
||||
command.
|
||||
.It Ar file
|
||||
Specify the name of a file to read. If
|
||||
Specify the name of a file to read.
|
||||
If
|
||||
.Ar file
|
||||
is prefixed with a
|
||||
bang (!), then it is interpreted as a shell command. In this case,
|
||||
bang (!), then it is interpreted as a shell command.
|
||||
In this case,
|
||||
what is read is
|
||||
the standard output of
|
||||
.Ar file
|
||||
@@ -171,13 +177,15 @@ utility maintains a
|
||||
.Em current address
|
||||
which is
|
||||
typically supplied to commands as the default address when none is specified.
|
||||
When a file is first read, the current address is set to the last line
|
||||
of the file. In general, the current address is set to the last line
|
||||
When a file is first read, the current address is set to the last line
|
||||
of the file.
|
||||
In general, the current address is set to the last line
|
||||
affected by a command.
|
||||
.Pp
|
||||
A line address is
|
||||
constructed from one of the bases in the list below, optionally followed
|
||||
by a numeric offset. The offset may include any combination
|
||||
by a numeric offset.
|
||||
The offset may include any combination
|
||||
of digits, operators (i.e.,
|
||||
.Em + ,
|
||||
.Em -
|
||||
@@ -197,8 +205,10 @@ and is legal wherever it makes sense.
|
||||
An address range is two addresses separated either by a comma or
|
||||
semi-colon.
|
||||
The value of the first address in a range cannot exceed the
|
||||
value of the second. If only one address is given in a range, then
|
||||
the second address is set to the given address. If an
|
||||
value of the second.
|
||||
If only one address is given in a range, then
|
||||
the second address is set to the given address.
|
||||
If an
|
||||
.Em n Ns -tuple
|
||||
of addresses is given where
|
||||
.Em "n\ >\ 2" ,
|
||||
@@ -208,7 +218,8 @@ the
|
||||
If only one address is expected, then the last address is used.
|
||||
.Pp
|
||||
Each address in a comma-delimited range is interpreted relative to the
|
||||
current address. In a semi-colon-delimited range, the first address is
|
||||
current address.
|
||||
In a semi-colon-delimited range, the first address is
|
||||
used to set the current address, and the second address is interpreted
|
||||
relative to the first.
|
||||
.Pp
|
||||
@@ -249,11 +260,13 @@ next line, where
|
||||
.Em n
|
||||
is a non-negative number.
|
||||
.It , or %
|
||||
The first through last lines in the buffer. This is equivalent to
|
||||
The first through last lines in the buffer.
|
||||
This is equivalent to
|
||||
the address range
|
||||
.Em 1,$ .
|
||||
.It ;
|
||||
The current through last lines in the buffer. This is equivalent to
|
||||
The current through last lines in the buffer.
|
||||
This is equivalent to
|
||||
the address range
|
||||
.Em .,$ .
|
||||
.It /re/
|
||||
@@ -296,7 +309,8 @@ command for selecting old text to be replaced with new.
|
||||
.Pp
|
||||
In addition to a specifying string literals, regular expressions can
|
||||
represent
|
||||
classes of strings. Strings thus represented are said to be matched
|
||||
classes of strings.
|
||||
Strings thus represented are said to be matched
|
||||
by the corresponding regular expression.
|
||||
If it is possible for a regular expression
|
||||
to match several strings in a line, then the left-most longest match is
|
||||
@@ -307,24 +321,43 @@ The following symbols are used in constructing regular expressions:
|
||||
.It c
|
||||
Any character
|
||||
.Em c
|
||||
not listed below, including `{', '}', `(', `)', `<' and `>',
|
||||
not listed below, including
|
||||
.Ql \&{ ,
|
||||
.Ql \&} ,
|
||||
.Ql \&( ,
|
||||
.Ql \&) ,
|
||||
.Ql <
|
||||
and
|
||||
.Ql > ,
|
||||
matches itself.
|
||||
.It Pf \e c
|
||||
Any backslash-escaped character
|
||||
.Em c ,
|
||||
except for `{', '}', `(', `)', `<' and `>',
|
||||
except for
|
||||
.Ql \&{ ,
|
||||
.Ql \&} ,
|
||||
.Ql \&( ,
|
||||
.Ql \&) ,
|
||||
.Ql <
|
||||
and
|
||||
.Ql > ,
|
||||
matches itself.
|
||||
.It .
|
||||
Match any single character.
|
||||
.It Op char-class
|
||||
Match any single character in
|
||||
.Em char-class .
|
||||
To include a `]'
|
||||
To include a
|
||||
.Ql \&]
|
||||
in
|
||||
.Em char-class ,
|
||||
it must be the first character.
|
||||
A range of characters may be specified by separating the end characters
|
||||
of the range with a `-', e.g., `a-z' specifies the lower case characters.
|
||||
of the range with a
|
||||
.Ql - ,
|
||||
e.g.,
|
||||
.Ql a-z
|
||||
specifies the lower case characters.
|
||||
The following literal expressions can also be used in
|
||||
.Em char-class
|
||||
to specify sets of characters:
|
||||
@@ -335,7 +368,9 @@ to specify sets of characters:
|
||||
.It [:blank:] Ta [:graph:] Ta [:punct:] Ta [:xdigit:]
|
||||
.El
|
||||
.Pp
|
||||
If `-' appears as the first or last
|
||||
If
|
||||
.Ql -
|
||||
appears as the first or last
|
||||
character of
|
||||
.Em char-class ,
|
||||
then it matches itself.
|
||||
@@ -402,21 +437,31 @@ where
|
||||
is a number in the range [1,9], expands to the text matched by the
|
||||
.Em n Ns th
|
||||
subexpression.
|
||||
For example, the regular expression `\e(.*\e)\e1' matches any string
|
||||
For example, the regular expression
|
||||
.Ql \e(.*\e)\e1
|
||||
matches any string
|
||||
consisting of identical adjacent substrings.
|
||||
Subexpressions are ordered relative to
|
||||
their left delimiter.
|
||||
.It *
|
||||
Match the single character regular expression or subexpression
|
||||
immediately preceding it zero or more times. If
|
||||
immediately preceding it zero or more times.
|
||||
If
|
||||
.Em *
|
||||
is the first
|
||||
character of a regular expression or subexpression, then it matches
|
||||
itself. The
|
||||
itself.
|
||||
The
|
||||
.Em *
|
||||
operator sometimes yields unexpected results.
|
||||
For example, the regular expression `b*' matches the beginning of
|
||||
the string `abbb' (as opposed to the substring `bbb'), since a null match
|
||||
For example, the regular expression
|
||||
.Ql b*
|
||||
matches the beginning of
|
||||
the string
|
||||
.Ql abbb
|
||||
(as opposed to the substring
|
||||
.Ql bbb ) ,
|
||||
since a null match
|
||||
is the only left-most match.
|
||||
.It \e{n,m\e} or \e{n,\e} or \e{n\e}
|
||||
Match the single character regular expression or subexpression
|
||||
@@ -464,7 +509,8 @@ and returning the editor to command mode.
|
||||
The
|
||||
.Nm
|
||||
utility
|
||||
recognizes the following commands. The commands are shown together with
|
||||
recognizes the following commands.
|
||||
The commands are shown together with
|
||||
the default address or address range supplied if none is
|
||||
specified (in parenthesis).
|
||||
.Bl -tag -width indent
|
||||
@@ -473,7 +519,8 @@ Append text to the buffer after the addressed line.
|
||||
Text is entered in input mode.
|
||||
The current address is set to last line entered.
|
||||
.It (.,.)c
|
||||
Change lines in the buffer. The addressed lines are deleted
|
||||
Change lines in the buffer.
|
||||
The addressed lines are deleted
|
||||
from the buffer, and text is appended in their place.
|
||||
Text is entered in input mode.
|
||||
The current address is set to last line entered.
|
||||
@@ -489,7 +536,7 @@ Edit
|
||||
and sets the default filename.
|
||||
If
|
||||
.Ar file
|
||||
is not specified, then the default filename is used.
|
||||
is not specified, then the default filename is used.
|
||||
Any lines in the buffer are deleted before
|
||||
the new file is read.
|
||||
The current address is set to the last line read.
|
||||
@@ -567,8 +614,11 @@ The format of
|
||||
.Ar command-list
|
||||
is the same as that of the
|
||||
.Em g
|
||||
command. A newline alone acts as a null command list.
|
||||
A single `&' repeats the last non-null command list.
|
||||
command.
|
||||
A newline alone acts as a null command list.
|
||||
A single
|
||||
.Ql &
|
||||
repeats the last non-null command list.
|
||||
.It H
|
||||
Toggle the printing of error explanations.
|
||||
By default, explanations are not printed.
|
||||
@@ -581,23 +631,26 @@ Insert text in the buffer before the current line.
|
||||
Text is entered in input mode.
|
||||
The current address is set to the last line entered.
|
||||
.It (.,.+1)j
|
||||
Join the addressed lines. The addressed lines are
|
||||
Join the addressed lines.
|
||||
The addressed lines are
|
||||
deleted from the buffer and replaced by a single
|
||||
line containing their joined text.
|
||||
The current address is set to the resultant line.
|
||||
.It (.)klc
|
||||
Mark a line with a lower case letter
|
||||
.Em lc .
|
||||
The line can then be addressed as
|
||||
The line can then be addressed as
|
||||
.Em 'lc
|
||||
(i.e., a single quote followed by
|
||||
.Em lc )
|
||||
in subsequent commands. The mark is not cleared until the line is
|
||||
in subsequent commands.
|
||||
The mark is not cleared until the line is
|
||||
deleted or otherwise modified.
|
||||
.It (.,.)l
|
||||
Print the addressed lines unambiguously.
|
||||
If a single line fills for than one screen (as might be the case
|
||||
when viewing a binary file, for instance), a `--More--'
|
||||
when viewing a binary file, for instance), a
|
||||
.Dq Li --More--
|
||||
prompt is printed on the last line.
|
||||
The
|
||||
.Nm
|
||||
@@ -606,7 +659,8 @@ before displaying the next screen.
|
||||
The current address is set to the last line
|
||||
printed.
|
||||
.It (.,.)m(.)
|
||||
Move lines in the buffer. The addressed lines are moved to after the
|
||||
Move lines in the buffer.
|
||||
The addressed lines are moved to after the
|
||||
right-hand destination address, which may be the address
|
||||
.Em 0
|
||||
(zero).
|
||||
@@ -614,7 +668,8 @@ The current address is set to the
|
||||
last line moved.
|
||||
.It (.,.)n
|
||||
Print the addressed lines along with
|
||||
their line numbers. The current address is set to the last line
|
||||
their line numbers.
|
||||
The current address is set to the last line
|
||||
printed.
|
||||
.It (.,.)p
|
||||
Print the addressed lines.
|
||||
@@ -639,10 +694,12 @@ except that unwritten changes are discarded without warning.
|
||||
.It ($)r Ar file
|
||||
Read
|
||||
.Ar file
|
||||
to after the addressed line. If
|
||||
to after the addressed line.
|
||||
If
|
||||
.Ar file
|
||||
is not specified, then the default
|
||||
filename is used. If there was no default filename prior to the command,
|
||||
filename is used.
|
||||
If there was no default filename prior to the command,
|
||||
then the default filename is set to
|
||||
.Ar file .
|
||||
Otherwise, the default filename is unchanged.
|
||||
@@ -692,7 +749,9 @@ affected is printed as though the print suffix
|
||||
.Em p
|
||||
were specified.
|
||||
.Pp
|
||||
An unescaped `&' in
|
||||
An unescaped
|
||||
.Ql &
|
||||
in
|
||||
.Ar replacement
|
||||
is replaced by the currently matched text.
|
||||
The character sequence
|
||||
@@ -704,7 +763,9 @@ is a number in the range [1,9], is replaced by the
|
||||
backreference expression of the matched text.
|
||||
If
|
||||
.Ar replacement
|
||||
consists of a single `%', then
|
||||
consists of a single
|
||||
.Ql % ,
|
||||
then
|
||||
.Ar replacement
|
||||
from the last substitution is used.
|
||||
Newlines may be embedded in
|
||||
@@ -779,7 +840,8 @@ Any previous contents of
|
||||
is lost without warning.
|
||||
If there is no default filename, then the default filename is set to
|
||||
.Ar file ,
|
||||
otherwise it is unchanged. If no filename is specified, then the default
|
||||
otherwise it is unchanged.
|
||||
If no filename is specified, then the default
|
||||
filename is used.
|
||||
The current address is unchanged.
|
||||
.It (1,$)wq Ar file
|
||||
@@ -804,15 +866,18 @@ command, expect that the previous contents of file is not clobbered.
|
||||
The current address is unchanged.
|
||||
.It x
|
||||
Prompt for an encryption key which is used in subsequent reads and
|
||||
writes. If a newline alone is entered as the key, then encryption is
|
||||
turned off. Otherwise, echoing is disabled while a key is read.
|
||||
writes.
|
||||
If a newline alone is entered as the key, then encryption is
|
||||
turned off.
|
||||
Otherwise, echoing is disabled while a key is read.
|
||||
Encryption/decryption is done using the
|
||||
.Xr bdes 1
|
||||
algorithm.
|
||||
.It Pf (.+1)z n
|
||||
Scroll
|
||||
.Ar n
|
||||
lines at a time starting at addressed line. If
|
||||
lines at a time starting at addressed line.
|
||||
If
|
||||
.Ar n
|
||||
is not specified, then the current window size is used.
|
||||
The current address is set to the last line printed.
|
||||
@@ -823,7 +888,9 @@ via
|
||||
.Xr sh 1 .
|
||||
If the first character of
|
||||
.Ar command
|
||||
is `!', then it is replaced by text of the
|
||||
is
|
||||
.Ql \&! ,
|
||||
then it is replaced by text of the
|
||||
previous
|
||||
.Ar !command .
|
||||
The
|
||||
@@ -834,7 +901,8 @@ for backslash (\\) escapes.
|
||||
However, an unescaped
|
||||
.Em %
|
||||
is replaced by the default filename.
|
||||
When the shell returns from execution, a `!'
|
||||
When the shell returns from execution, a
|
||||
.Ql \&!
|
||||
is printed to the standard output.
|
||||
The current line is unchanged.
|
||||
.It ($)=
|
||||
@@ -850,7 +918,7 @@ buffer file
|
||||
.It ed.hup
|
||||
the file to which
|
||||
.Nm
|
||||
attempts to write the buffer if the terminal hangs up
|
||||
attempts to write the buffer if the terminal hangs up
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr bdes 1 ,
|
||||
@@ -872,14 +940,15 @@ The
|
||||
.Nm
|
||||
utility processes
|
||||
.Ar file
|
||||
arguments for backslash escapes, i.e., in a filename,
|
||||
arguments for backslash escapes, i.e., in a filename,
|
||||
any characters preceded by a backslash (\\) are
|
||||
interpreted literally.
|
||||
.Pp
|
||||
If a text (non-binary) file is not terminated by a newline character,
|
||||
then
|
||||
.Nm
|
||||
appends one on reading/writing it. In the case of a binary file,
|
||||
appends one on reading/writing it.
|
||||
In the case of a binary file,
|
||||
.Nm
|
||||
does not append a newline on reading/writing.
|
||||
.Pp
|
||||
@@ -887,7 +956,9 @@ per line overhead: 4 ints
|
||||
.Sh DIAGNOSTICS
|
||||
When an error occurs,
|
||||
.Nm
|
||||
prints a `?' and either returns to command mode
|
||||
prints a
|
||||
.Ql \&?
|
||||
and either returns to command mode
|
||||
or exits if its input is from a script.
|
||||
An explanation of the last error can be
|
||||
printed with the
|
||||
@@ -896,7 +967,7 @@ printed with the
|
||||
.Pp
|
||||
Since the
|
||||
.Em g
|
||||
(global) command masks any errors from failed searches and substitutions,
|
||||
(global) command masks any errors from failed searches and substitutions,
|
||||
it can be used to perform conditional operations in scripts; e.g.,
|
||||
.Pp
|
||||
.Sm off
|
||||
|
||||
+25
-6
@@ -50,17 +50,19 @@
|
||||
.Fl l
|
||||
.Op Ar exit_status
|
||||
.Nm
|
||||
.Fl signal_name
|
||||
.Fl Ar signal_name
|
||||
.Ar pid
|
||||
\&...
|
||||
.Nm
|
||||
.Fl signal_number
|
||||
.Fl Ar signal_number
|
||||
.Ar pid
|
||||
\&...
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility sends a signal to the processes specified by the pid operand(s).
|
||||
utility sends a signal to the processes specified by the
|
||||
.Ar pid
|
||||
operand(s).
|
||||
.Pp
|
||||
Only the super-user may send signals to other users' processes.
|
||||
.Pp
|
||||
@@ -75,11 +77,11 @@ default
|
||||
If no operand is given, list the signal names; otherwise, write
|
||||
the signal name corresponding to
|
||||
.Ar exit_status .
|
||||
.It Fl signal_name
|
||||
.It Fl Ar signal_name
|
||||
A symbolic signal name specifying the signal to be sent instead of the
|
||||
default
|
||||
.Dv TERM .
|
||||
.It Fl signal_number
|
||||
.It Fl Ar signal_number
|
||||
A non-negative decimal integer, specifying the signal to be sent instead
|
||||
of the default
|
||||
.Dv TERM .
|
||||
@@ -116,6 +118,23 @@ command which is similar or identical to this utility.
|
||||
Consult the
|
||||
.Xr builtin 1
|
||||
manual page.
|
||||
.Sh EXAMPLES
|
||||
Terminate
|
||||
the processes with pids 142 and 157:
|
||||
.Pp
|
||||
.Dl "kill 142 157"
|
||||
.Pp
|
||||
Send the hangup signal
|
||||
.Pq Dv SIGHUP
|
||||
to the process with pid 507:
|
||||
.Pp
|
||||
.Dl "kill -s HUP 507"
|
||||
.Pp
|
||||
Terminate the process group with pgid 117:
|
||||
.Pp
|
||||
.Dl "kill -- -117"
|
||||
.Sh DIAGNOSTICS
|
||||
.Ex -std
|
||||
.Sh SEE ALSO
|
||||
.Xr builtin 1 ,
|
||||
.Xr csh 1 ,
|
||||
@@ -133,7 +152,7 @@ compatible.
|
||||
A
|
||||
.Nm
|
||||
command appeared in
|
||||
.At v6 .
|
||||
.At v3 .
|
||||
.Sh BUGS
|
||||
A replacement for the command
|
||||
.Dq Li kill 0
|
||||
|
||||
+15
-18
@@ -41,9 +41,9 @@ static char const copyright[] =
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)kill.c 8.4 (Berkeley) 4/28/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <ctype.h>
|
||||
#include <err.h>
|
||||
@@ -53,16 +53,13 @@ static const char rcsid[] =
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int main __P((int, char *[]));
|
||||
void nosig __P((char *));
|
||||
void printsignals __P((FILE *));
|
||||
int signame_to_signum __P((char *));
|
||||
void usage __P((void));
|
||||
void nosig(char *);
|
||||
void printsignals(FILE *);
|
||||
int signame_to_signum(char *);
|
||||
void usage(void);
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int errors, numsig, pid;
|
||||
char *ep;
|
||||
@@ -106,7 +103,7 @@ main(argc, argv)
|
||||
} else
|
||||
numsig = 0;
|
||||
argc--, argv++;
|
||||
} else if (**argv == '-') {
|
||||
} else if (**argv == '-' && *(*argv + 1) != '-') {
|
||||
++*argv;
|
||||
if (isalpha(**argv)) {
|
||||
if ((numsig = signame_to_signum(*argv)) < 0)
|
||||
@@ -122,6 +119,9 @@ main(argc, argv)
|
||||
argc--, argv++;
|
||||
}
|
||||
|
||||
if (argc > 0 && strncmp(*argv, "--", 2) == 0)
|
||||
argc--, argv++;
|
||||
|
||||
if (argc == 0)
|
||||
usage();
|
||||
|
||||
@@ -140,8 +140,7 @@ main(argc, argv)
|
||||
}
|
||||
|
||||
int
|
||||
signame_to_signum(sig)
|
||||
char *sig;
|
||||
signame_to_signum(char *sig)
|
||||
{
|
||||
int n;
|
||||
|
||||
@@ -155,8 +154,7 @@ signame_to_signum(sig)
|
||||
}
|
||||
|
||||
void
|
||||
nosig(name)
|
||||
char *name;
|
||||
nosig(char *name)
|
||||
{
|
||||
|
||||
warnx("unknown signal %s; valid signals:", name);
|
||||
@@ -165,8 +163,7 @@ nosig(name)
|
||||
}
|
||||
|
||||
void
|
||||
printsignals(fp)
|
||||
FILE *fp;
|
||||
printsignals(FILE *fp)
|
||||
{
|
||||
int n;
|
||||
|
||||
@@ -180,7 +177,7 @@ printsignals(fp)
|
||||
}
|
||||
|
||||
void
|
||||
usage()
|
||||
usage(void)
|
||||
{
|
||||
|
||||
(void)fprintf(stderr, "%s\n%s\n%s\n%s\n",
|
||||
|
||||
+4
-4
@@ -46,11 +46,11 @@
|
||||
.Nm
|
||||
.Op Fl fhinsv
|
||||
.Ar source_file
|
||||
.Op target_file
|
||||
.Op Ar target_file
|
||||
.Nm
|
||||
.Op Fl fhinsv
|
||||
.Ar source_file ...
|
||||
.Op target_dir
|
||||
.Ar target_dir
|
||||
.Nm link
|
||||
.Ar source_file Ar target_file
|
||||
.Sh DESCRIPTION
|
||||
@@ -124,7 +124,7 @@ links.
|
||||
A hard link to a file is indistinguishable from the original directory entry;
|
||||
any changes to a file are effectively independent of the name used to reference
|
||||
the file.
|
||||
Hard links may not normally refer to directories and may not span file systems.
|
||||
Hard links may not normally refer to directories and may not span filesystems.
|
||||
.Pp
|
||||
A symbolic link contains the name of the file to
|
||||
which it is linked. The referenced file is used when an
|
||||
@@ -138,7 +138,7 @@ must be done to obtain information about the link.
|
||||
The
|
||||
.Xr readlink 2
|
||||
call may be used to read the contents of a symbolic link.
|
||||
Symbolic links may span file systems and may refer to directories.
|
||||
Symbolic links may span filesystems and may refer to directories.
|
||||
.Pp
|
||||
Given one or two arguments,
|
||||
.Nm
|
||||
|
||||
+23
-18
@@ -41,9 +41,9 @@ static char const copyright[] =
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)ln.c 8.2 (Berkeley) 3/31/94";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -62,17 +62,14 @@ int iflag; /* Interactive mode. */
|
||||
int sflag; /* Symbolic, not hard, link. */
|
||||
int vflag; /* Verbose output. */
|
||||
/* System link call. */
|
||||
int (*linkf) __P((const char *, const char *));
|
||||
int (*linkf)(const char *, const char *);
|
||||
char linkch;
|
||||
|
||||
int linkit __P((const char *, const char *, int));
|
||||
int main __P((int, char *[]));
|
||||
void usage __P((void));
|
||||
int linkit(const char *, const char *, int);
|
||||
void usage(void);
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
struct stat sb;
|
||||
char *p, *sourcedir;
|
||||
@@ -88,11 +85,14 @@ main(argc, argv)
|
||||
else
|
||||
++p;
|
||||
if (strcmp(p, "link") == 0) {
|
||||
if (argc == 3) {
|
||||
linkf = link;
|
||||
exit(linkit(argv[1], argv[2], 0));
|
||||
} else
|
||||
while (getopt(argc, argv, "") != -1)
|
||||
usage();
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
if (argc != 2)
|
||||
usage();
|
||||
linkf = link;
|
||||
exit(linkit(argv[0], argv[1], 0));
|
||||
}
|
||||
|
||||
while ((ch = getopt(argc, argv, "fhinsv")) != -1)
|
||||
@@ -134,6 +134,8 @@ main(argc, argv)
|
||||
exit(linkit(argv[0], ".", 1));
|
||||
case 2: /* ln target source */
|
||||
exit(linkit(argv[0], argv[1], 0));
|
||||
default:
|
||||
;
|
||||
}
|
||||
/* ln target1 target2 directory */
|
||||
sourcedir = argv[argc - 1];
|
||||
@@ -155,9 +157,7 @@ main(argc, argv)
|
||||
}
|
||||
|
||||
int
|
||||
linkit(target, source, isdir)
|
||||
const char *target, *source;
|
||||
int isdir;
|
||||
linkit(const char *target, const char *source, int isdir)
|
||||
{
|
||||
struct stat sb;
|
||||
const char *p;
|
||||
@@ -189,7 +189,12 @@ linkit(target, source, isdir)
|
||||
p = target;
|
||||
else
|
||||
++p;
|
||||
(void)snprintf(path, sizeof(path), "%s/%s", source, p);
|
||||
if (snprintf(path, sizeof(path), "%s/%s", source, p) >=
|
||||
sizeof(path)) {
|
||||
errno = ENAMETOOLONG;
|
||||
warn("%s", target);
|
||||
return (1);
|
||||
}
|
||||
source = path;
|
||||
}
|
||||
|
||||
@@ -232,7 +237,7 @@ linkit(target, source, isdir)
|
||||
}
|
||||
|
||||
void
|
||||
usage()
|
||||
usage(void)
|
||||
{
|
||||
(void)fprintf(stderr, "%s\n%s\n%s\n",
|
||||
"usage: ln [-fhinsv] file1 file2",
|
||||
|
||||
+5
-5
@@ -34,14 +34,14 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)cmp.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
@@ -46,6 +46,7 @@ int revstatcmp(const FTSENT *, const FTSENT *);
|
||||
void printcol(DISPLAY *);
|
||||
void printlong(DISPLAY *);
|
||||
void printscol(DISPLAY *);
|
||||
void printstream(DISPLAY *);
|
||||
void usage(void);
|
||||
size_t len_octal(const char *, int);
|
||||
int prn_octal(const char *);
|
||||
|
||||
+25
-11
@@ -43,7 +43,7 @@
|
||||
.Nd list directory contents
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl ABCFGHLPRTWabcdfghiklnoqrstuw1
|
||||
.Op Fl ABCFGHLPRTWabcdfghiklmnopqrstuwx1
|
||||
.Op Ar
|
||||
.Sh DESCRIPTION
|
||||
For each operand that names a
|
||||
@@ -190,6 +190,8 @@ List in long format.
|
||||
(See below.)
|
||||
If the output is to a terminal, a total sum for all the file
|
||||
sizes is output on a line before the long listing.
|
||||
.It Fl m
|
||||
Stream output format; list files across the page, separated by commas.
|
||||
.It Fl n
|
||||
Display user and group IDs numerically rather than converting to a user
|
||||
or group name in a long
|
||||
@@ -199,6 +201,10 @@ output.
|
||||
Include the file flags in a long
|
||||
.Pq Fl l
|
||||
output.
|
||||
.It Fl p
|
||||
Write a slash
|
||||
.Pq Ql /
|
||||
after each filename if that file is a directory.
|
||||
.It Fl q
|
||||
Force printing of non-graphic characters in file names as
|
||||
the character
|
||||
@@ -208,7 +214,7 @@ this is the default when output is to a terminal.
|
||||
Reverse the order of the sort to get reverse
|
||||
lexicographical order or the oldest entries first.
|
||||
.It Fl s
|
||||
Display the number of file system blocks actually used by each file, in units
|
||||
Display the number of filesystem blocks actually used by each file, in units
|
||||
of 512 bytes, where partial units are rounded up to the next integer value.
|
||||
If the output is to a terminal, a total sum for all the file
|
||||
sizes is output on a line before the listing.
|
||||
@@ -230,6 +236,11 @@ or printing
|
||||
Force raw printing of non-printable characters.
|
||||
This is the default
|
||||
when output is not to a terminal.
|
||||
.It Fl x
|
||||
The same as
|
||||
.Fl C ,
|
||||
except that the multi-column output is produced with entries sorted
|
||||
across, rather than down, the columns.
|
||||
.It Fl 1
|
||||
(The numeric digit
|
||||
.Dq one . )
|
||||
@@ -240,7 +251,7 @@ output is not to a terminal.
|
||||
.El
|
||||
.Pp
|
||||
The
|
||||
.Fl 1 , C ,
|
||||
.Fl 1 , C , x ,
|
||||
and
|
||||
.Fl l
|
||||
options all override each other; the last one specified determines
|
||||
@@ -272,7 +283,9 @@ By default,
|
||||
lists one entry per line to standard
|
||||
output; the exceptions are to terminals or when the
|
||||
.Fl C
|
||||
option is specified.
|
||||
or
|
||||
.Fl x
|
||||
options are specified.
|
||||
.Pp
|
||||
File information is displayed with one or more
|
||||
.Ao blank Ac Ns s
|
||||
@@ -478,7 +491,9 @@ utility calculates how
|
||||
many pathname text columns to display
|
||||
based on the width provided.
|
||||
(See
|
||||
.Fl C . )
|
||||
.Fl C
|
||||
and
|
||||
.Fl x . )
|
||||
.It Ev LANG
|
||||
The locale to use when determining the order of day and month in the long
|
||||
.Fl l
|
||||
@@ -608,17 +623,16 @@ specification.
|
||||
.Xr termcap 5 ,
|
||||
.Xr symlink 7 ,
|
||||
.Xr sticky 8
|
||||
.Sh STANDARDS
|
||||
The
|
||||
.Nm
|
||||
utility conforms to
|
||||
.St -p1003.1-2001 .
|
||||
.Sh HISTORY
|
||||
An
|
||||
.Nm
|
||||
command appeared in
|
||||
.At v1 .
|
||||
.Sh STANDARDS
|
||||
The
|
||||
.Nm
|
||||
utility is expected to be a superset of the
|
||||
.St -p1003.2
|
||||
specification.
|
||||
.Sh BUGS
|
||||
To maintain backward compatibility, the relationships between the many
|
||||
options are quite complex.
|
||||
+40
-15
@@ -40,14 +40,13 @@ static const char copyright[] =
|
||||
The Regents of the University of California. All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)ls.c 8.5 (Berkeley) 4/2/94";
|
||||
#else
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -111,7 +110,10 @@ static int f_reversesort; /* reverse whatever sort is used */
|
||||
int f_sectime; /* print the real time for all files */
|
||||
static int f_singlecol; /* use single column output */
|
||||
int f_size; /* list size in short listing */
|
||||
int f_slash; /* similar to f_type, but only for dirs */
|
||||
int f_sortacross; /* sort across rows, not down columns */
|
||||
int f_statustime; /* use time of last mode change */
|
||||
int f_stream; /* stream the output, separate with commas */
|
||||
static int f_timesort; /* sort by time vice name */
|
||||
int f_type; /* add type character for non-regular files */
|
||||
static int f_whiteout; /* show whiteout entries */
|
||||
@@ -144,11 +146,11 @@ main(int argc, char *argv[])
|
||||
|
||||
/* Terminal defaults to -Cq, non-terminal defaults to -1. */
|
||||
if (isatty(STDOUT_FILENO)) {
|
||||
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &win) == -1 ||
|
||||
!win.ws_col) {
|
||||
if ((p = getenv("COLUMNS")) != NULL)
|
||||
termwidth = atoi(p);
|
||||
} else
|
||||
termwidth = 80;
|
||||
if ((p = getenv("COLUMNS")) != NULL && *p != '\0')
|
||||
termwidth = atoi(p);
|
||||
else if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &win) != -1 &&
|
||||
win.ws_col > 0)
|
||||
termwidth = win.ws_col;
|
||||
f_nonprint = 1;
|
||||
} else {
|
||||
@@ -164,15 +166,17 @@ main(int argc, char *argv[])
|
||||
f_listdot = 1;
|
||||
|
||||
fts_options = FTS_PHYSICAL;
|
||||
while ((ch = getopt(argc, argv, "1ABCFGHLPRTWabcdfghiklnoqrstuw")) != -1) {
|
||||
while ((ch = getopt(argc, argv, "1ABCFGHLPRTWabcdfghiklmnopqrstuwx"))
|
||||
!= -1) {
|
||||
switch (ch) {
|
||||
/*
|
||||
* The -1, -C and -l options all override each other so shell
|
||||
* aliasing works right.
|
||||
* The -1, -C, -x and -l options all override each other so
|
||||
* shell aliasing works right.
|
||||
*/
|
||||
case '1':
|
||||
f_singlecol = 1;
|
||||
f_longform = 0;
|
||||
f_stream = 0;
|
||||
break;
|
||||
case 'B':
|
||||
f_nonprint = 0;
|
||||
@@ -180,11 +184,17 @@ main(int argc, char *argv[])
|
||||
f_octal_escape = 0;
|
||||
break;
|
||||
case 'C':
|
||||
f_longform = f_singlecol = 0;
|
||||
f_sortacross = f_longform = f_singlecol = 0;
|
||||
break;
|
||||
case 'l':
|
||||
f_longform = 1;
|
||||
f_singlecol = 0;
|
||||
f_stream = 0;
|
||||
break;
|
||||
case 'x':
|
||||
f_sortacross = 1;
|
||||
f_longform = 0;
|
||||
f_singlecol = 0;
|
||||
break;
|
||||
/* The -c and -u options override each other. */
|
||||
case 'c':
|
||||
@@ -197,6 +207,7 @@ main(int argc, char *argv[])
|
||||
break;
|
||||
case 'F':
|
||||
f_type = 1;
|
||||
f_slash = 0;
|
||||
break;
|
||||
case 'H':
|
||||
fts_options |= FTS_COMFOLLOW;
|
||||
@@ -241,12 +252,21 @@ main(int argc, char *argv[])
|
||||
case 'k':
|
||||
f_kblocks = 1;
|
||||
break;
|
||||
case 'm':
|
||||
f_stream = 1;
|
||||
f_singlecol = 0;
|
||||
f_longform = 0;
|
||||
break;
|
||||
case 'n':
|
||||
f_numericonly = 1;
|
||||
break;
|
||||
case 'o':
|
||||
f_flags = 1;
|
||||
break;
|
||||
case 'p':
|
||||
f_slash = 1;
|
||||
f_type = 1;
|
||||
break;
|
||||
case 'q':
|
||||
f_nonprint = 1;
|
||||
f_octal = 0;
|
||||
@@ -384,6 +404,8 @@ main(int argc, char *argv[])
|
||||
printfcn = printscol;
|
||||
else if (f_longform)
|
||||
printfcn = printlong;
|
||||
else if (f_stream)
|
||||
printfcn = printstream;
|
||||
else
|
||||
printfcn = printcol;
|
||||
|
||||
@@ -456,6 +478,7 @@ traverse(int argc, char *argv[], int options)
|
||||
(void)fts_set(ftsp, p, FTS_SKIP);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (errno)
|
||||
err(1, "fts_read");
|
||||
@@ -481,7 +504,8 @@ display(FTSENT *p, FTSENT *list)
|
||||
size_t flen, ulen, glen;
|
||||
char *initmax;
|
||||
int entries, needstats;
|
||||
char *user, *group, *flags;
|
||||
const char *user, *group;
|
||||
char *flags;
|
||||
char buf[STRBUF_SIZEOF(u_quad_t) + 1];
|
||||
char ngroup[STRBUF_SIZEOF(uid_t) + 1];
|
||||
char nuser[STRBUF_SIZEOF(gid_t) + 1];
|
||||
@@ -564,6 +588,7 @@ display(FTSENT *p, FTSENT *list)
|
||||
f_notabs = 0;
|
||||
/* fall through */
|
||||
default:
|
||||
break;
|
||||
}
|
||||
maxinode = makenines(maxinode);
|
||||
maxblock = makenines(maxblock);
|
||||
|
||||
@@ -52,6 +52,8 @@ extern int f_octal_escape; /* like f_octal but use C escapes if possible */
|
||||
extern int f_nonprint; /* show unprintables as ? */
|
||||
extern int f_sectime; /* print the real time for all files */
|
||||
extern int f_size; /* list size in short listing */
|
||||
extern int f_slash; /* append a '/' if the file is a directory */
|
||||
extern int f_sortacross; /* sort across rows, not down columns */
|
||||
extern int f_statustime; /* use time of last mode change */
|
||||
extern int f_notabs; /* don't use tab-separated multi-col output */
|
||||
extern int f_type; /* add type character for non-regular files */
|
||||
|
||||
+52
-7
@@ -34,14 +34,13 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)print.c 8.4 (Berkeley) 4/17/94";
|
||||
#else
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -219,6 +218,31 @@ printlong(DISPLAY *dp)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
printstream(DISPLAY *dp)
|
||||
{
|
||||
FTSENT *p;
|
||||
extern int termwidth;
|
||||
int chcnt;
|
||||
|
||||
for (p = dp->list, chcnt = 0; p; p = p->fts_link) {
|
||||
if (p->fts_number == NO_PRINT)
|
||||
continue;
|
||||
if (strlen(p->fts_name) + chcnt +
|
||||
(p->fts_link ? 2 : 0) >= (unsigned)termwidth) {
|
||||
putchar('\n');
|
||||
chcnt = 0;
|
||||
}
|
||||
chcnt += printaname(p, dp->s_inode, dp->s_block);
|
||||
if (p->fts_link) {
|
||||
printf(", ");
|
||||
chcnt += 2;
|
||||
}
|
||||
}
|
||||
if (chcnt)
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
void
|
||||
printcol(DISPLAY *dp)
|
||||
{
|
||||
@@ -279,15 +303,26 @@ printcol(DISPLAY *dp)
|
||||
|
||||
if (dp->list->fts_level != FTS_ROOTLEVEL && (f_longform || f_size))
|
||||
(void)printf("total %lu\n", howmany(dp->btotal, blocksize));
|
||||
|
||||
if (f_sortacross)
|
||||
base = 0;
|
||||
for (row = 0; row < numrows; ++row) {
|
||||
endcol = colwidth;
|
||||
for (base = row, chcnt = col = 0; col < numcols; ++col) {
|
||||
if (!f_sortacross)
|
||||
base = row;
|
||||
for (col = 0, chcnt = 0; col < numcols; ++col) {
|
||||
chcnt += printaname(array[base], dp->s_inode,
|
||||
dp->s_block);
|
||||
if ((base += numrows) >= num)
|
||||
if (f_sortacross)
|
||||
base++;
|
||||
else
|
||||
base += numrows;
|
||||
if (base >= num)
|
||||
break;
|
||||
while ((cnt = ((chcnt + tabwidth) & ~(tabwidth - 1)))
|
||||
<= endcol) {
|
||||
if (f_sortacross && col + 1 >= numcols)
|
||||
break;
|
||||
(void)putchar(f_notabs ? ' ' : '\t');
|
||||
chcnt = cnt;
|
||||
}
|
||||
@@ -361,6 +396,15 @@ printtime(time_t ftime)
|
||||
static int
|
||||
printtype(u_int mode)
|
||||
{
|
||||
|
||||
if (f_slash) {
|
||||
if ((mode & S_IFMT) == S_IFDIR) {
|
||||
(void)putchar('/');
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
switch (mode & S_IFMT) {
|
||||
case S_IFDIR:
|
||||
(void)putchar('/');
|
||||
@@ -378,6 +422,7 @@ printtype(u_int mode)
|
||||
(void)putchar('%');
|
||||
return (1);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (mode & (S_IXUSR | S_IXGRP | S_IXOTH)) {
|
||||
(void)putchar('*');
|
||||
|
||||
+4
-5
@@ -34,14 +34,13 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)util.c 8.3 (Berkeley) 4/2/94";
|
||||
#else
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
+4
-2
@@ -58,10 +58,12 @@ as modified by the current
|
||||
The options are as follows:
|
||||
.Pp
|
||||
.Bl -tag -width indent
|
||||
.It Fl m
|
||||
.It Fl m Ar mode
|
||||
Set the file permission bits of the final created directory to
|
||||
the specified mode.
|
||||
The mode argument can be in any of the formats specified to the
|
||||
The
|
||||
.Ar mode
|
||||
argument can be in any of the formats specified to the
|
||||
.Xr chmod 1
|
||||
command.
|
||||
If a symbolic mode is specified, the operation characters
|
||||
|
||||
+19
-4
@@ -35,7 +35,7 @@
|
||||
.\" @(#)mv.1 8.1 (Berkeley) 5/31/93
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd May 31, 1993
|
||||
.Dd August 18, 2002
|
||||
.Dt MV 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@@ -43,11 +43,11 @@
|
||||
.Nd move files
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl f | Fl i
|
||||
.Op Fl f | i | n
|
||||
.Op Fl v
|
||||
.Ar source target
|
||||
.Nm
|
||||
.Op Fl f | Fl i
|
||||
.Op Fl f | i | n
|
||||
.Op Fl v
|
||||
.Ar source ... directory
|
||||
.Sh DESCRIPTION
|
||||
@@ -81,6 +81,8 @@ path.
|
||||
.Fl f
|
||||
option overrides any previous
|
||||
.Fl i
|
||||
or
|
||||
.Fl n
|
||||
options.)
|
||||
.It Fl i
|
||||
Cause
|
||||
@@ -96,6 +98,17 @@ the move is attempted.
|
||||
.Fl i
|
||||
option overrides any previous
|
||||
.Fl f
|
||||
or
|
||||
.Fl n
|
||||
options.)
|
||||
.It Fl n
|
||||
Do not overwrite an existing file.
|
||||
(The
|
||||
.Fl n
|
||||
option overrides any previous
|
||||
.Fl f
|
||||
or
|
||||
.Fl i
|
||||
options.)
|
||||
.It Fl v
|
||||
Cause
|
||||
@@ -136,8 +149,10 @@ rm -f destination_path && \e
|
||||
.Xr symlink 7
|
||||
.Sh COMPATIBILITY
|
||||
The
|
||||
.Fl n
|
||||
and
|
||||
.Fl v
|
||||
option is non-standard and its use in scripts is not recommended.
|
||||
options are non-standard and their use in scripts is not recommended.
|
||||
.Sh STANDARDS
|
||||
The
|
||||
.Nm
|
||||
|
||||
+15
-7
@@ -66,7 +66,7 @@ static const char rcsid[] =
|
||||
|
||||
#include "pathnames.h"
|
||||
|
||||
int fflg, iflg, vflg;
|
||||
int fflg, iflg, nflg, vflg;
|
||||
|
||||
int copy __P((char *, char *));
|
||||
int do_move __P((char *, char *));
|
||||
@@ -85,15 +85,19 @@ main(argc, argv)
|
||||
int ch;
|
||||
char path[PATH_MAX];
|
||||
|
||||
while ((ch = getopt(argc, argv, "fiv")) != -1)
|
||||
while ((ch = getopt(argc, argv, "finv")) != -1)
|
||||
switch (ch) {
|
||||
case 'i':
|
||||
iflg = 1;
|
||||
fflg = 0;
|
||||
fflg = nflg = 0;
|
||||
break;
|
||||
case 'f':
|
||||
fflg = 1;
|
||||
iflg = 0;
|
||||
iflg = nflg = 0;
|
||||
break;
|
||||
case 'n':
|
||||
nflg = 1;
|
||||
fflg = iflg = 0;
|
||||
break;
|
||||
case 'v':
|
||||
vflg = 1;
|
||||
@@ -173,7 +177,11 @@ do_move(from, to)
|
||||
|
||||
#define YESNO "(y/n [n]) "
|
||||
ask = 0;
|
||||
if (iflg) {
|
||||
if (nflg) {
|
||||
if (vflg)
|
||||
printf("%s not overwritten\n", to);
|
||||
return (0);
|
||||
} else if (iflg) {
|
||||
(void)fprintf(stderr, "overwrite %s? %s", to, YESNO);
|
||||
ask = 1;
|
||||
} else if (access(to, W_OK) && !stat(to, &sb)) {
|
||||
@@ -375,7 +383,7 @@ usage()
|
||||
{
|
||||
|
||||
(void)fprintf(stderr, "%s\n%s\n",
|
||||
"usage: mv [-f | -i] [-v] source target",
|
||||
" mv [-f | -i] [-v] source ... directory");
|
||||
"usage: mv [-f | -i | -n] [-v] source target",
|
||||
" mv [-f | -i | -n] [-v] source ... directory");
|
||||
exit(EX_USAGE);
|
||||
}
|
||||
+2
-3
@@ -183,9 +183,8 @@ The
|
||||
.Nm
|
||||
utility will read, write, and list the members of an archive file,
|
||||
and will copy directory hierarchies.
|
||||
.Nm Pax
|
||||
operation is independent of the specific archive format,
|
||||
and supports a wide variety of different archive formats.
|
||||
These operations are independent of the specific archive format,
|
||||
and support a wide variety of different archive formats.
|
||||
A list of supported archive formats can be found under the description of the
|
||||
.Fl x
|
||||
option.
|
||||
|
||||
+24
-10
@@ -86,8 +86,10 @@ int totwidth; /* calculated width of requested variables */
|
||||
static int needuser, needcomm, needenv;
|
||||
#if defined(LAZY_PS)
|
||||
static int forceuread=0;
|
||||
#define PS_ARGS "aCcefghjLlM:mN:O:o:p:rSTt:U:uvwx"
|
||||
#else
|
||||
static int forceuread=1;
|
||||
#define PS_ARGS "aCceghjLlM:mN:O:o:p:rSTt:U:uvwx"
|
||||
#endif
|
||||
|
||||
enum sort { DEFAULT, SORTMEM, SORTCPU } sortby = DEFAULT;
|
||||
@@ -124,9 +126,9 @@ main(argc, argv)
|
||||
dev_t ttydev;
|
||||
pid_t pid;
|
||||
uid_t *uids;
|
||||
int all, ch, flag, i, fmt, lineno, nentries, dropgid;
|
||||
int all, ch, flag, i, fmt, lineno, nentries, nocludge, dropgid;
|
||||
int prtheader, wflag, what, xflg, uid, nuids;
|
||||
char *nlistf, *memf, errbuf[_POSIX2_LINE_MAX];
|
||||
char *cp, *nlistf, *memf, errbuf[_POSIX2_LINE_MAX];
|
||||
|
||||
(void) setlocale(LC_ALL, "");
|
||||
|
||||
@@ -138,8 +140,25 @@ main(argc, argv)
|
||||
else
|
||||
termwidth = ws.ws_col - 1;
|
||||
|
||||
if (argc > 1)
|
||||
argv[1] = kludge_oldps_options(argv[1]);
|
||||
/*
|
||||
* Don't apply a kludge if the first argument is an option taking an
|
||||
* argument
|
||||
*/
|
||||
if (argc > 1) {
|
||||
nocludge = 0;
|
||||
if (argv[1][0] == '-') {
|
||||
for (cp = PS_ARGS; *cp != '\0'; cp++) {
|
||||
if (*cp != ':')
|
||||
continue;
|
||||
if (*(cp - 1) == argv[1][1]) {
|
||||
nocludge = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nocludge == 0)
|
||||
argv[1] = kludge_oldps_options(argv[1]);
|
||||
}
|
||||
|
||||
all = fmt = prtheader = wflag = xflg = 0;
|
||||
pid = -1;
|
||||
@@ -148,12 +167,7 @@ main(argc, argv)
|
||||
ttydev = NODEV;
|
||||
dropgid = 0;
|
||||
memf = nlistf = _PATH_DEVNULL;
|
||||
while ((ch = getopt(argc, argv,
|
||||
#if defined(LAZY_PS)
|
||||
"aCcefghjLlM:mN:O:o:p:rSTt:U:uvwx")) != -1)
|
||||
#else
|
||||
"aCceghjLlM:mN:O:o:p:rSTt:U:uvwx")) != -1)
|
||||
#endif
|
||||
while ((ch = getopt(argc, argv, PS_ARGS)) != -1)
|
||||
switch((char)ch) {
|
||||
case 'a':
|
||||
all = 1;
|
||||
|
||||
+4
-2
@@ -4,11 +4,13 @@
|
||||
PROG= rcp
|
||||
SRCS= rcp.c util.c
|
||||
CFLAGS+=-DBINDIR=${BINDIR}
|
||||
WARNS= 0
|
||||
WFORMAT=0
|
||||
|
||||
.if exists(${DESTDIR}${LIBDIR}/libkrb.a) && defined(MAKE_KERBEROS4)
|
||||
.if defined(MAKE_KERBEROS4) && !defined(NO_OPENSSL) && !defined(NOCRYPT)
|
||||
SRCS+= krcmd.c kcmd.c rcmd_util.c
|
||||
DPADD= ${LIBUTIL} ${LIBKRB} ${LIBCRYPTO}
|
||||
CFLAGS+=-DKERBEROS -DCRYPT -DHAVE_CONFIG_H \
|
||||
CFLAGS+=-DCRYPT -DHAVE_CONFIG_H \
|
||||
-I${.CURDIR}/../../kerberosIV/include \
|
||||
-I${.CURDIR}/../../crypto/kerberosIV/include \
|
||||
-I${.CURDIR}/../../crypto/kerberosIV/lib/roken \
|
||||
|
||||
+9
-9
@@ -35,17 +35,17 @@
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
int cnt;
|
||||
size_t cnt;
|
||||
char *buf;
|
||||
} BUF;
|
||||
|
||||
extern int iamremote;
|
||||
|
||||
BUF *allocbuf __P((BUF *, int, int));
|
||||
char *colon __P((char *));
|
||||
void lostconn __P((int));
|
||||
void nospace __P((void));
|
||||
int okname __P((char *));
|
||||
void run_err __P((const char *, ...)) __printflike(1, 2);
|
||||
int susystem __P((char *, int));
|
||||
void verifydir __P((char *));
|
||||
BUF *allocbuf(BUF *, int, int);
|
||||
char *colon(char *);
|
||||
void lostconn(int);
|
||||
void nospace(void);
|
||||
int okname(char *);
|
||||
void run_err(const char *, ...) __printflike(1, 2);
|
||||
int susystem(char *, int);
|
||||
void verifydir(char *);
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)pathnames.h 8.1 (Berkeley) 5/31/93
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <paths.h>
|
||||
|
||||
#define _PATH_CP "/bin/cp"
|
||||
#define _PATH_RCP "/bin/rcp"
|
||||
#define _PATH_RLOGIN "/usr/bin/rlogin"
|
||||
#define _PATH_RSH "/usr/bin/rsh"
|
||||
+6
-2
@@ -40,11 +40,11 @@
|
||||
.Nd remote file copy
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl Kpx
|
||||
.Op Fl 46Kpx
|
||||
.Op Fl k Ar realm
|
||||
.Ar file1 file2
|
||||
.Nm
|
||||
.Op Fl Kprx
|
||||
.Op Fl 46Kprx
|
||||
.Op Fl k Ar realm
|
||||
.Ar
|
||||
.Ar directory
|
||||
@@ -63,6 +63,10 @@ or a `/' before any `:'s).
|
||||
.Pp
|
||||
The following options are available:
|
||||
.Bl -tag -width indent
|
||||
.It Fl 4
|
||||
Use IPv4 addresses only.
|
||||
.It Fl 6
|
||||
Use IPv6 addresses only.
|
||||
.It Fl K
|
||||
Turn off all Kerberos authentication.
|
||||
.It Fl k
|
||||
|
||||
+76
-87
@@ -1,6 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) 1983, 1990, 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
* Copyright (c) 2002 Networks Associates Technology, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Portions of this software were developed for the FreeBSD Project by
|
||||
* ThinkSec AS and NAI Labs, the Security Research Division of Network
|
||||
* Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035
|
||||
* ("CBOSS"), as part of the DARPA CHATS research program.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -41,9 +48,9 @@ static char const copyright[] =
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)rcp.c 8.2 (Berkeley) 4/2/94";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -61,6 +68,7 @@ static const char rcsid[] =
|
||||
#include <libutil.h>
|
||||
#include <limits.h>
|
||||
#include <netdb.h>
|
||||
#include <paths.h>
|
||||
#include <pwd.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
@@ -69,7 +77,6 @@ static const char rcsid[] =
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "pathnames.h"
|
||||
#include "extern.h"
|
||||
|
||||
#ifdef KERBEROS
|
||||
@@ -80,17 +87,17 @@ static const char rcsid[] =
|
||||
char dst_realm_buf[REALM_SZ];
|
||||
char *dest_realm = NULL;
|
||||
int use_kerberos = 1;
|
||||
CREDENTIALS cred;
|
||||
CREDENTIALS cred;
|
||||
Key_schedule schedule;
|
||||
extern char *krb_realmofhost();
|
||||
#ifdef CRYPT
|
||||
int doencrypt = 0;
|
||||
#define OPTIONS "dfKk:prtx"
|
||||
#define OPTIONS "46dfKk:prtx"
|
||||
#else
|
||||
#define OPTIONS "dfKk:prt"
|
||||
#define OPTIONS "46dfKk:prt"
|
||||
#endif
|
||||
#else
|
||||
#define OPTIONS "dfprt"
|
||||
#define OPTIONS "46dfprt"
|
||||
#endif
|
||||
|
||||
struct passwd *pwd;
|
||||
@@ -98,6 +105,7 @@ u_short port;
|
||||
uid_t userid;
|
||||
int errs, rem;
|
||||
int pflag, iamremote, iamrecursive, targetshouldbedirectory;
|
||||
int family = PF_UNSPEC;
|
||||
|
||||
static int argc_copy;
|
||||
static char **argv_copy;
|
||||
@@ -106,22 +114,20 @@ static char **argv_copy;
|
||||
char cmd[CMDNEEDS]; /* must hold "rcp -r -p -d\0" */
|
||||
|
||||
#ifdef KERBEROS
|
||||
int kerberos __P((char **, char *, char *, char *));
|
||||
void oldw __P((const char *, ...)) __printflike(1, 2);
|
||||
int kerberos(char **, char *, char *, char *);
|
||||
void oldw(const char *, ...) __printflike(1, 2);
|
||||
#endif
|
||||
int response __P((void));
|
||||
void rsource __P((char *, struct stat *));
|
||||
void run_err __P((const char *, ...)) __printflike(1, 2);
|
||||
void sink __P((int, char *[]));
|
||||
void source __P((int, char *[]));
|
||||
void tolocal __P((int, char *[]));
|
||||
void toremote __P((char *, int, char *[]));
|
||||
void usage __P((void));
|
||||
int response(void);
|
||||
void rsource(char *, struct stat *);
|
||||
void run_err(const char *, ...) __printflike(1, 2);
|
||||
void sink(int, char *[]);
|
||||
void source(int, char *[]);
|
||||
void tolocal(int, char *[]);
|
||||
void toremote(char *, int, char *[]);
|
||||
void usage(void);
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
struct servent *sp;
|
||||
int ch, fflag, i, tflag;
|
||||
@@ -149,6 +155,14 @@ main(argc, argv)
|
||||
fflag = tflag = 0;
|
||||
while ((ch = getopt(argc, argv, OPTIONS)) != -1)
|
||||
switch(ch) { /* User-visible flags. */
|
||||
case '4':
|
||||
family = PF_INET;
|
||||
break;
|
||||
|
||||
case '6':
|
||||
family = PF_INET6;
|
||||
break;
|
||||
|
||||
case 'K':
|
||||
#ifdef KERBEROS
|
||||
use_kerberos = 0;
|
||||
@@ -269,9 +283,7 @@ main(argc, argv)
|
||||
}
|
||||
|
||||
void
|
||||
toremote(targ, argc, argv)
|
||||
char *targ, *argv[];
|
||||
int argc;
|
||||
toremote(char *targ, int argc, char *argv[])
|
||||
{
|
||||
int i, len, tos;
|
||||
char *bp, *host, *src, *suser, *thost, *tuser;
|
||||
@@ -304,7 +316,7 @@ toremote(targ, argc, argv)
|
||||
strlen(src) + (tuser ? strlen(tuser) : 0) +
|
||||
strlen(thost) + strlen(targ) + CMDNEEDS + 20;
|
||||
if (!(bp = malloc(len)))
|
||||
err(1, NULL);
|
||||
err(1, "malloc");
|
||||
if (host) {
|
||||
*host++ = 0;
|
||||
suser = argv[i];
|
||||
@@ -331,7 +343,7 @@ toremote(targ, argc, argv)
|
||||
if (rem == -1) {
|
||||
len = strlen(targ) + CMDNEEDS + 20;
|
||||
if (!(bp = malloc(len)))
|
||||
err(1, NULL);
|
||||
err(1, "malloc");
|
||||
(void)snprintf(bp, len, "%s -t %s", cmd, targ);
|
||||
host = thost;
|
||||
#ifdef KERBEROS
|
||||
@@ -341,15 +353,18 @@ toremote(targ, argc, argv)
|
||||
tuser ? tuser : pwd->pw_name);
|
||||
else
|
||||
#endif
|
||||
rem = rcmd(&host, port, pwd->pw_name,
|
||||
rem = rcmd_af(&host, port,
|
||||
pwd->pw_name,
|
||||
tuser ? tuser : pwd->pw_name,
|
||||
bp, 0);
|
||||
bp, 0, family);
|
||||
if (rem < 0)
|
||||
exit(1);
|
||||
tos = IPTOS_THROUGHPUT;
|
||||
if (setsockopt(rem, IPPROTO_IP, IP_TOS,
|
||||
&tos, sizeof(int)) < 0)
|
||||
warn("TOS (ignored)");
|
||||
if (family == PF_INET) {
|
||||
tos = IPTOS_THROUGHPUT;
|
||||
if (setsockopt(rem, IPPROTO_IP, IP_TOS,
|
||||
&tos, sizeof(int)) < 0)
|
||||
warn("TOS (ignored)");
|
||||
}
|
||||
if (response() < 0)
|
||||
exit(1);
|
||||
(void)free(bp);
|
||||
@@ -361,9 +376,7 @@ toremote(targ, argc, argv)
|
||||
}
|
||||
|
||||
void
|
||||
tolocal(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
tolocal(int argc, char *argv[])
|
||||
{
|
||||
int i, len, tos;
|
||||
char *bp, *host, *src, *suser;
|
||||
@@ -373,7 +386,7 @@ tolocal(argc, argv)
|
||||
len = strlen(_PATH_CP) + strlen(argv[i]) +
|
||||
strlen(argv[argc - 1]) + 20;
|
||||
if (!(bp = malloc(len)))
|
||||
err(1, NULL);
|
||||
err(1, "malloc");
|
||||
(void)snprintf(bp, len, "exec %s%s%s %s %s", _PATH_CP,
|
||||
iamrecursive ? " -PR" : "", pflag ? " -p" : "",
|
||||
argv[i], argv[argc - 1]);
|
||||
@@ -400,23 +413,27 @@ tolocal(argc, argv)
|
||||
}
|
||||
len = strlen(src) + CMDNEEDS + 20;
|
||||
if ((bp = malloc(len)) == NULL)
|
||||
err(1, NULL);
|
||||
err(1, "malloc");
|
||||
(void)snprintf(bp, len, "%s -f %s", cmd, src);
|
||||
rem =
|
||||
#ifdef KERBEROS
|
||||
use_kerberos ?
|
||||
kerberos(&host, bp, pwd->pw_name, suser) :
|
||||
#endif
|
||||
rcmd(&host, port, pwd->pw_name, suser, bp, 0);
|
||||
rcmd_af(&host, port, pwd->pw_name, suser, bp, 0,
|
||||
family);
|
||||
(void)free(bp);
|
||||
if (rem < 0) {
|
||||
++errs;
|
||||
continue;
|
||||
}
|
||||
(void)seteuid(userid);
|
||||
tos = IPTOS_THROUGHPUT;
|
||||
if (setsockopt(rem, IPPROTO_IP, IP_TOS, &tos, sizeof(int)) < 0)
|
||||
warn("TOS (ignored)");
|
||||
if (family == PF_INET) {
|
||||
tos = IPTOS_THROUGHPUT;
|
||||
if (setsockopt(rem, IPPROTO_IP, IP_TOS, &tos,
|
||||
sizeof(int)) < 0)
|
||||
warn("TOS (ignored)");
|
||||
}
|
||||
sink(1, argv + argc - 1);
|
||||
(void)seteuid(0);
|
||||
(void)close(rem);
|
||||
@@ -425,9 +442,7 @@ tolocal(argc, argv)
|
||||
}
|
||||
|
||||
void
|
||||
source(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
source(int argc, char *argv[])
|
||||
{
|
||||
struct stat stb;
|
||||
static BUF buffer;
|
||||
@@ -437,7 +452,7 @@ source(argc, argv)
|
||||
char *last, *name, buf[BUFSIZ];
|
||||
|
||||
for (indx = 0; indx < argc; ++indx) {
|
||||
name = argv[indx];
|
||||
name = argv[indx];
|
||||
if ((fd = open(name, O_RDONLY, 0)) < 0)
|
||||
goto syserr;
|
||||
if (fstat(fd, &stb)) {
|
||||
@@ -513,9 +528,7 @@ next: (void)close(fd);
|
||||
}
|
||||
|
||||
void
|
||||
rsource(name, statp)
|
||||
char *name;
|
||||
struct stat *statp;
|
||||
rsource(char *name, struct stat *statp)
|
||||
{
|
||||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
@@ -566,9 +579,7 @@ rsource(name, statp)
|
||||
}
|
||||
|
||||
void
|
||||
sink(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
sink(int argc, char *argv[])
|
||||
{
|
||||
static BUF buffer;
|
||||
struct stat stb;
|
||||
@@ -675,14 +686,17 @@ sink(argc, argv)
|
||||
if (*cp++ != ' ')
|
||||
SCREWUP("size not delimited");
|
||||
if (targisdir) {
|
||||
static char *namebuf;
|
||||
static int cursize;
|
||||
static char *namebuf = NULL;
|
||||
static size_t cursize;
|
||||
size_t need;
|
||||
|
||||
need = strlen(targ) + strlen(cp) + 250;
|
||||
if (need > cursize) {
|
||||
if (namebuf != NULL)
|
||||
free(namebuf);
|
||||
if (!(namebuf = malloc(need)))
|
||||
run_err("%s", strerror(errno));
|
||||
cursize = need;
|
||||
}
|
||||
(void)snprintf(namebuf, need, "%s%s%s", targ,
|
||||
*targ ? "/" : "", cp);
|
||||
@@ -806,8 +820,7 @@ screwup:
|
||||
|
||||
#ifdef KERBEROS
|
||||
int
|
||||
kerberos(host, bp, locuser, user)
|
||||
char **host, *bp, *locuser, *user;
|
||||
kerberos(char **host, char *bp, char *locuser, char *user)
|
||||
{
|
||||
if (use_kerberos) {
|
||||
setuid(getuid());
|
||||
@@ -837,14 +850,14 @@ kerberos(host, bp, locuser, user)
|
||||
errx(1,
|
||||
"the -x option requires Kerberos authentication");
|
||||
#endif
|
||||
rem = rcmd(host, port, locuser, user, bp, 0);
|
||||
rem = rcmd_af(host, port, locuser, user, bp, 0, family);
|
||||
}
|
||||
return (rem);
|
||||
}
|
||||
#endif /* KERBEROS */
|
||||
|
||||
int
|
||||
response()
|
||||
response(void)
|
||||
{
|
||||
char ch, *cp, resp, rbuf[BUFSIZ];
|
||||
|
||||
@@ -877,48 +890,34 @@ response()
|
||||
}
|
||||
|
||||
void
|
||||
usage()
|
||||
usage(void)
|
||||
{
|
||||
#ifdef KERBEROS
|
||||
#ifdef CRYPT
|
||||
(void)fprintf(stderr, "%s\n%s\n",
|
||||
"usage: rcp [-Kpx] [-k realm] f1 f2",
|
||||
" rcp [-Kprx] [-k realm] f1 ... fn directory");
|
||||
"usage: rcp [-46Kpx] [-k realm] f1 f2",
|
||||
" rcp [-46Kprx] [-k realm] f1 ... fn directory");
|
||||
#else
|
||||
(void)fprintf(stderr, "%s\n%s\n",
|
||||
"usage: rcp [-Kp] [-k realm] f1 f2",
|
||||
" rcp [-Kpr] [-k realm] f1 ... fn directory");
|
||||
"usage: rcp [-46Kp] [-k realm] f1 f2",
|
||||
" rcp [-46Kpr] [-k realm] f1 ... fn directory");
|
||||
#endif
|
||||
#else
|
||||
(void)fprintf(stderr, "%s\n%s\n",
|
||||
"usage: rcp [-p] f1 f2",
|
||||
" rcp [-pr] f1 ... fn directory");
|
||||
"usage: rcp [-46p] f1 f2",
|
||||
" rcp [-46pr] f1 ... fn directory");
|
||||
#endif
|
||||
exit(1);
|
||||
}
|
||||
|
||||
#if __STDC__
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
#ifdef KERBEROS
|
||||
void
|
||||
#if __STDC__
|
||||
oldw(const char *fmt, ...)
|
||||
#else
|
||||
oldw(fmt, va_alist)
|
||||
char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list ap;
|
||||
#if __STDC__
|
||||
va_start(ap, fmt);
|
||||
#else
|
||||
va_start(ap);
|
||||
#endif
|
||||
(void)fprintf(stderr, "rcp: ");
|
||||
(void)vfprintf(stderr, fmt, ap);
|
||||
(void)fprintf(stderr, ", using standard rcp\n");
|
||||
@@ -927,21 +926,11 @@ oldw(fmt, va_alist)
|
||||
#endif
|
||||
|
||||
void
|
||||
#if __STDC__
|
||||
run_err(const char *fmt, ...)
|
||||
#else
|
||||
run_err(fmt, va_alist)
|
||||
char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
static FILE *fp;
|
||||
va_list ap;
|
||||
#if __STDC__
|
||||
va_start(ap, fmt);
|
||||
#else
|
||||
va_start(ap);
|
||||
#endif
|
||||
|
||||
++errs;
|
||||
if (fp == NULL && !(fp = fdopen(rem, "w")))
|
||||
|
||||
+8
-16
@@ -35,9 +35,9 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)util.c 8.2 (Berkeley) 4/2/94";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -56,8 +56,7 @@ static const char rcsid[] =
|
||||
#include "extern.h"
|
||||
|
||||
char *
|
||||
colon(cp)
|
||||
char *cp;
|
||||
colon(char *cp)
|
||||
{
|
||||
if (*cp == ':') /* Leading colon is part of file name. */
|
||||
return (0);
|
||||
@@ -72,8 +71,7 @@ colon(cp)
|
||||
}
|
||||
|
||||
void
|
||||
verifydir(cp)
|
||||
char *cp;
|
||||
verifydir(char *cp)
|
||||
{
|
||||
struct stat stb;
|
||||
|
||||
@@ -87,8 +85,7 @@ verifydir(cp)
|
||||
}
|
||||
|
||||
int
|
||||
okname(cp0)
|
||||
char *cp0;
|
||||
okname(char *cp0)
|
||||
{
|
||||
int c;
|
||||
char *cp;
|
||||
@@ -108,9 +105,7 @@ bad: warnx("%s: invalid user name", cp0);
|
||||
}
|
||||
|
||||
int
|
||||
susystem(s, userid)
|
||||
int userid;
|
||||
char *s;
|
||||
susystem(char *s, int userid)
|
||||
{
|
||||
sig_t istat, qstat;
|
||||
int status;
|
||||
@@ -136,9 +131,7 @@ susystem(s, userid)
|
||||
}
|
||||
|
||||
BUF *
|
||||
allocbuf(bp, fd, blksize)
|
||||
BUF *bp;
|
||||
int fd, blksize;
|
||||
allocbuf(BUF *bp, int fd, int blksize)
|
||||
{
|
||||
struct stat stb;
|
||||
size_t size;
|
||||
@@ -162,8 +155,7 @@ allocbuf(bp, fd, blksize)
|
||||
}
|
||||
|
||||
void
|
||||
lostconn(signo)
|
||||
int signo;
|
||||
lostconn(int signo)
|
||||
{
|
||||
if (!iamremote)
|
||||
warnx("lost connection");
|
||||
|
||||
+24
-31
@@ -40,11 +40,10 @@ static const char copyright[] =
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)rm.c 8.5 (Berkeley) 4/18/94";
|
||||
#else
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/param.h>
|
||||
@@ -63,12 +62,12 @@ static const char rcsid[] =
|
||||
int dflag, eval, fflag, iflag, Pflag, vflag, Wflag, stdin_ok;
|
||||
uid_t uid;
|
||||
|
||||
int check __P((char *, char *, struct stat *));
|
||||
void checkdot __P((char **));
|
||||
void rm_file __P((char **));
|
||||
void rm_overwrite __P((char *, struct stat *));
|
||||
void rm_tree __P((char **));
|
||||
void usage __P((void));
|
||||
int check(char *, char *, struct stat *);
|
||||
void checkdot(char **);
|
||||
void rm_file(char **);
|
||||
void rm_overwrite(char *, struct stat *);
|
||||
void rm_tree(char **);
|
||||
void usage(void);
|
||||
|
||||
/*
|
||||
* rm --
|
||||
@@ -78,9 +77,7 @@ void usage __P((void));
|
||||
* file removal.
|
||||
*/
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int ch, rflag;
|
||||
char *p;
|
||||
@@ -95,11 +92,14 @@ main(argc, argv)
|
||||
else
|
||||
++p;
|
||||
if (strcmp(p, "unlink") == 0) {
|
||||
if (argc == 2) {
|
||||
rm_file(&argv[1]);
|
||||
exit(eval);
|
||||
} else
|
||||
while (getopt(argc, argv, "") != -1)
|
||||
usage();
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
if (argc != 1)
|
||||
usage();
|
||||
rm_file(&argv[0]);
|
||||
exit(eval);
|
||||
}
|
||||
|
||||
Pflag = rflag = 0;
|
||||
@@ -157,8 +157,7 @@ main(argc, argv)
|
||||
}
|
||||
|
||||
void
|
||||
rm_tree(argv)
|
||||
char **argv;
|
||||
rm_tree(char **argv)
|
||||
{
|
||||
FTS *fts;
|
||||
FTSENT *p;
|
||||
@@ -289,8 +288,7 @@ err:
|
||||
}
|
||||
|
||||
void
|
||||
rm_file(argv)
|
||||
char **argv;
|
||||
rm_file(char **argv)
|
||||
{
|
||||
struct stat sb;
|
||||
int rval;
|
||||
@@ -357,14 +355,12 @@ rm_file(argv)
|
||||
* XXX
|
||||
* This is a cheap way to *really* delete files. Note that only regular
|
||||
* files are deleted, directories (and therefore names) will remain.
|
||||
* Also, this assumes a fixed-block file system (like FFS, or a V7 or a
|
||||
* System V file system). In a logging file system, you'll have to have
|
||||
* Also, this assumes a fixed-block filesystem (like FFS, or a V7 or a
|
||||
* System V filesystem). In a logging filesystem, you'll have to have
|
||||
* kernel support.
|
||||
*/
|
||||
void
|
||||
rm_overwrite(file, sbp)
|
||||
char *file;
|
||||
struct stat *sbp;
|
||||
rm_overwrite(char *file, struct stat *sbp)
|
||||
{
|
||||
struct stat sb;
|
||||
struct statfs fsb;
|
||||
@@ -416,9 +412,7 @@ err: eval = 1;
|
||||
|
||||
|
||||
int
|
||||
check(path, name, sp)
|
||||
char *path, *name;
|
||||
struct stat *sp;
|
||||
check(char *path, char *name, struct stat *sp)
|
||||
{
|
||||
int ch, first;
|
||||
char modep[15], *flagsp;
|
||||
@@ -459,8 +453,7 @@ check(path, name, sp)
|
||||
|
||||
#define ISDOT(a) ((a)[0] == '.' && (!(a)[1] || ((a)[1] == '.' && !(a)[2])))
|
||||
void
|
||||
checkdot(argv)
|
||||
char **argv;
|
||||
checkdot(char **argv)
|
||||
{
|
||||
char *p, **save, **t;
|
||||
int complained;
|
||||
@@ -484,7 +477,7 @@ checkdot(argv)
|
||||
}
|
||||
|
||||
void
|
||||
usage()
|
||||
usage(void)
|
||||
{
|
||||
|
||||
(void)fprintf(stderr, "%s\n%s\n",
|
||||
|
||||
+25
-27
@@ -38,9 +38,9 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)alias.c 8.3 (Berkeley) 5/4/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "shell.h"
|
||||
@@ -56,14 +56,13 @@ static const char rcsid[] =
|
||||
|
||||
struct alias *atab[ATABSIZE];
|
||||
|
||||
STATIC void setalias __P((char *, char *));
|
||||
STATIC int unalias __P((char *));
|
||||
STATIC struct alias **hashalias __P((char *));
|
||||
STATIC void setalias(char *, char *);
|
||||
STATIC int unalias(char *);
|
||||
STATIC struct alias **hashalias(char *);
|
||||
|
||||
STATIC
|
||||
void
|
||||
setalias(name, val)
|
||||
char *name, *val;
|
||||
setalias(char *name, char *val)
|
||||
{
|
||||
struct alias *ap, **app;
|
||||
|
||||
@@ -116,9 +115,8 @@ setalias(name, val)
|
||||
}
|
||||
|
||||
STATIC int
|
||||
unalias(name)
|
||||
char *name;
|
||||
{
|
||||
unalias(char *name)
|
||||
{
|
||||
struct alias *ap, **app;
|
||||
|
||||
app = hashalias(name);
|
||||
@@ -158,7 +156,8 @@ SHELLPROC {
|
||||
#endif
|
||||
|
||||
void
|
||||
rmaliases() {
|
||||
rmaliases(void)
|
||||
{
|
||||
struct alias *ap, *tmp;
|
||||
int i;
|
||||
|
||||
@@ -178,9 +177,7 @@ rmaliases() {
|
||||
}
|
||||
|
||||
struct alias *
|
||||
lookupalias(name, check)
|
||||
char *name;
|
||||
int check;
|
||||
lookupalias(char *name, int check)
|
||||
{
|
||||
struct alias *ap = *hashalias(name);
|
||||
|
||||
@@ -199,9 +196,7 @@ lookupalias(name, check)
|
||||
* TODO - sort output
|
||||
*/
|
||||
int
|
||||
aliascmd(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
aliascmd(int argc, char **argv)
|
||||
{
|
||||
char *n, *v;
|
||||
int ret = 0;
|
||||
@@ -212,8 +207,11 @@ aliascmd(argc, argv)
|
||||
|
||||
for (i = 0; i < ATABSIZE; i++)
|
||||
for (ap = atab[i]; ap; ap = ap->next) {
|
||||
if (*ap->name != '\0')
|
||||
out1fmt("alias %s=%s\n", ap->name, ap->val);
|
||||
if (*ap->name != '\0') {
|
||||
out1fmt("alias %s=", ap->name);
|
||||
out1qstr(ap->val);
|
||||
out1c('\n');
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
@@ -222,8 +220,11 @@ aliascmd(argc, argv)
|
||||
if ((ap = lookupalias(n, 0)) == NULL) {
|
||||
outfmt(out2, "alias: %s not found\n", n);
|
||||
ret = 1;
|
||||
} else
|
||||
out1fmt("alias %s=%s\n", n, ap->val);
|
||||
} else {
|
||||
out1fmt("alias %s=", n);
|
||||
out1qstr(ap->val);
|
||||
out1c('\n');
|
||||
}
|
||||
else {
|
||||
*v++ = '\0';
|
||||
setalias(n, v);
|
||||
@@ -234,9 +235,7 @@ aliascmd(argc, argv)
|
||||
}
|
||||
|
||||
int
|
||||
unaliascmd(argc, argv)
|
||||
int argc __unused;
|
||||
char **argv __unused;
|
||||
unaliascmd(int argc __unused, char **argv __unused)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -253,9 +252,8 @@ unaliascmd(argc, argv)
|
||||
}
|
||||
|
||||
STATIC struct alias **
|
||||
hashalias(p)
|
||||
char *p;
|
||||
{
|
||||
hashalias(char *p)
|
||||
{
|
||||
unsigned int hashval;
|
||||
|
||||
hashval = *p << 4;
|
||||
|
||||
+4
-4
@@ -46,7 +46,7 @@ struct alias {
|
||||
int flag;
|
||||
};
|
||||
|
||||
struct alias *lookupalias __P((char *, int));
|
||||
int aliascmd __P((int, char **));
|
||||
int unaliascmd __P((int, char **));
|
||||
void rmaliases __P((void));
|
||||
struct alias *lookupalias(char *, int);
|
||||
int aliascmd(int, char **);
|
||||
int unaliascmd(int, char **);
|
||||
void rmaliases(void);
|
||||
+2
-2
@@ -34,5 +34,5 @@
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
int arith __P((char *));
|
||||
int expcmd __P((int , char **));
|
||||
int arith(char *);
|
||||
int expcmd(int , char **);
|
||||
+8
-15
@@ -87,8 +87,6 @@ expr: ARITH_LPAREN expr ARITH_RPAREN = { $$ = $2; }
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@@ -107,12 +105,11 @@ static const char rcsid[] =
|
||||
char *arith_buf, *arith_startbuf;
|
||||
extern void arith_lex_reset();
|
||||
|
||||
int yylex __P((void));
|
||||
int yyparse __P((void));
|
||||
int yylex(void);
|
||||
int yyparse(void);
|
||||
|
||||
int
|
||||
arith(s)
|
||||
char *s;
|
||||
arith(char *s)
|
||||
{
|
||||
long result;
|
||||
|
||||
@@ -127,8 +124,7 @@ arith(s)
|
||||
}
|
||||
|
||||
void
|
||||
yyerror(s)
|
||||
char *s;
|
||||
yyerror(char *s)
|
||||
{
|
||||
|
||||
yyerrok;
|
||||
@@ -141,9 +137,7 @@ yyerror(s)
|
||||
* The exp(1) builtin.
|
||||
*/
|
||||
int
|
||||
expcmd(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
expcmd(int argc, char **argv)
|
||||
{
|
||||
char *p;
|
||||
char *concat;
|
||||
@@ -180,13 +174,12 @@ expcmd(argc, argv)
|
||||
/*************************/
|
||||
#ifdef TEST_ARITH
|
||||
#include <stdio.h>
|
||||
main(argc, argv)
|
||||
char *argv[];
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
printf("%d\n", exp(argv[1]));
|
||||
}
|
||||
error(s)
|
||||
char *s;
|
||||
|
||||
error(char *s)
|
||||
{
|
||||
fprintf(stderr, "exp: %s\n", s);
|
||||
exit(1);
|
||||
|
||||
+2
-3
@@ -33,8 +33,6 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@@ -85,6 +83,7 @@ extern char *arith_buf, *arith_startbuf;
|
||||
%%
|
||||
|
||||
void
|
||||
arith_lex_reset() {
|
||||
arith_lex_reset()
|
||||
{
|
||||
YY_NEW_FILE;
|
||||
}
|
||||
@@ -83,13 +83,8 @@
|
||||
#define INITARGS(argv) if ((commandname = argv[0]) == NULL) {fputs("Argc is zero\n", stderr); exit(2);} else
|
||||
#endif
|
||||
|
||||
#ifdef __STDC__
|
||||
pointer stalloc(int);
|
||||
void error(const char *, ...) __printf0like(1, 2);
|
||||
#else
|
||||
pointer stalloc();
|
||||
void error();
|
||||
#endif
|
||||
|
||||
|
||||
extern char *commandname;
|
||||
+1
-3
@@ -48,9 +48,7 @@
|
||||
/* #define eflag 1 */
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
char **ap;
|
||||
char *p;
|
||||
|
||||
+3
-1
@@ -49,7 +49,8 @@
|
||||
#
|
||||
# NOTE: bltincmd must come first!
|
||||
|
||||
bltincmd command
|
||||
bltincmd builtin
|
||||
commandcmd command
|
||||
#alloccmd alloc
|
||||
bgcmd -j bg
|
||||
breakcmd break continue
|
||||
@@ -91,3 +92,4 @@ waitcmd wait
|
||||
aliascmd alias
|
||||
ulimitcmd ulimit
|
||||
testcmd test [
|
||||
bindcmd bind
|
||||
+114
-105
@@ -38,9 +38,9 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)cd.c 8.2 (Berkeley) 5/4/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -48,6 +48,7 @@ static const char rcsid[] =
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
|
||||
/*
|
||||
* The cd and pwd commands.
|
||||
@@ -67,27 +68,47 @@ static const char rcsid[] =
|
||||
#include "show.h"
|
||||
#include "cd.h"
|
||||
|
||||
STATIC int docd __P((char *, int));
|
||||
STATIC char *getcomponent __P((void));
|
||||
STATIC void updatepwd __P((char *));
|
||||
STATIC int cdlogical(char *);
|
||||
STATIC int cdphysical(char *);
|
||||
STATIC int docd(char *, int, int);
|
||||
STATIC char *getcomponent(void);
|
||||
STATIC int updatepwd(char *);
|
||||
|
||||
char *curdir = NULL; /* current working directory */
|
||||
char *prevdir; /* previous working directory */
|
||||
STATIC char *cdcomppath;
|
||||
|
||||
int
|
||||
cdcmd(argc, argv)
|
||||
int argc __unused;
|
||||
char **argv __unused;
|
||||
cdcmd(int argc, char **argv)
|
||||
{
|
||||
char *dest;
|
||||
char *path;
|
||||
char *p;
|
||||
struct stat statb;
|
||||
int print = 0;
|
||||
int ch, phys, print = 0;
|
||||
|
||||
nextopt(nullstr);
|
||||
if ((dest = *argptr) == NULL && (dest = bltinlookup("HOME", 1)) == NULL)
|
||||
optreset = 1; optind = 1; opterr = 0; /* initialize getopt */
|
||||
phys = Pflag;
|
||||
while ((ch = getopt(argc, argv, "LP")) != -1) {
|
||||
switch (ch) {
|
||||
case 'L':
|
||||
phys = 0;
|
||||
break;
|
||||
case 'P':
|
||||
phys = 1;
|
||||
break;
|
||||
default:
|
||||
error("unknown option: -%c", optopt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if (argc > 1)
|
||||
error("too many arguments");
|
||||
|
||||
if ((dest = *argv) == NULL && (dest = bltinlookup("HOME", 1)) == NULL)
|
||||
error("HOME not set");
|
||||
if (*dest == '\0')
|
||||
dest = ".";
|
||||
@@ -110,9 +131,8 @@ cdcmd(argc, argv)
|
||||
p += 2;
|
||||
print = strcmp(p, dest);
|
||||
}
|
||||
if (docd(p, print) >= 0)
|
||||
if (docd(p, print, phys) >= 0)
|
||||
return 0;
|
||||
|
||||
}
|
||||
}
|
||||
error("can't cd to %s", dest);
|
||||
@@ -122,13 +142,27 @@ cdcmd(argc, argv)
|
||||
|
||||
|
||||
/*
|
||||
* Actually do the chdir. In an interactive shell, print the
|
||||
* Actually change the directory. In an interactive shell, print the
|
||||
* directory name if "print" is nonzero.
|
||||
*/
|
||||
STATIC int
|
||||
docd(dest, print)
|
||||
char *dest;
|
||||
int print;
|
||||
docd(char *dest, int print, int phys)
|
||||
{
|
||||
|
||||
TRACE(("docd(\"%s\", %d, %d) called\n", dest, print, phys));
|
||||
|
||||
/* If logical cd fails, fall back to physical. */
|
||||
if ((phys || cdlogical(dest) < 0) && cdphysical(dest) < 0)
|
||||
return (-1);
|
||||
|
||||
if (print && iflag && curdir)
|
||||
out1fmt("%s\n", curdir);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
STATIC int
|
||||
cdlogical(char *dest)
|
||||
{
|
||||
char *p;
|
||||
char *q;
|
||||
@@ -137,8 +171,6 @@ docd(dest, print)
|
||||
int first;
|
||||
int badstat;
|
||||
|
||||
TRACE(("docd(\"%s\", %d) called\n", dest, print));
|
||||
|
||||
/*
|
||||
* Check each component of the path. If we find a symlink or
|
||||
* something we can't stat, clear curdir to force a getcwd()
|
||||
@@ -165,33 +197,40 @@ docd(dest, print)
|
||||
if (equal(component, ".."))
|
||||
continue;
|
||||
STACKSTRNUL(p);
|
||||
if ((lstat(stackblock(), &statb) < 0)
|
||||
|| (S_ISLNK(statb.st_mode))) {
|
||||
/* print = 1; */
|
||||
if (lstat(stackblock(), &statb) < 0) {
|
||||
badstat = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
INTOFF;
|
||||
if (chdir(dest) < 0) {
|
||||
if (updatepwd(badstat ? NULL : dest) < 0 || chdir(curdir) < 0) {
|
||||
INTON;
|
||||
return -1;
|
||||
return (-1);
|
||||
}
|
||||
updatepwd(badstat ? NULL : dest);
|
||||
INTON;
|
||||
if (print && iflag && curdir)
|
||||
out1fmt("%s\n", curdir);
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
STATIC int
|
||||
cdphysical(char *dest)
|
||||
{
|
||||
|
||||
INTOFF;
|
||||
if (chdir(dest) < 0 || updatepwd(NULL) < 0) {
|
||||
INTON;
|
||||
return (-1);
|
||||
}
|
||||
INTON;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the next component of the path name pointed to by cdcomppath.
|
||||
* This routine overwrites the string pointed to by cdcomppath.
|
||||
*/
|
||||
STATIC char *
|
||||
getcomponent()
|
||||
getcomponent(void)
|
||||
{
|
||||
char *p;
|
||||
char *start;
|
||||
@@ -216,9 +255,8 @@ getcomponent()
|
||||
* cd command. We also call hashcd to let the routines in exec.c know
|
||||
* that the current directory has changed.
|
||||
*/
|
||||
STATIC void
|
||||
updatepwd(dir)
|
||||
char *dir;
|
||||
STATIC int
|
||||
updatepwd(char *dir)
|
||||
{
|
||||
char *new;
|
||||
char *p;
|
||||
@@ -236,12 +274,14 @@ updatepwd(dir)
|
||||
INTOFF;
|
||||
prevdir = curdir;
|
||||
curdir = NULL;
|
||||
if (getpwd() == NULL)
|
||||
error("getcwd() failed: %s", strerror(errno));
|
||||
if (getpwd() == NULL) {
|
||||
INTON;
|
||||
return (-1);
|
||||
}
|
||||
setvar("PWD", curdir, VEXPORT);
|
||||
setvar("OLDPWD", prevdir, VEXPORT);
|
||||
INTON;
|
||||
return;
|
||||
return (0);
|
||||
}
|
||||
cdcomppath = stalloc(strlen(dir) + 1);
|
||||
scopy(dir, cdcomppath);
|
||||
@@ -273,51 +313,61 @@ updatepwd(dir)
|
||||
setvar("PWD", curdir, VEXPORT);
|
||||
setvar("OLDPWD", prevdir, VEXPORT);
|
||||
INTON;
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
pwdcmd(argc, argv)
|
||||
int argc __unused;
|
||||
char **argv __unused;
|
||||
pwdcmd(int argc, char **argv)
|
||||
{
|
||||
if (!getpwd())
|
||||
error("getcwd() failed: %s", strerror(errno));
|
||||
out1str(curdir);
|
||||
out1c('\n');
|
||||
char buf[PATH_MAX];
|
||||
int ch, phys;
|
||||
|
||||
optreset = 1; optind = 1; opterr = 0; /* initialize getopt */
|
||||
phys = Pflag;
|
||||
while ((ch = getopt(argc, argv, "LP")) != -1) {
|
||||
switch (ch) {
|
||||
case 'L':
|
||||
phys = 0;
|
||||
break;
|
||||
case 'P':
|
||||
phys = 1;
|
||||
break;
|
||||
default:
|
||||
error("unknown option: -%c", optopt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if (argc != 0)
|
||||
error("too many arguments");
|
||||
|
||||
if (!phys && getpwd()) {
|
||||
out1str(curdir);
|
||||
out1c('\n');
|
||||
} else {
|
||||
if (getcwd(buf, sizeof(buf)) == NULL)
|
||||
error(".: %s", strerror(errno));
|
||||
out1str(buf);
|
||||
out1c('\n');
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#define MAXPWD 256
|
||||
|
||||
/*
|
||||
* Find out what the current directory is. If we already know the current
|
||||
* directory, this routine returns immediately.
|
||||
*/
|
||||
char *
|
||||
getpwd()
|
||||
getpwd(void)
|
||||
{
|
||||
char buf[MAXPWD];
|
||||
char buf[PATH_MAX];
|
||||
|
||||
if (curdir)
|
||||
return curdir;
|
||||
/*
|
||||
* Things are a bit complicated here; we could have just used
|
||||
* getcwd, but traditionally getcwd is implemented using popen
|
||||
* to /bin/pwd. This creates a problem for us, since we cannot
|
||||
* keep track of the job if it is being ran behind our backs.
|
||||
* So we re-implement getcwd(), and we suppress interrupts
|
||||
* throughout the process. This is not completely safe, since
|
||||
* the user can still break out of it by killing the pwd program.
|
||||
* We still try to use getcwd for systems that we know have a
|
||||
* c implementation of getcwd, that does not open a pipe to
|
||||
* /bin/pwd.
|
||||
*/
|
||||
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__SVR4)
|
||||
|
||||
if (getcwd(buf, sizeof(buf)) == NULL) {
|
||||
char *pwd = getenv("PWD");
|
||||
struct stat stdot, stpwd;
|
||||
@@ -332,47 +382,6 @@ getpwd()
|
||||
return NULL;
|
||||
}
|
||||
curdir = savestr(buf);
|
||||
#else
|
||||
{
|
||||
char *p;
|
||||
int i;
|
||||
int status;
|
||||
struct job *jp;
|
||||
int pip[2];
|
||||
|
||||
INTOFF;
|
||||
if (pipe(pip) < 0)
|
||||
error("Pipe call failed: %s", strerror(errno));
|
||||
jp = makejob((union node *)NULL, 1);
|
||||
if (forkshell(jp, (union node *)NULL, FORK_NOJOB) == 0) {
|
||||
(void) close(pip[0]);
|
||||
if (pip[1] != 1) {
|
||||
close(1);
|
||||
copyfd(pip[1], 1);
|
||||
close(pip[1]);
|
||||
}
|
||||
(void) execl("/bin/pwd", "pwd", (char *)0);
|
||||
error("Cannot exec /bin/pwd");
|
||||
}
|
||||
(void) close(pip[1]);
|
||||
pip[1] = -1;
|
||||
p = buf;
|
||||
while ((i = read(pip[0], p, buf + MAXPWD - p)) > 0
|
||||
|| (i == -1 && errno == EINTR)) {
|
||||
if (i > 0)
|
||||
p += i;
|
||||
}
|
||||
(void) close(pip[0]);
|
||||
pip[0] = -1;
|
||||
status = waitforjob(jp);
|
||||
if (status != 0)
|
||||
error((char *)0);
|
||||
if (i < 0 || p == buf || p[-1] != '\n')
|
||||
error("pwd command failed");
|
||||
p[-1] = '\0';
|
||||
}
|
||||
curdir = savestr(buf);
|
||||
INTON;
|
||||
#endif
|
||||
return curdir;
|
||||
}
|
||||
+3
-3
@@ -33,6 +33,6 @@
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
char *getpwd __P((void));
|
||||
int cdcmd __P((int, char **));
|
||||
int pwdcmd __P((int, char **));
|
||||
char *getpwd(void);
|
||||
int cdcmd (int, char **);
|
||||
int pwdcmd(int, char **);
|
||||
+9
-46
@@ -38,9 +38,9 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)error.c 8.2 (Berkeley) 5/4/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
/*
|
||||
* Errors and exceptions.
|
||||
@@ -71,7 +71,7 @@ volatile sig_atomic_t intpending;
|
||||
char *commandname;
|
||||
|
||||
|
||||
static void exverror __P((int, const char *, va_list)) __printf0like(2, 0);
|
||||
static void exverror(int, const char *, va_list) __printf0like(2, 0);
|
||||
|
||||
/*
|
||||
* Called to raise an exception. Since C doesn't include exceptions, we
|
||||
@@ -80,8 +80,7 @@ static void exverror __P((int, const char *, va_list)) __printf0like(2, 0);
|
||||
*/
|
||||
|
||||
void
|
||||
exraise(e)
|
||||
int e;
|
||||
exraise(int e)
|
||||
{
|
||||
if (handler == NULL)
|
||||
abort();
|
||||
@@ -101,7 +100,8 @@ exraise(e)
|
||||
*/
|
||||
|
||||
void
|
||||
onint() {
|
||||
onint(void)
|
||||
{
|
||||
sigset_t sigset;
|
||||
|
||||
/*
|
||||
@@ -140,10 +140,7 @@ onint() {
|
||||
* formatting. It then raises the error exception.
|
||||
*/
|
||||
static void
|
||||
exverror(cond, msg, ap)
|
||||
int cond;
|
||||
const char *msg;
|
||||
va_list ap;
|
||||
exverror(int cond, const char *msg, va_list ap)
|
||||
{
|
||||
CLEAR_PENDING_INT;
|
||||
INTOFF;
|
||||
@@ -165,51 +162,21 @@ exverror(cond, msg, ap)
|
||||
}
|
||||
|
||||
|
||||
#ifdef __STDC__
|
||||
void
|
||||
error(const char *msg, ...)
|
||||
#else
|
||||
void
|
||||
error(va_alist)
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
#ifndef __STDC__
|
||||
const char *msg;
|
||||
#endif
|
||||
va_list ap;
|
||||
#ifdef __STDC__
|
||||
va_start(ap, msg);
|
||||
#else
|
||||
va_start(ap);
|
||||
msg = va_arg(ap, char *);
|
||||
#endif
|
||||
exverror(EXERROR, msg, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
|
||||
#ifdef __STDC__
|
||||
void
|
||||
exerror(int cond, const char *msg, ...)
|
||||
#else
|
||||
void
|
||||
exerror(va_alist)
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
#ifndef __STDC__
|
||||
int cond;
|
||||
char *msg;
|
||||
#endif
|
||||
va_list ap;
|
||||
#ifdef __STDC__
|
||||
va_start(ap, msg);
|
||||
#else
|
||||
va_start(ap);
|
||||
cond = va_arg(ap, int);
|
||||
msg = va_arg(ap, char *);
|
||||
#endif
|
||||
exverror(cond, msg, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
@@ -254,9 +221,6 @@ STATIC const struct errname errormsg[] = {
|
||||
{ ENXIO, ALL, "no such device or address" },
|
||||
{ EROFS, ALL, "read-only file system" },
|
||||
{ ETXTBSY, ALL, "text busy" },
|
||||
#ifdef SYSV
|
||||
{ EAGAIN, E_EXEC, "not enough memory" },
|
||||
#endif
|
||||
{ ENOMEM, ALL, "not enough memory" },
|
||||
#ifdef ENOLINK
|
||||
{ ENOLINK, ALL, "remote access failed" },
|
||||
@@ -280,6 +244,7 @@ STATIC const struct errname errormsg[] = {
|
||||
#ifdef ELIBACC
|
||||
{ ELIBACC, E_EXEC, "shared library missing" },
|
||||
#endif
|
||||
{ EEXIST, E_CREAT, "file exists" },
|
||||
{ 0, 0, NULL },
|
||||
};
|
||||
|
||||
@@ -291,9 +256,7 @@ STATIC const struct errname errormsg[] = {
|
||||
*/
|
||||
|
||||
char *
|
||||
errmsg(e, action)
|
||||
int e;
|
||||
int action;
|
||||
errmsg(int e, int action)
|
||||
{
|
||||
struct errname const *ep;
|
||||
static char buf[12];
|
||||
|
||||
+5
-7
@@ -89,11 +89,11 @@ extern volatile sig_atomic_t intpending;
|
||||
#define CLEAR_PENDING_INT intpending = 0
|
||||
#define int_pending() intpending
|
||||
|
||||
void exraise __P((int));
|
||||
void onint __P((void));
|
||||
void error __P((const char *, ...)) __printf0like(1, 2);
|
||||
void exerror __P((int, const char *, ...)) __printf0like(2, 3);
|
||||
char *errmsg __P((int, int));
|
||||
void exraise(int);
|
||||
void onint(void);
|
||||
void error(const char *, ...) __printf0like(1, 2);
|
||||
void exerror(int, const char *, ...) __printf0like(2, 3);
|
||||
char *errmsg(int, int);
|
||||
|
||||
|
||||
/*
|
||||
@@ -101,7 +101,5 @@ char *errmsg __P((int, int));
|
||||
* so we use _setjmp instead.
|
||||
*/
|
||||
|
||||
#ifdef BSD
|
||||
#define setjmp(jmploc) _setjmp(jmploc)
|
||||
#define longjmp(jmploc, val) _longjmp(jmploc, val)
|
||||
#endif
|
||||
+85
-62
@@ -38,10 +38,11 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)eval.c 8.9 (Berkeley) 6/8/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <paths.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/wait.h> /* For WIFSIGNALED(status) */
|
||||
@@ -92,14 +93,14 @@ int exitstatus; /* exit status of last command */
|
||||
int oexitstatus; /* saved exit status */
|
||||
|
||||
|
||||
STATIC void evalloop __P((union node *));
|
||||
STATIC void evalfor __P((union node *));
|
||||
STATIC void evalcase __P((union node *, int));
|
||||
STATIC void evalsubshell __P((union node *, int));
|
||||
STATIC void expredir __P((union node *));
|
||||
STATIC void evalpipe __P((union node *));
|
||||
STATIC void evalcommand __P((union node *, int, struct backcmd *));
|
||||
STATIC void prehash __P((union node *));
|
||||
STATIC void evalloop(union node *);
|
||||
STATIC void evalfor(union node *);
|
||||
STATIC void evalcase(union node *, int);
|
||||
STATIC void evalsubshell(union node *, int);
|
||||
STATIC void expredir(union node *);
|
||||
STATIC void evalpipe(union node *);
|
||||
STATIC void evalcommand(union node *, int, struct backcmd *);
|
||||
STATIC void prehash(union node *);
|
||||
|
||||
|
||||
/*
|
||||
@@ -127,9 +128,7 @@ SHELLPROC {
|
||||
*/
|
||||
|
||||
int
|
||||
evalcmd(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
evalcmd(int argc, char **argv)
|
||||
{
|
||||
char *p;
|
||||
char *concat;
|
||||
@@ -161,9 +160,8 @@ evalcmd(argc, argv)
|
||||
*/
|
||||
|
||||
void
|
||||
evalstring(s)
|
||||
char *s;
|
||||
{
|
||||
evalstring(char *s)
|
||||
{
|
||||
union node *n;
|
||||
struct stackmark smark;
|
||||
|
||||
@@ -185,9 +183,7 @@ evalstring(s)
|
||||
*/
|
||||
|
||||
void
|
||||
evaltree(n, flags)
|
||||
union node *n;
|
||||
int flags;
|
||||
evaltree(union node *n, int flags)
|
||||
{
|
||||
if (n == NULL) {
|
||||
TRACE(("evaltree(NULL) called\n"));
|
||||
@@ -305,8 +301,7 @@ out:
|
||||
|
||||
|
||||
STATIC void
|
||||
evalloop(n)
|
||||
union node *n;
|
||||
evalloop(union node *n)
|
||||
{
|
||||
int status;
|
||||
|
||||
@@ -342,8 +337,7 @@ skipping: if (evalskip == SKIPCONT && --skipcount <= 0) {
|
||||
|
||||
|
||||
STATIC void
|
||||
evalfor(n)
|
||||
union node *n;
|
||||
evalfor(union node *n)
|
||||
{
|
||||
struct arglist arglist;
|
||||
union node *argp;
|
||||
@@ -383,9 +377,7 @@ out:
|
||||
|
||||
|
||||
STATIC void
|
||||
evalcase(n, flags)
|
||||
union node *n;
|
||||
int flags;
|
||||
evalcase(union node *n, int flags)
|
||||
{
|
||||
union node *cp;
|
||||
union node *patp;
|
||||
@@ -417,9 +409,7 @@ out:
|
||||
*/
|
||||
|
||||
STATIC void
|
||||
evalsubshell(n, flags)
|
||||
union node *n;
|
||||
int flags;
|
||||
evalsubshell(union node *n, int flags)
|
||||
{
|
||||
struct job *jp;
|
||||
int backgnd = (n->type == NBACKGND);
|
||||
@@ -446,8 +436,7 @@ evalsubshell(n, flags)
|
||||
*/
|
||||
|
||||
STATIC void
|
||||
expredir(n)
|
||||
union node *n;
|
||||
expredir(union node *n)
|
||||
{
|
||||
union node *redir;
|
||||
|
||||
@@ -460,6 +449,7 @@ expredir(n)
|
||||
case NTO:
|
||||
case NFROMTO:
|
||||
case NAPPEND:
|
||||
case NCLOBBER:
|
||||
expandarg(redir->nfile.fname, &fn, EXP_TILDE | EXP_REDIR);
|
||||
redir->nfile.expfname = fn.list->text;
|
||||
break;
|
||||
@@ -484,8 +474,7 @@ expredir(n)
|
||||
*/
|
||||
|
||||
STATIC void
|
||||
evalpipe(n)
|
||||
union node *n;
|
||||
evalpipe(union node *n)
|
||||
{
|
||||
struct job *jp;
|
||||
struct nodelist *lp;
|
||||
@@ -551,9 +540,7 @@ evalpipe(n)
|
||||
*/
|
||||
|
||||
void
|
||||
evalbackcmd(n, result)
|
||||
union node *n;
|
||||
struct backcmd *result;
|
||||
evalbackcmd(union node *n, struct backcmd *result)
|
||||
{
|
||||
int pip[2];
|
||||
struct job *jp;
|
||||
@@ -603,10 +590,7 @@ out:
|
||||
*/
|
||||
|
||||
STATIC void
|
||||
evalcommand(cmd, flags, backcmd)
|
||||
union node *cmd;
|
||||
int flags;
|
||||
struct backcmd *backcmd;
|
||||
evalcommand(union node *cmd, int flags, struct backcmd *backcmd)
|
||||
{
|
||||
struct stackmark smark;
|
||||
union node *argp;
|
||||
@@ -764,7 +748,9 @@ evalcommand(cmd, flags, backcmd)
|
||||
&& (cmdentry.cmdtype != CMDBUILTIN
|
||||
|| cmdentry.u.index == CDCMD
|
||||
|| cmdentry.u.index == DOTCMD
|
||||
|| cmdentry.u.index == EVALCMD))) {
|
||||
|| cmdentry.u.index == EVALCMD))
|
||||
|| (cmdentry.cmdtype == CMDBUILTIN &&
|
||||
cmdentry.u.index == COMMANDCMD)) {
|
||||
jp = makejob(cmd, 1);
|
||||
mode = cmd->ncmd.backgnd;
|
||||
if (flags & EV_BACKCMD) {
|
||||
@@ -886,7 +872,8 @@ cmddone:
|
||||
#ifndef NO_HISTORY
|
||||
|| cmdentry.u.index == HISTCMD
|
||||
#endif
|
||||
|| cmdentry.u.index == EXECCMD)
|
||||
|| cmdentry.u.index == EXECCMD
|
||||
|| cmdentry.u.index == COMMANDCMD)
|
||||
exraise(e);
|
||||
FORCEINTON;
|
||||
}
|
||||
@@ -944,8 +931,7 @@ out:
|
||||
*/
|
||||
|
||||
STATIC void
|
||||
prehash(n)
|
||||
union node *n;
|
||||
prehash(union node *n)
|
||||
{
|
||||
struct cmdentry entry;
|
||||
|
||||
@@ -968,9 +954,7 @@ prehash(n)
|
||||
*/
|
||||
|
||||
int
|
||||
bltincmd(argc, argv)
|
||||
int argc __unused;
|
||||
char **argv __unused;
|
||||
bltincmd(int argc __unused, char **argv __unused)
|
||||
{
|
||||
listsetvar(cmdenviron);
|
||||
/*
|
||||
@@ -993,9 +977,7 @@ bltincmd(argc, argv)
|
||||
*/
|
||||
|
||||
int
|
||||
breakcmd(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
breakcmd(int argc, char **argv)
|
||||
{
|
||||
int n = argc > 1 ? number(argv[1]) : 1;
|
||||
|
||||
@@ -1008,15 +990,62 @@ breakcmd(argc, argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* The `command' command.
|
||||
*/
|
||||
int
|
||||
commandcmd(int argc, char **argv)
|
||||
{
|
||||
static char stdpath[] = _PATH_STDPATH;
|
||||
struct jmploc loc, *old;
|
||||
struct strlist *sp;
|
||||
char *path;
|
||||
int ch;
|
||||
|
||||
for (sp = cmdenviron; sp ; sp = sp->next)
|
||||
setvareq(sp->text, VEXPORT|VSTACK);
|
||||
path = pathval();
|
||||
|
||||
optind = optreset = 1;
|
||||
opterr = 0;
|
||||
while ((ch = getopt(argc, argv, "p")) != -1) {
|
||||
switch (ch) {
|
||||
case 'p':
|
||||
path = stdpath;
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
error("unknown option: -%c", optopt);
|
||||
}
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if (argc != 0) {
|
||||
old = handler;
|
||||
handler = &loc;
|
||||
if (setjmp(handler->loc) == 0)
|
||||
shellexec(argv, environment(), path, 0);
|
||||
handler = old;
|
||||
if (exception == EXEXEC)
|
||||
exit(exerrno);
|
||||
exraise(exception);
|
||||
}
|
||||
|
||||
/*
|
||||
* Do nothing successfully if no command was specified;
|
||||
* ksh also does this.
|
||||
*/
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* The return command.
|
||||
*/
|
||||
|
||||
int
|
||||
returncmd(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
returncmd(int argc, char **argv)
|
||||
{
|
||||
int ret = argc > 1 ? number(argv[1]) : oexitstatus;
|
||||
|
||||
@@ -1033,27 +1062,21 @@ returncmd(argc, argv)
|
||||
|
||||
|
||||
int
|
||||
falsecmd(argc, argv)
|
||||
int argc __unused;
|
||||
char **argv __unused;
|
||||
falsecmd(int argc __unused, char **argv __unused)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
truecmd(argc, argv)
|
||||
int argc __unused;
|
||||
char **argv __unused;
|
||||
truecmd(int argc __unused, char **argv __unused)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
execcmd(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
execcmd(int argc, char **argv)
|
||||
{
|
||||
if (argc > 1) {
|
||||
struct strlist *sp;
|
||||
|
||||
+11
-10
@@ -49,17 +49,18 @@ struct backcmd { /* result of evalbackcmd */
|
||||
struct job *jp; /* job structure for command */
|
||||
};
|
||||
|
||||
int evalcmd __P((int, char **));
|
||||
void evalstring __P((char *));
|
||||
int evalcmd(int, char **);
|
||||
void evalstring(char *);
|
||||
union node; /* BLETCH for ansi C */
|
||||
void evaltree __P((union node *, int));
|
||||
void evalbackcmd __P((union node *, struct backcmd *));
|
||||
int bltincmd __P((int, char **));
|
||||
int breakcmd __P((int, char **));
|
||||
int returncmd __P((int, char **));
|
||||
int falsecmd __P((int, char **));
|
||||
int truecmd __P((int, char **));
|
||||
int execcmd __P((int, char **));
|
||||
void evaltree(union node *, int);
|
||||
void evalbackcmd(union node *, struct backcmd *);
|
||||
int bltincmd(int, char **);
|
||||
int breakcmd(int, char **);
|
||||
int returncmd(int, char **);
|
||||
int falsecmd(int, char **);
|
||||
int truecmd(int, char **);
|
||||
int execcmd(int, char **);
|
||||
int commandcmd(int, char **);
|
||||
|
||||
/* in_function returns nonzero if we are currently evaluating a function */
|
||||
#define in_function() funcnest
|
||||
|
||||
+35
-182
@@ -38,9 +38,9 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)exec.c 8.4 (Berkeley) 6/8/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -99,13 +99,10 @@ STATIC int builtinloc = -1; /* index in path of %builtin, or -1 */
|
||||
int exerrno = 0; /* Last exec error */
|
||||
|
||||
|
||||
STATIC void tryexec __P((char *, char **, char **));
|
||||
#ifndef BSD
|
||||
STATIC void execinterp __P((char **, char **));
|
||||
#endif
|
||||
STATIC void printentry __P((struct tblentry *, int));
|
||||
STATIC struct tblentry *cmdlookup __P((char *, int));
|
||||
STATIC void delete_cmd_entry __P((void));
|
||||
STATIC void tryexec(char *, char **, char **);
|
||||
STATIC void printentry(struct tblentry *, int);
|
||||
STATIC struct tblentry *cmdlookup(char *, int);
|
||||
STATIC void delete_cmd_entry(void);
|
||||
|
||||
|
||||
|
||||
@@ -115,10 +112,7 @@ STATIC void delete_cmd_entry __P((void));
|
||||
*/
|
||||
|
||||
void
|
||||
shellexec(argv, envp, path, index)
|
||||
char **argv, **envp;
|
||||
char *path;
|
||||
int index;
|
||||
shellexec(char **argv, char **envp, char *path, int index)
|
||||
{
|
||||
char *cmdname;
|
||||
int e;
|
||||
@@ -155,36 +149,16 @@ shellexec(argv, envp, path, index)
|
||||
|
||||
|
||||
STATIC void
|
||||
tryexec(cmd, argv, envp)
|
||||
char *cmd;
|
||||
char **argv;
|
||||
char **envp;
|
||||
{
|
||||
tryexec(char *cmd, char **argv, char **envp)
|
||||
{
|
||||
int e;
|
||||
#ifndef BSD
|
||||
char *p;
|
||||
#endif
|
||||
|
||||
#ifdef SYSV
|
||||
do {
|
||||
execve(cmd, argv, envp);
|
||||
} while (errno == EINTR);
|
||||
#else
|
||||
execve(cmd, argv, envp);
|
||||
#endif
|
||||
e = errno;
|
||||
if (e == ENOEXEC) {
|
||||
initshellproc();
|
||||
setinputfile(cmd, 0);
|
||||
commandname = arg0 = savestr(argv[0]);
|
||||
#ifndef BSD
|
||||
pgetc(); pungetc(); /* fill up input buffer */
|
||||
p = parsenextc;
|
||||
if (parsenleft > 2 && p[0] == '#' && p[1] == '!') {
|
||||
argv[0] = cmd;
|
||||
execinterp(argv, envp);
|
||||
}
|
||||
#endif
|
||||
setparam(argv + 1);
|
||||
exraise(EXSHELLPROC);
|
||||
/*NOTREACHED*/
|
||||
@@ -192,86 +166,6 @@ tryexec(cmd, argv, envp)
|
||||
errno = e;
|
||||
}
|
||||
|
||||
|
||||
#ifndef BSD
|
||||
/*
|
||||
* Execute an interpreter introduced by "#!", for systems where this
|
||||
* feature has not been built into the kernel. If the interpreter is
|
||||
* the shell, return (effectively ignoring the "#!"). If the execution
|
||||
* of the interpreter fails, exit.
|
||||
*
|
||||
* This code peeks inside the input buffer in order to avoid actually
|
||||
* reading any input. It would benefit from a rewrite.
|
||||
*/
|
||||
|
||||
#define NEWARGS 5
|
||||
|
||||
STATIC void
|
||||
execinterp(argv, envp)
|
||||
char **argv, **envp;
|
||||
{
|
||||
int n;
|
||||
char *inp;
|
||||
char *outp;
|
||||
char c;
|
||||
char *p;
|
||||
char **ap;
|
||||
char *newargs[NEWARGS];
|
||||
int i;
|
||||
char **ap2;
|
||||
char **new;
|
||||
|
||||
n = parsenleft - 2;
|
||||
inp = parsenextc + 2;
|
||||
ap = newargs;
|
||||
for (;;) {
|
||||
while (--n >= 0 && (*inp == ' ' || *inp == '\t'))
|
||||
inp++;
|
||||
if (n < 0)
|
||||
goto bad;
|
||||
if ((c = *inp++) == '\n')
|
||||
break;
|
||||
if (ap == &newargs[NEWARGS])
|
||||
bad: error("Bad #! line");
|
||||
STARTSTACKSTR(outp);
|
||||
do {
|
||||
STPUTC(c, outp);
|
||||
} while (--n >= 0 && (c = *inp++) != ' ' && c != '\t' && c != '\n');
|
||||
STPUTC('\0', outp);
|
||||
n++, inp--;
|
||||
*ap++ = grabstackstr(outp);
|
||||
}
|
||||
if (ap == newargs + 1) { /* if no args, maybe no exec is needed */
|
||||
p = newargs[0];
|
||||
for (;;) {
|
||||
if (equal(p, "sh") || equal(p, "ash")) {
|
||||
return;
|
||||
}
|
||||
while (*p != '/') {
|
||||
if (*p == '\0')
|
||||
goto break2;
|
||||
p++;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
break2:;
|
||||
}
|
||||
i = (char *)ap - (char *)newargs; /* size in bytes */
|
||||
if (i == 0)
|
||||
error("Bad #! line");
|
||||
for (ap2 = argv ; *ap2++ != NULL ; );
|
||||
new = ckmalloc(i + ((char *)ap2 - (char *)argv));
|
||||
ap = newargs, ap2 = new;
|
||||
while ((i -= sizeof (char **)) >= 0)
|
||||
*ap2++ = *ap++;
|
||||
ap = argv;
|
||||
while (*ap2++ = *ap++);
|
||||
shellexec(new, envp, pathval(), 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Do a path search. The variable path (passed by reference) should be
|
||||
* set to the start of the path before the first call; padvance will update
|
||||
@@ -285,10 +179,8 @@ break2:;
|
||||
char *pathopt;
|
||||
|
||||
char *
|
||||
padvance(path, name)
|
||||
char **path;
|
||||
char *name;
|
||||
{
|
||||
padvance(char **path, char *name)
|
||||
{
|
||||
char *p, *q;
|
||||
char *start;
|
||||
int len;
|
||||
@@ -325,9 +217,7 @@ padvance(path, name)
|
||||
|
||||
|
||||
int
|
||||
hashcmd(argc, argv)
|
||||
int argc __unused;
|
||||
char **argv __unused;
|
||||
hashcmd(int argc __unused, char **argv __unused)
|
||||
{
|
||||
struct tblentry **pp;
|
||||
struct tblentry *cmdp;
|
||||
@@ -347,7 +237,8 @@ hashcmd(argc, argv)
|
||||
if (*argptr == NULL) {
|
||||
for (pp = cmdtable ; pp < &cmdtable[CMDTABLESIZE] ; pp++) {
|
||||
for (cmdp = *pp ; cmdp ; cmdp = cmdp->next) {
|
||||
printentry(cmdp, verbose);
|
||||
if (cmdp->cmdtype == CMDNORMAL)
|
||||
printentry(cmdp, verbose);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@@ -375,10 +266,8 @@ hashcmd(argc, argv)
|
||||
|
||||
|
||||
STATIC void
|
||||
printentry(cmdp, verbose)
|
||||
struct tblentry *cmdp;
|
||||
int verbose;
|
||||
{
|
||||
printentry(struct tblentry *cmdp, int verbose)
|
||||
{
|
||||
int index;
|
||||
char *path;
|
||||
char *name;
|
||||
@@ -421,11 +310,7 @@ printentry(cmdp, verbose)
|
||||
*/
|
||||
|
||||
void
|
||||
find_command(name, entry, printerr, path)
|
||||
char *name;
|
||||
struct cmdentry *entry;
|
||||
int printerr;
|
||||
char *path;
|
||||
find_command(char *name, struct cmdentry *entry, int printerr, char *path)
|
||||
{
|
||||
struct tblentry *cmdp;
|
||||
int index;
|
||||
@@ -494,11 +379,7 @@ loop:
|
||||
TRACE(("searchexec \"%s\": no change\n", name));
|
||||
goto success;
|
||||
}
|
||||
while (stat(fullname, &statb) < 0) {
|
||||
#ifdef SYSV
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
#endif
|
||||
if (stat(fullname, &statb) < 0) {
|
||||
if (errno != ENOENT && errno != ENOTDIR)
|
||||
e = errno;
|
||||
goto loop;
|
||||
@@ -556,8 +437,7 @@ success:
|
||||
*/
|
||||
|
||||
int
|
||||
find_builtin(name)
|
||||
char *name;
|
||||
find_builtin(char *name)
|
||||
{
|
||||
const struct builtincmd *bp;
|
||||
|
||||
@@ -576,7 +456,8 @@ find_builtin(name)
|
||||
*/
|
||||
|
||||
void
|
||||
hashcd() {
|
||||
hashcd(void)
|
||||
{
|
||||
struct tblentry **pp;
|
||||
struct tblentry *cmdp;
|
||||
|
||||
@@ -598,8 +479,7 @@ hashcd() {
|
||||
*/
|
||||
|
||||
void
|
||||
changepath(newval)
|
||||
const char *newval;
|
||||
changepath(const char *newval)
|
||||
{
|
||||
const char *old, *new;
|
||||
int index;
|
||||
@@ -643,8 +523,7 @@ changepath(newval)
|
||||
*/
|
||||
|
||||
void
|
||||
clearcmdentry(firstchange)
|
||||
int firstchange;
|
||||
clearcmdentry(int firstchange)
|
||||
{
|
||||
struct tblentry **tblp;
|
||||
struct tblentry **pp;
|
||||
@@ -682,7 +561,8 @@ SHELLPROC {
|
||||
#endif
|
||||
|
||||
void
|
||||
deletefuncs() {
|
||||
deletefuncs(void)
|
||||
{
|
||||
struct tblentry **tblp;
|
||||
struct tblentry **pp;
|
||||
struct tblentry *cmdp;
|
||||
@@ -717,9 +597,7 @@ struct tblentry **lastcmdentry;
|
||||
|
||||
|
||||
STATIC struct tblentry *
|
||||
cmdlookup(name, add)
|
||||
char *name;
|
||||
int add;
|
||||
cmdlookup(char *name, int add)
|
||||
{
|
||||
int hashval;
|
||||
char *p;
|
||||
@@ -756,7 +634,8 @@ cmdlookup(name, add)
|
||||
*/
|
||||
|
||||
STATIC void
|
||||
delete_cmd_entry() {
|
||||
delete_cmd_entry(void)
|
||||
{
|
||||
struct tblentry *cmdp;
|
||||
|
||||
INTOFF;
|
||||
@@ -768,35 +647,14 @@ delete_cmd_entry() {
|
||||
|
||||
|
||||
|
||||
#ifdef notdef
|
||||
void
|
||||
getcmdentry(name, entry)
|
||||
char *name;
|
||||
struct cmdentry *entry;
|
||||
{
|
||||
struct tblentry *cmdp = cmdlookup(name, 0);
|
||||
|
||||
if (cmdp) {
|
||||
entry->u = cmdp->param;
|
||||
entry->cmdtype = cmdp->cmdtype;
|
||||
} else {
|
||||
entry->cmdtype = CMDUNKNOWN;
|
||||
entry->u.index = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Add a new command entry, replacing any existing command entry for
|
||||
* the same name.
|
||||
*/
|
||||
|
||||
void
|
||||
addcmdentry(name, entry)
|
||||
char *name;
|
||||
struct cmdentry *entry;
|
||||
{
|
||||
addcmdentry(char *name, struct cmdentry *entry)
|
||||
{
|
||||
struct tblentry *cmdp;
|
||||
|
||||
INTOFF;
|
||||
@@ -815,10 +673,8 @@ addcmdentry(name, entry)
|
||||
*/
|
||||
|
||||
void
|
||||
defun(name, func)
|
||||
char *name;
|
||||
union node *func;
|
||||
{
|
||||
defun(char *name, union node *func)
|
||||
{
|
||||
struct cmdentry entry;
|
||||
|
||||
INTOFF;
|
||||
@@ -834,9 +690,8 @@ defun(name, func)
|
||||
*/
|
||||
|
||||
int
|
||||
unsetfunc(name)
|
||||
char *name;
|
||||
{
|
||||
unsetfunc(char *name)
|
||||
{
|
||||
struct tblentry *cmdp;
|
||||
|
||||
if ((cmdp = cmdlookup(name, 0)) != NULL && cmdp->cmdtype == CMDFUNCTION) {
|
||||
@@ -852,9 +707,7 @@ unsetfunc(name)
|
||||
*/
|
||||
|
||||
int
|
||||
typecmd(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
typecmd(int argc, char **argv)
|
||||
{
|
||||
struct cmdentry entry;
|
||||
struct tblentry *cmdp;
|
||||
|
||||
+14
-14
@@ -56,17 +56,17 @@ struct cmdentry {
|
||||
extern char *pathopt; /* set by padvance */
|
||||
extern int exerrno; /* last exec error */
|
||||
|
||||
void shellexec __P((char **, char **, char *, int));
|
||||
char *padvance __P((char **, char *));
|
||||
int hashcmd __P((int, char **));
|
||||
void find_command __P((char *, struct cmdentry *, int, char *));
|
||||
int find_builtin __P((char *));
|
||||
void hashcd __P((void));
|
||||
void changepath __P((const char *));
|
||||
void deletefuncs __P((void));
|
||||
void getcmdentry __P((char *, struct cmdentry *));
|
||||
void addcmdentry __P((char *, struct cmdentry *));
|
||||
void defun __P((char *, union node *));
|
||||
int unsetfunc __P((char *));
|
||||
int typecmd __P((int, char **));
|
||||
void clearcmdentry __P((int));
|
||||
void shellexec(char **, char **, char *, int);
|
||||
char *padvance(char **, char *);
|
||||
int hashcmd(int, char **);
|
||||
void find_command(char *, struct cmdentry *, int, char *);
|
||||
int find_builtin(char *);
|
||||
void hashcd(void);
|
||||
void changepath(const char *);
|
||||
void deletefuncs(void);
|
||||
void getcmdentry(char *, struct cmdentry *);
|
||||
void addcmdentry(char *, struct cmdentry *);
|
||||
void defun(char *, union node *);
|
||||
int unsetfunc(char *);
|
||||
int typecmd(int, char **);
|
||||
void clearcmdentry(int);
|
||||
+68
-105
@@ -38,9 +38,9 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)expand.c 8.5 (Berkeley) 5/15/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
@@ -95,27 +95,27 @@ struct ifsregion ifsfirst; /* first struct in list of ifs regions */
|
||||
struct ifsregion *ifslastp; /* last struct in list */
|
||||
struct arglist exparg; /* holds expanded arg list */
|
||||
|
||||
STATIC void argstr __P((char *, int));
|
||||
STATIC char *exptilde __P((char *, int));
|
||||
STATIC void expbackq __P((union node *, int, int));
|
||||
STATIC int subevalvar __P((char *, char *, int, int, int, int));
|
||||
STATIC char *evalvar __P((char *, int));
|
||||
STATIC int varisset __P((char *, int));
|
||||
STATIC void varvalue __P((char *, int, int));
|
||||
STATIC void recordregion __P((int, int, int));
|
||||
STATIC void removerecordregions __P((int));
|
||||
STATIC void ifsbreakup __P((char *, struct arglist *));
|
||||
STATIC void expandmeta __P((struct strlist *, int));
|
||||
STATIC void expmeta __P((char *, char *));
|
||||
STATIC void addfname __P((char *));
|
||||
STATIC struct strlist *expsort __P((struct strlist *));
|
||||
STATIC struct strlist *msort __P((struct strlist *, int));
|
||||
STATIC int pmatch __P((char *, char *, int));
|
||||
STATIC char *cvtnum __P((int, char *));
|
||||
STATIC int collate_range_cmp __P((int, int));
|
||||
STATIC void argstr(char *, int);
|
||||
STATIC char *exptilde(char *, int);
|
||||
STATIC void expbackq(union node *, int, int);
|
||||
STATIC int subevalvar(char *, char *, int, int, int, int);
|
||||
STATIC char *evalvar(char *, int);
|
||||
STATIC int varisset(char *, int);
|
||||
STATIC void varvalue(char *, int, int);
|
||||
STATIC void recordregion(int, int, int);
|
||||
STATIC void removerecordregions(int);
|
||||
STATIC void ifsbreakup(char *, struct arglist *);
|
||||
STATIC void expandmeta(struct strlist *, int);
|
||||
STATIC void expmeta(char *, char *);
|
||||
STATIC void addfname(char *);
|
||||
STATIC struct strlist *expsort(struct strlist *);
|
||||
STATIC struct strlist *msort(struct strlist *, int);
|
||||
STATIC int pmatch(char *, char *, int);
|
||||
STATIC char *cvtnum(int, char *);
|
||||
STATIC int collate_range_cmp(int, int);
|
||||
|
||||
STATIC int collate_range_cmp (c1, c2)
|
||||
int c1, c2;
|
||||
STATIC int
|
||||
collate_range_cmp (int c1, int c2)
|
||||
{
|
||||
static char s1[2], s2[2];
|
||||
int ret;
|
||||
@@ -133,13 +133,13 @@ STATIC int collate_range_cmp (c1, c2)
|
||||
|
||||
/*
|
||||
* Expand shell variables and backquotes inside a here document.
|
||||
* union node *arg the document
|
||||
* int fd; where to write the expanded version
|
||||
*/
|
||||
|
||||
void
|
||||
expandhere(arg, fd)
|
||||
union node *arg; /* the document */
|
||||
int fd; /* where to write the expanded version */
|
||||
{
|
||||
expandhere(union node *arg, int fd)
|
||||
{
|
||||
herefd = fd;
|
||||
expandarg(arg, (struct arglist *)NULL, 0);
|
||||
xwrite(fd, stackblock(), expdest - stackblock());
|
||||
@@ -154,10 +154,7 @@ expandhere(arg, fd)
|
||||
*/
|
||||
|
||||
void
|
||||
expandarg(arg, arglist, flag)
|
||||
union node *arg;
|
||||
struct arglist *arglist;
|
||||
int flag;
|
||||
expandarg(union node *arg, struct arglist *arglist, int flag)
|
||||
{
|
||||
struct strlist *sp;
|
||||
char *p;
|
||||
@@ -213,9 +210,7 @@ expandarg(arg, arglist, flag)
|
||||
*/
|
||||
|
||||
STATIC void
|
||||
argstr(p, flag)
|
||||
char *p;
|
||||
int flag;
|
||||
argstr(char *p, int flag)
|
||||
{
|
||||
char c;
|
||||
int quotes = flag & (EXP_FULL | EXP_CASE); /* do CTLESC */
|
||||
@@ -277,9 +272,7 @@ breakloop:;
|
||||
}
|
||||
|
||||
STATIC char *
|
||||
exptilde(p, flag)
|
||||
char *p;
|
||||
int flag;
|
||||
exptilde(char *p, int flag)
|
||||
{
|
||||
char c, *startp = p;
|
||||
struct passwd *pw;
|
||||
@@ -327,8 +320,7 @@ lose:
|
||||
|
||||
|
||||
STATIC void
|
||||
removerecordregions(endoff)
|
||||
int endoff;
|
||||
removerecordregions(int endoff)
|
||||
{
|
||||
if (ifslastp == NULL)
|
||||
return;
|
||||
@@ -371,8 +363,7 @@ removerecordregions(endoff)
|
||||
* evaluate, place result in (backed up) result, adjust string position.
|
||||
*/
|
||||
void
|
||||
expari(flag)
|
||||
int flag;
|
||||
expari(int flag)
|
||||
{
|
||||
char *p, *start;
|
||||
int result;
|
||||
@@ -431,10 +422,7 @@ expari(flag)
|
||||
*/
|
||||
|
||||
STATIC void
|
||||
expbackq(cmd, quoted, flag)
|
||||
union node *cmd;
|
||||
int quoted;
|
||||
int flag;
|
||||
expbackq(union node *cmd, int quoted, int flag)
|
||||
{
|
||||
struct backcmd in;
|
||||
int i;
|
||||
@@ -507,13 +495,8 @@ expbackq(cmd, quoted, flag)
|
||||
|
||||
|
||||
STATIC int
|
||||
subevalvar(p, str, strloc, subtype, startloc, varflags)
|
||||
char *p;
|
||||
char *str;
|
||||
int strloc;
|
||||
int subtype;
|
||||
int startloc;
|
||||
int varflags;
|
||||
subevalvar(char *p, char *str, int strloc, int subtype, int startloc,
|
||||
int varflags)
|
||||
{
|
||||
char *startp;
|
||||
char *loc = NULL;
|
||||
@@ -638,9 +621,7 @@ recordleft:
|
||||
*/
|
||||
|
||||
STATIC char *
|
||||
evalvar(p, flag)
|
||||
char *p;
|
||||
int flag;
|
||||
evalvar(char *p, int flag)
|
||||
{
|
||||
int subtype;
|
||||
int varflags;
|
||||
@@ -676,6 +657,17 @@ again: /* jump here after setting a variable with ${var=text} */
|
||||
}
|
||||
varlen = 0;
|
||||
startloc = expdest - stackblock();
|
||||
if (!set && uflag) {
|
||||
switch (subtype) {
|
||||
case VSNORMAL:
|
||||
case VSTRIMLEFT:
|
||||
case VSTRIMLEFTMAX:
|
||||
case VSTRIMRIGHT:
|
||||
case VSTRIMRIGHTMAX:
|
||||
case VSLENGTH:
|
||||
error("%.*s: parameter not set", p - var - 1, var);
|
||||
}
|
||||
}
|
||||
if (set && subtype != VSPLUS) {
|
||||
/* insert the value of the variable */
|
||||
if (special) {
|
||||
@@ -804,9 +796,7 @@ record:
|
||||
*/
|
||||
|
||||
STATIC int
|
||||
varisset(name, nulok)
|
||||
char *name;
|
||||
int nulok;
|
||||
varisset(char *name, int nulok)
|
||||
{
|
||||
|
||||
if (*name == '!')
|
||||
@@ -848,10 +838,7 @@ varisset(name, nulok)
|
||||
*/
|
||||
|
||||
STATIC void
|
||||
varvalue(name, quoted, allow_split)
|
||||
char *name;
|
||||
int quoted;
|
||||
int allow_split;
|
||||
varvalue(char *name, int quoted, int allow_split)
|
||||
{
|
||||
int num;
|
||||
char *p;
|
||||
@@ -942,10 +929,7 @@ numvar:
|
||||
*/
|
||||
|
||||
STATIC void
|
||||
recordregion(start, end, nulonly)
|
||||
int start;
|
||||
int end;
|
||||
int nulonly;
|
||||
recordregion(int start, int end, int nulonly)
|
||||
{
|
||||
struct ifsregion *ifsp;
|
||||
|
||||
@@ -970,10 +954,8 @@ recordregion(start, end, nulonly)
|
||||
* searched for IFS characters have been stored by recordregion.
|
||||
*/
|
||||
STATIC void
|
||||
ifsbreakup(string, arglist)
|
||||
char *string;
|
||||
struct arglist *arglist;
|
||||
{
|
||||
ifsbreakup(char *string, struct arglist *arglist)
|
||||
{
|
||||
struct ifsregion *ifsp;
|
||||
struct strlist *sp;
|
||||
char *start;
|
||||
@@ -1068,9 +1050,7 @@ char *expdir;
|
||||
|
||||
|
||||
STATIC void
|
||||
expandmeta(str, flag)
|
||||
struct strlist *str;
|
||||
int flag __unused;
|
||||
expandmeta(struct strlist *str, int flag __unused)
|
||||
{
|
||||
char *p;
|
||||
struct strlist **savelastp;
|
||||
@@ -1124,10 +1104,8 @@ nometa:
|
||||
*/
|
||||
|
||||
STATIC void
|
||||
expmeta(enddir, name)
|
||||
char *enddir;
|
||||
char *name;
|
||||
{
|
||||
expmeta(char *enddir, char *name)
|
||||
{
|
||||
char *p;
|
||||
char *q;
|
||||
char *start;
|
||||
@@ -1255,9 +1233,8 @@ expmeta(enddir, name)
|
||||
*/
|
||||
|
||||
STATIC void
|
||||
addfname(name)
|
||||
char *name;
|
||||
{
|
||||
addfname(char *name)
|
||||
{
|
||||
char *p;
|
||||
struct strlist *sp;
|
||||
|
||||
@@ -1277,9 +1254,8 @@ addfname(name)
|
||||
*/
|
||||
|
||||
STATIC struct strlist *
|
||||
expsort(str)
|
||||
struct strlist *str;
|
||||
{
|
||||
expsort(struct strlist *str)
|
||||
{
|
||||
int len;
|
||||
struct strlist *sp;
|
||||
|
||||
@@ -1291,9 +1267,7 @@ expsort(str)
|
||||
|
||||
|
||||
STATIC struct strlist *
|
||||
msort(list, len)
|
||||
struct strlist *list;
|
||||
int len;
|
||||
msort(struct strlist *list, int len)
|
||||
{
|
||||
struct strlist *p, *q = NULL;
|
||||
struct strlist **lpp;
|
||||
@@ -1339,11 +1313,8 @@ msort(list, len)
|
||||
*/
|
||||
|
||||
int
|
||||
patmatch(pattern, string, squoted)
|
||||
char *pattern;
|
||||
char *string;
|
||||
int squoted; /* string might have quote chars */
|
||||
{
|
||||
patmatch(char *pattern, char *string, int squoted)
|
||||
{
|
||||
#ifdef notdef
|
||||
if (pattern[0] == '!' && pattern[1] == '!')
|
||||
return 1 - pmatch(pattern + 2, string);
|
||||
@@ -1354,11 +1325,8 @@ patmatch(pattern, string, squoted)
|
||||
|
||||
|
||||
STATIC int
|
||||
pmatch(pattern, string, squoted)
|
||||
char *pattern;
|
||||
char *string;
|
||||
int squoted;
|
||||
{
|
||||
pmatch(char *pattern, char *string, int squoted)
|
||||
{
|
||||
char *p, *q;
|
||||
char c;
|
||||
|
||||
@@ -1482,8 +1450,7 @@ breakloop:
|
||||
*/
|
||||
|
||||
void
|
||||
rmescapes(str)
|
||||
char *str;
|
||||
rmescapes(char *str)
|
||||
{
|
||||
char *p, *q;
|
||||
|
||||
@@ -1512,10 +1479,8 @@ rmescapes(str)
|
||||
*/
|
||||
|
||||
int
|
||||
casematch(pattern, val)
|
||||
union node *pattern;
|
||||
char *val;
|
||||
{
|
||||
casematch(union node *pattern, char *val)
|
||||
{
|
||||
struct stackmark smark;
|
||||
int result;
|
||||
char *p;
|
||||
@@ -1537,10 +1502,8 @@ casematch(pattern, val)
|
||||
*/
|
||||
|
||||
STATIC char *
|
||||
cvtnum(num, buf)
|
||||
int num;
|
||||
char *buf;
|
||||
{
|
||||
cvtnum(int num, char *buf)
|
||||
{
|
||||
char temp[32];
|
||||
int neg = num < 0;
|
||||
char *p = temp + 31;
|
||||
|
||||
+6
-6
@@ -59,9 +59,9 @@ struct arglist {
|
||||
|
||||
|
||||
union node;
|
||||
void expandhere __P((union node *, int));
|
||||
void expandarg __P((union node *, struct arglist *, int));
|
||||
void expari __P((int));
|
||||
int patmatch __P((char *, char *, int));
|
||||
void rmescapes __P((char *));
|
||||
int casematch __P((union node *, char *));
|
||||
void expandhere(union node *, int);
|
||||
void expandarg(union node *, struct arglist *, int);
|
||||
void expari(int);
|
||||
int patmatch(char *, char *, int);
|
||||
void rmescapes(char *);
|
||||
int casematch(union node *, char *);
|
||||
+31
-19
@@ -38,9 +38,9 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)histedit.c 8.2 (Berkeley) 5/4/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <limits.h>
|
||||
@@ -72,14 +72,14 @@ EditLine *el; /* editline cookie */
|
||||
int displayhist;
|
||||
static FILE *el_in, *el_out;
|
||||
|
||||
STATIC char *fc_replace __P((const char *, char *, char *));
|
||||
STATIC char *fc_replace(const char *, char *, char *);
|
||||
|
||||
/*
|
||||
* Set history and editing status. Called whenever the status may
|
||||
* have changed (figures out what to do).
|
||||
*/
|
||||
void
|
||||
histedit()
|
||||
histedit(void)
|
||||
{
|
||||
|
||||
#define editing (Eflag || Vflag)
|
||||
@@ -130,6 +130,7 @@ bad:
|
||||
el_set(el, EL_EDITOR, "vi");
|
||||
else if (Eflag)
|
||||
el_set(el, EL_EDITOR, "emacs");
|
||||
el_source(el, NULL);
|
||||
}
|
||||
} else {
|
||||
INTOFF;
|
||||
@@ -165,9 +166,7 @@ sethistsize(hs)
|
||||
* the Korn shell fc command. Oh well...
|
||||
*/
|
||||
int
|
||||
histcmd(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
histcmd(int argc, char **argv)
|
||||
{
|
||||
int ch;
|
||||
char *editor = NULL;
|
||||
@@ -182,6 +181,7 @@ histcmd(argc, argv)
|
||||
struct jmploc *volatile savehandler;
|
||||
char editfile[PATH_MAX];
|
||||
FILE *efp;
|
||||
int oldhistnum;
|
||||
#ifdef __GNUC__
|
||||
/* Avoid longjmp clobbering */
|
||||
(void) &editor;
|
||||
@@ -205,11 +205,12 @@ histcmd(argc, argv)
|
||||
error("missing history argument");
|
||||
|
||||
optreset = 1; optind = 1; /* initialize getopt */
|
||||
opterr = 0;
|
||||
while (not_fcnumber(argv[optind]) &&
|
||||
(ch = getopt(argc, argv, ":e:lnrs")) != -1)
|
||||
switch ((char)ch) {
|
||||
case 'e':
|
||||
editor = shoptarg;
|
||||
editor = optarg;
|
||||
break;
|
||||
case 'l':
|
||||
lflg = 1;
|
||||
@@ -392,9 +393,7 @@ histcmd(argc, argv)
|
||||
}
|
||||
|
||||
STATIC char *
|
||||
fc_replace(s, p, r)
|
||||
const char *s;
|
||||
char *p, *r;
|
||||
fc_replace(const char *s, char *p, char *r)
|
||||
{
|
||||
char *dest;
|
||||
int plen = strlen(p);
|
||||
@@ -416,8 +415,7 @@ fc_replace(s, p, r)
|
||||
}
|
||||
|
||||
int
|
||||
not_fcnumber(s)
|
||||
char *s;
|
||||
not_fcnumber(char *s)
|
||||
{
|
||||
if (s == NULL)
|
||||
return (0);
|
||||
@@ -427,9 +425,7 @@ not_fcnumber(s)
|
||||
}
|
||||
|
||||
int
|
||||
str_to_event(str, last)
|
||||
char *str;
|
||||
int last;
|
||||
str_to_event(char *str, int last)
|
||||
{
|
||||
const HistEvent *he;
|
||||
char *s = str;
|
||||
@@ -475,17 +471,33 @@ str_to_event(str, last)
|
||||
}
|
||||
return (he->num);
|
||||
}
|
||||
|
||||
int
|
||||
bindcmd(int argc, char **argv)
|
||||
{
|
||||
|
||||
if (el == NULL)
|
||||
error("line editing is disabled");
|
||||
return (el_parse(el, argc, argv));
|
||||
}
|
||||
|
||||
#else
|
||||
#include "error.h"
|
||||
|
||||
int
|
||||
histcmd(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
histcmd(int argc, char **argv)
|
||||
{
|
||||
|
||||
error("not compiled with history support");
|
||||
/*NOTREACHED*/
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
bindcmd(int argc, char **argv)
|
||||
{
|
||||
|
||||
error("not compiled with line editing support");
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
+3
-3
@@ -37,6 +37,6 @@
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
void init __P((void));
|
||||
void reset __P((void));
|
||||
void initshellproc __P((void));
|
||||
void init(void);
|
||||
void reset(void);
|
||||
void initshellproc(void);
|
||||
+32
-30
@@ -38,9 +38,9 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)input.c 8.3 (Berkeley) 6/9/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <stdio.h> /* defines BUFSIZ */
|
||||
#include <fcntl.h>
|
||||
@@ -64,6 +64,7 @@ static const char rcsid[] =
|
||||
#include "alias.h"
|
||||
#include "parser.h"
|
||||
#include "myhistedit.h"
|
||||
#include "trap.h"
|
||||
|
||||
#define EOF_NLEFT -99 /* value of parsenleft when EOF pushed back */
|
||||
|
||||
@@ -107,8 +108,8 @@ int whichprompt; /* 1 == PS1, 2 == PS2 */
|
||||
|
||||
EditLine *el; /* cookie for editline package */
|
||||
|
||||
STATIC void pushfile __P((void));
|
||||
static int preadfd __P((void));
|
||||
STATIC void pushfile(void);
|
||||
static int preadfd(void);
|
||||
|
||||
#ifdef mkinit
|
||||
INCLUDE "input.h"
|
||||
@@ -137,9 +138,7 @@ SHELLPROC {
|
||||
*/
|
||||
|
||||
char *
|
||||
pfgets(line, len)
|
||||
char *line;
|
||||
int len;
|
||||
pfgets(char *line, int len)
|
||||
{
|
||||
char *p = line;
|
||||
int nleft = len;
|
||||
@@ -168,18 +167,24 @@ pfgets(line, len)
|
||||
*/
|
||||
|
||||
int
|
||||
pgetc()
|
||||
pgetc(void)
|
||||
{
|
||||
return pgetc_macro();
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
preadfd()
|
||||
preadfd(void)
|
||||
{
|
||||
int nr;
|
||||
parsenextc = parsefile->buf;
|
||||
|
||||
#ifndef NO_HISTORY
|
||||
if (el != NULL && gotwinch) {
|
||||
gotwinch = 0;
|
||||
el_resize(el);
|
||||
}
|
||||
#endif
|
||||
retry:
|
||||
#ifndef NO_HISTORY
|
||||
if (parsefile->fd == 0 && el) {
|
||||
@@ -227,7 +232,7 @@ retry:
|
||||
*/
|
||||
|
||||
int
|
||||
preadbuffer()
|
||||
preadbuffer(void)
|
||||
{
|
||||
char *p, *q;
|
||||
int more;
|
||||
@@ -314,7 +319,8 @@ check:
|
||||
*/
|
||||
|
||||
void
|
||||
pungetc() {
|
||||
pungetc(void)
|
||||
{
|
||||
parsenleft++;
|
||||
parsenextc--;
|
||||
}
|
||||
@@ -324,11 +330,8 @@ pungetc() {
|
||||
* We handle aliases this way.
|
||||
*/
|
||||
void
|
||||
pushstring(s, len, ap)
|
||||
char *s;
|
||||
int len;
|
||||
void *ap;
|
||||
{
|
||||
pushstring(char *s, int len, void *ap)
|
||||
{
|
||||
struct strpush *sp;
|
||||
|
||||
INTOFF;
|
||||
@@ -351,7 +354,7 @@ pushstring(s, len, ap)
|
||||
}
|
||||
|
||||
void
|
||||
popstring()
|
||||
popstring(void)
|
||||
{
|
||||
struct strpush *sp = parsefile->strpush;
|
||||
|
||||
@@ -374,9 +377,7 @@ popstring()
|
||||
*/
|
||||
|
||||
void
|
||||
setinputfile(fname, push)
|
||||
char *fname;
|
||||
int push;
|
||||
setinputfile(char *fname, int push)
|
||||
{
|
||||
int fd;
|
||||
int fd2;
|
||||
@@ -402,8 +403,7 @@ setinputfile(fname, push)
|
||||
*/
|
||||
|
||||
void
|
||||
setinputfd(fd, push)
|
||||
int fd, push;
|
||||
setinputfd(int fd, int push)
|
||||
{
|
||||
(void)fcntl(fd, F_SETFD, FD_CLOEXEC);
|
||||
if (push) {
|
||||
@@ -425,10 +425,8 @@ setinputfd(fd, push)
|
||||
*/
|
||||
|
||||
void
|
||||
setinputstring(string, push)
|
||||
char *string;
|
||||
int push;
|
||||
{
|
||||
setinputstring(char *string, int push)
|
||||
{
|
||||
INTOFF;
|
||||
if (push)
|
||||
pushfile();
|
||||
@@ -447,7 +445,8 @@ setinputstring(string, push)
|
||||
*/
|
||||
|
||||
STATIC void
|
||||
pushfile() {
|
||||
pushfile(void)
|
||||
{
|
||||
struct parsefile *pf;
|
||||
|
||||
parsefile->nleft = parsenleft;
|
||||
@@ -464,7 +463,8 @@ pushfile() {
|
||||
|
||||
|
||||
void
|
||||
popfile() {
|
||||
popfile(void)
|
||||
{
|
||||
struct parsefile *pf = parsefile;
|
||||
|
||||
INTOFF;
|
||||
@@ -489,7 +489,8 @@ popfile() {
|
||||
*/
|
||||
|
||||
void
|
||||
popallfiles() {
|
||||
popallfiles(void)
|
||||
{
|
||||
while (parsefile != &basepf)
|
||||
popfile();
|
||||
}
|
||||
@@ -502,7 +503,8 @@ popallfiles() {
|
||||
*/
|
||||
|
||||
void
|
||||
closescript() {
|
||||
closescript(void)
|
||||
{
|
||||
popallfiles();
|
||||
if (parsefile->fd > 0) {
|
||||
close(parsefile->fd);
|
||||
|
||||
+12
-12
@@ -49,17 +49,17 @@ extern int parsenleft; /* number of characters left in input buffer */
|
||||
extern char *parsenextc; /* next character in input buffer */
|
||||
extern int init_editline; /* 0 == not setup, 1 == OK, -1 == failed */
|
||||
|
||||
char *pfgets __P((char *, int));
|
||||
int pgetc __P((void));
|
||||
int preadbuffer __P((void));
|
||||
void pungetc __P((void));
|
||||
void pushstring __P((char *, int, void *));
|
||||
void popstring __P((void));
|
||||
void setinputfile __P((char *, int));
|
||||
void setinputfd __P((int, int));
|
||||
void setinputstring __P((char *, int));
|
||||
void popfile __P((void));
|
||||
void popallfiles __P((void));
|
||||
void closescript __P((void));
|
||||
char *pfgets(char *, int);
|
||||
int pgetc(void);
|
||||
int preadbuffer(void);
|
||||
void pungetc(void);
|
||||
void pushstring(char *, int, void *);
|
||||
void popstring(void);
|
||||
void setinputfile(char *, int);
|
||||
void setinputfd(int, int);
|
||||
void setinputstring(char *, int);
|
||||
void popfile(void);
|
||||
void popallfiles(void);
|
||||
void closescript(void);
|
||||
|
||||
#define pgetc_macro() (--parsenleft >= 0? *parsenextc++ : preadbuffer())
|
||||
+337
-266
@@ -38,31 +38,26 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)jobs.c 8.5 (Berkeley) 5/4/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
#include <paths.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/param.h>
|
||||
#ifdef BSD
|
||||
#include <sys/wait.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <paths.h>
|
||||
#endif
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include "shell.h"
|
||||
#if JOBS
|
||||
#if OLD_TTY_DRIVER
|
||||
#include "sgtty.h"
|
||||
#else
|
||||
#include <termios.h>
|
||||
#endif
|
||||
#undef CEOF /* syntax.h redefines this */
|
||||
#endif
|
||||
#include "redir.h"
|
||||
@@ -85,90 +80,84 @@ struct job *jobtab; /* array of jobs */
|
||||
int njobs; /* size of array */
|
||||
MKINIT pid_t backgndpid = -1; /* pid of last background process */
|
||||
#if JOBS
|
||||
int initialpgrp; /* pgrp of shell on invocation */
|
||||
int curjob; /* current job */
|
||||
struct job *jobmru; /* most recently used job list */
|
||||
pid_t initialpgrp; /* pgrp of shell on invocation */
|
||||
#endif
|
||||
int in_waitcmd = 0; /* are we in waitcmd()? */
|
||||
int in_dowait = 0; /* are we in dowait()? */
|
||||
volatile sig_atomic_t breakwaitcmd = 0; /* should wait be terminated? */
|
||||
static int ttyfd = -1;
|
||||
|
||||
#if JOBS
|
||||
STATIC void restartjob __P((struct job *));
|
||||
STATIC void restartjob(struct job *);
|
||||
#endif
|
||||
STATIC void freejob __P((struct job *));
|
||||
STATIC struct job *getjob __P((char *));
|
||||
STATIC int dowait __P((int, struct job *));
|
||||
#if SYSV
|
||||
STATIC int onsigchild __P((void));
|
||||
STATIC void freejob(struct job *);
|
||||
STATIC struct job *getjob(char *);
|
||||
STATIC pid_t dowait(int, struct job *);
|
||||
STATIC pid_t waitproc(int, int *);
|
||||
STATIC void cmdtxt(union node *);
|
||||
STATIC void cmdputs(char *);
|
||||
#if JOBS
|
||||
STATIC void setcurjob(struct job *);
|
||||
STATIC void deljob(struct job *);
|
||||
STATIC struct job *getcurjob(struct job *);
|
||||
#endif
|
||||
STATIC int waitproc __P((int, int *));
|
||||
STATIC void cmdtxt __P((union node *));
|
||||
STATIC void cmdputs __P((char *));
|
||||
STATIC void showjob(struct job *, pid_t, int, int);
|
||||
|
||||
|
||||
/*
|
||||
* Turn job control on and off.
|
||||
*
|
||||
* Note: This code assumes that the third arg to ioctl is a character
|
||||
* pointer, which is true on Berkeley systems but not System V. Since
|
||||
* System V doesn't have job control yet, this isn't a problem now.
|
||||
*/
|
||||
|
||||
MKINIT int jobctl;
|
||||
|
||||
#if JOBS
|
||||
void
|
||||
setjobctl(on)
|
||||
int on;
|
||||
setjobctl(int on)
|
||||
{
|
||||
#ifdef OLD_TTY_DRIVER
|
||||
int ldisc;
|
||||
#endif
|
||||
int i;
|
||||
|
||||
if (on == jobctl || rootshell == 0)
|
||||
return;
|
||||
if (on) {
|
||||
if (ttyfd != -1)
|
||||
close(ttyfd);
|
||||
if ((ttyfd = open(_PATH_TTY, O_RDWR)) < 0) {
|
||||
i = 0;
|
||||
while (i <= 2 && !isatty(i))
|
||||
i++;
|
||||
if (i > 2 || (ttyfd = dup(i)) < 0)
|
||||
goto out;
|
||||
}
|
||||
if (fcntl(ttyfd, F_SETFD, FD_CLOEXEC) < 0) {
|
||||
close(ttyfd);
|
||||
ttyfd = -1;
|
||||
goto out;
|
||||
}
|
||||
do { /* while we are in the background */
|
||||
#ifdef OLD_TTY_DRIVER
|
||||
if (ioctl(2, TIOCGPGRP, (char *)&initialpgrp) < 0) {
|
||||
#else
|
||||
initialpgrp = tcgetpgrp(2);
|
||||
initialpgrp = tcgetpgrp(ttyfd);
|
||||
if (initialpgrp < 0) {
|
||||
#endif
|
||||
out2str("sh: can't access tty; job control turned off\n");
|
||||
out: out2str("sh: can't access tty; job control turned off\n");
|
||||
mflag = 0;
|
||||
return;
|
||||
}
|
||||
if (initialpgrp == -1)
|
||||
initialpgrp = getpgrp();
|
||||
else if (initialpgrp != getpgrp()) {
|
||||
killpg(initialpgrp, SIGTTIN);
|
||||
killpg(0, SIGTTIN);
|
||||
continue;
|
||||
}
|
||||
} while (0);
|
||||
#ifdef OLD_TTY_DRIVER
|
||||
if (ioctl(2, TIOCGETD, (char *)&ldisc) < 0 || ldisc != NTTYDISC) {
|
||||
out2str("sh: need new tty driver to run job control; job control turned off\n");
|
||||
mflag = 0;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
setsignal(SIGTSTP);
|
||||
setsignal(SIGTTOU);
|
||||
setsignal(SIGTTIN);
|
||||
setpgid(0, rootpid);
|
||||
#ifdef OLD_TTY_DRIVER
|
||||
ioctl(2, TIOCSPGRP, (char *)&rootpid);
|
||||
#else
|
||||
tcsetpgrp(2, rootpid);
|
||||
#endif
|
||||
tcsetpgrp(ttyfd, rootpid);
|
||||
} else { /* turning job control off */
|
||||
setpgid(0, initialpgrp);
|
||||
#ifdef OLD_TTY_DRIVER
|
||||
ioctl(2, TIOCSPGRP, (char *)&initialpgrp);
|
||||
#else
|
||||
tcsetpgrp(2, initialpgrp);
|
||||
#endif
|
||||
tcsetpgrp(ttyfd, initialpgrp);
|
||||
close(ttyfd);
|
||||
ttyfd = -1;
|
||||
setsignal(SIGTSTP);
|
||||
setsignal(SIGTTOU);
|
||||
setsignal(SIGTTIN);
|
||||
@@ -195,24 +184,22 @@ SHELLPROC {
|
||||
|
||||
#if JOBS
|
||||
int
|
||||
fgcmd(argc, argv)
|
||||
int argc __unused;
|
||||
char **argv;
|
||||
fgcmd(int argc __unused, char **argv)
|
||||
{
|
||||
struct job *jp;
|
||||
int pgrp;
|
||||
pid_t pgrp;
|
||||
int status;
|
||||
|
||||
jp = getjob(argv[1]);
|
||||
if (jp->jobctl == 0)
|
||||
error("job not created under job control");
|
||||
out1str(jp->ps[0].cmd);
|
||||
out1c('\n');
|
||||
flushout(&output);
|
||||
pgrp = jp->ps[0].pid;
|
||||
#ifdef OLD_TTY_DRIVER
|
||||
ioctl(2, TIOCSPGRP, (char *)&pgrp);
|
||||
#else
|
||||
tcsetpgrp(2, pgrp);
|
||||
#endif
|
||||
tcsetpgrp(ttyfd, pgrp);
|
||||
restartjob(jp);
|
||||
jp->foreground = 1;
|
||||
INTOFF;
|
||||
status = waitforjob(jp, (int *)NULL);
|
||||
INTON;
|
||||
@@ -221,31 +208,37 @@ fgcmd(argc, argv)
|
||||
|
||||
|
||||
int
|
||||
bgcmd(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
bgcmd(int argc, char **argv)
|
||||
{
|
||||
char s[64];
|
||||
struct job *jp;
|
||||
|
||||
do {
|
||||
jp = getjob(*++argv);
|
||||
if (jp->jobctl == 0)
|
||||
error("job not created under job control");
|
||||
if (jp->state == JOBDONE)
|
||||
continue;
|
||||
restartjob(jp);
|
||||
jp->foreground = 0;
|
||||
fmtstr(s, 64, "[%d] ", jp - jobtab + 1);
|
||||
out1str(s);
|
||||
out1str(jp->ps[0].cmd);
|
||||
out1c('\n');
|
||||
} while (--argc > 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
STATIC void
|
||||
restartjob(jp)
|
||||
struct job *jp;
|
||||
restartjob(struct job *jp)
|
||||
{
|
||||
struct procstat *ps;
|
||||
int i;
|
||||
|
||||
if (jp->state == JOBDONE)
|
||||
return;
|
||||
setcurjob(jp);
|
||||
INTOFF;
|
||||
killpg(jp->ps[0].pid, SIGCONT);
|
||||
for (ps = jp->ps, i = jp->nprocs ; --i >= 0 ; ps++) {
|
||||
@@ -260,14 +253,121 @@ restartjob(jp)
|
||||
|
||||
|
||||
int
|
||||
jobscmd(argc, argv)
|
||||
int argc __unused;
|
||||
char **argv __unused;
|
||||
jobscmd(int argc, char *argv[])
|
||||
{
|
||||
showjobs(0);
|
||||
return 0;
|
||||
char *id;
|
||||
int ch, sformat, lformat;
|
||||
|
||||
optind = optreset = 1;
|
||||
opterr = 0;
|
||||
sformat = lformat = 0;
|
||||
while ((ch = getopt(argc, argv, "ls")) != -1) {
|
||||
switch (ch) {
|
||||
case 'l':
|
||||
lformat = 1;
|
||||
break;
|
||||
case 's':
|
||||
sformat = 1;
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
error("unknown option: -%c", optopt);
|
||||
}
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if (argc == 0)
|
||||
showjobs(0, sformat, lformat);
|
||||
else
|
||||
while ((id = *argv++) != NULL)
|
||||
showjob(getjob(id), 0, sformat, lformat);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
STATIC void
|
||||
showjob(struct job *jp, pid_t pid, int sformat, int lformat)
|
||||
{
|
||||
char s[64];
|
||||
struct procstat *ps;
|
||||
struct job *j;
|
||||
int col, curr, i, jobno, prev, procno;
|
||||
char c;
|
||||
|
||||
procno = jp->nprocs;
|
||||
jobno = jp - jobtab + 1;
|
||||
curr = prev = 0;
|
||||
#if JOBS
|
||||
if ((j = getcurjob(NULL)) != NULL) {
|
||||
curr = j - jobtab + 1;
|
||||
if ((j = getcurjob(j)) != NULL)
|
||||
prev = j - jobtab + 1;
|
||||
}
|
||||
#endif
|
||||
for (ps = jp->ps ; ; ps++) { /* for each process */
|
||||
if (sformat) {
|
||||
out1fmt("%d\n", (int)ps->pid);
|
||||
goto skip;
|
||||
}
|
||||
if (!lformat && ps != jp->ps && pid == 0)
|
||||
goto skip;
|
||||
if (pid != 0 && pid != ps->pid)
|
||||
goto skip;
|
||||
if (jobno == curr && ps == jp->ps)
|
||||
c = '+';
|
||||
else if (jobno == prev && ps == jp->ps)
|
||||
c = '-';
|
||||
else
|
||||
c = ' ';
|
||||
if (ps == jp->ps)
|
||||
fmtstr(s, 64, "[%d] %c ", jobno, c);
|
||||
else
|
||||
fmtstr(s, 64, " %c ", c);
|
||||
out1str(s);
|
||||
col = strlen(s);
|
||||
if (lformat) {
|
||||
fmtstr(s, 64, "%d ", (int)ps->pid);
|
||||
out1str(s);
|
||||
col += strlen(s);
|
||||
}
|
||||
s[0] = '\0';
|
||||
if (ps != jp->ps) {
|
||||
*s = '\0';
|
||||
} else if (ps->status == -1) {
|
||||
strcpy(s, "Running");
|
||||
} else if (WIFEXITED(ps->status)) {
|
||||
if (WEXITSTATUS(ps->status) == 0)
|
||||
strcpy(s, "Done");
|
||||
else
|
||||
fmtstr(s, 64, "Done (%d)",
|
||||
WEXITSTATUS(ps->status));
|
||||
} else {
|
||||
#if JOBS
|
||||
if (WIFSTOPPED(ps->status))
|
||||
i = WSTOPSIG(ps->status);
|
||||
else
|
||||
#endif
|
||||
i = WTERMSIG(ps->status);
|
||||
if ((i & 0x7F) < NSIG && sys_siglist[i & 0x7F])
|
||||
scopy(sys_siglist[i & 0x7F], s);
|
||||
else
|
||||
fmtstr(s, 64, "Signal %d", i & 0x7F);
|
||||
if (WCOREDUMP(ps->status))
|
||||
strcat(s, " (core dumped)");
|
||||
}
|
||||
out1str(s);
|
||||
col += strlen(s);
|
||||
do {
|
||||
out1c(' ');
|
||||
col++;
|
||||
} while (col < 30);
|
||||
out1str(ps->cmd);
|
||||
out1c('\n');
|
||||
skip: if (--procno <= 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Print a list of jobs. If "change" is nonzero, only print jobs whose
|
||||
@@ -279,16 +379,10 @@ jobscmd(argc, argv)
|
||||
*/
|
||||
|
||||
void
|
||||
showjobs(change)
|
||||
int change;
|
||||
showjobs(int change, int sformat, int lformat)
|
||||
{
|
||||
int jobno;
|
||||
int procno;
|
||||
int i;
|
||||
struct job *jp;
|
||||
struct procstat *ps;
|
||||
int col;
|
||||
char s[64];
|
||||
|
||||
TRACE(("showjobs(%d) called\n", change));
|
||||
while (dowait(0, (struct job *)NULL) > 0);
|
||||
@@ -301,44 +395,7 @@ showjobs(change)
|
||||
}
|
||||
if (change && ! jp->changed)
|
||||
continue;
|
||||
procno = jp->nprocs;
|
||||
for (ps = jp->ps ; ; ps++) { /* for each process */
|
||||
if (ps == jp->ps)
|
||||
fmtstr(s, 64, "[%d] %d ", jobno, ps->pid);
|
||||
else
|
||||
fmtstr(s, 64, " %d ", ps->pid);
|
||||
out1str(s);
|
||||
col = strlen(s);
|
||||
s[0] = '\0';
|
||||
if (ps->status == -1) {
|
||||
/* don't print anything */
|
||||
} else if (WIFEXITED(ps->status)) {
|
||||
fmtstr(s, 64, "Exit %d", WEXITSTATUS(ps->status));
|
||||
} else {
|
||||
#if JOBS
|
||||
if (WIFSTOPPED(ps->status))
|
||||
i = WSTOPSIG(ps->status);
|
||||
else
|
||||
#endif
|
||||
i = WTERMSIG(ps->status);
|
||||
if ((i & 0x7F) < NSIG && sys_siglist[i & 0x7F])
|
||||
scopy(sys_siglist[i & 0x7F], s);
|
||||
else
|
||||
fmtstr(s, 64, "Signal %d", i & 0x7F);
|
||||
if (WCOREDUMP(ps->status))
|
||||
strcat(s, " (core dumped)");
|
||||
}
|
||||
out1str(s);
|
||||
col += strlen(s);
|
||||
do {
|
||||
out1c(' ');
|
||||
col++;
|
||||
} while (col < 30);
|
||||
out1str(ps->cmd);
|
||||
out1c('\n');
|
||||
if (--procno <= 0)
|
||||
break;
|
||||
}
|
||||
showjob(jp, 0, sformat, lformat);
|
||||
jp->changed = 0;
|
||||
if (jp->state == JOBDONE) {
|
||||
freejob(jp);
|
||||
@@ -352,9 +409,8 @@ showjobs(change)
|
||||
*/
|
||||
|
||||
STATIC void
|
||||
freejob(jp)
|
||||
struct job *jp;
|
||||
{
|
||||
freejob(struct job *jp)
|
||||
{
|
||||
struct procstat *ps;
|
||||
int i;
|
||||
|
||||
@@ -367,8 +423,7 @@ freejob(jp)
|
||||
ckfree(jp->ps);
|
||||
jp->used = 0;
|
||||
#if JOBS
|
||||
if (curjob == jp - jobtab + 1)
|
||||
curjob = 0;
|
||||
deljob(jp);
|
||||
#endif
|
||||
INTON;
|
||||
}
|
||||
@@ -376,9 +431,7 @@ freejob(jp)
|
||||
|
||||
|
||||
int
|
||||
waitcmd(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
waitcmd(int argc, char **argv)
|
||||
{
|
||||
struct job *job;
|
||||
int status, retval;
|
||||
@@ -432,16 +485,14 @@ waitcmd(argc, argv)
|
||||
|
||||
|
||||
int
|
||||
jobidcmd(argc, argv)
|
||||
int argc __unused;
|
||||
char **argv;
|
||||
jobidcmd(int argc __unused, char **argv)
|
||||
{
|
||||
struct job *jp;
|
||||
int i;
|
||||
|
||||
jp = getjob(argv[1]);
|
||||
for (i = 0 ; i < jp->nprocs ; ) {
|
||||
out1fmt("%d", jp->ps[i].pid);
|
||||
out1fmt("%d", (int)jp->ps[i].pid);
|
||||
out1c(++i < jp->nprocs? ' ' : '\n');
|
||||
}
|
||||
return 0;
|
||||
@@ -454,20 +505,18 @@ jobidcmd(argc, argv)
|
||||
*/
|
||||
|
||||
STATIC struct job *
|
||||
getjob(name)
|
||||
char *name;
|
||||
{
|
||||
getjob(char *name)
|
||||
{
|
||||
int jobno;
|
||||
struct job *jp;
|
||||
int pid;
|
||||
struct job *found, *jp;
|
||||
pid_t pid;
|
||||
int i;
|
||||
|
||||
if (name == NULL) {
|
||||
#if JOBS
|
||||
currentjob:
|
||||
if ((jobno = curjob) == 0 || jobtab[jobno - 1].used == 0)
|
||||
currentjob: if ((jp = getcurjob(NULL)) == NULL)
|
||||
error("No current job");
|
||||
return &jobtab[jobno - 1];
|
||||
return (jp);
|
||||
#else
|
||||
error("No current job");
|
||||
#endif
|
||||
@@ -480,9 +529,28 @@ currentjob:
|
||||
#if JOBS
|
||||
} else if (name[1] == '%' && name[2] == '\0') {
|
||||
goto currentjob;
|
||||
} else if (name[1] == '+' && name[2] == '\0') {
|
||||
goto currentjob;
|
||||
} else if (name[1] == '-' && name[2] == '\0') {
|
||||
if ((jp = getcurjob(NULL)) == NULL ||
|
||||
(jp = getcurjob(jp)) == NULL)
|
||||
error("No previous job");
|
||||
return (jp);
|
||||
#endif
|
||||
} else if (name[1] == '?') {
|
||||
found = NULL;
|
||||
for (jp = jobtab, i = njobs ; --i >= 0 ; jp++) {
|
||||
if (jp->used && jp->nprocs > 0
|
||||
&& strstr(jp->ps[0].cmd, name + 2) != NULL) {
|
||||
if (found)
|
||||
error("%s: ambiguous", name);
|
||||
found = jp;
|
||||
}
|
||||
}
|
||||
if (found != NULL)
|
||||
return (found);
|
||||
} else {
|
||||
struct job *found = NULL;
|
||||
found = NULL;
|
||||
for (jp = jobtab, i = njobs ; --i >= 0 ; jp++) {
|
||||
if (jp->used && jp->nprocs > 0
|
||||
&& prefix(name + 1, jp->ps[0].cmd)) {
|
||||
@@ -495,7 +563,7 @@ currentjob:
|
||||
return found;
|
||||
}
|
||||
} else if (is_number(name)) {
|
||||
pid = number(name);
|
||||
pid = (pid_t)number(name);
|
||||
for (jp = jobtab, i = njobs ; --i >= 0 ; jp++) {
|
||||
if (jp->used && jp->nprocs > 0
|
||||
&& jp->ps[jp->nprocs - 1].pid == pid)
|
||||
@@ -514,9 +582,7 @@ currentjob:
|
||||
*/
|
||||
|
||||
struct job *
|
||||
makejob(node, nprocs)
|
||||
union node *node __unused;
|
||||
int nprocs;
|
||||
makejob(union node *node __unused, int nprocs)
|
||||
{
|
||||
int i;
|
||||
struct job *jp;
|
||||
@@ -526,9 +592,21 @@ makejob(node, nprocs)
|
||||
INTOFF;
|
||||
if (njobs == 0) {
|
||||
jobtab = ckmalloc(4 * sizeof jobtab[0]);
|
||||
#if JOBS
|
||||
jobmru = NULL;
|
||||
#endif
|
||||
} else {
|
||||
jp = ckmalloc((njobs + 4) * sizeof jobtab[0]);
|
||||
memcpy(jp, jobtab, njobs * sizeof jp[0]);
|
||||
#if JOBS
|
||||
/* Relocate `next' pointers and list head */
|
||||
if (jobmru != NULL)
|
||||
jobmru = &jp[jobmru - jobtab];
|
||||
for (i = 0; i < njobs; i++)
|
||||
if (jp[i].next != NULL)
|
||||
jp[i].next = &jp[jp[i].next -
|
||||
jobtab];
|
||||
#endif
|
||||
/* Relocate `ps' pointers */
|
||||
for (i = 0; i < njobs; i++)
|
||||
if (jp[i].ps == &jobtab[i].ps0)
|
||||
@@ -549,8 +627,10 @@ makejob(node, nprocs)
|
||||
jp->used = 1;
|
||||
jp->changed = 0;
|
||||
jp->nprocs = 0;
|
||||
jp->foreground = 0;
|
||||
#if JOBS
|
||||
jp->jobctl = jobctl;
|
||||
jp->next = NULL;
|
||||
#endif
|
||||
if (nprocs > 1) {
|
||||
jp->ps = ckmalloc(nprocs * sizeof (struct procstat));
|
||||
@@ -563,6 +643,65 @@ makejob(node, nprocs)
|
||||
return jp;
|
||||
}
|
||||
|
||||
#if JOBS
|
||||
STATIC void
|
||||
setcurjob(struct job *cj)
|
||||
{
|
||||
struct job *jp, *prev;
|
||||
|
||||
for (prev = NULL, jp = jobmru; jp != NULL; prev = jp, jp = jp->next) {
|
||||
if (jp == cj) {
|
||||
if (prev != NULL)
|
||||
prev->next = jp->next;
|
||||
else
|
||||
jobmru = jp->next;
|
||||
jp->next = jobmru;
|
||||
jobmru = cj;
|
||||
return;
|
||||
}
|
||||
}
|
||||
cj->next = jobmru;
|
||||
jobmru = cj;
|
||||
}
|
||||
|
||||
STATIC void
|
||||
deljob(struct job *j)
|
||||
{
|
||||
struct job *jp, *prev;
|
||||
|
||||
for (prev = NULL, jp = jobmru; jp != NULL; prev = jp, jp = jp->next) {
|
||||
if (jp == j) {
|
||||
if (prev != NULL)
|
||||
prev->next = jp->next;
|
||||
else
|
||||
jobmru = jp->next;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the most recently used job that isn't `nj', and preferably one
|
||||
* that is stopped.
|
||||
*/
|
||||
STATIC struct job *
|
||||
getcurjob(struct job *nj)
|
||||
{
|
||||
struct job *jp;
|
||||
|
||||
/* Try to find a stopped one.. */
|
||||
for (jp = jobmru; jp != NULL; jp = jp->next)
|
||||
if (jp->used && jp != nj && jp->state == JOBSTOPPED)
|
||||
return (jp);
|
||||
/* Otherwise the most recently used job that isn't `nj' */
|
||||
for (jp = jobmru; jp != NULL; jp = jp->next)
|
||||
if (jp->used && jp != nj)
|
||||
return (jp);
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Fork of a subshell. If we are doing job control, give the subshell its
|
||||
@@ -579,14 +718,11 @@ makejob(node, nprocs)
|
||||
* in a pipeline).
|
||||
*/
|
||||
|
||||
int
|
||||
forkshell(jp, n, mode)
|
||||
union node *n;
|
||||
struct job *jp;
|
||||
int mode;
|
||||
pid_t
|
||||
forkshell(struct job *jp, union node *n, int mode)
|
||||
{
|
||||
int pid;
|
||||
int pgrp;
|
||||
pid_t pid;
|
||||
pid_t pgrp;
|
||||
|
||||
TRACE(("forkshell(%%%d, 0x%lx, %d) called\n", jp - jobtab, (long)n,
|
||||
mode));
|
||||
@@ -602,12 +738,9 @@ forkshell(jp, n, mode)
|
||||
int wasroot;
|
||||
int i;
|
||||
|
||||
TRACE(("Child shell %d\n", getpid()));
|
||||
TRACE(("Child shell %d\n", (int)getpid()));
|
||||
wasroot = rootshell;
|
||||
rootshell = 0;
|
||||
for (i = njobs, p = jobtab ; --i >= 0 ; p++)
|
||||
if (p->used)
|
||||
freejob(p);
|
||||
closescript();
|
||||
INTON;
|
||||
clear_traps();
|
||||
@@ -620,13 +753,8 @@ forkshell(jp, n, mode)
|
||||
pgrp = jp->ps[0].pid;
|
||||
if (setpgid(0, pgrp) == 0 && mode == FORK_FG) {
|
||||
/*** this causes superfluous TIOCSPGRPS ***/
|
||||
#ifdef OLD_TTY_DRIVER
|
||||
if (ioctl(2, TIOCSPGRP, (char *)&pgrp) < 0)
|
||||
error("TIOCSPGRP failed, errno=%d", errno);
|
||||
#else
|
||||
if (tcsetpgrp(2, pgrp) < 0)
|
||||
if (tcsetpgrp(ttyfd, pgrp) < 0)
|
||||
error("tcsetpgrp failed, errno=%d", errno);
|
||||
#endif
|
||||
}
|
||||
setsignal(SIGTSTP);
|
||||
setsignal(SIGTTOU);
|
||||
@@ -654,6 +782,11 @@ forkshell(jp, n, mode)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
INTOFF;
|
||||
for (i = njobs, p = jobtab ; --i >= 0 ; p++)
|
||||
if (p->used)
|
||||
freejob(p);
|
||||
INTON;
|
||||
if (wasroot && iflag) {
|
||||
setsignal(SIGINT);
|
||||
setsignal(SIGQUIT);
|
||||
@@ -677,9 +810,13 @@ forkshell(jp, n, mode)
|
||||
ps->cmd = nullstr;
|
||||
if (iflag && rootshell && n)
|
||||
ps->cmd = commandtext(n);
|
||||
jp->foreground = mode == FORK_FG;
|
||||
#if JOBS
|
||||
setcurjob(jp);
|
||||
#endif
|
||||
}
|
||||
INTON;
|
||||
TRACE(("In parent shell: child = %d\n", pid));
|
||||
TRACE(("In parent shell: child = %d\n", (int)pid));
|
||||
return pid;
|
||||
}
|
||||
|
||||
@@ -705,12 +842,10 @@ forkshell(jp, n, mode)
|
||||
*/
|
||||
|
||||
int
|
||||
waitforjob(jp, origstatus)
|
||||
struct job *jp;
|
||||
int *origstatus;
|
||||
waitforjob(struct job *jp, int *origstatus)
|
||||
{
|
||||
#if JOBS
|
||||
int mypgrp = getpgrp();
|
||||
pid_t mypgrp = getpgrp();
|
||||
#endif
|
||||
int status;
|
||||
int st;
|
||||
@@ -722,16 +857,11 @@ waitforjob(jp, origstatus)
|
||||
dotrap();
|
||||
#if JOBS
|
||||
if (jp->jobctl) {
|
||||
#ifdef OLD_TTY_DRIVER
|
||||
if (ioctl(2, TIOCSPGRP, (char *)&mypgrp) < 0)
|
||||
error("TIOCSPGRP failed, errno=%d\n", errno);
|
||||
#else
|
||||
if (tcsetpgrp(2, mypgrp) < 0)
|
||||
if (tcsetpgrp(ttyfd, mypgrp) < 0)
|
||||
error("tcsetpgrp failed, errno=%d\n", errno);
|
||||
#endif
|
||||
}
|
||||
if (jp->state == JOBSTOPPED)
|
||||
curjob = jp - jobtab + 1;
|
||||
setcurjob(jp);
|
||||
#endif
|
||||
status = jp->ps[jp->nprocs - 1].status;
|
||||
if (origstatus != NULL)
|
||||
@@ -763,26 +893,24 @@ waitforjob(jp, origstatus)
|
||||
* Wait for a process to terminate.
|
||||
*/
|
||||
|
||||
STATIC int
|
||||
dowait(block, job)
|
||||
int block;
|
||||
struct job *job;
|
||||
STATIC pid_t
|
||||
dowait(int block, struct job *job)
|
||||
{
|
||||
int pid;
|
||||
pid_t pid;
|
||||
int status;
|
||||
struct procstat *sp;
|
||||
struct job *jp;
|
||||
struct job *thisjob;
|
||||
int done;
|
||||
int stopped;
|
||||
int core;
|
||||
int sig;
|
||||
int i;
|
||||
|
||||
in_dowait++;
|
||||
TRACE(("dowait(%d) called\n", block));
|
||||
do {
|
||||
pid = waitproc(block, &status);
|
||||
TRACE(("wait returns %d, status=%d\n", pid, status));
|
||||
TRACE(("wait returns %d, status=%d\n", (int)pid, status));
|
||||
} while ((pid == -1 && errno == EINTR && breakwaitcmd == 0) ||
|
||||
(WIFSTOPPED(status) && !iflag));
|
||||
in_dowait--;
|
||||
@@ -803,7 +931,8 @@ dowait(block, job)
|
||||
continue;
|
||||
if (sp->pid == pid) {
|
||||
TRACE(("Changing status of proc %d from 0x%x to 0x%x\n",
|
||||
pid, sp->status, status));
|
||||
(int)pid, sp->status,
|
||||
status));
|
||||
sp->status = status;
|
||||
thisjob = jp;
|
||||
}
|
||||
@@ -818,8 +947,8 @@ dowait(block, job)
|
||||
TRACE(("Job %d: changing state from %d to %d\n", jp - jobtab + 1, jp->state, state));
|
||||
jp->state = state;
|
||||
#if JOBS
|
||||
if (done && curjob == jp - jobtab + 1)
|
||||
curjob = 0; /* no current job */
|
||||
if (done)
|
||||
deljob(jp);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -827,35 +956,29 @@ dowait(block, job)
|
||||
}
|
||||
INTON;
|
||||
if (! rootshell || ! iflag || (job && thisjob == job)) {
|
||||
core = WCOREDUMP(status);
|
||||
#if JOBS
|
||||
if (WIFSTOPPED(status))
|
||||
sig = WSTOPSIG(status);
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if (WIFEXITED(status))
|
||||
sig = 0;
|
||||
else
|
||||
sig = WTERMSIG(status);
|
||||
|
||||
}
|
||||
if (sig != 0 && sig != SIGINT && sig != SIGPIPE) {
|
||||
if (thisjob != job)
|
||||
outfmt(out2, "%d: ", pid);
|
||||
#if JOBS
|
||||
if (sig == SIGTSTP && rootshell && iflag)
|
||||
outfmt(out2, "%%%d ", job - jobtab + 1);
|
||||
#endif
|
||||
if (sig < NSIG && sys_siglist[sig])
|
||||
out2str(sys_siglist[sig]);
|
||||
else
|
||||
outfmt(out2, "Signal %d", sig);
|
||||
if (core)
|
||||
out2str(" - core dumped");
|
||||
out2c('\n');
|
||||
flushout(&errout);
|
||||
} else {
|
||||
TRACE(("Not printing status: status=%d, sig=%d\n",
|
||||
status, sig));
|
||||
if (thisjob->foreground && !WIFSTOPPED(status)) {
|
||||
i = WTERMSIG(status);
|
||||
if ((i & 0x7F) < NSIG && sys_siglist[i & 0x7F])
|
||||
out1str(sys_siglist[i & 0x7F]);
|
||||
else
|
||||
out1fmt("Signal %d", i & 0x7F);
|
||||
if (WCOREDUMP(status))
|
||||
out1str(" (core dumped)");
|
||||
out1c('\n');
|
||||
} else
|
||||
showjob(thisjob, pid, 0, 0);
|
||||
}
|
||||
} else {
|
||||
TRACE(("Not printing status, rootshell=%d, job=0x%x\n", rootshell, job));
|
||||
@@ -871,46 +994,10 @@ dowait(block, job)
|
||||
* Do a wait system call. If job control is compiled in, we accept
|
||||
* stopped processes. If block is zero, we return a value of zero
|
||||
* rather than blocking.
|
||||
*
|
||||
* System V doesn't have a non-blocking wait system call. It does
|
||||
* have a SIGCLD signal that is sent to a process when one of it's
|
||||
* children dies. The obvious way to use SIGCLD would be to install
|
||||
* a handler for SIGCLD which simply bumped a counter when a SIGCLD
|
||||
* was received, and have waitproc bump another counter when it got
|
||||
* the status of a process. Waitproc would then know that a wait
|
||||
* system call would not block if the two counters were different.
|
||||
* This approach doesn't work because if a process has children that
|
||||
* have not been waited for, System V will send it a SIGCLD when it
|
||||
* installs a signal handler for SIGCLD. What this means is that when
|
||||
* a child exits, the shell will be sent SIGCLD signals continuously
|
||||
* until is runs out of stack space, unless it does a wait call before
|
||||
* restoring the signal handler. The code below takes advantage of
|
||||
* this (mis)feature by installing a signal handler for SIGCLD and
|
||||
* then checking to see whether it was called. If there are any
|
||||
* children to be waited for, it will be.
|
||||
*
|
||||
* If neither SYSV nor BSD is defined, we don't implement nonblocking
|
||||
* waits at all. In this case, the user will not be informed when
|
||||
* a background process until the next time she runs a real program
|
||||
* (as opposed to running a builtin command or just typing return),
|
||||
* and the jobs command may give out of date information.
|
||||
*/
|
||||
|
||||
#ifdef SYSV
|
||||
STATIC sig_atomic_t gotsigchild;
|
||||
|
||||
STATIC int onsigchild() {
|
||||
gotsigchild = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
STATIC int
|
||||
waitproc(block, status)
|
||||
int block;
|
||||
int *status;
|
||||
STATIC pid_t
|
||||
waitproc(int block, int *status)
|
||||
{
|
||||
#ifdef BSD
|
||||
int flags;
|
||||
|
||||
#if JOBS
|
||||
@@ -921,24 +1008,6 @@ waitproc(block, status)
|
||||
if (block == 0)
|
||||
flags |= WNOHANG;
|
||||
return wait3(status, flags, (struct rusage *)NULL);
|
||||
#else
|
||||
#ifdef SYSV
|
||||
int (*save)();
|
||||
|
||||
if (block == 0) {
|
||||
gotsigchild = 0;
|
||||
save = signal(SIGCLD, onsigchild);
|
||||
signal(SIGCLD, save);
|
||||
if (gotsigchild == 0)
|
||||
return 0;
|
||||
}
|
||||
return wait(status);
|
||||
#else
|
||||
if (block == 0)
|
||||
return 0;
|
||||
return wait(status);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -946,7 +1015,7 @@ waitproc(block, status)
|
||||
*/
|
||||
int job_warning = 0;
|
||||
int
|
||||
stoppedjobs()
|
||||
stoppedjobs(void)
|
||||
{
|
||||
int jobno;
|
||||
struct job *jp;
|
||||
@@ -976,9 +1045,8 @@ STATIC int cmdnleft;
|
||||
#define MAXCMDTEXT 200
|
||||
|
||||
char *
|
||||
commandtext(n)
|
||||
union node *n;
|
||||
{
|
||||
commandtext(union node *n)
|
||||
{
|
||||
char *name;
|
||||
|
||||
cmdnextc = name = ckmalloc(MAXCMDTEXT);
|
||||
@@ -990,9 +1058,8 @@ commandtext(n)
|
||||
|
||||
|
||||
STATIC void
|
||||
cmdtxt(n)
|
||||
union node *n;
|
||||
{
|
||||
cmdtxt(union node *n)
|
||||
{
|
||||
union node *np;
|
||||
struct nodelist *lp;
|
||||
char *p;
|
||||
@@ -1085,6 +1152,8 @@ until:
|
||||
p = ">>"; i = 1; goto redir;
|
||||
case NTOFD:
|
||||
p = ">&"; i = 1; goto redir;
|
||||
case NCLOBBER:
|
||||
p = ">|"; i = 1; goto redir;
|
||||
case NFROM:
|
||||
p = "<"; i = 0; goto redir;
|
||||
case NFROMTO:
|
||||
@@ -1099,7 +1168,10 @@ redir:
|
||||
}
|
||||
cmdputs(p);
|
||||
if (n->type == NTOFD || n->type == NFROMFD) {
|
||||
s[0] = n->ndup.dupfd + '0';
|
||||
if (n->ndup.dupfd >= 0)
|
||||
s[0] = n->ndup.dupfd + '0';
|
||||
else
|
||||
s[0] = '-';
|
||||
s[1] = '\0';
|
||||
cmdputs(s);
|
||||
} else {
|
||||
@@ -1119,9 +1191,8 @@ redir:
|
||||
|
||||
|
||||
STATIC void
|
||||
cmdputs(s)
|
||||
char *s;
|
||||
{
|
||||
cmdputs(char *s)
|
||||
{
|
||||
char *p, *q;
|
||||
char c;
|
||||
int subtype = 0;
|
||||
|
||||
+15
-13
@@ -67,12 +67,14 @@ struct job {
|
||||
struct procstat ps0; /* status of process */
|
||||
struct procstat *ps; /* status or processes when more than one */
|
||||
short nprocs; /* number of processes */
|
||||
short pgrp; /* process group of this job */
|
||||
pid_t pgrp; /* process group of this job */
|
||||
char state; /* true if job is finished */
|
||||
char used; /* true if this entry is in used */
|
||||
char changed; /* true if status has changed */
|
||||
char foreground; /* true if running in the foreground */
|
||||
#if JOBS
|
||||
char jobctl; /* job running under job control */
|
||||
struct job *next; /* job used after this one */
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -82,18 +84,18 @@ extern int in_waitcmd; /* are we in waitcmd()? */
|
||||
extern int in_dowait; /* are we in dowait()? */
|
||||
extern volatile sig_atomic_t breakwaitcmd; /* break wait to process traps? */
|
||||
|
||||
void setjobctl __P((int));
|
||||
int fgcmd __P((int, char **));
|
||||
int bgcmd __P((int, char **));
|
||||
int jobscmd __P((int, char **));
|
||||
void showjobs __P((int));
|
||||
int waitcmd __P((int, char **));
|
||||
int jobidcmd __P((int, char **));
|
||||
struct job *makejob __P((union node *, int));
|
||||
int forkshell __P((struct job *, union node *, int));
|
||||
int waitforjob __P((struct job *, int *));
|
||||
int stoppedjobs __P((void));
|
||||
char *commandtext __P((union node *));
|
||||
void setjobctl(int);
|
||||
int fgcmd(int, char **);
|
||||
int bgcmd(int, char **);
|
||||
int jobscmd(int, char **);
|
||||
void showjobs(int, int, int);
|
||||
int waitcmd(int, char **);
|
||||
int jobidcmd(int, char **);
|
||||
struct job *makejob(union node *, int);
|
||||
pid_t forkshell(struct job *, union node *, int);
|
||||
int waitforjob(struct job *, int *);
|
||||
int stoppedjobs(void);
|
||||
char *commandtext(union node *);
|
||||
|
||||
#if ! JOBS
|
||||
#define setjobctl(on) /* do nothing */
|
||||
|
||||
+3
-4
@@ -38,9 +38,9 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)mail.c 8.2 (Berkeley) 5/4/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
/*
|
||||
* Routines to check for mail. (Perhaps make part of main.c?)
|
||||
@@ -72,8 +72,7 @@ STATIC time_t mailtime[MAXMBOXES]; /* times of mailboxes */
|
||||
*/
|
||||
|
||||
void
|
||||
chkmail(silent)
|
||||
int silent;
|
||||
chkmail(int silent)
|
||||
{
|
||||
int i;
|
||||
char *mpath;
|
||||
|
||||
+1
-1
@@ -37,4 +37,4 @@
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
void chkmail __P((int));
|
||||
void chkmail(int);
|
||||
+13
-35
@@ -44,9 +44,9 @@ static char const copyright[] =
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/28/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
@@ -86,8 +86,8 @@ short profile_buf[16384];
|
||||
extern int etext();
|
||||
#endif
|
||||
|
||||
STATIC void read_profile __P((char *));
|
||||
STATIC char *find_dot_file __P((char *));
|
||||
STATIC void read_profile(char *);
|
||||
STATIC char *find_dot_file(char *);
|
||||
|
||||
/*
|
||||
* Main routine. We initialize things, parse the arguments, execute
|
||||
@@ -98,9 +98,7 @@ STATIC char *find_dot_file __P((char *));
|
||||
*/
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
struct jmploc jmploc;
|
||||
struct stackmark smark;
|
||||
@@ -216,8 +214,7 @@ state4: /* XXX ??? - why isn't this before the "if" statement */
|
||||
*/
|
||||
|
||||
void
|
||||
cmdloop(top)
|
||||
int top;
|
||||
cmdloop(int top)
|
||||
{
|
||||
union node *n;
|
||||
struct stackmark smark;
|
||||
@@ -232,7 +229,7 @@ cmdloop(top)
|
||||
inter = 0;
|
||||
if (iflag && top) {
|
||||
inter++;
|
||||
showjobs(1);
|
||||
showjobs(1, 0, 0);
|
||||
chkmail(0);
|
||||
flushout(&output);
|
||||
}
|
||||
@@ -269,9 +266,8 @@ cmdloop(top)
|
||||
*/
|
||||
|
||||
STATIC void
|
||||
read_profile(name)
|
||||
char *name;
|
||||
{
|
||||
read_profile(char *name)
|
||||
{
|
||||
int fd;
|
||||
|
||||
INTOFF;
|
||||
@@ -291,8 +287,7 @@ read_profile(name)
|
||||
*/
|
||||
|
||||
void
|
||||
readcmdfile(name)
|
||||
char *name;
|
||||
readcmdfile(char *name)
|
||||
{
|
||||
int fd;
|
||||
|
||||
@@ -315,8 +310,7 @@ readcmdfile(name)
|
||||
|
||||
|
||||
STATIC char *
|
||||
find_dot_file(basename)
|
||||
char *basename;
|
||||
find_dot_file(char *basename)
|
||||
{
|
||||
static char localname[FILENAME_MAX+1];
|
||||
char *fullname;
|
||||
@@ -337,9 +331,7 @@ find_dot_file(basename)
|
||||
}
|
||||
|
||||
int
|
||||
dotcmd(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
dotcmd(int argc, char **argv)
|
||||
{
|
||||
struct strlist *sp;
|
||||
exitstatus = 0;
|
||||
@@ -360,9 +352,7 @@ dotcmd(argc, argv)
|
||||
|
||||
|
||||
int
|
||||
exitcmd(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
exitcmd(int argc, char **argv)
|
||||
{
|
||||
extern int oexitstatus;
|
||||
|
||||
@@ -376,15 +366,3 @@ exitcmd(argc, argv)
|
||||
/*NOTREACHED*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#ifdef notdef
|
||||
/*
|
||||
* Should never be called.
|
||||
*/
|
||||
|
||||
void
|
||||
exit(exitstatus) {
|
||||
_exit(exitstatus);
|
||||
}
|
||||
#endif
|
||||
+4
-4
@@ -40,7 +40,7 @@
|
||||
extern int rootpid; /* pid of main shell */
|
||||
extern int rootshell; /* true if we aren't a child of the main shell */
|
||||
|
||||
void readcmdfile __P((char *));
|
||||
void cmdloop __P((int));
|
||||
int dotcmd __P((int, char **));
|
||||
int exitcmd __P((int, char **));
|
||||
void readcmdfile(char *);
|
||||
void cmdloop(int);
|
||||
int dotcmd(int, char **);
|
||||
int exitcmd(int, char **);
|
||||
+15
-26
@@ -38,9 +38,9 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)memalloc.c 8.3 (Berkeley) 5/4/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "shell.h"
|
||||
#include "output.h"
|
||||
@@ -57,8 +57,7 @@ static const char rcsid[] =
|
||||
*/
|
||||
|
||||
pointer
|
||||
ckmalloc(nbytes)
|
||||
int nbytes;
|
||||
ckmalloc(int nbytes)
|
||||
{
|
||||
pointer p;
|
||||
|
||||
@@ -73,9 +72,7 @@ ckmalloc(nbytes)
|
||||
*/
|
||||
|
||||
pointer
|
||||
ckrealloc(p, nbytes)
|
||||
pointer p;
|
||||
int nbytes;
|
||||
ckrealloc(pointer p, int nbytes)
|
||||
{
|
||||
if ((p = realloc(p, nbytes)) == NULL)
|
||||
error("Out of space");
|
||||
@@ -88,8 +85,7 @@ ckrealloc(p, nbytes)
|
||||
*/
|
||||
|
||||
char *
|
||||
savestr(s)
|
||||
char *s;
|
||||
savestr(char *s)
|
||||
{
|
||||
char *p;
|
||||
|
||||
@@ -127,8 +123,7 @@ int herefd = -1;
|
||||
|
||||
|
||||
pointer
|
||||
stalloc(nbytes)
|
||||
int nbytes;
|
||||
stalloc(int nbytes)
|
||||
{
|
||||
char *p;
|
||||
|
||||
@@ -157,11 +152,10 @@ stalloc(nbytes)
|
||||
|
||||
|
||||
void
|
||||
stunalloc(p)
|
||||
pointer p;
|
||||
stunalloc(pointer p)
|
||||
{
|
||||
if (p == NULL) { /*DEBUG */
|
||||
write(2, "stunalloc\n", 10);
|
||||
write(STDERR_FILENO, "stunalloc\n", 10);
|
||||
abort();
|
||||
}
|
||||
stacknleft += stacknxt - (char *)p;
|
||||
@@ -171,8 +165,7 @@ stunalloc(p)
|
||||
|
||||
|
||||
void
|
||||
setstackmark(mark)
|
||||
struct stackmark *mark;
|
||||
setstackmark(struct stackmark *mark)
|
||||
{
|
||||
mark->stackp = stackp;
|
||||
mark->stacknxt = stacknxt;
|
||||
@@ -183,8 +176,7 @@ setstackmark(mark)
|
||||
|
||||
|
||||
void
|
||||
popstackmark(mark)
|
||||
struct stackmark *mark;
|
||||
popstackmark(struct stackmark *mark)
|
||||
{
|
||||
struct stack_block *sp;
|
||||
|
||||
@@ -212,7 +204,7 @@ popstackmark(mark)
|
||||
*/
|
||||
|
||||
void
|
||||
growstackblock()
|
||||
growstackblock(void)
|
||||
{
|
||||
char *p;
|
||||
int newlen;
|
||||
@@ -261,8 +253,7 @@ growstackblock()
|
||||
|
||||
|
||||
void
|
||||
grabstackblock(len)
|
||||
int len;
|
||||
grabstackblock(int len)
|
||||
{
|
||||
len = ALIGN(len);
|
||||
stacknxt += len;
|
||||
@@ -291,7 +282,7 @@ grabstackblock(len)
|
||||
|
||||
|
||||
char *
|
||||
growstackstr()
|
||||
growstackstr(void)
|
||||
{
|
||||
int len;
|
||||
|
||||
@@ -312,7 +303,7 @@ growstackstr()
|
||||
*/
|
||||
|
||||
char *
|
||||
makestrspace()
|
||||
makestrspace(void)
|
||||
{
|
||||
int len;
|
||||
|
||||
@@ -325,9 +316,7 @@ makestrspace()
|
||||
|
||||
|
||||
void
|
||||
ungrabstackstr(s, p)
|
||||
char *s;
|
||||
char *p;
|
||||
ungrabstackstr(char *s, char *p)
|
||||
{
|
||||
stacknleft += stacknxt - s;
|
||||
stacknxt = s;
|
||||
|
||||
+12
-12
@@ -50,18 +50,18 @@ extern int stacknleft;
|
||||
extern int sstrnleft;
|
||||
extern int herefd;
|
||||
|
||||
pointer ckmalloc __P((int));
|
||||
pointer ckrealloc __P((pointer, int));
|
||||
char *savestr __P((char *));
|
||||
pointer stalloc __P((int));
|
||||
void stunalloc __P((pointer));
|
||||
void setstackmark __P((struct stackmark *));
|
||||
void popstackmark __P((struct stackmark *));
|
||||
void growstackblock __P((void));
|
||||
void grabstackblock __P((int));
|
||||
char *growstackstr __P((void));
|
||||
char *makestrspace __P((void));
|
||||
void ungrabstackstr __P((char *, char *));
|
||||
pointer ckmalloc(int);
|
||||
pointer ckrealloc(pointer, int);
|
||||
char *savestr(char *);
|
||||
pointer stalloc(int);
|
||||
void stunalloc(pointer);
|
||||
void setstackmark(struct stackmark *);
|
||||
void popstackmark(struct stackmark *);
|
||||
void growstackblock(void);
|
||||
void grabstackblock(int);
|
||||
char *growstackstr(void);
|
||||
char *makestrspace(void);
|
||||
void ungrabstackstr(char *, char *);
|
||||
|
||||
|
||||
|
||||
|
||||
+7
-13
@@ -38,9 +38,9 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)miscbltin.c 8.4 (Berkeley) 5/4/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
/*
|
||||
* Miscellaneous builtins.
|
||||
@@ -75,9 +75,7 @@ static const char rcsid[] =
|
||||
*/
|
||||
|
||||
int
|
||||
readcmd(argc, argv)
|
||||
int argc __unused;
|
||||
char **argv __unused;
|
||||
readcmd(int argc __unused, char **argv __unused)
|
||||
{
|
||||
char **ap;
|
||||
int backslash;
|
||||
@@ -171,7 +169,7 @@ readcmd(argc, argv)
|
||||
backslash = 0;
|
||||
STARTSTACKSTR(p);
|
||||
for (;;) {
|
||||
if (read(0, &c, 1) != 1) {
|
||||
if (read(STDIN_FILENO, &c, 1) != 1) {
|
||||
status = 1;
|
||||
break;
|
||||
}
|
||||
@@ -194,7 +192,7 @@ readcmd(argc, argv)
|
||||
}
|
||||
startword = 0;
|
||||
if (backslash && c == '\\') {
|
||||
if (read(0, &c, 1) != 1) {
|
||||
if (read(STDIN_FILENO, &c, 1) != 1) {
|
||||
status = 1;
|
||||
break;
|
||||
}
|
||||
@@ -219,9 +217,7 @@ readcmd(argc, argv)
|
||||
|
||||
|
||||
int
|
||||
umaskcmd(argc, argv)
|
||||
int argc __unused;
|
||||
char **argv;
|
||||
umaskcmd(int argc __unused, char **argv)
|
||||
{
|
||||
char *ap;
|
||||
int mask;
|
||||
@@ -353,9 +349,7 @@ static const struct limits limits[] = {
|
||||
};
|
||||
|
||||
int
|
||||
ulimitcmd(argc, argv)
|
||||
int argc __unused;
|
||||
char **argv __unused;
|
||||
ulimitcmd(int argc __unused, char **argv __unused)
|
||||
{
|
||||
int c;
|
||||
quad_t val = 0;
|
||||
|
||||
@@ -54,6 +54,7 @@ cat <<\!
|
||||
* This file was generated by the mkbuiltins program.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "shell.h"
|
||||
#include "builtins.h"
|
||||
|
||||
|
||||
+41
-63
@@ -44,9 +44,9 @@ static char const copyright[] =
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)mkinit.c 8.2 (Berkeley) 5/4/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
/*
|
||||
* This program scans all the source files for code to handle various
|
||||
@@ -152,27 +152,25 @@ struct text decls; /* declarations */
|
||||
int amiddecls; /* for formatting */
|
||||
|
||||
|
||||
void readfile __P((char *));
|
||||
int match __P((char *, char *));
|
||||
int gooddefine __P((char *));
|
||||
void doevent __P((struct event *, FILE *, char *));
|
||||
void doinclude __P((char *));
|
||||
void dodecl __P((char *, FILE *));
|
||||
void output __P((void));
|
||||
void addstr __P((char *, struct text *));
|
||||
void addchar __P((int, struct text *));
|
||||
void writetext __P((struct text *, FILE *));
|
||||
FILE *ckfopen __P((char *, char *));
|
||||
void *ckmalloc __P((int));
|
||||
char *savestr __P((char *));
|
||||
void error __P((char *));
|
||||
void readfile(char *);
|
||||
int match(char *, char *);
|
||||
int gooddefine(char *);
|
||||
void doevent(struct event *, FILE *, char *);
|
||||
void doinclude(char *);
|
||||
void dodecl(char *, FILE *);
|
||||
void output(void);
|
||||
void addstr(char *, struct text *);
|
||||
void addchar(int, struct text *);
|
||||
void writetext(struct text *, FILE *);
|
||||
FILE *ckfopen(char *, char *);
|
||||
void *ckmalloc(int);
|
||||
char *savestr(char *);
|
||||
void error(char *);
|
||||
|
||||
#define equal(s1, s2) (strcmp(s1, s2) == 0)
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc __unused;
|
||||
char **argv;
|
||||
main(int argc __unused, char *argv[])
|
||||
{
|
||||
char **ap;
|
||||
|
||||
@@ -191,9 +189,8 @@ main(argc, argv)
|
||||
*/
|
||||
|
||||
void
|
||||
readfile(fname)
|
||||
char *fname;
|
||||
{
|
||||
readfile(char *fname)
|
||||
{
|
||||
FILE *fp;
|
||||
char line[1024];
|
||||
struct event *ep;
|
||||
@@ -236,9 +233,7 @@ readfile(fname)
|
||||
|
||||
|
||||
int
|
||||
match(name, line)
|
||||
char *name;
|
||||
char *line;
|
||||
match(char *name, char *line)
|
||||
{
|
||||
char *p, *q;
|
||||
|
||||
@@ -254,8 +249,7 @@ match(name, line)
|
||||
|
||||
|
||||
int
|
||||
gooddefine(line)
|
||||
char *line;
|
||||
gooddefine(char *line)
|
||||
{
|
||||
char *p;
|
||||
|
||||
@@ -278,11 +272,8 @@ gooddefine(line)
|
||||
|
||||
|
||||
void
|
||||
doevent(ep, fp, fname)
|
||||
struct event *ep;
|
||||
FILE *fp;
|
||||
char *fname;
|
||||
{
|
||||
doevent(struct event *ep, FILE *fp, char *fname)
|
||||
{
|
||||
char line[1024];
|
||||
int indent;
|
||||
char *p;
|
||||
@@ -318,9 +309,8 @@ doevent(ep, fp, fname)
|
||||
|
||||
|
||||
void
|
||||
doinclude(line)
|
||||
char *line;
|
||||
{
|
||||
doinclude(char *line)
|
||||
{
|
||||
char *p;
|
||||
char *name;
|
||||
char **pp;
|
||||
@@ -343,10 +333,8 @@ doinclude(line)
|
||||
|
||||
|
||||
void
|
||||
dodecl(line1, fp)
|
||||
char *line1;
|
||||
FILE *fp;
|
||||
{
|
||||
dodecl(char *line1, FILE *fp)
|
||||
{
|
||||
char line[1024];
|
||||
char *p, *q;
|
||||
|
||||
@@ -390,7 +378,8 @@ dodecl(line1, fp)
|
||||
*/
|
||||
|
||||
void
|
||||
output() {
|
||||
output(void)
|
||||
{
|
||||
FILE *fp;
|
||||
char **pp;
|
||||
struct event *ep;
|
||||
@@ -421,10 +410,8 @@ output() {
|
||||
*/
|
||||
|
||||
void
|
||||
addstr(s, text)
|
||||
char *s;
|
||||
struct text *text;
|
||||
{
|
||||
addstr(char *s, struct text *text)
|
||||
{
|
||||
while (*s) {
|
||||
if (--text->nleft < 0)
|
||||
addchar(*s++, text);
|
||||
@@ -435,9 +422,7 @@ addstr(s, text)
|
||||
|
||||
|
||||
void
|
||||
addchar(c, text)
|
||||
int c;
|
||||
struct text *text;
|
||||
addchar(int c, struct text *text)
|
||||
{
|
||||
struct block *bp;
|
||||
|
||||
@@ -458,10 +443,8 @@ addchar(c, text)
|
||||
* Write the contents of a text structure to a file.
|
||||
*/
|
||||
void
|
||||
writetext(text, fp)
|
||||
struct text *text;
|
||||
FILE *fp;
|
||||
{
|
||||
writetext(struct text *text, FILE *fp)
|
||||
{
|
||||
struct block *bp;
|
||||
|
||||
if (text->start != NULL) {
|
||||
@@ -472,10 +455,8 @@ writetext(text, fp)
|
||||
}
|
||||
|
||||
FILE *
|
||||
ckfopen(file, mode)
|
||||
char *file;
|
||||
char *mode;
|
||||
{
|
||||
ckfopen(char *file, char *mode)
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
if ((fp = fopen(file, mode)) == NULL) {
|
||||
@@ -486,8 +467,7 @@ ckfopen(file, mode)
|
||||
}
|
||||
|
||||
void *
|
||||
ckmalloc(nbytes)
|
||||
int nbytes;
|
||||
ckmalloc(int nbytes)
|
||||
{
|
||||
char *p;
|
||||
|
||||
@@ -497,9 +477,8 @@ ckmalloc(nbytes)
|
||||
}
|
||||
|
||||
char *
|
||||
savestr(s)
|
||||
char *s;
|
||||
{
|
||||
savestr(char *s)
|
||||
{
|
||||
char *p;
|
||||
|
||||
p = ckmalloc(strlen(s) + 1);
|
||||
@@ -508,9 +487,8 @@ savestr(s)
|
||||
}
|
||||
|
||||
void
|
||||
error(msg)
|
||||
char *msg;
|
||||
{
|
||||
error(char *msg)
|
||||
{
|
||||
if (curfile != NULL)
|
||||
fprintf(stderr, "%s:%d: ", curfile, linno);
|
||||
fprintf(stderr, "%s\n", msg);
|
||||
|
||||
+24
-55
@@ -44,9 +44,9 @@ static char const copyright[] =
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)mknodes.c 8.2 (Berkeley) 5/4/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
/*
|
||||
* This program reads the nodetypes file and nodes.c.pat file. It generates
|
||||
@@ -57,12 +57,7 @@ static const char rcsid[] =
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#ifdef __STDC__
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
|
||||
#define MAXTYPES 50 /* max number of node types */
|
||||
#define MAXFIELDS 20 /* max fields in a structure */
|
||||
@@ -103,23 +98,21 @@ static char line[1024];
|
||||
static int linno;
|
||||
static char *linep;
|
||||
|
||||
static void parsenode __P((void));
|
||||
static void parsefield __P((void));
|
||||
static void output __P((char *));
|
||||
static void outsizes __P((FILE *));
|
||||
static void outfunc __P((FILE *, int));
|
||||
static void indent __P((int, FILE *));
|
||||
static int nextfield __P((char *));
|
||||
static void skipbl __P((void));
|
||||
static int readline __P((void));
|
||||
static void error __P((const char *, ...)) __printf0like(1, 2);
|
||||
static char *savestr __P((const char *));
|
||||
static void parsenode(void);
|
||||
static void parsefield(void);
|
||||
static void output(char *);
|
||||
static void outsizes(FILE *);
|
||||
static void outfunc(FILE *, int);
|
||||
static void indent(int, FILE *);
|
||||
static int nextfield(char *);
|
||||
static void skipbl(void);
|
||||
static int readline(void);
|
||||
static void error(const char *, ...) __printf0like(1, 2);
|
||||
static char *savestr(const char *);
|
||||
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
if (argc != 3)
|
||||
error("usage: mknodes file");
|
||||
@@ -139,7 +132,7 @@ main(argc, argv)
|
||||
|
||||
|
||||
static void
|
||||
parsenode()
|
||||
parsenode(void)
|
||||
{
|
||||
char name[BUFLEN];
|
||||
char tag[BUFLEN];
|
||||
@@ -169,7 +162,7 @@ parsenode()
|
||||
|
||||
|
||||
static void
|
||||
parsefield()
|
||||
parsefield(void)
|
||||
{
|
||||
char name[BUFLEN];
|
||||
char type[BUFLEN];
|
||||
@@ -222,8 +215,7 @@ char writer[] = "\
|
||||
\n";
|
||||
|
||||
static void
|
||||
output(file)
|
||||
char *file;
|
||||
output(char *file)
|
||||
{
|
||||
FILE *hfile;
|
||||
FILE *cfile;
|
||||
@@ -260,13 +252,8 @@ output(file)
|
||||
fputs("\tstruct nodelist *next;\n", hfile);
|
||||
fputs("\tunion node *n;\n", hfile);
|
||||
fputs("};\n\n\n", hfile);
|
||||
fputs("#ifdef __STDC__\n", hfile);
|
||||
fputs("union node *copyfunc(union node *);\n", hfile);
|
||||
fputs("void freefunc(union node *);\n", hfile);
|
||||
fputs("#else\n", hfile);
|
||||
fputs("union node *copyfunc();\n", hfile);
|
||||
fputs("void freefunc();\n", hfile);
|
||||
fputs("#endif\n", hfile);
|
||||
|
||||
fputs(writer, cfile);
|
||||
while (fgets(line, sizeof line, patfile) != NULL) {
|
||||
@@ -285,8 +272,7 @@ output(file)
|
||||
|
||||
|
||||
static void
|
||||
outsizes(cfile)
|
||||
FILE *cfile;
|
||||
outsizes(FILE *cfile)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -299,9 +285,7 @@ outsizes(cfile)
|
||||
|
||||
|
||||
static void
|
||||
outfunc(cfile, calcsize)
|
||||
FILE *cfile;
|
||||
int calcsize;
|
||||
outfunc(FILE *cfile, int calcsize)
|
||||
{
|
||||
struct str *sp;
|
||||
struct field *fp;
|
||||
@@ -380,9 +364,7 @@ outfunc(cfile, calcsize)
|
||||
|
||||
|
||||
static void
|
||||
indent(amount, fp)
|
||||
int amount;
|
||||
FILE *fp;
|
||||
indent(int amount, FILE *fp)
|
||||
{
|
||||
while (amount >= 8) {
|
||||
putc('\t', fp);
|
||||
@@ -395,8 +377,7 @@ indent(amount, fp)
|
||||
|
||||
|
||||
static int
|
||||
nextfield(buf)
|
||||
char *buf;
|
||||
nextfield(char *buf)
|
||||
{
|
||||
char *p, *q;
|
||||
|
||||
@@ -413,7 +394,7 @@ nextfield(buf)
|
||||
|
||||
|
||||
static void
|
||||
skipbl()
|
||||
skipbl(void)
|
||||
{
|
||||
while (*linep == ' ' || *linep == '\t')
|
||||
linep++;
|
||||
@@ -421,7 +402,7 @@ skipbl()
|
||||
|
||||
|
||||
static int
|
||||
readline()
|
||||
readline(void)
|
||||
{
|
||||
char *p;
|
||||
|
||||
@@ -441,21 +422,10 @@ readline()
|
||||
|
||||
|
||||
static void
|
||||
#ifdef __STDC__
|
||||
error(const char *msg, ...)
|
||||
#else
|
||||
error(va_alist)
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list va;
|
||||
#ifdef __STDC__
|
||||
va_start(va, msg);
|
||||
#else
|
||||
const char *msg;
|
||||
va_start(va);
|
||||
msg = va_arg(va, char *);
|
||||
#endif
|
||||
|
||||
(void) fprintf(stderr, "line %d: ", linno);
|
||||
(void) vfprintf(stderr, msg, va);
|
||||
@@ -469,8 +439,7 @@ error(va_alist)
|
||||
|
||||
|
||||
static char *
|
||||
savestr(s)
|
||||
const char *s;
|
||||
savestr(const char *s)
|
||||
{
|
||||
char *p;
|
||||
|
||||
|
||||
+15
-20
@@ -44,9 +44,9 @@ static char const copyright[] =
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)mksyntax.c 8.2 (Berkeley) 5/4/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
/*
|
||||
* This program creates syntax.h and syntax.c.
|
||||
@@ -111,17 +111,15 @@ static int size; /* number of values which a char variable can have */
|
||||
static int nbits; /* number of bits in a character */
|
||||
static int digit_contig;/* true if digits are contiguous */
|
||||
|
||||
static void filltable __P((char *));
|
||||
static void init __P((void));
|
||||
static void add __P((char *, char *));
|
||||
static void print __P((char *));
|
||||
static void output_type_macros __P((void));
|
||||
static void digit_convert __P((void));
|
||||
static void filltable(char *);
|
||||
static void init(void);
|
||||
static void add(char *, char *);
|
||||
static void print(char *);
|
||||
static void output_type_macros(void);
|
||||
static void digit_convert(void);
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc __unused;
|
||||
char **argv __unused;
|
||||
main(int argc __unused, char **argv __unused)
|
||||
{
|
||||
char c;
|
||||
char d;
|
||||
@@ -268,8 +266,7 @@ main(argc, argv)
|
||||
*/
|
||||
|
||||
static void
|
||||
filltable(dftval)
|
||||
char *dftval;
|
||||
filltable(char *dftval)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -283,7 +280,7 @@ filltable(dftval)
|
||||
*/
|
||||
|
||||
static void
|
||||
init()
|
||||
init(void)
|
||||
{
|
||||
filltable("CWORD");
|
||||
syntax[0] = "CEOF";
|
||||
@@ -303,8 +300,7 @@ init()
|
||||
*/
|
||||
|
||||
static void
|
||||
add(p, type)
|
||||
char *p, *type;
|
||||
add(char *p, char *type)
|
||||
{
|
||||
while (*p)
|
||||
syntax[*p++ + base] = type;
|
||||
@@ -317,8 +313,7 @@ add(p, type)
|
||||
*/
|
||||
|
||||
static void
|
||||
print(name)
|
||||
char *name;
|
||||
print(char *name)
|
||||
{
|
||||
int i;
|
||||
int col;
|
||||
@@ -360,7 +355,7 @@ static char *macro[] = {
|
||||
};
|
||||
|
||||
static void
|
||||
output_type_macros()
|
||||
output_type_macros(void)
|
||||
{
|
||||
char **pp;
|
||||
|
||||
@@ -381,7 +376,7 @@ output_type_macros()
|
||||
*/
|
||||
|
||||
static void
|
||||
digit_convert()
|
||||
digit_convert(void)
|
||||
{
|
||||
int maxdigit;
|
||||
static char digit[] = "0123456789";
|
||||
|
||||
+2
-2
@@ -81,14 +81,14 @@ const char tokendlist[] = {'
|
||||
awk '{print "\t" $2 ","}' $temp
|
||||
echo '};
|
||||
|
||||
char *const tokname[] = {'
|
||||
const char *const tokname[] = {'
|
||||
sed -e 's/"/\\"/g' \
|
||||
-e 's/[^ ]*[ ][ ]*[^ ]*[ ][ ]*\(.*\)/ "\1",/' \
|
||||
$temp
|
||||
echo '};
|
||||
'
|
||||
sed 's/"//g' $temp | awk '
|
||||
/TIF/{print "#define KWDOFFSET " NR-1; print ""; print "char *const parsekwd[] = {"}
|
||||
/TIF/{print "#define KWDOFFSET " NR-1; print ""; print "const char *const parsekwd[] = {"}
|
||||
/TIF/,/neverfound/{print " \"" $3 "\","}'
|
||||
echo ' 0
|
||||
};'
|
||||
|
||||
+6
-5
@@ -40,9 +40,10 @@ extern History *hist;
|
||||
extern EditLine *el;
|
||||
extern int displayhist;
|
||||
|
||||
void histedit __P((void));
|
||||
void sethistsize __P((const char *));
|
||||
int histcmd __P((int, char **));
|
||||
int not_fcnumber __P((char *));
|
||||
int str_to_event __P((char *, int));
|
||||
void histedit(void);
|
||||
void sethistsize(const char *);
|
||||
int histcmd(int, char **);
|
||||
int not_fcnumber(char *);
|
||||
int str_to_event(char *, int);
|
||||
int bindcmd(int, char **);
|
||||
|
||||
+10
-18
@@ -38,9 +38,9 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)mystring.c 8.2 (Berkeley) 5/4/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
/*
|
||||
* String functions.
|
||||
@@ -77,11 +77,8 @@ char nullstr[1]; /* zero length string */
|
||||
*/
|
||||
|
||||
void
|
||||
scopyn(from, to, size)
|
||||
char const *from;
|
||||
char *to;
|
||||
int size;
|
||||
{
|
||||
scopyn(const char *from, char *to, int size)
|
||||
{
|
||||
|
||||
while (--size > 0) {
|
||||
if ((*to++ = *from++) == '\0')
|
||||
@@ -96,10 +93,8 @@ scopyn(from, to, size)
|
||||
*/
|
||||
|
||||
int
|
||||
prefix(pfx, string)
|
||||
char const *pfx;
|
||||
char const *string;
|
||||
{
|
||||
prefix(const char *pfx, const char *string)
|
||||
{
|
||||
while (*pfx) {
|
||||
if (*pfx++ != *string++)
|
||||
return 0;
|
||||
@@ -114,10 +109,8 @@ prefix(pfx, string)
|
||||
*/
|
||||
|
||||
int
|
||||
number(s)
|
||||
const char *s;
|
||||
{
|
||||
|
||||
number(const char *s)
|
||||
{
|
||||
if (! is_number(s))
|
||||
error("Illegal number: %s", (char *)s);
|
||||
return atoi(s);
|
||||
@@ -130,9 +123,8 @@ number(s)
|
||||
*/
|
||||
|
||||
int
|
||||
is_number(p)
|
||||
const char *p;
|
||||
{
|
||||
is_number(const char *p)
|
||||
{
|
||||
do {
|
||||
if (! is_digit(*p))
|
||||
return 0;
|
||||
|
||||
+4
-4
@@ -39,10 +39,10 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
void scopyn __P((const char *, char *, int));
|
||||
int prefix __P((const char *, const char *));
|
||||
int number __P((const char *));
|
||||
int is_number __P((const char *));
|
||||
void scopyn(const char *, char *, int);
|
||||
int prefix(const char *, const char *);
|
||||
int number(const char *);
|
||||
int is_number(const char *);
|
||||
|
||||
#define equal(s1, s2) (strcmp(s1, s2) == 0)
|
||||
#define scopy(s1, s2) ((void)strcpy(s2, s1))
|
||||
+12
-19
@@ -57,11 +57,11 @@ char *funcstring; /* block to allocate strings from */
|
||||
%SIZES
|
||||
|
||||
|
||||
STATIC void calcsize __P((union node *));
|
||||
STATIC void sizenodelist __P((struct nodelist *));
|
||||
STATIC union node *copynode __P((union node *));
|
||||
STATIC struct nodelist *copynodelist __P((struct nodelist *));
|
||||
STATIC char *nodesavestr __P((char *));
|
||||
STATIC void calcsize(union node *);
|
||||
STATIC void sizenodelist(struct nodelist *);
|
||||
STATIC union node *copynode(union node *);
|
||||
STATIC struct nodelist *copynodelist(struct nodelist *);
|
||||
STATIC char *nodesavestr(char *);
|
||||
|
||||
|
||||
|
||||
@@ -70,8 +70,7 @@ STATIC char *nodesavestr __P((char *));
|
||||
*/
|
||||
|
||||
union node *
|
||||
copyfunc(n)
|
||||
union node *n;
|
||||
copyfunc(union node *n)
|
||||
{
|
||||
if (n == NULL)
|
||||
return NULL;
|
||||
@@ -86,8 +85,7 @@ copyfunc(n)
|
||||
|
||||
|
||||
STATIC void
|
||||
calcsize(n)
|
||||
union node *n;
|
||||
calcsize(union node *n)
|
||||
{
|
||||
%CALCSIZE
|
||||
}
|
||||
@@ -95,8 +93,7 @@ calcsize(n)
|
||||
|
||||
|
||||
STATIC void
|
||||
sizenodelist(lp)
|
||||
struct nodelist *lp;
|
||||
sizenodelist(struct nodelist *lp)
|
||||
{
|
||||
while (lp) {
|
||||
funcblocksize += ALIGN(sizeof(struct nodelist));
|
||||
@@ -108,8 +105,7 @@ sizenodelist(lp)
|
||||
|
||||
|
||||
STATIC union node *
|
||||
copynode(n)
|
||||
union node *n;
|
||||
copynode(union node *n)
|
||||
{
|
||||
union node *new;
|
||||
|
||||
@@ -119,8 +115,7 @@ copynode(n)
|
||||
|
||||
|
||||
STATIC struct nodelist *
|
||||
copynodelist(lp)
|
||||
struct nodelist *lp;
|
||||
copynodelist(struct nodelist *lp)
|
||||
{
|
||||
struct nodelist *start;
|
||||
struct nodelist **lpp;
|
||||
@@ -140,8 +135,7 @@ copynodelist(lp)
|
||||
|
||||
|
||||
STATIC char *
|
||||
nodesavestr(s)
|
||||
char *s;
|
||||
nodesavestr(char *s)
|
||||
{
|
||||
char *p = s;
|
||||
char *q = funcstring;
|
||||
@@ -160,8 +154,7 @@ nodesavestr(s)
|
||||
*/
|
||||
|
||||
void
|
||||
freefunc(n)
|
||||
union node *n;
|
||||
freefunc(union node *n)
|
||||
{
|
||||
if (n)
|
||||
ckfree(n);
|
||||
|
||||
@@ -120,6 +120,7 @@ NTO nfile # fd> fname
|
||||
NFROM nfile # fd< fname
|
||||
NFROMTO nfile # fd<> fname
|
||||
NAPPEND nfile # fd>> fname
|
||||
NCLOBBER nfile # fd>| fname
|
||||
type int
|
||||
next nodeptr # next redirection in list
|
||||
fd int # file descriptor being redirected
|
||||
|
||||
+45
-51
@@ -38,9 +38,9 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)options.c 8.2 (Berkeley) 5/4/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
@@ -73,10 +73,10 @@ char *optptr; /* used by nextopt */
|
||||
char *minusc; /* argument to -c option */
|
||||
|
||||
|
||||
STATIC void options __P((int));
|
||||
STATIC void minus_o __P((char *, int));
|
||||
STATIC void setoption __P((int, int));
|
||||
STATIC int getopts __P((char *, char *, char **, char ***, char **));
|
||||
STATIC void options(int);
|
||||
STATIC void minus_o(char *, int);
|
||||
STATIC void setoption(int, int);
|
||||
STATIC int getopts(char *, char *, char **, char ***, char **);
|
||||
|
||||
|
||||
/*
|
||||
@@ -84,9 +84,7 @@ STATIC int getopts __P((char *, char *, char **, char ***, char **));
|
||||
*/
|
||||
|
||||
void
|
||||
procargs(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
procargs(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -127,7 +125,7 @@ procargs(argc, argv)
|
||||
|
||||
|
||||
void
|
||||
optschanged()
|
||||
optschanged(void)
|
||||
{
|
||||
setinteractive(iflag);
|
||||
#ifndef NO_HISTORY
|
||||
@@ -142,8 +140,7 @@ optschanged()
|
||||
*/
|
||||
|
||||
STATIC void
|
||||
options(cmdline)
|
||||
int cmdline;
|
||||
options(int cmdline)
|
||||
{
|
||||
char *p;
|
||||
int val;
|
||||
@@ -201,17 +198,30 @@ options(cmdline)
|
||||
}
|
||||
|
||||
STATIC void
|
||||
minus_o(name, val)
|
||||
char *name;
|
||||
int val;
|
||||
minus_o(char *name, int val)
|
||||
{
|
||||
int i;
|
||||
int doneset, i;
|
||||
|
||||
if (name == NULL) {
|
||||
out1str("Current option settings\n");
|
||||
for (i = 0; i < NOPTS; i++)
|
||||
out1fmt("%-16s%s\n", optlist[i].name,
|
||||
optlist[i].val ? "on" : "off");
|
||||
if (val) {
|
||||
/* "Pretty" output. */
|
||||
out1str("Current option settings\n");
|
||||
for (i = 0; i < NOPTS; i++)
|
||||
out1fmt("%-16s%s\n", optlist[i].name,
|
||||
optlist[i].val ? "on" : "off");
|
||||
} else {
|
||||
/* Output suitable for re-input to shell. */
|
||||
for (doneset = i = 0; i < NOPTS; i++)
|
||||
if (optlist[i].val) {
|
||||
if (!doneset) {
|
||||
out1str("set");
|
||||
doneset = 1;
|
||||
}
|
||||
out1fmt(" -o %s", optlist[i].name);
|
||||
}
|
||||
if (doneset)
|
||||
out1c('\n');
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < NOPTS; i++)
|
||||
if (equal(name, optlist[i].name)) {
|
||||
@@ -228,10 +238,8 @@ minus_o(name, val)
|
||||
|
||||
|
||||
STATIC void
|
||||
setoption(flag, val)
|
||||
char flag;
|
||||
int val;
|
||||
{
|
||||
setoption(int flag, int val)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NOPTS; i++)
|
||||
@@ -270,9 +278,8 @@ SHELLPROC {
|
||||
*/
|
||||
|
||||
void
|
||||
setparam(argv)
|
||||
char **argv;
|
||||
{
|
||||
setparam(char **argv)
|
||||
{
|
||||
char **newparam;
|
||||
char **ap;
|
||||
int nparam;
|
||||
@@ -296,9 +303,8 @@ setparam(argv)
|
||||
*/
|
||||
|
||||
void
|
||||
freeparam(param)
|
||||
struct shparam *param;
|
||||
{
|
||||
freeparam(struct shparam *param)
|
||||
{
|
||||
char **ap;
|
||||
|
||||
if (param->malloc) {
|
||||
@@ -315,9 +321,7 @@ freeparam(param)
|
||||
*/
|
||||
|
||||
int
|
||||
shiftcmd(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
shiftcmd(int argc, char **argv)
|
||||
{
|
||||
int n;
|
||||
char **ap1, **ap2;
|
||||
@@ -347,9 +351,7 @@ shiftcmd(argc, argv)
|
||||
*/
|
||||
|
||||
int
|
||||
setcmd(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
setcmd(int argc, char **argv)
|
||||
{
|
||||
if (argc == 1)
|
||||
return showvarscmd(argc, argv);
|
||||
@@ -365,8 +367,7 @@ setcmd(argc, argv)
|
||||
|
||||
|
||||
void
|
||||
getoptsreset(value)
|
||||
const char *value;
|
||||
getoptsreset(const char *value)
|
||||
{
|
||||
if (number(value) == 1) {
|
||||
shellparam.optnext = NULL;
|
||||
@@ -382,14 +383,12 @@ getoptsreset(value)
|
||||
*/
|
||||
|
||||
int
|
||||
getoptscmd(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
getoptscmd(int argc, char **argv)
|
||||
{
|
||||
char **optbase = NULL;
|
||||
|
||||
if (argc < 3)
|
||||
error("Usage: getopts optstring var [arg]");
|
||||
error("usage: getopts optstring var [arg]");
|
||||
else if (argc == 3)
|
||||
optbase = shellparam.p;
|
||||
else
|
||||
@@ -406,12 +405,8 @@ getoptscmd(argc, argv)
|
||||
}
|
||||
|
||||
STATIC int
|
||||
getopts(optstr, optvar, optfirst, optnext, optptr)
|
||||
char *optstr;
|
||||
char *optvar;
|
||||
char **optfirst;
|
||||
char ***optnext;
|
||||
char **optptr;
|
||||
getopts(char *optstr, char *optvar, char **optfirst, char ***optnext,
|
||||
char **optptr)
|
||||
{
|
||||
char *p, *q;
|
||||
char c = '?';
|
||||
@@ -515,9 +510,8 @@ out:
|
||||
*/
|
||||
|
||||
int
|
||||
nextopt(optstring)
|
||||
char *optstring;
|
||||
{
|
||||
nextopt(char *optstring)
|
||||
{
|
||||
char *p, *q;
|
||||
char c;
|
||||
|
||||
|
||||
+12
-10
@@ -65,8 +65,9 @@ struct shparam {
|
||||
#define uflag optlist[14].val
|
||||
#define privileged optlist[15].val
|
||||
#define Tflag optlist[16].val
|
||||
#define Pflag optlist[17].val
|
||||
|
||||
#define NOPTS 17
|
||||
#define NOPTS 18
|
||||
|
||||
struct optent {
|
||||
const char *name;
|
||||
@@ -93,6 +94,7 @@ struct optent optlist[NOPTS] = {
|
||||
{ "nounset", 'u', 0 },
|
||||
{ "privileged", 'p', 0 },
|
||||
{ "trapsasync", 'T', 0 },
|
||||
{ "physical", 'P', 0 },
|
||||
};
|
||||
#else
|
||||
extern struct optent optlist[NOPTS];
|
||||
@@ -106,12 +108,12 @@ extern char **argptr; /* argument list for builtin commands */
|
||||
extern char *shoptarg; /* set by nextopt */
|
||||
extern char *optptr; /* used by nextopt */
|
||||
|
||||
void procargs __P((int, char **));
|
||||
void optschanged __P((void));
|
||||
void setparam __P((char **));
|
||||
void freeparam __P((struct shparam *));
|
||||
int shiftcmd __P((int, char **));
|
||||
int setcmd __P((int, char **));
|
||||
int getoptscmd __P((int, char **));
|
||||
int nextopt __P((char *));
|
||||
void getoptsreset __P((const char *));
|
||||
void procargs(int, char **);
|
||||
void optschanged(void);
|
||||
void setparam(char **);
|
||||
void freeparam(struct shparam *);
|
||||
int shiftcmd(int, char **);
|
||||
int setcmd(int, char **);
|
||||
int getoptscmd(int, char **);
|
||||
int nextopt(char *);
|
||||
void getoptsreset(const char *);
|
||||
+67
-148
@@ -38,9 +38,9 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)output.c 8.2 (Berkeley) 5/4/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
/*
|
||||
* Shell output routines. We use our own output routines because:
|
||||
@@ -58,11 +58,7 @@ static const char rcsid[] =
|
||||
|
||||
#include <stdio.h> /* defines BUFSIZ */
|
||||
#include <string.h>
|
||||
#ifdef __STDC__
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
@@ -72,6 +68,7 @@ static const char rcsid[] =
|
||||
#include "output.h"
|
||||
#include "memalloc.h"
|
||||
#include "error.h"
|
||||
#include "var.h"
|
||||
|
||||
|
||||
#define OUTBUFSIZ BUFSIZ
|
||||
@@ -105,60 +102,73 @@ RESET {
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef notdef /* no longer used */
|
||||
/*
|
||||
* Set up an output file to write to memory rather than a file.
|
||||
*/
|
||||
|
||||
void
|
||||
open_mem(block, length, file)
|
||||
char *block;
|
||||
int length;
|
||||
struct output *file;
|
||||
{
|
||||
file->nextc = block;
|
||||
file->nleft = --length;
|
||||
file->fd = BLOCK_OUT;
|
||||
file->flags = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void
|
||||
out1str(p)
|
||||
const char *p;
|
||||
{
|
||||
out1str(const char *p)
|
||||
{
|
||||
outstr(p, out1);
|
||||
}
|
||||
|
||||
void
|
||||
out1qstr(const char *p)
|
||||
{
|
||||
outqstr(p, out1);
|
||||
}
|
||||
|
||||
void
|
||||
out2str(p)
|
||||
const char *p;
|
||||
{
|
||||
out2str(const char *p)
|
||||
{
|
||||
outstr(p, out2);
|
||||
}
|
||||
|
||||
void
|
||||
out2qstr(const char *p)
|
||||
{
|
||||
outqstr(p, out2);
|
||||
}
|
||||
|
||||
void
|
||||
outstr(p, file)
|
||||
const char *p;
|
||||
struct output *file;
|
||||
{
|
||||
outstr(const char *p, struct output *file)
|
||||
{
|
||||
while (*p)
|
||||
outc(*p++, file);
|
||||
if (file == out2)
|
||||
flushout(file);
|
||||
}
|
||||
|
||||
/* Like outstr(), but quote for re-input into the shell. */
|
||||
void
|
||||
outqstr(const char *p, struct output *file)
|
||||
{
|
||||
char ch;
|
||||
|
||||
if (p[strcspn(p, "|&;<>()$`\\\"'")] == '\0' && (!ifsset() ||
|
||||
p[strcspn(p, ifsval())] == '\0')) {
|
||||
outstr(p, file);
|
||||
return;
|
||||
}
|
||||
|
||||
out1c('\'');
|
||||
while ((ch = *p++) != '\0') {
|
||||
switch (ch) {
|
||||
case '\'':
|
||||
/*
|
||||
* Can't quote single quotes inside single quotes;
|
||||
* close them, write escaped single quote, open again.
|
||||
*/
|
||||
outstr("'\\''", file);
|
||||
break;
|
||||
default:
|
||||
outc(ch, file);
|
||||
}
|
||||
}
|
||||
out1c('\'');
|
||||
}
|
||||
|
||||
char out_junk[16];
|
||||
|
||||
|
||||
void
|
||||
emptyoutbuf(dest)
|
||||
struct output *dest;
|
||||
{
|
||||
emptyoutbuf(struct output *dest)
|
||||
{
|
||||
int offset;
|
||||
|
||||
if (dest->fd == BLOCK_OUT) {
|
||||
@@ -187,16 +197,16 @@ emptyoutbuf(dest)
|
||||
|
||||
|
||||
void
|
||||
flushall() {
|
||||
flushall(void)
|
||||
{
|
||||
flushout(&output);
|
||||
flushout(&errout);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
flushout(dest)
|
||||
struct output *dest;
|
||||
{
|
||||
flushout(struct output *dest)
|
||||
{
|
||||
|
||||
if (dest->buf == NULL || dest->nextc == dest->buf || dest->fd < 0)
|
||||
return;
|
||||
@@ -208,7 +218,8 @@ flushout(dest)
|
||||
|
||||
|
||||
void
|
||||
freestdout() {
|
||||
freestdout(void)
|
||||
{
|
||||
INTOFF;
|
||||
if (output.buf) {
|
||||
ckfree(output.buf);
|
||||
@@ -219,9 +230,9 @@ freestdout() {
|
||||
}
|
||||
|
||||
|
||||
#ifdef __STDC__
|
||||
void
|
||||
outfmt(struct output *file, const char *fmt, ...) {
|
||||
outfmt(struct output *file, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
@@ -231,7 +242,8 @@ outfmt(struct output *file, const char *fmt, ...) {
|
||||
|
||||
|
||||
void
|
||||
out1fmt(const char *fmt, ...) {
|
||||
out1fmt(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
@@ -240,7 +252,8 @@ out1fmt(const char *fmt, ...) {
|
||||
}
|
||||
|
||||
void
|
||||
dprintf(const char *fmt, ...) {
|
||||
dprintf(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
@@ -250,7 +263,8 @@ dprintf(const char *fmt, ...) {
|
||||
}
|
||||
|
||||
void
|
||||
fmtstr(char *outbuf, int length, const char *fmt, ...) {
|
||||
fmtstr(char *outbuf, int length, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
struct output strout;
|
||||
|
||||
@@ -265,77 +279,6 @@ fmtstr(char *outbuf, int length, const char *fmt, ...) {
|
||||
outbuf[length - 1] = '\0';
|
||||
}
|
||||
|
||||
#else /* not __STDC__ */
|
||||
|
||||
void
|
||||
outfmt(va_alist)
|
||||
va_dcl
|
||||
{
|
||||
va_list ap;
|
||||
struct output *file;
|
||||
const char *fmt;
|
||||
|
||||
va_start(ap);
|
||||
file = va_arg(ap, struct output *);
|
||||
fmt = va_arg(ap, char *);
|
||||
doformat(file, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
out1fmt(va_alist)
|
||||
va_dcl
|
||||
{
|
||||
va_list ap;
|
||||
const char *fmt;
|
||||
|
||||
va_start(ap);
|
||||
fmt = va_arg(ap, char *);
|
||||
doformat(out1, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void
|
||||
dprintf(va_alist)
|
||||
va_dcl
|
||||
{
|
||||
va_list ap;
|
||||
const char *fmt;
|
||||
|
||||
va_start(ap);
|
||||
fmt = va_arg(ap, char *);
|
||||
doformat(out2, fmt, ap);
|
||||
va_end(ap);
|
||||
flushout(out2);
|
||||
}
|
||||
|
||||
void
|
||||
fmtstr(va_alist)
|
||||
va_dcl
|
||||
{
|
||||
va_list ap;
|
||||
struct output strout;
|
||||
char *outbuf;
|
||||
int length;
|
||||
const char *fmt;
|
||||
|
||||
va_start(ap);
|
||||
outbuf = va_arg(ap, char *);
|
||||
length = va_arg(ap, int);
|
||||
fmt = va_arg(ap, char *);
|
||||
strout.nextc = outbuf;
|
||||
strout.nleft = length;
|
||||
strout.fd = BLOCK_OUT;
|
||||
strout.flags = 0;
|
||||
doformat(&strout, fmt, ap);
|
||||
outc('\0', &strout);
|
||||
if (strout.flags & OUTPUT_ERR)
|
||||
outbuf[length - 1] = '\0';
|
||||
}
|
||||
#endif /* __STDC__ */
|
||||
|
||||
|
||||
/*
|
||||
* Formatted output. This routine handles a subset of the printf formats:
|
||||
* - Formats supported: d, u, o, X, s, and c.
|
||||
@@ -355,11 +298,8 @@ static const char digit[] = "0123456789ABCDEF";
|
||||
|
||||
|
||||
void
|
||||
doformat(dest, f, ap)
|
||||
struct output *dest;
|
||||
const char *f; /* format string */
|
||||
va_list ap;
|
||||
{
|
||||
doformat(struct output *dest, const char *f, va_list ap)
|
||||
{
|
||||
char c;
|
||||
char temp[TEMPSIZE];
|
||||
int flushleft;
|
||||
@@ -529,11 +469,8 @@ number: /* process a number */
|
||||
*/
|
||||
|
||||
int
|
||||
xwrite(fd, buf, nbytes)
|
||||
int fd;
|
||||
char *buf;
|
||||
int nbytes;
|
||||
{
|
||||
xwrite(int fd, char *buf, int nbytes)
|
||||
{
|
||||
int ntry;
|
||||
int i;
|
||||
int n;
|
||||
@@ -555,21 +492,3 @@ xwrite(fd, buf, nbytes)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Version of ioctl that retries after a signal is caught.
|
||||
* XXX unused function
|
||||
*/
|
||||
|
||||
int
|
||||
xioctl(fd, request, arg)
|
||||
int fd;
|
||||
unsigned long request;
|
||||
char * arg;
|
||||
{
|
||||
int i;
|
||||
|
||||
while ((i = ioctl(fd, request, arg)) == -1 && errno == EINTR);
|
||||
return i;
|
||||
}
|
||||
+17
-19
@@ -39,11 +39,7 @@
|
||||
|
||||
#ifndef OUTPUT_INCL
|
||||
|
||||
#ifdef __STDC__
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
struct output {
|
||||
char *nextc;
|
||||
@@ -60,21 +56,23 @@ extern struct output memout;
|
||||
extern struct output *out1;
|
||||
extern struct output *out2;
|
||||
|
||||
void open_mem __P((char *, int, struct output *));
|
||||
void out1str __P((const char *));
|
||||
void out2str __P((const char *));
|
||||
void outstr __P((const char *, struct output *));
|
||||
void emptyoutbuf __P((struct output *));
|
||||
void flushall __P((void));
|
||||
void flushout __P((struct output *));
|
||||
void freestdout __P((void));
|
||||
void outfmt __P((struct output *, const char *, ...)) __printflike(2, 3);
|
||||
void out1fmt __P((const char *, ...)) __printflike(1, 2);
|
||||
void dprintf __P((const char *, ...)) __printflike(1, 2);
|
||||
void fmtstr __P((char *, int, const char *, ...)) __printflike(3, 4);
|
||||
void doformat __P((struct output *, const char *, va_list)) __printflike(2, 0);
|
||||
int xwrite __P((int, char *, int));
|
||||
int xioctl __P((int, unsigned long, char *));
|
||||
void open_mem(char *, int, struct output *);
|
||||
void out1str(const char *);
|
||||
void out1qstr(const char *);
|
||||
void out2str(const char *);
|
||||
void out2qstr(const char *);
|
||||
void outstr(const char *, struct output *);
|
||||
void outqstr(const char *, struct output *);
|
||||
void emptyoutbuf(struct output *);
|
||||
void flushall(void);
|
||||
void flushout(struct output *);
|
||||
void freestdout(void);
|
||||
void outfmt(struct output *, const char *, ...) __printflike(2, 3);
|
||||
void out1fmt(const char *, ...) __printflike(1, 2);
|
||||
void dprintf(const char *, ...) __printflike(1, 2);
|
||||
void fmtstr(char *, int, const char *, ...) __printflike(3, 4);
|
||||
void doformat(struct output *, const char *, va_list) __printflike(2, 0);
|
||||
int xwrite(int, char *, int);
|
||||
|
||||
#define outc(c, file) (--(file)->nleft < 0? (emptyoutbuf(file), *(file)->nextc++ = (c)) : (*(file)->nextc++ = (c)))
|
||||
#define out1c(c) outc(c, out1);
|
||||
|
||||
+60
-65
@@ -38,9 +38,9 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)parser.c 8.7 (Berkeley) 5/16/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -108,22 +108,22 @@ static const char types[] = "}-+?=";
|
||||
#endif
|
||||
|
||||
|
||||
STATIC union node *list __P((int));
|
||||
STATIC union node *andor __P((void));
|
||||
STATIC union node *pipeline __P((void));
|
||||
STATIC union node *command __P((void));
|
||||
STATIC union node *simplecmd __P((union node **, union node *));
|
||||
STATIC union node *makename __P((void));
|
||||
STATIC void parsefname __P((void));
|
||||
STATIC void parseheredoc __P((void));
|
||||
STATIC int peektoken __P((void));
|
||||
STATIC int readtoken __P((void));
|
||||
STATIC int xxreadtoken __P((void));
|
||||
STATIC int readtoken1 __P((int, char const *, char *, int));
|
||||
STATIC int noexpand __P((char *));
|
||||
STATIC void synexpect __P((int));
|
||||
STATIC void synerror __P((char *));
|
||||
STATIC void setprompt __P((int));
|
||||
STATIC union node *list(int);
|
||||
STATIC union node *andor(void);
|
||||
STATIC union node *pipeline(void);
|
||||
STATIC union node *command(void);
|
||||
STATIC union node *simplecmd(union node **, union node *);
|
||||
STATIC union node *makename(void);
|
||||
STATIC void parsefname(void);
|
||||
STATIC void parseheredoc(void);
|
||||
STATIC int peektoken(void);
|
||||
STATIC int readtoken(void);
|
||||
STATIC int xxreadtoken(void);
|
||||
STATIC int readtoken1(int, char const *, char *, int);
|
||||
STATIC int noexpand(char *);
|
||||
STATIC void synexpect(int);
|
||||
STATIC void synerror(char *);
|
||||
STATIC void setprompt(int);
|
||||
|
||||
|
||||
/*
|
||||
@@ -132,8 +132,7 @@ STATIC void setprompt __P((int));
|
||||
*/
|
||||
|
||||
union node *
|
||||
parsecmd(interact)
|
||||
int interact;
|
||||
parsecmd(int interact)
|
||||
{
|
||||
int t;
|
||||
|
||||
@@ -155,8 +154,7 @@ parsecmd(interact)
|
||||
|
||||
|
||||
STATIC union node *
|
||||
list(nlflag)
|
||||
int nlflag;
|
||||
list(int nlflag)
|
||||
{
|
||||
union node *n1, *n2, *n3;
|
||||
int tok;
|
||||
@@ -226,7 +224,8 @@ list(nlflag)
|
||||
|
||||
|
||||
STATIC union node *
|
||||
andor() {
|
||||
andor(void)
|
||||
{
|
||||
union node *n1, *n2, *n3;
|
||||
int t;
|
||||
|
||||
@@ -252,7 +251,8 @@ andor() {
|
||||
|
||||
|
||||
STATIC union node *
|
||||
pipeline() {
|
||||
pipeline(void)
|
||||
{
|
||||
union node *n1, *n2, *pipenode;
|
||||
struct nodelist *lp, *prev;
|
||||
int negate;
|
||||
@@ -292,7 +292,8 @@ pipeline() {
|
||||
|
||||
|
||||
STATIC union node *
|
||||
command() {
|
||||
command(void)
|
||||
{
|
||||
union node *n1, *n2;
|
||||
union node *ap, **app;
|
||||
union node *cp, **cpp;
|
||||
@@ -477,14 +478,14 @@ TRACE(("expecting DO got %s %s\n", tokname[got], got == TWORD ? wordtext : ""));
|
||||
break;
|
||||
/* Handle an empty command like other simple commands. */
|
||||
case TSEMI:
|
||||
case TAND:
|
||||
case TOR:
|
||||
/*
|
||||
* An empty command before a ; doesn't make much sense, and
|
||||
* should certainly be disallowed in the case of `if ;'.
|
||||
*/
|
||||
if (!redir)
|
||||
synexpect(-1);
|
||||
case TAND:
|
||||
case TOR:
|
||||
case TNL:
|
||||
case TEOF:
|
||||
case TWORD:
|
||||
@@ -527,9 +528,8 @@ checkneg:
|
||||
|
||||
|
||||
STATIC union node *
|
||||
simplecmd(rpp, redir)
|
||||
union node **rpp, *redir;
|
||||
{
|
||||
simplecmd(union node **rpp, union node *redir)
|
||||
{
|
||||
union node *args, **app;
|
||||
union node **orig_rpp = rpp;
|
||||
union node *n = NULL, *n2;
|
||||
@@ -604,7 +604,8 @@ checkneg:
|
||||
}
|
||||
|
||||
STATIC union node *
|
||||
makename() {
|
||||
makename(void)
|
||||
{
|
||||
union node *n;
|
||||
|
||||
n = (union node *)stalloc(sizeof (struct narg));
|
||||
@@ -615,11 +616,8 @@ makename() {
|
||||
return n;
|
||||
}
|
||||
|
||||
void fixredir(n, text, err)
|
||||
union node *n;
|
||||
const char *text;
|
||||
int err;
|
||||
{
|
||||
void fixredir(union node *n, const char *text, int err)
|
||||
{
|
||||
TRACE(("Fix redir %s %d\n", text, err));
|
||||
if (!err)
|
||||
n->ndup.vname = NULL;
|
||||
@@ -639,7 +637,8 @@ void fixredir(n, text, err)
|
||||
|
||||
|
||||
STATIC void
|
||||
parsefname() {
|
||||
parsefname(void)
|
||||
{
|
||||
union node *n = redirnode;
|
||||
|
||||
if (readtoken() != TWORD)
|
||||
@@ -680,7 +679,8 @@ parsefname() {
|
||||
*/
|
||||
|
||||
STATIC void
|
||||
parseheredoc() {
|
||||
parseheredoc(void)
|
||||
{
|
||||
struct heredoc *here;
|
||||
union node *n;
|
||||
|
||||
@@ -703,7 +703,8 @@ parseheredoc() {
|
||||
}
|
||||
|
||||
STATIC int
|
||||
peektoken() {
|
||||
peektoken(void)
|
||||
{
|
||||
int t;
|
||||
|
||||
t = readtoken();
|
||||
@@ -712,7 +713,8 @@ peektoken() {
|
||||
}
|
||||
|
||||
STATIC int
|
||||
readtoken() {
|
||||
readtoken(void)
|
||||
{
|
||||
int t;
|
||||
int savecheckkwd = checkkwd;
|
||||
struct alias *ap;
|
||||
@@ -740,9 +742,9 @@ readtoken() {
|
||||
*/
|
||||
if (t == TWORD && !quoteflag)
|
||||
{
|
||||
char * const *pp;
|
||||
const char * const *pp;
|
||||
|
||||
for (pp = (char **)parsekwd; *pp; pp++) {
|
||||
for (pp = parsekwd; *pp; pp++) {
|
||||
if (**pp == *wordtext && equal(*pp, wordtext))
|
||||
{
|
||||
lasttoken = t = pp - parsekwd + KWDOFFSET;
|
||||
@@ -791,7 +793,8 @@ out:
|
||||
#define RETURN(token) return lasttoken = token
|
||||
|
||||
STATIC int
|
||||
xxreadtoken() {
|
||||
xxreadtoken(void)
|
||||
{
|
||||
int c;
|
||||
|
||||
if (tokpushback) {
|
||||
@@ -881,12 +884,8 @@ breakloop:
|
||||
#define PARSEARITH() {goto parsearith; parsearith_return:;}
|
||||
|
||||
STATIC int
|
||||
readtoken1(firstc, syntax, eofmark, striptabs)
|
||||
int firstc;
|
||||
char const *syntax;
|
||||
char *eofmark;
|
||||
int striptabs;
|
||||
{
|
||||
readtoken1(int firstc, char const *syntax, char *eofmark, int striptabs)
|
||||
{
|
||||
int c = firstc;
|
||||
char *out;
|
||||
int len;
|
||||
@@ -1146,6 +1145,8 @@ parseredir: {
|
||||
np->type = NAPPEND;
|
||||
else if (c == '&')
|
||||
np->type = NTOFD;
|
||||
else if (c == '|')
|
||||
np->type = NCLOBBER;
|
||||
else {
|
||||
np->type = NTO;
|
||||
pungetc();
|
||||
@@ -1484,9 +1485,8 @@ RESET {
|
||||
*/
|
||||
|
||||
STATIC int
|
||||
noexpand(text)
|
||||
char *text;
|
||||
{
|
||||
noexpand(char *text)
|
||||
{
|
||||
char *p;
|
||||
char c;
|
||||
|
||||
@@ -1509,9 +1509,8 @@ noexpand(text)
|
||||
*/
|
||||
|
||||
int
|
||||
goodname(name)
|
||||
char *name;
|
||||
{
|
||||
goodname(char *name)
|
||||
{
|
||||
char *p;
|
||||
|
||||
p = name;
|
||||
@@ -1532,8 +1531,7 @@ goodname(name)
|
||||
*/
|
||||
|
||||
STATIC void
|
||||
synexpect(token)
|
||||
int token;
|
||||
synexpect(int token)
|
||||
{
|
||||
char msg[64];
|
||||
|
||||
@@ -1548,9 +1546,8 @@ synexpect(token)
|
||||
|
||||
|
||||
STATIC void
|
||||
synerror(msg)
|
||||
char *msg;
|
||||
{
|
||||
synerror(char *msg)
|
||||
{
|
||||
if (commandname)
|
||||
outfmt(&errout, "%s: %d: ", commandname, startlinno);
|
||||
outfmt(&errout, "Syntax error: %s\n", msg);
|
||||
@@ -1558,9 +1555,8 @@ synerror(msg)
|
||||
}
|
||||
|
||||
STATIC void
|
||||
setprompt(which)
|
||||
int which;
|
||||
{
|
||||
setprompt(int which)
|
||||
{
|
||||
whichprompt = which;
|
||||
|
||||
#ifndef NO_HISTORY
|
||||
@@ -1574,8 +1570,7 @@ setprompt(which)
|
||||
* should be added here.
|
||||
*/
|
||||
char *
|
||||
getprompt(unused)
|
||||
void *unused __unused;
|
||||
getprompt(void *unused __unused)
|
||||
{
|
||||
switch (whichprompt) {
|
||||
case 0:
|
||||
|
||||
+4
-4
@@ -76,7 +76,7 @@ extern int tokpushback;
|
||||
extern int whichprompt; /* 1 == PS1, 2 == PS2 */
|
||||
|
||||
|
||||
union node *parsecmd __P((int));
|
||||
void fixredir __P((union node *, const char *, int));
|
||||
int goodname __P((char *));
|
||||
char *getprompt __P((void *));
|
||||
union node *parsecmd(int);
|
||||
void fixredir(union node *, const char *, int);
|
||||
int goodname(char *);
|
||||
char *getprompt(void *);
|
||||
+31
-23
@@ -38,11 +38,12 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)redir.c 8.2 (Berkeley) 5/4/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
@@ -62,6 +63,7 @@ static const char rcsid[] =
|
||||
#include "output.h"
|
||||
#include "memalloc.h"
|
||||
#include "error.h"
|
||||
#include "options.h"
|
||||
|
||||
|
||||
#define EMPTY -2 /* marks an unused slot in redirtab */
|
||||
@@ -71,7 +73,7 @@ static const char rcsid[] =
|
||||
MKINIT
|
||||
struct redirtab {
|
||||
struct redirtab *next;
|
||||
short renamed[10];
|
||||
int renamed[10];
|
||||
};
|
||||
|
||||
|
||||
@@ -84,8 +86,8 @@ MKINIT struct redirtab *redirlist;
|
||||
*/
|
||||
int fd0_redirected = 0;
|
||||
|
||||
STATIC void openredirect __P((union node *, char[10 ]));
|
||||
STATIC int openhere __P((union node *));
|
||||
STATIC void openredirect(union node *, char[10 ]);
|
||||
STATIC int openhere(union node *);
|
||||
|
||||
|
||||
/*
|
||||
@@ -97,10 +99,8 @@ STATIC int openhere __P((union node *));
|
||||
*/
|
||||
|
||||
void
|
||||
redirect(redir, flags)
|
||||
union node *redir;
|
||||
int flags;
|
||||
{
|
||||
redirect(union node *redir, int flags)
|
||||
{
|
||||
union node *n;
|
||||
struct redirtab *sv = NULL;
|
||||
int i;
|
||||
@@ -161,10 +161,9 @@ again:
|
||||
|
||||
|
||||
STATIC void
|
||||
openredirect(redir, memory)
|
||||
union node *redir;
|
||||
char memory[10];
|
||||
{
|
||||
openredirect(union node *redir, char memory[10])
|
||||
{
|
||||
struct stat sb;
|
||||
int fd = redir->nfile.fd;
|
||||
char *fname;
|
||||
int f;
|
||||
@@ -211,6 +210,9 @@ movefd:
|
||||
goto movefd;
|
||||
case NTO:
|
||||
fname = redir->nfile.expfname;
|
||||
if (Cflag && stat(fname, &sb) != -1 && S_ISREG(sb.st_mode))
|
||||
error("cannot create %s: %s", fname,
|
||||
errmsg(EEXIST, E_CREAT));
|
||||
#ifdef O_CREAT
|
||||
if ((f = open(fname, O_WRONLY|O_CREAT|O_TRUNC, 0666)) < 0)
|
||||
error("cannot create %s: %s", fname, errmsg(errno, E_CREAT));
|
||||
@@ -219,6 +221,11 @@ movefd:
|
||||
error("cannot create %s: %s", fname, errmsg(errno, E_CREAT));
|
||||
#endif
|
||||
goto movefd;
|
||||
case NCLOBBER:
|
||||
fname = redir->nfile.expfname;
|
||||
if ((f = open(fname, O_WRONLY|O_CREAT|O_TRUNC, 0666)) < 0)
|
||||
error("cannot create %s: %s", fname, errmsg(errno, E_CREAT));
|
||||
goto movefd;
|
||||
case NAPPEND:
|
||||
fname = redir->nfile.expfname;
|
||||
#ifdef O_APPEND
|
||||
@@ -240,7 +247,8 @@ movefd:
|
||||
close(fd);
|
||||
copyfd(redir->ndup.dupfd, fd);
|
||||
}
|
||||
}
|
||||
} else
|
||||
close(fd);
|
||||
break;
|
||||
case NHERE:
|
||||
case NXHERE:
|
||||
@@ -260,9 +268,8 @@ movefd:
|
||||
*/
|
||||
|
||||
STATIC int
|
||||
openhere(redir)
|
||||
union node *redir;
|
||||
{
|
||||
openhere(union node *redir)
|
||||
{
|
||||
int pip[2];
|
||||
int len = 0;
|
||||
|
||||
@@ -302,7 +309,8 @@ out:
|
||||
*/
|
||||
|
||||
void
|
||||
popredir() {
|
||||
popredir(void)
|
||||
{
|
||||
struct redirtab *rp = redirlist;
|
||||
int i;
|
||||
|
||||
@@ -344,7 +352,8 @@ SHELLPROC {
|
||||
|
||||
/* Return true if fd 0 has already been redirected at least once. */
|
||||
int
|
||||
fd0_redirected_p () {
|
||||
fd0_redirected_p(void)
|
||||
{
|
||||
return fd0_redirected != 0;
|
||||
}
|
||||
|
||||
@@ -353,7 +362,8 @@ fd0_redirected_p () {
|
||||
*/
|
||||
|
||||
void
|
||||
clearredir() {
|
||||
clearredir(void)
|
||||
{
|
||||
struct redirtab *rp;
|
||||
int i;
|
||||
|
||||
@@ -376,9 +386,7 @@ clearredir() {
|
||||
*/
|
||||
|
||||
int
|
||||
copyfd(from, to)
|
||||
int from;
|
||||
int to;
|
||||
copyfd(int from, int to)
|
||||
{
|
||||
int newfd;
|
||||
|
||||
|
||||
+5
-5
@@ -42,9 +42,9 @@
|
||||
#define REDIR_BACKQ 02 /* save the command output in memory */
|
||||
|
||||
union node;
|
||||
void redirect __P((union node *, int));
|
||||
void popredir __P((void));
|
||||
int fd0_redirected_p __P((void));
|
||||
void clearredir __P((void));
|
||||
int copyfd __P((int, int));
|
||||
void redirect(union node *, int);
|
||||
void popredir(void);
|
||||
int fd0_redirected_p(void);
|
||||
void clearredir(void);
|
||||
int copyfd(int, int);
|
||||
|
||||
+178
-182
@@ -43,10 +43,10 @@
|
||||
.Nd command interpreter (shell)
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl /+abCEefIimnpsTuVvx
|
||||
.Op Fl /+abCEefIimnPpsTuVvx
|
||||
.Op Fl /+o Ar longname
|
||||
.Op Fl c Ar string
|
||||
.Op Ar arg ...\&
|
||||
.Op Ar arg ...
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
@@ -77,7 +77,7 @@ command.
|
||||
The shell
|
||||
implements a language that has flow control constructs,
|
||||
a macro facility that provides a variety of features in
|
||||
addition to data storage, along with builtin history and line
|
||||
addition to data storage, along with built-in history and line
|
||||
editing capabilities. It incorporates many features to
|
||||
aid interactive use and has the advantage that the interpretative
|
||||
language is common to both interactive and non-interactive
|
||||
@@ -164,9 +164,9 @@ the long name for an option may be specified as an argument to the
|
||||
.Fl /+o
|
||||
option of the
|
||||
.Ic set
|
||||
builtin command
|
||||
built-in command
|
||||
(described later in the section called
|
||||
.Sx Builtin Commands ) .
|
||||
.Sx Built-in Commands ) .
|
||||
Introducing an option with a dash
|
||||
.Pq Li -
|
||||
enables the option,
|
||||
@@ -185,7 +185,7 @@ and
|
||||
.Fl c
|
||||
options do not have long names.
|
||||
They take arguments and are described after the single letter options.
|
||||
.Bl -tag -width Ds
|
||||
.Bl -tag -width indent
|
||||
.It Fl a Li allexport
|
||||
Flag variables for export when assignments are made to them.
|
||||
.It Fl b Li notify
|
||||
@@ -195,9 +195,8 @@ completion.
|
||||
.It Fl C Li noclobber
|
||||
Do not overwrite existing files with
|
||||
.Dq Li > .
|
||||
(UNIMPLEMENTED)
|
||||
.It Fl E Li emacs
|
||||
Enable the builtin
|
||||
Enable the built-in
|
||||
.Xr emacs 1
|
||||
command line editor (disables the
|
||||
.Fl V
|
||||
@@ -226,6 +225,17 @@ Turn on job control (set automatically when interactive).
|
||||
If not interactive, read commands but do not
|
||||
execute them. This is useful for checking the
|
||||
syntax of shell scripts.
|
||||
.It Fl P Li physical
|
||||
Change the default for the
|
||||
.Ic cd
|
||||
and
|
||||
.Ic pwd
|
||||
commands from
|
||||
.Fl L
|
||||
(logical directory layout)
|
||||
to
|
||||
.Fl P
|
||||
(physical directory layout).
|
||||
.It Fl p Li privileged
|
||||
Turn on privileged mode. This mode is enabled on startup
|
||||
if either the effective user or group id is not equal to the
|
||||
@@ -265,9 +275,8 @@ sh -T -c "trap 'exit 1' 2 ; some-blocking-program"
|
||||
Write a message to standard error when attempting
|
||||
to expand a variable that is not set, and if the
|
||||
shell is not interactive, exit immediately.
|
||||
(UNIMPLEMENTED)
|
||||
.It Fl V Li vi
|
||||
Enable the builtin
|
||||
Enable the built-in
|
||||
.Xr vi 1
|
||||
command line editor (disables
|
||||
.Fl E
|
||||
@@ -296,13 +305,21 @@ option takes as its only argument the long name of an option
|
||||
to be enabled or disabled.
|
||||
For example, the following two invocations of
|
||||
.Nm
|
||||
both enable the builtin
|
||||
both enable the built-in
|
||||
.Xr emacs 1
|
||||
command line editor:
|
||||
.Bd -literal -offset indent
|
||||
set -E
|
||||
set -o emacs
|
||||
.Ed
|
||||
.Pp
|
||||
If used without an argument, the
|
||||
.Fl o
|
||||
option displays the current option settings in a human-readable format.
|
||||
If
|
||||
.Cm +o
|
||||
is used without an argument, the current option settings are output
|
||||
in a format suitable for re-input into the shell.
|
||||
.Ss Lexical Structure
|
||||
The shell reads input in terms of lines from a file and breaks
|
||||
it up into words at whitespace (blanks and tabs), and at
|
||||
@@ -313,38 +330,16 @@ which are special to the shell.
|
||||
There are two types of operators: control operators and
|
||||
redirection operators (their meaning is discussed later).
|
||||
The following is a list of valid operators:
|
||||
.Bl -tag -width Ds
|
||||
.Bl -tag -width indent
|
||||
.It Control operators:
|
||||
.Bl -column "XXX" "XXX" "XXX" "XXX" "XXX" -offset center -compact
|
||||
.It Xo
|
||||
.Li & Ta Xo
|
||||
.Li && Ta Xo
|
||||
.Li ( Ta Xo
|
||||
.Li ) Ta Xo
|
||||
.Li \en
|
||||
.Xc Xc Xc Xc Xc
|
||||
.It Xo
|
||||
.Li ;; Ta Xo
|
||||
.Li ; Ta Xo
|
||||
.Li | Ta Xo
|
||||
.Li ||
|
||||
.Xc Xc Xc Xc
|
||||
.It Li & Ta Li && Ta Li ( Ta Li ) Ta Li \en
|
||||
.It Li ;; Ta Li ; Ta Li | Ta Li ||
|
||||
.El
|
||||
.It Redirection operators:
|
||||
.Bl -column "XXX" "XXX" "XXX" "XXX" "XXX" -offset center -compact
|
||||
.It Xo
|
||||
.Li < Ta Xo
|
||||
.Li > Ta Xo
|
||||
.Li << Ta Xo
|
||||
.Li >> Ta Xo
|
||||
.Li <>
|
||||
.Xc Xc Xc Xc Xc
|
||||
.It Xo
|
||||
.Li <& Ta Xo
|
||||
.Li >& Ta Xo
|
||||
.Li <<- Ta Xo
|
||||
.Li >|
|
||||
.Xc Xc Xc Xc
|
||||
.It Li < Ta Li > Ta Li << Ta Li >> Ta Li <>
|
||||
.It Li <& Ta Li >& Ta Li <<- Ta Li >|
|
||||
.El
|
||||
.El
|
||||
.Ss Quoting
|
||||
@@ -352,7 +347,7 @@ Quoting is used to remove the special meaning of certain characters
|
||||
or words to the shell, such as operators, whitespace, or
|
||||
keywords. There are three types of quoting: matched single quotes,
|
||||
matched double quotes, and backslash.
|
||||
.Bl -tag -width Ds
|
||||
.Bl -tag -width indent
|
||||
.It Single Quotes
|
||||
Enclosing characters in single quotes preserves the literal
|
||||
meaning of all the characters (except single quotes, making
|
||||
@@ -369,13 +364,7 @@ The backslash inside double quotes is historically weird.
|
||||
It remains literal unless it precedes the following characters,
|
||||
which it serves to quote:
|
||||
.Bl -column "XXX" "XXX" "XXX" "XXX" "XXX" -offset center -compact
|
||||
.It Xo
|
||||
.Li $ Ta Xo
|
||||
.Li ` Ta Xo
|
||||
.Li \&" Ta Xo
|
||||
.Li \e\ Ta Xo
|
||||
.Li \en
|
||||
.Xc Xc Xc Xc Xc
|
||||
.It Li $ Ta Li ` Ta Li \&" Ta Li \e\ Ta Li \en
|
||||
.El
|
||||
.It Backslash
|
||||
A backslash preserves the literal meaning of the following
|
||||
@@ -388,32 +377,14 @@ Reserved words are words that have special meaning to the
|
||||
shell and are recognized at the beginning of a line and
|
||||
after a control operator. The following are reserved words:
|
||||
.Bl -column "doneXX" "elifXX" "elseXX" "untilXX" "whileX" -offset center
|
||||
.It Xo
|
||||
.Li \&! Ta Xo
|
||||
.Li { Ta Xo
|
||||
.Li } Ta Xo
|
||||
.Ic case Ta Xo
|
||||
.Ic do
|
||||
.Xc Xc Xc Xc Xc
|
||||
.It Xo
|
||||
.Ic done Ta Xo
|
||||
.Ic elif Ta Xo
|
||||
.Ic else Ta Xo
|
||||
.Ic esac Ta Xo
|
||||
.Ic fi
|
||||
.Xc Xc Xc Xc Xc
|
||||
.It Xo
|
||||
.Ic for Ta Xo
|
||||
.Ic if Ta Xo
|
||||
.Ic then Ta Xo
|
||||
.Ic until Ta Xo
|
||||
.Ic while
|
||||
.Xc Xc Xc Xc Xc
|
||||
.It Li \&! Ta { Ta } Ta Ic case Ta Ic do
|
||||
.It Ic done Ta Ic elif Ta Ic else Ta Ic esac Ta Ic fi
|
||||
.It Ic for Ta Ic if Ta Ic then Ta Ic until Ta Ic while
|
||||
.El
|
||||
.Ss Aliases
|
||||
An alias is a name and corresponding value set using the
|
||||
.Ic alias
|
||||
builtin command. Whenever a reserved word may occur (see above),
|
||||
built-in command. Whenever a reserved word may occur (see above),
|
||||
and after checking for reserved words, the shell
|
||||
checks the word to see if it matches an alias.
|
||||
If it does, it replaces it in the input stream with its value.
|
||||
@@ -534,7 +505,7 @@ then leading tabs
|
||||
in the here-doc-text are stripped.
|
||||
.Ss Search and Execution
|
||||
There are three types of commands: shell functions,
|
||||
builtin commands, and normal programs.
|
||||
built-in commands, and normal programs.
|
||||
The command is searched for (by name) in that order.
|
||||
The three types of commands are all executed in a different way.
|
||||
.Pp
|
||||
@@ -550,12 +521,12 @@ The positional parameters are restored to their original values
|
||||
when the command completes.
|
||||
This all occurs within the current shell.
|
||||
.Pp
|
||||
Shell builtin commands are executed internally to the shell, without
|
||||
Shell built-in commands are executed internally to the shell, without
|
||||
spawning a new process.
|
||||
.Pp
|
||||
Otherwise, if the command name does not match a function
|
||||
or builtin command, the command is searched for as a normal
|
||||
program in the filesystem (as described in the next section).
|
||||
or built-in command, the command is searched for as a normal
|
||||
program in the file system (as described in the next section).
|
||||
When a normal program is executed, the shell runs the program,
|
||||
passing the arguments and the environment to the program.
|
||||
If the program is not a normal executable file
|
||||
@@ -584,7 +555,7 @@ as a
|
||||
.Ss Path Search
|
||||
When locating a command, the shell first looks to see if
|
||||
it has a shell function by that name. Then it looks for a
|
||||
builtin command by that name. If a builtin command is not found,
|
||||
built-in command by that name. If a built-in command is not found,
|
||||
one of two things happen:
|
||||
.Bl -enum
|
||||
.It
|
||||
@@ -608,7 +579,7 @@ of other shell commands. The paradigm is that a command exits
|
||||
with zero for normal or success, and non-zero for failure,
|
||||
error, or a false indication. The man page for each command
|
||||
should indicate the various exit codes and what they mean.
|
||||
Additionally, the builtin commands return exit codes, as does
|
||||
Additionally, the built-in commands return exit codes, as does
|
||||
an executed shell function.
|
||||
.Pp
|
||||
If a command is terminated by a signal, its exit status is 128 plus
|
||||
@@ -688,7 +659,7 @@ Note that unlike some other shells,
|
||||
executes each process in the pipeline as a child of the
|
||||
.Nm
|
||||
process.
|
||||
Shell builtin commands are the exception to this rule.
|
||||
Shell built-in commands are the exception to this rule.
|
||||
They are executed in the current shell, although they do not affect its
|
||||
environment when used in pipelines.
|
||||
.Ss Background Commands (&)
|
||||
@@ -712,7 +683,7 @@ and optionally terminated by one of these three characters.
|
||||
The commands in a
|
||||
list are executed in the order they are written.
|
||||
If command is followed by an ampersand, the shell starts the
|
||||
command and immediately proceed onto the next command;
|
||||
command and immediately proceeds onto the next command;
|
||||
otherwise it waits for the command to terminate before
|
||||
proceeding to the next one.
|
||||
.Ss Short-Circuit List Operators
|
||||
@@ -800,7 +771,7 @@ loops.
|
||||
The
|
||||
.Ic continue
|
||||
command continues with the next iteration of the innermost loop.
|
||||
These are implemented as builtin commands.
|
||||
These are implemented as built-in commands.
|
||||
.Pp
|
||||
The syntax of the
|
||||
.Ic case
|
||||
@@ -829,7 +800,7 @@ or
|
||||
.Ed
|
||||
.Pp
|
||||
The first form executes the commands in a subshell.
|
||||
Note that builtin commands thus executed do not affect the current shell.
|
||||
Note that built-in commands thus executed do not affect the current shell.
|
||||
The second form does not fork another shell,
|
||||
so it is slightly more efficient.
|
||||
Grouping commands together this way allows the user to
|
||||
@@ -859,13 +830,13 @@ This should appear as the first statement of a function,
|
||||
and the syntax is:
|
||||
.Bd -ragged -offset indent
|
||||
.Ic local
|
||||
.Op Ar variable ...\&
|
||||
.Op Ar variable ...
|
||||
.Op Ar -
|
||||
.Ed
|
||||
.Pp
|
||||
The
|
||||
.Ic local
|
||||
command is implemented as a builtin command.
|
||||
command is implemented as a built-in command.
|
||||
.Pp
|
||||
When a variable is made local, it inherits the initial
|
||||
value and exported and readonly flags from the variable
|
||||
@@ -908,7 +879,7 @@ command is
|
||||
It terminates the currently executing function.
|
||||
The
|
||||
.Ic return
|
||||
command is implemented as a builtin command.
|
||||
command is implemented as a built-in command.
|
||||
.Ss Variables and Parameters
|
||||
The shell maintains a set of parameters. A parameter
|
||||
denoted by a name is called a variable. When starting up,
|
||||
@@ -928,7 +899,7 @@ A positional parameter is a parameter denoted by a number greater than zero.
|
||||
The shell sets these initially to the values of its command line
|
||||
arguments that follow the name of the shell script. The
|
||||
.Ic set
|
||||
builtin command can also be used to set or reset them.
|
||||
built-in command can also be used to set or reset them.
|
||||
.Ss Special Parameters
|
||||
A special parameter is a parameter denoted by one of the following
|
||||
special characters. The value of the parameter is listed
|
||||
@@ -974,7 +945,7 @@ Expands to the exit status of the most recent pipeline.
|
||||
.It Li -
|
||||
(hyphen) Expands to the current option flags (the single-letter
|
||||
option names concatenated into a string) as specified on
|
||||
invocation, by the set builtin command, or implicitly
|
||||
invocation, by the set built-in command, or implicitly
|
||||
by the shell.
|
||||
.It Li $
|
||||
Expands to the process ID of the invoked shell. A subshell
|
||||
@@ -1076,7 +1047,7 @@ expansion, with the exception of the special parameter
|
||||
.Pp
|
||||
In addition, a parameter expansion can be modified by using one of the
|
||||
following formats.
|
||||
.Bl -tag -width Ds
|
||||
.Bl -tag -width indent
|
||||
.It Li ${parameter:-word}
|
||||
Use Default Values. If parameter is unset or
|
||||
null, the expansion of word is
|
||||
@@ -1129,7 +1100,7 @@ the result of the expansion is unspecified.
|
||||
Enclosing the full parameter expansion string in double-quotes does not
|
||||
cause the following four varieties of pattern characters to be quoted,
|
||||
whereas quoting characters within the braces has this effect.
|
||||
.Bl -tag -width Ds
|
||||
.Bl -tag -width indent
|
||||
.It Li ${parameter%word}
|
||||
Remove Smallest Suffix Pattern. The word
|
||||
is expanded to produce a pattern. The
|
||||
@@ -1269,16 +1240,16 @@ if any).
|
||||
To include a
|
||||
.Dq Li - ,
|
||||
make it the first or last character listed.
|
||||
.Ss Builtin Commands
|
||||
.Ss Built-in Commands
|
||||
This section lists the commands which
|
||||
are builtin because they need to perform some operation
|
||||
are built-in because they need to perform some operation
|
||||
that cannot be performed by a separate process. In addition to
|
||||
these, builtin versions of the
|
||||
these, built-in versions of the
|
||||
.Xr printf 1
|
||||
and
|
||||
.Xr test 1
|
||||
commands are provided for efficiency.
|
||||
.Bl -tag -width Ds
|
||||
.Bl -tag -width indent
|
||||
.It Ic \&:
|
||||
A null command that returns a 0 (true) exit value.
|
||||
.It Ic \&. Ar file
|
||||
@@ -1293,9 +1264,7 @@ for the file. If it is not found in the
|
||||
.Ev PATH ,
|
||||
it is sought in the current working directory.
|
||||
.It Ic alias Op Ar name ...
|
||||
.It Ic alias Xo
|
||||
.Op Ar name Ns = Ns Ar string ...
|
||||
.Xc
|
||||
.It Ic alias Op Ar name Ns = Ns Ar string ...
|
||||
If
|
||||
.Ar name Ns = Ns Ar string
|
||||
is specified, the shell defines the alias
|
||||
@@ -1309,19 +1278,25 @@ is specified, the value of the alias
|
||||
is printed.
|
||||
With no arguments, the
|
||||
.Ic alias
|
||||
builtin command prints the names and values of all defined aliases
|
||||
built-in command prints the names and values of all defined aliases
|
||||
(see
|
||||
.Ic unalias ) .
|
||||
Alias values are written with appropriate quoting so that they are
|
||||
suitable for re-input to the shell.
|
||||
.It Ic bg Op Ar job ...
|
||||
Continue the specified jobs
|
||||
(or the current job if no jobs are given)
|
||||
in the background.
|
||||
.It Ic command Ar cmd Op Ar arg ...
|
||||
Execute the specified builtin command,
|
||||
.It Ic builtin Ar cmd Op Ar arg ...
|
||||
Execute the specified built-in command,
|
||||
.Ar cmd .
|
||||
This is useful when the user wishes to override a shell function
|
||||
with the same name as a builtin command.
|
||||
.It Ic cd Op Ar directory
|
||||
with the same name as a built-in command.
|
||||
.It Ic bind Oo Fl aeklrsv Oc Oo Ar key Oo Ar command Oc Oc
|
||||
List or alter key bindings for the line editor.
|
||||
This command is documented in
|
||||
.Xr editrc 5 .
|
||||
.It Ic cd Oo Fl LP Oc Op Ar directory
|
||||
Switch to the specified
|
||||
.Ar directory ,
|
||||
or to the directory specified in the
|
||||
@@ -1332,8 +1307,7 @@ is specified.
|
||||
If
|
||||
.Ar directory
|
||||
does not begin with
|
||||
.Pa / ,
|
||||
.Pa \&. ,
|
||||
.Pa / , \&. ,
|
||||
or
|
||||
.Pa .. ,
|
||||
then the directories listed in the
|
||||
@@ -1357,26 +1331,49 @@ if this is different from the name that the user gave.
|
||||
These may be different either because the
|
||||
.Ev CDPATH
|
||||
mechanism was used or because a symbolic link was crossed.
|
||||
.Pp
|
||||
If the
|
||||
.Fl P
|
||||
option is specified,
|
||||
.Pa ..
|
||||
is handled physically and symbolic links are resolved before
|
||||
.Pa ..
|
||||
components are processed.
|
||||
If the
|
||||
.Fl L
|
||||
option is specified,
|
||||
.Pa ..
|
||||
is handled logically.
|
||||
This is the default.
|
||||
.It Ic chdir
|
||||
A synonym for the
|
||||
.Ic cd
|
||||
builtin command.
|
||||
.It Xo
|
||||
.Ic echo
|
||||
.Op Fl en
|
||||
.Ar string
|
||||
.Xc
|
||||
built-in command.
|
||||
.It Ic command Oo Fl p Oc Op Ar utility Op Ar argument ...
|
||||
Execute the specified
|
||||
.Ar utility
|
||||
as a simple command (see the
|
||||
.Sx Simple Commands
|
||||
section).
|
||||
.Pp
|
||||
If the
|
||||
.Fl p
|
||||
option is specified, the command search is performed using a
|
||||
default value of
|
||||
.Ev PATH
|
||||
that is guaranteed to find all of the standard utilities.
|
||||
.It Ic echo Oo Fl e | n Oc Op Ar string
|
||||
Print
|
||||
.Ar string
|
||||
to the standard output with a newline appended.
|
||||
.Bl -tag -width Ds
|
||||
.Bl -tag -width indent
|
||||
.It Fl n
|
||||
Suppress the output of the trailing newline.
|
||||
.It Fl e
|
||||
Process C-style backslash escape sequences.
|
||||
.Ic echo
|
||||
understands the following character escapes:
|
||||
.Bl -tag -width Ds
|
||||
.Bl -tag -width indent
|
||||
.It \ea
|
||||
Alert (ring the terminal bell)
|
||||
.It \eb
|
||||
@@ -1419,6 +1416,12 @@ $ echo -e a\e\e\e\eb
|
||||
a\eb
|
||||
.Ed
|
||||
.El
|
||||
.Pp
|
||||
Only one of the
|
||||
.Fl e
|
||||
and
|
||||
.Fl n
|
||||
options may be specified.
|
||||
.It Ic eval Ar string ...
|
||||
Concatenate all the arguments with spaces.
|
||||
Then re-parse and execute the command.
|
||||
@@ -1427,7 +1430,7 @@ Unless
|
||||
.Ar command
|
||||
is omitted,
|
||||
the shell process is replaced with the specified program
|
||||
(which must be a real program, not a shell builtin command or function).
|
||||
(which must be a real program, not a shell built-in command or function).
|
||||
Any redirections on the
|
||||
.Ic exec
|
||||
command are marked as permanent,
|
||||
@@ -1441,7 +1444,7 @@ If
|
||||
is given
|
||||
it is used as the exit status of the shell;
|
||||
otherwise the exit status of the preceding command is used.
|
||||
.It Ic export Ar name ...
|
||||
.It Ic export Oo Fl p Oc Op Ar name ...
|
||||
The specified names are exported so that they will
|
||||
appear in the environment of subsequent commands.
|
||||
The only way to un-export a variable is to
|
||||
@@ -1455,28 +1458,19 @@ export name=value
|
||||
.Pp
|
||||
With no arguments the export command lists the names
|
||||
of all exported variables.
|
||||
.It Xo
|
||||
.Ic fc
|
||||
.Op Fl e Ar editor
|
||||
.Op Ar first Op Ar last
|
||||
.Xc
|
||||
.It Xo
|
||||
.Ic fc
|
||||
.Fl l
|
||||
.Op Fl nr
|
||||
.Op Ar first Op Ar last
|
||||
.Xc
|
||||
.It Xo
|
||||
.Ic fc
|
||||
.Fl s
|
||||
.Op Ar old=new
|
||||
.Op Ar first
|
||||
.Xc
|
||||
If the
|
||||
.Fl p
|
||||
option is specified, the exported variables are printed as
|
||||
.Dq Ic export Ar name Ns = Ns Ar value
|
||||
lines, suitable for re-input to the shell.
|
||||
.It Ic fc Oo Fl e Ar editor Oc Op Ar first Op Ar last
|
||||
.It Ic fc Fl l Oo Fl nr Oc Op Ar first Op Ar last
|
||||
.It Ic fc Fl s Oo Ar old Ns = Ns Ar new Oc Op Ar first
|
||||
The
|
||||
.Ic fc
|
||||
builtin command lists, or edits and re-executes,
|
||||
built-in command lists, or edits and re-executes,
|
||||
commands previously entered to an interactive shell.
|
||||
.Bl -tag -width Ds
|
||||
.Bl -tag -width indent
|
||||
.It Fl e Ar editor
|
||||
Use the editor named by
|
||||
.Ar editor
|
||||
@@ -1533,7 +1527,7 @@ The value of
|
||||
or
|
||||
.Ar last
|
||||
or both are one of the following:
|
||||
.Bl -tag -width Ds
|
||||
.Bl -tag -width indent
|
||||
.It Ar [+]num
|
||||
A positive number representing a command number;
|
||||
command numbers can be displayed with the
|
||||
@@ -1559,7 +1553,7 @@ the string form of the first operand cannot contain an embedded equal sign.
|
||||
.Pp
|
||||
The following environment variables affect the execution of
|
||||
.Ic fc :
|
||||
.Bl -tag -width Ds
|
||||
.Bl -tag -width indent
|
||||
.It Ev FCEDIT
|
||||
Name of the editor to use.
|
||||
.It Ev HISTSIZE
|
||||
@@ -1590,11 +1584,7 @@ If an invalid option is encountered,
|
||||
is set to
|
||||
.Dq Li \&? .
|
||||
It returns a false value (1) when it encounters the end of the options.
|
||||
.It Xo
|
||||
.Ic hash
|
||||
.Op Fl rv
|
||||
.Op Ar command ...
|
||||
.Xc
|
||||
.It Ic hash Oo Fl rv Oc Op Ar command ...
|
||||
The shell maintains a hash table which remembers the locations of commands.
|
||||
With no arguments whatsoever, the
|
||||
.Ic hash
|
||||
@@ -1625,26 +1615,38 @@ Print the process id's of the processes in the specified
|
||||
If the
|
||||
.Ar job
|
||||
argument is omitted, use the current job.
|
||||
.It Ic jobs
|
||||
This command lists out all the background processes
|
||||
which are children of the current shell process.
|
||||
.It Ic pwd
|
||||
Print the path of the current directory. The builtin command may
|
||||
.It Ic jobs Oo Fl ls Oc Op Ar job ...
|
||||
Print information about the specified jobs, or all jobs if no
|
||||
.Ar job
|
||||
argument is given.
|
||||
The information printed includes job ID, status and command name.
|
||||
.Pp
|
||||
If the
|
||||
.Fl l
|
||||
option is specified, the PID of each job is also printed.
|
||||
If the
|
||||
.Fl s
|
||||
option is specified, only the PIDs of the jobs are printed, one per line.
|
||||
.It Ic pwd Op Fl LP
|
||||
Print the path of the current directory. The built-in command may
|
||||
differ from the program of the same name because the
|
||||
builtin command remembers what the current directory
|
||||
built-in command remembers what the current directory
|
||||
is rather than recomputing it each time. This makes
|
||||
it faster. However, if the current directory is
|
||||
renamed,
|
||||
the builtin version of
|
||||
the built-in version of
|
||||
.Xr pwd 1
|
||||
will continue to print the old name for the directory.
|
||||
.It Xo
|
||||
.Ic read
|
||||
.Op Fl p Ar prompt
|
||||
.Op Fl t Ar timeout
|
||||
.Op Fl er
|
||||
.Ar variable ...
|
||||
.Xc
|
||||
.Pp
|
||||
If the
|
||||
.Fl P
|
||||
option is specified, symbolic links are resolved.
|
||||
If the
|
||||
.Fl L
|
||||
option is specified, the shell's notion of the current directory
|
||||
is printed (symbolic links are not resolved).
|
||||
This is the default.
|
||||
.It Ic read Oo Fl p Ar prompt Oc Oo Fl t Ar timeout Oc Oo Fl er Oc Ar variable ...
|
||||
The
|
||||
.Ar prompt
|
||||
is printed if the
|
||||
@@ -1699,7 +1701,7 @@ is assumed.
|
||||
The
|
||||
.Fl e
|
||||
option exists only for backward compatibility with older scripts.
|
||||
.It Ic readonly Ar name ...
|
||||
.It Ic readonly Oo Fl p Oc Op Ar name ...
|
||||
Each specified
|
||||
.Ar name
|
||||
is marked as read only,
|
||||
@@ -1714,13 +1716,13 @@ readonly name=value
|
||||
With no arguments the
|
||||
.Ic readonly
|
||||
command lists the names of all read only variables.
|
||||
.It Xo
|
||||
.Ic set
|
||||
.Op Fl /+abCEefIimnpTuVvx
|
||||
.Op Fl /+o Ar longname
|
||||
.Op Fl c Ar string
|
||||
.Op Fl - Ar arg ...
|
||||
.Xc
|
||||
If the
|
||||
.Fl p
|
||||
option is specified, the read-only variables are printed as
|
||||
.Dq Ic readonly Ar name Ns = Ns Ar value
|
||||
lines, suitable for re-input to the shell.
|
||||
.It Ic set Oo Fl /+abCEefIimnpTuVvx Oc Oo Fl /+o Ar longname Oc Oo
|
||||
.Fl c Ar string Oc Op Fl - Ar arg ...
|
||||
The
|
||||
.Ic set
|
||||
command performs three different functions:
|
||||
@@ -1749,7 +1751,7 @@ which is equivalent to executing the command
|
||||
.Dq Li shift $# .
|
||||
The
|
||||
.Dq Fl -
|
||||
flag may be ommitted when specifying arguments to be used
|
||||
flag may be omitted when specifying arguments to be used
|
||||
as positional replacement parameters.
|
||||
This is not recommended,
|
||||
because the first argument may begin with a dash
|
||||
@@ -1784,11 +1786,7 @@ A shift sets the value of $1 to the value of $2,
|
||||
the value of $2 to the value of $3, and so on,
|
||||
decreasing the value of $# by one.
|
||||
If there are zero positional parameters, shifting does not do anything.
|
||||
.It Xo
|
||||
.Ic trap
|
||||
.Op Ar action
|
||||
.Ar signal ...
|
||||
.Xc
|
||||
.It Ic trap Oo Ar action Oc Ar signal ...
|
||||
Cause the shell to parse and execute
|
||||
.Ar action
|
||||
when any specified
|
||||
@@ -1810,16 +1808,12 @@ Interpret each
|
||||
.Ar name
|
||||
as a command and print the resolution of the command search.
|
||||
Possible resolutions are:
|
||||
shell keyword, alias, shell builtin command, command, tracked alias
|
||||
shell keyword, alias, shell built-in command, command, tracked alias
|
||||
and not found.
|
||||
For aliases the alias expansion is printed;
|
||||
for commands and tracked aliases
|
||||
the complete pathname of the command is printed.
|
||||
.It Xo
|
||||
.Ic ulimit
|
||||
.Op Fl HSabcdflmnstuv
|
||||
.Op Ar limit
|
||||
.Xc
|
||||
.It Ic ulimit Oo Fl HSabcdflmnstuv Oc Op Ar limit
|
||||
Set or display resource limits (see
|
||||
.Xr getrlimit 2 ) .
|
||||
If
|
||||
@@ -1856,7 +1850,7 @@ is not acceptable in this mode.
|
||||
The remaining options specify which resource value is to be
|
||||
displayed or modified.
|
||||
They are mutually exclusive.
|
||||
.Bl -tag -width Ds
|
||||
.Bl -tag -width indent
|
||||
.It Fl b Ar sbsize
|
||||
The maximum size of socket buffer usage, in bytes.
|
||||
.It Fl c Ar coredumpsize
|
||||
@@ -1887,23 +1881,25 @@ Set the file creation mask (see
|
||||
to the octal value specified by
|
||||
.Ar mask .
|
||||
If the argument is omitted, the current mask value is printed.
|
||||
.It Xo
|
||||
.Ic unalias
|
||||
.Op Fl a
|
||||
.Op Ar name
|
||||
.Xc
|
||||
.It Ic unalias Oo Fl a Oc Op Ar name
|
||||
If
|
||||
.Ar name
|
||||
is specified, the shell removes that alias.
|
||||
If
|
||||
.Fl a
|
||||
is specified, all aliases are removed.
|
||||
.It Ic unset Ar name ...
|
||||
The specified variables and functions are unset and unexported.
|
||||
If a given
|
||||
.It Ic unset Oo Fl fv Oc Ar name ...
|
||||
The specified variables or functions are unset and unexported.
|
||||
If the
|
||||
.Fl v
|
||||
option is specified or no options are given, the
|
||||
.Ar name
|
||||
corresponds to both a variable and a function,
|
||||
both the variable and the function are unset.
|
||||
arguments are treated as variable names.
|
||||
If the
|
||||
.Fl f
|
||||
option is specified, the
|
||||
.Ar name
|
||||
arguments are treated as function names.
|
||||
.It Ic wait Op Ar job
|
||||
Wait for the specified
|
||||
.Ar job
|
||||
@@ -1920,7 +1916,7 @@ and the command history
|
||||
(see
|
||||
.Ic fc
|
||||
in
|
||||
.Sx Builtin Commands )
|
||||
.Sx Built-in Commands )
|
||||
can be edited using vi-mode command line editing.
|
||||
This mode uses commands similar
|
||||
to a subset of those described in the vi man page.
|
||||
@@ -1955,4 +1951,4 @@ emacs-style command line editing features.
|
||||
A
|
||||
.Nm
|
||||
command appeared in
|
||||
.At V.1 .
|
||||
.At v1 .
|
||||
@@ -40,9 +40,6 @@
|
||||
/*
|
||||
* The follow should be set to reflect the type of system you have:
|
||||
* JOBS -> 1 if you have Berkeley job control, 0 otherwise.
|
||||
* SHORTNAMES -> 1 if your linker cannot handle long names.
|
||||
* define BSD if you are running 4.2 BSD or later.
|
||||
* define SYSV if you are running under System V.
|
||||
* define DEBUG=1 to compile in debugging (set global "debug" to turn on)
|
||||
* define DEBUG=2 to compile in and turn on debugging.
|
||||
*
|
||||
@@ -52,22 +49,9 @@
|
||||
|
||||
|
||||
#define JOBS 1
|
||||
#ifndef BSD
|
||||
#define BSD 1
|
||||
#endif
|
||||
/* #define DEBUG 1 */
|
||||
|
||||
#ifdef __STDC__
|
||||
typedef void *pointer;
|
||||
#ifndef NULL
|
||||
#define NULL (void *)0
|
||||
#endif
|
||||
#else /* not __STDC__ */
|
||||
typedef char *pointer;
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
#endif /* not __STDC__ */
|
||||
#define STATIC static
|
||||
#define MKINIT /* empty */
|
||||
|
||||
|
||||
+24
-53
@@ -38,19 +38,12 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)show.c 8.3 (Berkeley) 5/4/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <stdio.h>
|
||||
#ifdef __STDC__
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
#if DEBUG == 2
|
||||
#include <errno.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
|
||||
#include "shell.h"
|
||||
@@ -61,16 +54,15 @@ static const char rcsid[] =
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
static void shtree __P((union node *, int, char *, FILE*));
|
||||
static void shcmd __P((union node *, FILE *));
|
||||
static void sharg __P((union node *, FILE *));
|
||||
static void indent __P((int, char *, FILE *));
|
||||
static void trstring __P((char *));
|
||||
static void shtree(union node *, int, char *, FILE*);
|
||||
static void shcmd(union node *, FILE *);
|
||||
static void sharg(union node *, FILE *);
|
||||
static void indent(int, char *, FILE *);
|
||||
static void trstring(char *);
|
||||
|
||||
|
||||
void
|
||||
showtree(n)
|
||||
union node *n;
|
||||
showtree(union node *n)
|
||||
{
|
||||
trputs("showtree called\n");
|
||||
shtree(n, 1, NULL, stdout);
|
||||
@@ -78,11 +70,7 @@ showtree(n)
|
||||
|
||||
|
||||
static void
|
||||
shtree(n, ind, pfx, fp)
|
||||
union node *n;
|
||||
int ind;
|
||||
char *pfx;
|
||||
FILE *fp;
|
||||
shtree(union node *n, int ind, char *pfx, FILE *fp)
|
||||
{
|
||||
struct nodelist *lp;
|
||||
char *s;
|
||||
@@ -133,9 +121,7 @@ binop:
|
||||
|
||||
|
||||
static void
|
||||
shcmd(cmd, fp)
|
||||
union node *cmd;
|
||||
FILE *fp;
|
||||
shcmd(union node *cmd, FILE *fp)
|
||||
{
|
||||
union node *np;
|
||||
int first;
|
||||
@@ -156,6 +142,7 @@ shcmd(cmd, fp)
|
||||
case NTO: s = ">"; dftfd = 1; break;
|
||||
case NAPPEND: s = ">>"; dftfd = 1; break;
|
||||
case NTOFD: s = ">&"; dftfd = 1; break;
|
||||
case NCLOBBER: s = ">|"; dftfd = 1; break;
|
||||
case NFROM: s = "<"; dftfd = 0; break;
|
||||
case NFROMTO: s = "<>"; dftfd = 0; break;
|
||||
case NFROMFD: s = "<&"; dftfd = 0; break;
|
||||
@@ -165,7 +152,10 @@ shcmd(cmd, fp)
|
||||
fprintf(fp, "%d", np->nfile.fd);
|
||||
fputs(s, fp);
|
||||
if (np->nfile.type == NTOFD || np->nfile.type == NFROMFD) {
|
||||
fprintf(fp, "%d", np->ndup.dupfd);
|
||||
if (np->ndup.dupfd >= 0)
|
||||
fprintf(fp, "%d", np->ndup.dupfd);
|
||||
else
|
||||
fprintf(fp, "-");
|
||||
} else {
|
||||
sharg(np->nfile.fname, fp);
|
||||
}
|
||||
@@ -176,10 +166,8 @@ shcmd(cmd, fp)
|
||||
|
||||
|
||||
static void
|
||||
sharg(arg, fp)
|
||||
union node *arg;
|
||||
FILE *fp;
|
||||
{
|
||||
sharg(union node *arg, FILE *fp)
|
||||
{
|
||||
char *p;
|
||||
struct nodelist *bqlist;
|
||||
int subtype;
|
||||
@@ -263,10 +251,7 @@ sharg(arg, fp)
|
||||
|
||||
|
||||
static void
|
||||
indent(amount, pfx, fp)
|
||||
int amount;
|
||||
char *pfx;
|
||||
FILE *fp;
|
||||
indent(int amount, char *pfx, FILE *fp)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -293,8 +278,7 @@ int debug = 0;
|
||||
|
||||
|
||||
void
|
||||
trputc(c)
|
||||
int c;
|
||||
trputc(int c)
|
||||
{
|
||||
if (tracefile == NULL)
|
||||
return;
|
||||
@@ -305,21 +289,10 @@ trputc(c)
|
||||
|
||||
|
||||
void
|
||||
#ifdef __STDC__
|
||||
sh_trace(const char *fmt, ...)
|
||||
#else
|
||||
sh_trace(va_alist)
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list va;
|
||||
#ifdef __STDC__
|
||||
va_start(va, fmt);
|
||||
#else
|
||||
char *fmt;
|
||||
va_start(va);
|
||||
fmt = va_arg(va, char *);
|
||||
#endif
|
||||
if (tracefile != NULL) {
|
||||
(void) vfprintf(tracefile, fmt, va);
|
||||
if (strchr(fmt, '\n'))
|
||||
@@ -330,8 +303,7 @@ sh_trace(va_alist)
|
||||
|
||||
|
||||
void
|
||||
trputs(s)
|
||||
char *s;
|
||||
trputs(char *s)
|
||||
{
|
||||
if (tracefile == NULL)
|
||||
return;
|
||||
@@ -342,8 +314,7 @@ trputs(s)
|
||||
|
||||
|
||||
static void
|
||||
trstring(s)
|
||||
char *s;
|
||||
trstring(char *s)
|
||||
{
|
||||
char *p;
|
||||
char c;
|
||||
@@ -383,8 +354,7 @@ backslash: putc('\\', tracefile);
|
||||
|
||||
|
||||
void
|
||||
trargs(ap)
|
||||
char **ap;
|
||||
trargs(char **ap)
|
||||
{
|
||||
if (tracefile == NULL)
|
||||
return;
|
||||
@@ -400,7 +370,8 @@ trargs(ap)
|
||||
|
||||
|
||||
void
|
||||
opentrace() {
|
||||
opentrace(void)
|
||||
{
|
||||
char s[100];
|
||||
char *getenv();
|
||||
#ifdef O_APPEND
|
||||
|
||||
+6
-6
@@ -34,11 +34,11 @@
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
void showtree __P((union node *));
|
||||
void showtree(union node *);
|
||||
#ifdef DEBUG
|
||||
void sh_trace __P((const char *, ...)) __printflike(1, 2);
|
||||
void trargs __P((char **));
|
||||
void trputc __P((int));
|
||||
void trputs __P((char *));
|
||||
void opentrace __P((void));
|
||||
void sh_trace(const char *, ...) __printflike(1, 2);
|
||||
void trargs(char **);
|
||||
void trputc(int);
|
||||
void trputs(char *);
|
||||
void opentrace(void);
|
||||
#endif
|
||||
+30
-29
@@ -38,9 +38,9 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)trap.c 8.5 (Berkeley) 6/5/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
@@ -59,6 +59,7 @@ static const char rcsid[] =
|
||||
#include "error.h"
|
||||
#include "trap.h"
|
||||
#include "mystring.h"
|
||||
#include "myhistedit.h"
|
||||
|
||||
|
||||
/*
|
||||
@@ -81,16 +82,16 @@ static char *volatile trap[NSIG]; /* trap handler commands */
|
||||
static volatile sig_atomic_t gotsig[NSIG];
|
||||
/* indicates specified signal received */
|
||||
static int ignore_sigchld; /* Used while handling SIGCHLD traps. */
|
||||
volatile sig_atomic_t gotwinch;
|
||||
|
||||
static int getsigaction __P((int, sig_t *));
|
||||
static int getsigaction(int, sig_t *);
|
||||
|
||||
|
||||
/*
|
||||
* Map a string to a signal number.
|
||||
*/
|
||||
static int
|
||||
sigstring_to_signum(sig)
|
||||
char *sig;
|
||||
sigstring_to_signum(char *sig)
|
||||
{
|
||||
|
||||
if (is_number(sig)) {
|
||||
@@ -117,7 +118,7 @@ sigstring_to_signum(sig)
|
||||
* Print a list of valid signal names.
|
||||
*/
|
||||
static void
|
||||
printsignals()
|
||||
printsignals(void)
|
||||
{
|
||||
int n;
|
||||
|
||||
@@ -135,9 +136,7 @@ printsignals()
|
||||
* The trap builtin.
|
||||
*/
|
||||
int
|
||||
trapcmd(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
trapcmd(int argc, char **argv)
|
||||
{
|
||||
char *action;
|
||||
int signo;
|
||||
@@ -188,7 +187,7 @@ trapcmd(argc, argv)
|
||||
* Clear traps on a fork.
|
||||
*/
|
||||
void
|
||||
clear_traps()
|
||||
clear_traps(void)
|
||||
{
|
||||
char *volatile *tp;
|
||||
|
||||
@@ -210,8 +209,7 @@ clear_traps()
|
||||
* out what it should be set to.
|
||||
*/
|
||||
void
|
||||
setsignal(signo)
|
||||
int signo;
|
||||
setsignal(int signo)
|
||||
{
|
||||
int action;
|
||||
sig_t sig, sigact = SIG_DFL;
|
||||
@@ -249,6 +247,12 @@ setsignal(signo)
|
||||
if (rootshell && mflag)
|
||||
action = S_IGN;
|
||||
break;
|
||||
#endif
|
||||
#ifndef NO_HISTORY
|
||||
case SIGWINCH:
|
||||
if (rootshell && iflag)
|
||||
action = S_CATCH;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -285,10 +289,8 @@ setsignal(signo)
|
||||
}
|
||||
*t = action;
|
||||
sig = signal(signo, sigact);
|
||||
#ifdef BSD
|
||||
if (sig != SIG_ERR && action == S_CATCH)
|
||||
siginterrupt(signo, 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -296,9 +298,7 @@ setsignal(signo)
|
||||
* Return the current setting for sig w/o changing it.
|
||||
*/
|
||||
static int
|
||||
getsigaction(signo, sigact)
|
||||
int signo;
|
||||
sig_t *sigact;
|
||||
getsigaction(int signo, sig_t *sigact)
|
||||
{
|
||||
struct sigaction sa;
|
||||
|
||||
@@ -313,8 +313,7 @@ getsigaction(signo, sigact)
|
||||
* Ignore a signal.
|
||||
*/
|
||||
void
|
||||
ignoresig(signo)
|
||||
int signo;
|
||||
ignoresig(int signo)
|
||||
{
|
||||
|
||||
if (sigmode[signo] != S_IGN && sigmode[signo] != S_HARD_IGN) {
|
||||
@@ -344,13 +343,9 @@ SHELLPROC {
|
||||
* Signal handler.
|
||||
*/
|
||||
void
|
||||
onsig(signo)
|
||||
int signo;
|
||||
onsig(int signo)
|
||||
{
|
||||
|
||||
#ifndef BSD
|
||||
signal(signo, onsig);
|
||||
#endif
|
||||
if (signo == SIGINT && trap[SIGINT] == NULL) {
|
||||
onint();
|
||||
return;
|
||||
@@ -372,6 +367,11 @@ onsig(signo)
|
||||
! trap[signo][0] == '\0' &&
|
||||
! (trap[signo][0] == ':' && trap[signo][1] == '\0'))
|
||||
breakwaitcmd = 1;
|
||||
|
||||
#ifndef NO_HISTORY
|
||||
if (signo == SIGWINCH)
|
||||
gotwinch = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -380,7 +380,7 @@ onsig(signo)
|
||||
* handlers while we are executing a trap handler.
|
||||
*/
|
||||
void
|
||||
dotrap()
|
||||
dotrap(void)
|
||||
{
|
||||
int i;
|
||||
int savestatus;
|
||||
@@ -418,8 +418,7 @@ dotrap()
|
||||
* Controls whether the shell is interactive or not.
|
||||
*/
|
||||
void
|
||||
setinteractive(on)
|
||||
int on;
|
||||
setinteractive(int on)
|
||||
{
|
||||
static int is_interactive = -1;
|
||||
|
||||
@@ -428,6 +427,9 @@ setinteractive(on)
|
||||
setsignal(SIGINT);
|
||||
setsignal(SIGQUIT);
|
||||
setsignal(SIGTERM);
|
||||
#ifndef NO_HISTORY
|
||||
setsignal(SIGWINCH);
|
||||
#endif
|
||||
is_interactive = on;
|
||||
}
|
||||
|
||||
@@ -436,8 +438,7 @@ setinteractive(on)
|
||||
* Called to exit the shell.
|
||||
*/
|
||||
void
|
||||
exitshell(status)
|
||||
int status;
|
||||
exitshell(int status)
|
||||
{
|
||||
struct jmploc loc1, loc2;
|
||||
char *p;
|
||||
|
||||
+9
-8
@@ -39,12 +39,13 @@
|
||||
|
||||
extern int pendingsigs;
|
||||
extern int in_dotrap;
|
||||
extern volatile sig_atomic_t gotwinch;
|
||||
|
||||
int trapcmd __P((int, char **));
|
||||
void clear_traps __P((void));
|
||||
void setsignal __P((int));
|
||||
void ignoresig __P((int));
|
||||
void onsig __P((int));
|
||||
void dotrap __P((void));
|
||||
void setinteractive __P((int));
|
||||
void exitshell __P((int));
|
||||
int trapcmd(int, char **);
|
||||
void clear_traps(void);
|
||||
void setsignal(int);
|
||||
void ignoresig(int);
|
||||
void onsig(int);
|
||||
void dotrap(void);
|
||||
void setinteractive(int);
|
||||
void exitshell(int);
|
||||
+84
-62
@@ -38,9 +38,9 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 5/4/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
@@ -77,7 +77,7 @@ struct varinit {
|
||||
struct var *var;
|
||||
int flags;
|
||||
char *text;
|
||||
void (*func) __P((const char *));
|
||||
void (*func)(const char *);
|
||||
};
|
||||
|
||||
|
||||
@@ -91,6 +91,7 @@ struct var vifs;
|
||||
struct var vmail;
|
||||
struct var vmpath;
|
||||
struct var vpath;
|
||||
struct var vppid;
|
||||
struct var vps1;
|
||||
struct var vps2;
|
||||
struct var vvers;
|
||||
@@ -116,6 +117,8 @@ const struct varinit varinit[] = {
|
||||
NULL },
|
||||
{ &vpath, VSTRFIXED|VTEXTFIXED, "PATH=/bin:/usr/bin",
|
||||
changepath },
|
||||
{ &vppid, VSTRFIXED|VTEXTFIXED|VUNSET, "PPID=",
|
||||
NULL },
|
||||
/*
|
||||
* vps1 depends on uid
|
||||
*/
|
||||
@@ -133,9 +136,9 @@ const struct varinit varinit[] = {
|
||||
|
||||
struct var *vartab[VTABSIZE];
|
||||
|
||||
STATIC struct var **hashvar __P((char *));
|
||||
STATIC int varequal __P((char *, char *));
|
||||
STATIC int localevar __P((char *));
|
||||
STATIC struct var **hashvar(char *);
|
||||
STATIC int varequal(char *, char *);
|
||||
STATIC int localevar(char *);
|
||||
|
||||
/*
|
||||
* Initialize the varable symbol tables and import the environment
|
||||
@@ -163,7 +166,9 @@ INIT {
|
||||
*/
|
||||
|
||||
void
|
||||
initvar() {
|
||||
initvar(void)
|
||||
{
|
||||
char ppid[20];
|
||||
const struct varinit *ip;
|
||||
struct var *vp;
|
||||
struct var **vpp;
|
||||
@@ -188,6 +193,10 @@ initvar() {
|
||||
vps1.text = geteuid() ? "PS1=$ " : "PS1=# ";
|
||||
vps1.flags = VSTRFIXED|VTEXTFIXED;
|
||||
}
|
||||
if ((vppid.flags & VEXPORT) == 0) {
|
||||
fmtstr(ppid, sizeof(ppid), "%d", (int)getppid());
|
||||
setvarsafe("PPID", ppid, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -195,9 +204,7 @@ initvar() {
|
||||
*/
|
||||
|
||||
int
|
||||
setvarsafe(name, val, flags)
|
||||
char *name, *val;
|
||||
int flags;
|
||||
setvarsafe(char *name, char *val, int flags)
|
||||
{
|
||||
struct jmploc jmploc;
|
||||
struct jmploc *volatile savehandler = handler;
|
||||
@@ -223,9 +230,7 @@ setvarsafe(name, val, flags)
|
||||
*/
|
||||
|
||||
void
|
||||
setvar(name, val, flags)
|
||||
char *name, *val;
|
||||
int flags;
|
||||
setvar(char *name, char *val, int flags)
|
||||
{
|
||||
char *p, *q;
|
||||
int len;
|
||||
@@ -267,9 +272,8 @@ setvar(name, val, flags)
|
||||
}
|
||||
|
||||
STATIC int
|
||||
localevar(s)
|
||||
char *s;
|
||||
{
|
||||
localevar(char *s)
|
||||
{
|
||||
static char *lnames[7] = {
|
||||
"ALL", "COLLATE", "CTYPE", "MONETARY",
|
||||
"NUMERIC", "TIME", NULL
|
||||
@@ -296,11 +300,10 @@ localevar(s)
|
||||
*/
|
||||
|
||||
void
|
||||
setvareq(s, flags)
|
||||
char *s;
|
||||
int flags;
|
||||
setvareq(char *s, int flags)
|
||||
{
|
||||
struct var *vp, **vpp;
|
||||
int len;
|
||||
|
||||
if (aflag)
|
||||
flags |= VEXPORT;
|
||||
@@ -308,7 +311,7 @@ setvareq(s, flags)
|
||||
for (vp = *vpp ; vp ; vp = vp->next) {
|
||||
if (varequal(s, vp->text)) {
|
||||
if (vp->flags & VREADONLY) {
|
||||
size_t len = strchr(s, '=') - s;
|
||||
len = strchr(s, '=') - s;
|
||||
error("%.*s: is read only", len, s);
|
||||
}
|
||||
INTOFF;
|
||||
@@ -359,9 +362,8 @@ setvareq(s, flags)
|
||||
*/
|
||||
|
||||
void
|
||||
listsetvar(list)
|
||||
struct strlist *list;
|
||||
{
|
||||
listsetvar(struct strlist *list)
|
||||
{
|
||||
struct strlist *lp;
|
||||
|
||||
INTOFF;
|
||||
@@ -378,9 +380,8 @@ listsetvar(list)
|
||||
*/
|
||||
|
||||
char *
|
||||
lookupvar(name)
|
||||
char *name;
|
||||
{
|
||||
lookupvar(char *name)
|
||||
{
|
||||
struct var *v;
|
||||
|
||||
for (v = *hashvar(name) ; v ; v = v->next) {
|
||||
@@ -402,9 +403,7 @@ lookupvar(name)
|
||||
*/
|
||||
|
||||
char *
|
||||
bltinlookup(name, doall)
|
||||
char *name;
|
||||
int doall;
|
||||
bltinlookup(char *name, int doall)
|
||||
{
|
||||
struct strlist *sp;
|
||||
struct var *v;
|
||||
@@ -432,7 +431,8 @@ bltinlookup(name, doall)
|
||||
*/
|
||||
|
||||
char **
|
||||
environment() {
|
||||
environment(void)
|
||||
{
|
||||
int nenv;
|
||||
struct var **vpp;
|
||||
struct var *vp;
|
||||
@@ -470,7 +470,8 @@ SHELLPROC {
|
||||
#endif
|
||||
|
||||
void
|
||||
shprocvar() {
|
||||
shprocvar(void)
|
||||
{
|
||||
struct var **vpp;
|
||||
struct var *vp, **prev;
|
||||
|
||||
@@ -503,17 +504,21 @@ shprocvar() {
|
||||
*/
|
||||
|
||||
int
|
||||
showvarscmd(argc, argv)
|
||||
int argc __unused;
|
||||
char **argv __unused;
|
||||
showvarscmd(int argc __unused, char **argv __unused)
|
||||
{
|
||||
struct var **vpp;
|
||||
struct var *vp;
|
||||
const char *s;
|
||||
|
||||
for (vpp = vartab ; vpp < vartab + VTABSIZE ; vpp++) {
|
||||
for (vp = *vpp ; vp ; vp = vp->next) {
|
||||
if ((vp->flags & VUNSET) == 0)
|
||||
out1fmt("%s\n", vp->text);
|
||||
if (vp->flags & VUNSET)
|
||||
continue;
|
||||
for (s = vp->text; *s != '='; s++)
|
||||
out1c(*s);
|
||||
out1c('=');
|
||||
out1qstr(s + 1);
|
||||
out1c('\n');
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@@ -526,18 +531,35 @@ showvarscmd(argc, argv)
|
||||
*/
|
||||
|
||||
int
|
||||
exportcmd(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
exportcmd(int argc, char **argv)
|
||||
{
|
||||
struct var **vpp;
|
||||
struct var *vp;
|
||||
char *name;
|
||||
char *p;
|
||||
char *cmdname;
|
||||
int ch, values;
|
||||
int flag = argv[0][0] == 'r'? VREADONLY : VEXPORT;
|
||||
|
||||
cmdname = argv[0];
|
||||
optreset = optind = 1;
|
||||
opterr = 0;
|
||||
values = 0;
|
||||
while ((ch = getopt(argc, argv, "p")) != -1) {
|
||||
switch (ch) {
|
||||
case 'p':
|
||||
values = 1;
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
error("unknown option: -%c", optopt);
|
||||
}
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
listsetvar(cmdenviron);
|
||||
if (argc > 1) {
|
||||
if (argc != 0) {
|
||||
while ((name = *argptr++) != NULL) {
|
||||
if ((p = strchr(name, '=')) != NULL) {
|
||||
p++;
|
||||
@@ -545,6 +567,7 @@ exportcmd(argc, argv)
|
||||
vpp = hashvar(name);
|
||||
for (vp = *vpp ; vp ; vp = vp->next) {
|
||||
if (varequal(vp->text, name)) {
|
||||
|
||||
vp->flags |= flag;
|
||||
if ((vp->flags & VEXPORT) && localevar(vp->text)) {
|
||||
putenv(vp->text);
|
||||
@@ -561,8 +584,16 @@ found:;
|
||||
for (vpp = vartab ; vpp < vartab + VTABSIZE ; vpp++) {
|
||||
for (vp = *vpp ; vp ; vp = vp->next) {
|
||||
if (vp->flags & flag) {
|
||||
if (values) {
|
||||
out1str(cmdname);
|
||||
out1c(' ');
|
||||
}
|
||||
for (p = vp->text ; *p != '=' ; p++)
|
||||
out1c(*p);
|
||||
if (values && !(vp->flags & VUNSET)) {
|
||||
out1c('=');
|
||||
out1qstr(p + 1);
|
||||
}
|
||||
out1c('\n');
|
||||
}
|
||||
}
|
||||
@@ -577,9 +608,7 @@ found:;
|
||||
*/
|
||||
|
||||
int
|
||||
localcmd(argc, argv)
|
||||
int argc __unused;
|
||||
char **argv __unused;
|
||||
localcmd(int argc __unused, char **argv __unused)
|
||||
{
|
||||
char *name;
|
||||
|
||||
@@ -600,9 +629,8 @@ localcmd(argc, argv)
|
||||
*/
|
||||
|
||||
void
|
||||
mklocal(name)
|
||||
char *name;
|
||||
{
|
||||
mklocal(char *name)
|
||||
{
|
||||
struct localvar *lvp;
|
||||
struct var **vpp;
|
||||
struct var *vp;
|
||||
@@ -644,7 +672,8 @@ mklocal(name)
|
||||
*/
|
||||
|
||||
void
|
||||
poplocalvars() {
|
||||
poplocalvars(void)
|
||||
{
|
||||
struct localvar *lvp;
|
||||
struct var *vp;
|
||||
|
||||
@@ -668,9 +697,7 @@ poplocalvars() {
|
||||
|
||||
|
||||
int
|
||||
setvarcmd(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
setvarcmd(int argc, char **argv)
|
||||
{
|
||||
if (argc <= 2)
|
||||
return unsetcmd(argc, argv);
|
||||
@@ -689,9 +716,7 @@ setvarcmd(argc, argv)
|
||||
*/
|
||||
|
||||
int
|
||||
unsetcmd(argc, argv)
|
||||
int argc __unused;
|
||||
char **argv __unused;
|
||||
unsetcmd(int argc __unused, char **argv __unused)
|
||||
{
|
||||
char **ap;
|
||||
int i;
|
||||
@@ -723,9 +748,8 @@ unsetcmd(argc, argv)
|
||||
*/
|
||||
|
||||
int
|
||||
unsetvar(s)
|
||||
char *s;
|
||||
{
|
||||
unsetvar(char *s)
|
||||
{
|
||||
struct var **vpp;
|
||||
struct var *vp;
|
||||
|
||||
@@ -764,9 +788,8 @@ unsetvar(s)
|
||||
*/
|
||||
|
||||
STATIC struct var **
|
||||
hashvar(p)
|
||||
char *p;
|
||||
{
|
||||
hashvar(char *p)
|
||||
{
|
||||
unsigned int hashval;
|
||||
|
||||
hashval = ((unsigned char) *p) << 4;
|
||||
@@ -784,9 +807,8 @@ hashvar(p)
|
||||
*/
|
||||
|
||||
STATIC int
|
||||
varequal(p, q)
|
||||
char *p, *q;
|
||||
{
|
||||
varequal(char *p, char *q)
|
||||
{
|
||||
while (*p == *q++) {
|
||||
if (*p++ == '=')
|
||||
return 1;
|
||||
|
||||
Loaded 100 of 3856 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user