Question: 2. is_valid_pkg.sh The unqualified name of a Java package should obey the following rules: the first character of the name must be a lowercase English
2. is_valid_pkg.sh
The unqualified name of a Java package should obey the following rules:
- the first character of the name must be a lowercase English letter
- all other characters of the name must be a lowercase English letter, a digit, or an underscore _ character
(The fully qualified name of a package is made up of unqualified package names separated by ., but this question does not deal with fully qualified package names)
Write a script named is_valid_pkg.sh requiring exactly one command line argument that is taken to be a possible package name. The script sets its exit status to 0 if the command line argument is a valid unqualified package name, otherwise it sets its exit status to 1.
Error checking:If the number of command line arguments is not equal to one, then the script prints an error message to standard error and exits with a status of 2.
Examples (comments indicate the expected output and are not part of the command):
is_valid_pkg.sh util; echo $? # 0
is_valid_pkg.sh big_hero6; echo $? # 0
is_valid_pkg.sh "cisc_124"; echo $? # 0
is_valid_pkg.sh Util; echo $? # 1
is_valid_pkg.sh 7up; echo $? # 1
is_valid_pkg.sh "cisc 124"; echo $? # 1
answer bash please
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
