Faculty of Engineering and Mathematical Sciences 
Not logged in (login)

help4407


This forum is provided to promote discussion amongst students enrolled in Open Source Tools and Scripting (CITS4407).
 
Options:
RSS cloud
Jump to:

lec # wk 10 File Attributes - Square Bracket command external or internal

1 of 390 articles shown, currently no other people reading this forum.
photo
From: Christopher M.
Date: Wed 10th Jun 2020, 3:28pm
Actions: 
        Login-to-reply

 

"Lee de Byl" <10*0*8*[email protected]*u*e*t*u*a*e*u*a*> wrote:

> Thanks for the historical context on Unix 6. I might have to do some reading on how the mechanism worked.

I hadn't seen them before, but that webpage provides the source code of some of those external commands.
All in C, but they reveal how it all worked.

 
> I appreciate that external commands can't change the environment of the parent shell, but I was wondering if 
> there's a fundamental reason why this design was put in place? Is it just that there's no real need to do so in 
> practical usage, or could it cause other problems?

When one (parent) process spawns another (child) process, both continue their execution, unless one blocks to wait for the 
other.  Normally the parent waits for the child to finish - we see this as the default action in the shell, unless we 
explicitly place the child process in the background:   command &

If (any) child process *could* alter the environment of its parent, it could be a bit of a nightmare.
Imagine if you'd written a program, it's executing, and suddenly one of your child processes changes *your* current working 
directory;  suddenly you start creating files in 'random' places, or the 'local' files you wished to open are no longer 
there.


 
> It seems to me that setting environment variables and making them predictably persistent across a system seems 
> to be a bit of a hassle. In your opinion, is there potentially a better way?

It two parent+child processes do wish to communicate, there's a number of mechanisms for them to do so - such as pipes, 
same-computer networking, shared memory, first-in-first-out files.  Knowing that your child process wants to communicate 
with you is great, and workable, but knowing that *any* process you spawn could change your state without prior agreement, 
would make life very difficult for programmers.

Related articles

lec # wk 10 File Attributes - Square Bracket command external or internal (all 14) RSS
├─ original   Tue 9th Jun 2020, 11:15am, Alastair H.
├─ reply 1   Tue 9th Jun 2020, 4:26pm, David M.
├─ reply 2   Tue 9th Jun 2020, 4:36pm, David M.
├─ reply 3   Tue 9th Jun 2020, 5:15pm, Christopher M.
├─ reply 4   Tue 9th Jun 2020, 5:26pm, David M.
├─ reply 5   Tue 9th Jun 2020, 7:50pm, Lee dB.
├─ reply 6   Tue 9th Jun 2020, 9:01pm, Alastair H.  O.P.
├─ reply 7   Wed 10th Jun 2020, 4:11am, Christopher M.
├─ reply 8   Wed 10th Jun 2020, 4:12am, Christopher M.
├─ reply 9   Wed 10th Jun 2020, 9:33am, Lee dB.
├─ THIS   Wed 10th Jun 2020, 3:28pm, Christopher M.
├─ reply 11   Wed 10th Jun 2020, 6:39pm, Lee dB.
├─ reply 12   Fri 12th Jun 2020, 3:51am, Christopher M.
└─ reply 13   Fri 12th Jun 2020, 10:31am, Lee dB.
This Page


Program written by: [email protected]
Feedback welcome
Last modified: 11:27am Sep 21 2020