Deutsch   English   Français   Italiano  
<87msnw4ljk.fsf@bsb.me.uk>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!feeds.phibee-telecom.net!3.eu.feeder.erje.net!feeder.erje.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Ben Bacarisse <ben@bsb.me.uk>
Newsgroups: comp.lang.c
Subject: Re: Running an editor from ANSI C
Date: Fri, 07 Jun 2024 20:09:35 +0100
Organization: A noiseless patient Spider
Lines: 50
Message-ID: <87msnw4ljk.fsf@bsb.me.uk>
References: <v3pge7$uf2i$1@dont-email.me> <v3r2pl$16mtl$1@dont-email.me>
	<v3r7v8$1b57j$1@dont-email.me> <v3rek5$1c4i5$1@dont-email.me>
	<v3rrtm$1e6g8$1@dont-email.me> <v3ru84$1eafb$1@dont-email.me>
	<87o78dzw1a.fsf@nosuchdomain.example.com>
	<v3te2i$1ms1q$1@dont-email.me>
	<87frtpznoa.fsf@nosuchdomain.example.com>
	<v3uimm$20jte$3@dont-email.me>
	<871q59yty1.fsf@nosuchdomain.example.com>
	<v3v03l$22nnp$3@dont-email.me> <v3vhl0$25r3d$1@dont-email.me>
	<v3vkt6$265uv$3@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Fri, 07 Jun 2024 21:09:36 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="81bf2a31a00efc4cf649cb2a53df83a8";
	logging-data="2303981"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18AmwTO4QQ0BNylczzybQotbERFoSlmSOg="
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:B3eoQtg/l5QkB2rNX62Bt/MF+VY=
	sha1:7qkp4bWEHmZdAmD+vKqMyK3YHXA=
X-BSB-Auth: 1.d2dea22a9d60185061cd.20240607200935BST.87msnw4ljk.fsf@bsb.me.uk
Bytes: 3149

Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:

> On 07/06/2024 18:56, Janis Papanagnou wrote:
>> On 07.06.2024 14:57, Malcolm McLean wrote:
>>> On 07/06/2024 10:37, Keith Thompson wrote:
>>>> Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:
>>>>>
>>>>> Ah thank you. But then main has to take an extra parameter. Now  will
>>>>> the shell still be absolutely robust, and completely portable, and run
>>>>> just anywhere?
>>>>
>>>> What?  Why would main need an extra parameter?
>>>>
>>> Hre's the main function for the shell.
>>>
>>> int main(int argc, char **argv)
>>> {
>> [...]
>>> }
>>>
>>> Now to get the $EDITOR variable I will have to modify this function.
>>>
>>> int main(int argc, char **argv, char **envp)
>>>
>>> Now what are the implications of doing that? [...]
>> I'm certainly not the most qualified person to answer that, so
>> just two comments...
>> Declaring the extra parameter doesn't spoil the code, does it?
>> (If you don't use it you don't need to specify it. If you have
>> declared it you can use it or not.)
>> Personally my first reflex would be to use a dedicated function
>> to obtain a specific environment variable, specifically getenv();
>> I thought it wouldn't require the 'envp' to work?
>> For me it works
>>    #include <stdlib.h>
>>    #include <stdio.h>
>>    void main (int argc, char * argv[])
>>    {
>>        printf ("%s\t%s\n", argv[1], getenv(argv[1]));
>>    }
>> Janis
>> 
> Is getenv() standard now? When did it come in?

It was in the first C standard.  Basically it predates standardisation:

https://bsb.me.uk/ansi-c/ansi-c.html#sec_4_10_4_4

-- 
Ben.