Set PWD to readonly v1 PROPOSED

Drew DeVault: 1
 Set PWD to readonly

 1 files changed, 5 insertions(+), 1 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~emersion/mrsh-dev/patches/4819/mbox | git am -3
Learn more about email & git

[PATCH] Set PWD to readonly Export this patch

This is the first of several patches which will be necessary to make
$PWD POSIX-complaint.

>Assignments to this variable may be ignored. If an application sets or
>unsets the value of PWD, the behaviors of the cd and pwd utilities are

An argument could be made for aborting the shell when PWD is set, or
tainting the shell and aborting later if cd/pwd is called again.
 shell/entry.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/shell/entry.c b/shell/entry.c
index 6b42d0c..d2f3c71 100644
--- a/shell/entry.c
+++ b/shell/entry.c
@@ -79,7 +79,11 @@ bool mrsh_populate_env(struct mrsh_state *state, char **environ) {
			fprintf(stderr, "getcwd failed: %s\n", strerror(errno));
			return false;
		mrsh_env_set(state, "PWD", cwd, MRSH_VAR_ATTRIB_EXPORT);
		mrsh_env_set(state, "PWD", cwd,
	} else {
		mrsh_env_set(state, "PWD", pwd,

	mrsh_env_set(state, "OPTIND", "1", MRSH_VAR_ATTRIB_NONE);
View this thread in the archives