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: alex xmb sw ratchev
Subject: Re: why does </proc/self/environ not work in bash?
Date: Mon, 12 Feb 2024 09:06:12 +0100

i dont get it all , with invalid env names
ah thats why , env

i tried get /environ and it worked
no idea if this matches any interest of this thread

f() ( cat /proc/self/cmdline & kill -STOP $! ; cat /proc/$!/environ ; kill
-CONT $! ) ; f

On Mon, Feb 12, 2024, 00:13 Greg Wooledge <greg@wooledge.org> wrote:

> 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]