rev_args.sh -- bourne shell version rev_args_bash.sh -- bash version rev_args.ksh -- ksh version
$ rev_args arg1 'argument two' arg3 arg3 argument two arg1 $
$ ./rev_args -q "multi word arg" hi there "'tis good" ''"'"'tis good' 'there' 'hi' 'multi word arg' $with the appropriate quoting so that the output can be passed to the following showargs script :
$ cat ~/bin/showargs #!/bin/sh echo "There are $# args" for i do printf '%s\n' "$i" done $by an eval:
$ eval ./showargs $(./rev_args -q "multi word arg" hi there "'tis good") There are 4 args 'tis good there hi multi word arg $(Note that the $(...) construct is the same as the backquote that I mentioned in class. The $(...) construct is a bash extension, which makes nesting of backquoted commands easier.)
Good test cases:
$ ./rev_args.sh -q "'tis a cruel world" "ain't it?" sure thang -n '-n' 'thang' 'sure' 'ain'"'"'t it?' ''"'"'tis a cruel world' $ ./rev_args.sh "'tis a cruel world" "ain't it?" sure thang -n -n thang sure ain't it? 'tis a cruel world $ ./rev_args.sh -q -- -q -n -q -n '-n' '-q' '-n' '-q' $ ./rev_args.ksh -- sometimes -q means just -q -q just means -q sometimesNote: I did not ask for you to implement the common idiom of using "--" to indicate the end of command flags processing. You don't have to implement it, but it is a good idea. Without it, there is no way to do the following:
$ ./rev_args.sh -- -q means quoting quoting means -q $
Also, think about the difference between the following two commands:
$ eval ./showargs `./rev_args.sh -q "'tis a shame" foo bar "ain't so hard"` There are 4 args ain't so hard bar foo 'tis a shame $ eval ./showargs "`./rev_args.sh -q "'tis a shame" foo bar "ain't so hard"`" There are 4 args ain't so hard bar foo 'tis a shame $
38 students handed in assignment 3. assignment 3 as a whole: mean 75.2368 stdev 28.5615 w/o late adjustment: mean 75.2368 stdev 28.5615 Excluding all-zero scores: assignment 3 as a whole: mean 81.6857 stdev 18.9447 w/o late adjustment: mean 81.6857 stdev 18.9447 Per-problem statistics: Num 1: mean 9.026316 stdev 2.869869 Num 2: mean 7.000000 stdev 4.198997 Num 3: mean 7.947368 stdev 3.986473 Num 4: mean 5.447368 stdev 3.904770 Num 5: mean 6.421053 stdev 4.705157 Num 6: mean 9.000000 stdev 2.928984 Num 7: mean 7.684211 stdev 3.907518 Num 8: mean 7.736842 stdev 3.843547 Num 9: mean 8.578947 stdev 3.305749 Num 10: mean 6.394737 stdev 4.088105 Per-problem statistics, omitting zero grades: Num 1: mean 9.800000 stdev 1.166190 Num 2: mean 8.060606 stdev 3.428397 Num 3: mean 9.741935 stdev 1.413478 Num 4: mean 6.088235 stdev 3.624814 Num 5: mean 9.384615 stdev 2.131755 Num 6: mean 9.771429 stdev 1.332789 Num 7: mean 8.588235 stdev 3.049760 Num 8: mean 8.647059 stdev 2.939411 Num 9: mean 9.314286 stdev 2.239533 Num 10: mean 6.942857 stdev 3.786765The grade distribution is:
The test cases and the program used to test your script can be found in /home/solaris/ieng9/cs190e/public/assn3/
bsy+cse190.s00@cs.ucsd.edu, last updated
email bsy.