help-bash
[Top][All Lists]
Advanced

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

Re: access exported var


From: Matthew Mueller
Subject: Re: access exported var
Date: Mon, 16 Jan 2023 18:30:26 +0000 (UTC)

Why am I receiving these emails? I know nothing about code and programming. 
While I feel like my accounts and devices are compromised from hackers. 
Receiving these emails are worrying.


Sent from Yahoo Mail for iPhone


On Monday, January 16, 2023, 12:00 AM, Peng Yu <pengyu.ut@gmail.com> wrote:

On 1/15/23, Kerin Millar <kfm@plushkava.net> wrote:
> On Sun, 15 Jan 2023 23:10:41 -0600
> Peng Yu <pengyu.ut@gmail.com> wrote:
>
>> I use the following C code to check env var.
>>
>> #include <stdlib.h>
>> #include <stdio.h>
>>
>> int main(int argc, char *argv[]) {
>>  const char *s=getenv(argv[1]);
>>  puts(s);
>>  return 0;
>> }
>>
>> The results are different depending on whether the variable is a
>> scalar or an array (the result is always null). Why is it so? Why even
>> in the last case, "a" of the first element of the array cannot be
>> retrieved?
>
> Bash cannot export arrays. It's not particularly surprising. The value of an
> environment variable is a NUL-terminated string; there's no universally safe
> delimiter that could be used to join the array's elements.

But `echo "$Z"` print "a". Why bash can not treat exporting array as
exporting the first element?

-- 
Regards,
Peng





reply via email to

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