A bad thing about ALFS in c

Fabio Fracassi turiya at linuxfromscratch.org
Wed Nov 7 01:14:19 PST 2001

On Tuesday 06 November 2001 17:40, Felipe Contreras wrote:
> On Tue, Nov 06, 2001 at 02:19:07AM -0800, John Schmerge wrote:
> > void
> > doStuff(void)
> > {
> > 	putenv("LFS=/mnt/lfs");
> > 	system("cd $LFS; ls");
> > }
> Yes that can also be done, but what if "cd $LFS" fails, how do you know
> what command fails? What if I want display each command while it's
> executing. In that case it should be:
> void
> doStuff(void)
> {
>         char *lfs;
> 	putenv("LFS=/mnt/lfs");
> 	lfs=getenv("LFS");
> 	chdir(lfs);
> 	system("ls");
> }
> That should work for most purposes of "chdir" and "export" but then what
> if I some script needs bash substitution? For example "export
> tmp=${LFS%/*}". Or what if there are some other commands that alter the
> environment? Things go harder and harder, just because the commands of a
> shell script need to run on the same shell, just as if you were
> executing it. Unfortunately there is no easy way to interact with bash
> nicely.

I think your aproch is a little bit of ways (sorry if I'm wrong, I cant 
remember the whole thread, just my impression.)
It looks as if you are always searching for a way to do things you want to
do with the shell in C. In this case C is of course the looser.
It would be better to "think in C" from the beginning.
Like the shell substitutions, you would use std C lib String and 
File/Directory access Functions. 

> Might be I'm thinking too much, but I just think it's much easier to run
> shell scripts with bash than with c, 

Of course.

> and the easiest way to install a
> package is by runing shell scripts. I'm pretty sure there can a lot of
> ways to do it, I just think simple is better.

<Philosophy> The simple path is not always the best </Philosophy>


Unsubscribe: send email to listar at linuxfromscratch.org
and put 'unsubscribe alfs-discuss' in the subject header of the message

More information about the alfs-discuss mailing list