help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: why does </proc/self/environ not work in bash?


From: Greg Wooledge
Subject: Re: why does </proc/self/environ not work in bash?
Date: Sun, 11 Feb 2024 18:13:23 -0500

On Sun, Feb 11, 2024 at 11:57:31PM +0100, Christoph Anton Mitterer wrote:
> What I basically do is, making a check, whether the current /bin/sh
> would export any variables in its own environment, that are not valid
> shell names, into executed utilities.

OK, then simply do that.


env - GOOD=valid B+A-D=invalid PATH="$PATH" sh -c env | grep valid


Here's what I get on Debian 12 (with sh -> dash):

unicorn:~$ env - GOOD=valid B+A-D=invalid PATH="$PATH" sh -c env | grep valid
GOOD=valid
unicorn:~$ env - GOOD=valid B+A-D=invalid PATH="$PATH" bash -c env | grep valid
B+A-D=invalid
GOOD=valid

There's no need for /proc shenanigans here.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]