Write anbspbashnbspscript to comment code blocks in


Write a bash script to comment code blocks in a bash source file. A bash comment is all characters from a # character (beginning a word) to the end of the line.

Conditions:

  • The source file will contain only printing characters, spaces, and newlines.
  • The source file will contain validbashcode. It is not necessary to check for invalid input.
  • The source file may contain nested blocks.
  • In the source file the keywords while until for case if done esac elif else fi 
    will be the first words on a line, will not be in comments, and will not be quoted.

Requirements:

  • Read from standard input, write to standard output.
  • At the end of any line containing while until for add the comment: # loop n 
    (n is a number, 1 for the first loop, 2 for the second loop, etc)
  • At the end of any line containing done add the comment: # loop n 
    (n is the number corresponding to the matching while until for )
  • At the end of any line containing if case add the comment: # selection n 
    (n is a number, 1 for the first selection, 2 for the second selection, etc)
  • At the end of any line containing fi esac add the comment: # selection n 
    (n is the number corresponding to the matching if case )

Include all of the following:

  • comments with your name, the date, and the assignment
  • comments with instructions for using the program
  • descriptive names and/or comments explaining variables & functions
  • indentation of code blocks
  • comments explaining any non-obvious control flow

Hints:

  • work on the simplest cases first
  • think about the structure of your data and logic before you write any code
  • start with the smallest possible amount of code
  • make sure your existing code works before adding new code
  • add the smallest possible amount of new code, then test again
  • output variable values, loop counts, etc. for debugging
  • test your code with a variety of inputs

Solution Preview :

Prepared by a verified Expert
Macroeconomics: Write anbspbashnbspscript to comment code blocks in
Reference No:- TGS01702345

Now Priced at $30 (50% Discount)

Recommended (93%)

Rated (4.5/5)