Avoid ugly --rcfile lines in ps output by exploiting the fact that a
POSIX mode bash will read startup commands from the file specified in
ENV.
Set ENV and POSIXLY_CORRECT for startup, unsetting them and disabling
POSIX mode as the first actions in the new shell.
#!/bin/bash
file="${TMPDIR:-/tmp}/$SUDO_USER.became.$USER.$RANDOM.$$"
-( umask 077; cat > "$file"; echo "/bin/rm -f '$file'" >> "$file" )
-exec </dev/tty /bin/bash --rcfile "$file"
+( umask 077; echo "unset ENV POSIXLY_CORRECT; set +o posix" > "$file"; cat >> "$file"; echo "/bin/rm -f '$file'" >> "$file" )
+exec </dev/tty env ENV="$file" POSIXLY_CORRECT=1 /bin/bash
# Fall back to the shell.
exec </dev/tty /bin/bash
exit 111