3 # Script to rename DLL name within side deck.
6 # Stops execution if a command or pipeline has an error.
14 printf "ERROR: %s\n" "$*"
20 Usage: $(basename $0) <side deck file> <old dll name> <new dll name>:
21 [-h|--help] Display this help and exit.
25 rename_dll_name_inside_side_deck
() {
27 if [[ -z "$sidedeck" ||
-z "$old_dll_name" ||
-z "$new_dll_name" ]]; then
29 error
"All 3 parameters must be specified."
32 [[ -f "$sidedeck" ]] || error
"The '$sidedeck' file must exists."
34 old_len
=${#old_dll_name}
35 new_len
=${#new_dll_name}
37 if (( $new_len > $old_len )); then
38 error
"New DLL name $new_dll_name must have $old_len characters or less."
41 if ((padding_len
=$old_len-$new_len )); then
42 pad
=$
(printf "%*s" $padding_len "")
45 # Touch the temp. file and set the tag to 1047 first so the redirecting statement
46 # will write in 1047 and not 819 encoding.
47 touch $sidedeck.tmp
; chtag
-tc1047 $sidedeck.tmp
48 sed "/ IMPORT /s/'$old_dll_name/$pad'$new_dll_name/g" $sidedeck > $sidedeck.tmp
49 mv $sidedeck.tmp
$sidedeck
53 rename_dll_name_inside_side_deck