A bad thing about ALFS in c

Felipe Contreras al593181 at mail.mty.itesm.mx
Mon Nov 5 18:41:52 PST 2001

On Mon, Nov 05, 2001 at 04:14:27PM -0800, John Schmerge wrote:
> Why not just use system(3) ?

Let's supose you want to execute this.

	export LFS=/mnt/lfs
	cd $LFS

If you run each command in a separated system() call, then each of them
will be executed in a subshell, so in the second system command the
environment variable LFS will be cleared, also on the third command the
working directory will be the same as where you started before the cd
$LFS command. So the commands are not executed on the same shell.

If you run the commands as a whole in the same subshell then if it fails
you can't know on which command the shell failed. Let's suppose 'cd
$LFS' exited with an error because that directory didn't existed. So
with system you can't really interact with the shell, just tell what to

Felipe Contreras
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