1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

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.
This commit is contained in:
Johnothan King 2021-12-05 21:48:32 -08:00 committed by Martijn Dekker
parent a3f4b5efd1
commit cd8c48cc5a
5 changed files with 111 additions and 25 deletions

6
NEWS
View file

@ -8,6 +8,12 @@ Any uppercase BUG_* names are modernish shell bug IDs.
- Fixed an issue on illumos that caused some parameters in the getconf
builtin to fail.
- The cd built-in command now supports a -e option (as specified in
https://www.austingroupbugs.net/view.php?id=253). Passing -e alongside -P
is used to guarantee the cd built-in returns with exit status 1 if the
current working directory couldn't be determined after successfully changing
the directory.
2021-12-01:
- Fixed a memory fault that occurred when a discipline function exited