[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:37:47 +0100 |
an invalid shell env name checker
c() { [[ $2 != [_a-zA-Z]*([_a-zA-Z0-9])=* ]] && printf %s\\n "$2" ; }
f() ( cat &>/dev/null /proc/self/cmdline & kill -STOP $! ; mapfile -d '' -c
1 -C c m < /proc/$!/environ ; kill -CONT $! )
f
On Mon, Feb 12, 2024, 09:06 alex xmb sw ratchev <fxmbsw7@gmail.com> wrote:
> 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.
>>
>>
Re: why does </proc/self/environ not work in bash?, Lawrence Velázquez, 2024/02/11
Re: why does </proc/self/environ not work in bash?, Kerin Millar, 2024/02/11
Re: why does </proc/self/environ not work in bash?, Christoph Anton Mitterer, 2024/02/11
Re: why does </proc/self/environ not work in bash?, Christoph Anton Mitterer, 2024/02/11
Re: why does </proc/self/environ not work in bash?, Chet Ramey, 2024/02/12
Re: why does </proc/self/environ not work in bash?, Christoph Anton Mitterer, 2024/02/12
Re: why does </proc/self/environ not work in bash?, Lawrence Velázquez, 2024/02/12
Re: why does </proc/self/environ not work in bash?, Chet Ramey, 2024/02/13
Re: why does </proc/self/environ not work in bash?, Chet Ramey, 2024/02/13
Re: why does </proc/self/environ not work in bash?, Kerin Millar, 2024/02/11
Re: why does </proc/self/environ not work in bash?, Christoph Anton Mitterer, 2024/02/11
Re: why does </proc/self/environ not work in bash?, Greg Wooledge, 2024/02/11