#!/bin/csh ############################################################### # This script will parse the name of the directory from which # the files will be played. The name is supposed to start # in the 'cds' directory. If it is of the form: # 1/a/f: It reports '1.wav firsta.wav secondf.wav' # 1/a: It reports '1.wav onlya.wav' # 1: It reports 'only1.wav' # by_id/ID: It reports 'uncataloged_cd.wav' # /tmp/XXX: It reports 'uncataloged_cd.wav' # all/XXX: It reports 'all.wav' # The idea is to use this to produce a set of command-line # arguments to send to the musicbox_interrupt_to_say.txt # script. # # It returns 0 on success and 1 on failure. ############################################################## ############################################################## # Extract the parts of the name from between slashes. set dirname = "$1" set first_element = `echo $1 | cut -s -f 1 -d/` set second_element = `echo $1 | cut -s -f 2 -d/` set third_element = `echo $1 | cut -s -f 3 -d/` ############################################################## # If this is the all directory then say so if ( "$first_element" == all ) then echo all.wav exit 0 endif ############################################################## # If this is the by_id directory then the # record's ID is unknown if ( "$first_element" == by_id ) then echo uncataloged_cd.wav exit 0 endif ############################################################## # If the directory is in /tmp, then the # record's ID is unknown if ( "$second_element" == tmp ) then echo uncataloged_cd.wav exit 0 endif ############################################################## # If the name has three parts, then report each part in turn, # using the first style of letter for the middle element and # the second style for the third. There are different styles # because people say letters differently when they are strung # together than when they are not; also, when they are in # different parts of the string. # 1/a/f: It reports '1.wav firsta.wav secondf.wav' if ( `echo -n $third_element | wc -c` > 0 ) then echo "$first_element".wav "first$second_element".wav "second$third_element".wav exit 0 endif ############################################################## # If the name has two parts, then report each part in turn: # 1/a: It reports '1.wav onlya.wav' if ( `echo -n $second_element | wc -c` > 0 ) then echo "$first_element".wav "only$second_element".wav exit 0 endif ############################################################## # If the name has one part (there will be no slash), then report: # 1: It reports 'only1.wav' if ( `echo -n $dirname | wc -c` > 0 ) then echo "only$dirname".wav exit 0 endif ############################################################## # Never heard of it... the name is empty! exit 1