Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

For the final scripting assignment in CSE 15L, you will be writing your own 14 # implementation of the `gethw` script that you have been using this

For the final scripting assignment in CSE 15L, you will be writing your own

 14 # implementation of the `gethw` script that you have been using this quarter.

 15 #

 16 # You should be fairly familiar with what the script does, But just to bring

 17 # everyone on the same page, here are some expected behaviors of your script

 18 # upon different use cases:

 19 #

 20 #

 1. Script usage error

 22 #

 23 #  Your script takes exactly one positional parameter. If a user passes in

 24 #  incorrect number of parameters, print the following usage message and exit

 25 #  the script with code 1.

    USAGE="Usage: ./my_gethw [hw-name]"

2. Invalid homework error

 30 #

 31 #  Your script takes in the name of the homework as its only parameter. Your

 32 #  script should look at the public `homework` directory to see if homeowrk

 33 #  directory of the same name can be found. If the user has passed in a

 34 #  homework name that does not match any directory inside public `homework`,

 35 #  print the following error message and exit the script with code 1.

    EINVALID="Invalid homework: $1"

3. Retrieving valid homework for the first time

 40 #

 41 #  If the parameter turns out to be valid, and that the homework does not

 42 #  already exist inside your home directory, simply go ahead and copy the

 43 #  entire homeworking directory matching the specified name under `~/homework`

 44 #  and print the following message once it's done.

    SUCCESS="Done. Navigate to `~/homework/$1` to get started."

 4. Confirm overwrite

 49 #

 50 #  In case the user forgot that the homework is already half way done, it

 51 #  would be very upsetting if the `gethw` script simply copies a fresh set

 52 #  of empty homework files and overwrites the existing ones. To prevent such

 53 #  incident from happening, if a user specifies a homework name that already

 54 #  exists under `~/homework/`, prompt the user for each individual file

 55 #  inside the homework directory to ask for confirmation whether the user

 56 #  wants the this file to be overwritten by a fresh copy. Use the following

 57 #  strings to for user interaction.

    PROMPT="$file already exists. Overwrite? (y/N) "

    ABORT="Skipping $file."

 62 #  Notice that the 'N' is capitalized, which means that the response is

 63 #  negative by default -- unless the user either enters 'y' or 'Y'. (We won't

 64 #  be testing any response other than upper and lower case 'n' and 'y', but we

 65 #  will be testing on empty response where the user simply hits "enter"

 66 #  without any input. In this case, your script should treat it as negative.

 USEFUL TIPS

 71 #===============================================================================

 72 #

 73 # 1. To access both public and home directory, use defined environment variables

 74 #  `$PUBLIC` and `$HOME` (or tilde `~`) instead of hard coding the absolute

 75 #  path -- we can't grade you if you hard code it.

 76 #

 77 # 2. You may find the command `read` useful when prompting the user. Read its

 78 #  man page to best utilize what it can do for you.

 79 #

 80 #  (No pun intended)

 81 #

 82 # 3. For reference, you can always run your script against the `gethw` command

 83 #  on various test cases. We won't be testing beyond what was covered in the

 84 #  "INSTRUCTIONS" section of the write-up.

 85 #

 86 #

 87 #===============================================================================

 88 # CODE STARTS BELOW -- HAVE FUN

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question