Liste des Groupes | Revenir à cl c |
On 07/06/2024 18:56, Janis Papanagnou wrote:C11, I think.On 07.06.2024 14:57, Malcolm McLean wrote:Is getenv() standard now? When did it come in?On 07/06/2024 10:37, Keith Thompson wrote:[...]Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:Hre's the main function for the shell.>>
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?
>
>
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
>
Les messages affichés proviennent d'usenet.