> For the complete documentation index, see [llms.txt](https://serciiit.gitbook.io/introduction-to-software-systems/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://serciiit.gitbook.io/introduction-to-software-systems/lab-activities/shell-lab-2/untitled-1.md).

# Class Test Script

Please go through the following script and identify the defects

### UPDATE:&#x20;

There was an issue with the way the MS Forms was created. So we have updated the Key below.

### Question

```aspnet
!#/bash/bin
echo Please talk to me ...
while 
do
  read INPUT_STRING
  case INPUT_STRING 
        hello) echo "Hello yourself!" ;;
        bye)   echo "See you again!" break ;;
        #)     echo "Sorry, I don't understand" ;
  esac
echo
echo "That's all folks!"
```

### Corrected Script

```bash
#!/bin/bash
echo "Please talk to me ..."
while true
do
  read INPUT_STRING
  case $INPUT_STRING 
        hello) echo "Hello yourself!" ;;
        bye)   echo "See you again!" break ;;
        *)     echo "Sorry, I don't understand" ;;
  esac
echo
echo "That's all folks!"
```

### Key

Highlighted responses are correct

Q1: Which of the following are correct for the provided Bash Script?&#x20;

* Line 1: !#/bash/bin - *This is incorrect - It should be #!/bin/bash*
* **Line 2: echo Please talk to me ... -&#x20;*****This is correct***&#x20;
* Line 3: while - *This is incorrect - it should as per the above solution to let the WHILE loop run*
* **Line 5: read INPUT\_STRING -&#x20;*****This is correct***

Q2: Which of the following are incorrect in provided Bash Script?

* **Line 1: !#/bash/bin -&#x20;*****This is incorrect - It should be #!/bin/bash***
* Line 2: echo Please talk to me ... - *This is correct*&#x20;
* **Line 3: while -&#x20;*****This is incorrect - it should as per the above solution to let the WHILE loop run***
* Line 5: read INPUT\_STRING - *This is correct*

Q3: Which of the following are missing in the provided Bash Script?

* **Line 11: done  -&#x20;*****As it is required to end the WHILE loop***
* **Line 6: case $INPUTSTRING in&#x20;*****- As we need to read the value of INPUT\_STRING in case***
* Line 5: echo - It is not required as it doesn't matter if echo existed or not. So it is not considered missing.
* None of the Above - Obviously not an answer here.

Q4: Which of the following is true for Line 9?

* **should be replaced by \***
* **The line should end with ;;**
* **\*) echo "Sorry, I don't understand" ;; - is the correct final replacement**
* None of the above - Obviously not an answer here.

Q5: Which of the following correct in regards to the provided Bash Script?

* The script takes in an input from console and responds based on CASE statements and repeated in WHILE loop
* The scripts takes in an input from console and responds only based on WHILE loop
* **The script is completely incorrect and does nothing**
* None of the options are correct
