Commit cd8c48c
Add the '-e' flag to the 'cd' builtin (#358)
This change adds the -e flag to the cd builtin, as specified in
<https://www.austingroupbugs.net/view.php?id=253>. The -e flag is
used to verify if the the current working directory after 'cd -P'
successfully changes the directory, and returns with exit status 1
if the cwd couldn't be determined. Additionally, it causes all
other errors to return with exit status >1 (i.e., status 2 unless
ENOMEM occurs) if -e and -P are both active.
src/cmd/ksh93/bltins/cd_pwd.c:
- Add -e option to the cd builtin command. It verifies $PWD by
using test_inode() to execute the equivalent of [[ . -ef $PWD ]].
- The check for restricted mode has been moved after optget to
allow 'cd -eP' to return with exit status 2 when in restricted
mode. To avoid changing the previous behavior of cd when -e isn't
passed, extra checks have been added to prevent cd from printing
usage information in restricted mode.
src/cmd/ksh93/tests/builtins.sh:
- Add regression tests for the exit status when using the cd -P
flag with and without -e.
src/cmd/ksh93/data/builtins.c,
src/cmd/ksh93/sh.1:
- Document the addition of -e to the cd builtin.1 parent a3f4b5e commit cd8c48c
File tree
5 files changed
+111
-25
lines changed- src/cmd/ksh93
- bltins
- data
- tests
5 files changed
+111
-25
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
11 | 17 | | |
12 | 18 | | |
13 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
| 23 | + | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
| 60 | + | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | 63 | | |
69 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
70 | 68 | | |
71 | | - | |
| 69 | + | |
72 | 70 | | |
73 | 71 | | |
74 | | - | |
| 72 | + | |
75 | 73 | | |
76 | 74 | | |
| 75 | + | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
| 81 | + | |
80 | 82 | | |
81 | 83 | | |
82 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
83 | 93 | | |
84 | 94 | | |
85 | 95 | | |
86 | | - | |
| 96 | + | |
87 | 97 | | |
88 | 98 | | |
89 | 99 | | |
| |||
106 | 116 | | |
107 | 117 | | |
108 | 118 | | |
109 | | - | |
| 119 | + | |
110 | 120 | | |
111 | 121 | | |
112 | 122 | | |
| |||
179 | 189 | | |
180 | 190 | | |
181 | 191 | | |
182 | | - | |
| 192 | + | |
183 | 193 | | |
184 | 194 | | |
185 | 195 | | |
| |||
200 | 210 | | |
201 | 211 | | |
202 | 212 | | |
203 | | - | |
| 213 | + | |
204 | 214 | | |
205 | 215 | | |
206 | 216 | | |
207 | 217 | | |
208 | 218 | | |
209 | | - | |
| 219 | + | |
210 | 220 | | |
211 | 221 | | |
212 | 222 | | |
213 | 223 | | |
214 | 224 | | |
215 | | - | |
| 225 | + | |
216 | 226 | | |
217 | 227 | | |
218 | 228 | | |
| |||
223 | 233 | | |
224 | 234 | | |
225 | 235 | | |
226 | | - | |
| 236 | + | |
227 | 237 | | |
228 | | - | |
229 | | - | |
| 238 | + | |
| 239 | + | |
230 | 240 | | |
231 | 241 | | |
232 | 242 | | |
| |||
243 | 253 | | |
244 | 254 | | |
245 | 255 | | |
246 | | - | |
| 256 | + | |
247 | 257 | | |
248 | 258 | | |
249 | 259 | | |
250 | 260 | | |
251 | 261 | | |
252 | 262 | | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
253 | 268 | | |
254 | 269 | | |
255 | 270 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
441 | 441 | | |
442 | 442 | | |
443 | 443 | | |
444 | | - | |
| 444 | + | |
445 | 445 | | |
446 | 446 | | |
447 | 447 | | |
| |||
482 | 482 | | |
483 | 483 | | |
484 | 484 | | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
485 | 489 | | |
486 | 490 | | |
487 | 491 | | |
488 | 492 | | |
489 | 493 | | |
490 | | - | |
491 | | - | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
492 | 501 | | |
493 | 502 | | |
494 | 503 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5772 | 5772 | | |
5773 | 5773 | | |
5774 | 5774 | | |
5775 | | - | |
| 5775 | + | |
5776 | 5776 | | |
5777 | | - | |
| 5777 | + | |
5778 | 5778 | | |
5779 | 5779 | | |
5780 | 5780 | | |
| |||
5846 | 5846 | | |
5847 | 5847 | | |
5848 | 5848 | | |
| 5849 | + | |
| 5850 | + | |
| 5851 | + | |
| 5852 | + | |
| 5853 | + | |
| 5854 | + | |
| 5855 | + | |
| 5856 | + | |
| 5857 | + | |
| 5858 | + | |
| 5859 | + | |
| 5860 | + | |
| 5861 | + | |
| 5862 | + | |
5849 | 5863 | | |
5850 | 5864 | | |
5851 | 5865 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1354 | 1354 | | |
1355 | 1355 | | |
1356 | 1356 | | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
1357 | 1399 | | |
1358 | 1400 | | |
0 commit comments