Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

STION 9 Changes which then parent makes to the environment after the child is cr

ID: 3905220 • Letter: S

Question

STION 9

Changes which then parent makes to the environment after the child is created, do not effect the child's environment.

True

False

2 points   

QUESTION 10

Given the scripts inner and outer that are both executable and exist in the same directory.

The script inner:

#!/bin/sh
echo $#
exit

The script outer:

#!/bin/sh

./inner $*
./inner $@
./inner "$*"
./inner "$@"
exit

and the command line


./outer " " A

which of the following statements are true? There is a space between the double quotes.

The value of $# in outer is 2

The value of $# in outer is 1

The value of $# in inner when called from outer with the argument $* is 1

A & B

A & C

a.

The value of $# in outer is 2

b.

The value of $# in outer is 1

c.

The value of $# in inner when called from outer with the argument $* is 1

d.

A & B

e.

A & C

Explanation / Answer

9. b) True

When fork()is called,Child process inherits a copy of the parent's environment.

Any after changes to the environment in child or parent process do not affect the other.

10. e)A and C

$# represents the number of arguments passed to program

Inner:

#!/bin/sh

echo $#

exit

Outer:

#!/bin/sh

./inner $*

./inner $@

./inner "$*"

./inner "$@"

exit

./outer " " A

There are no difference between $* and $@

$* and $@ contains all command line arguments

./outer " " A

It passed 2 arguments to outer shell file

so $# :which is number of argument is 2 . So option A is correct

$# in inner while called is 1 since we are passing $* as one argument which contains ("" ,A ) arguments