From d002967908118df1de1290042e8a06e10567c4c2 Mon Sep 17 00:00:00 2001 From: chase Date: Sat, 25 Aug 2018 23:03:02 -0500 Subject: [PATCH] dtprintegrate: fix shellcheck warnings --- cde/programs/dtprintegrate/dtlp.src | 492 +++++++++---------- cde/programs/dtprintegrate/dtlpsetup.src | 50 +- cde/programs/dtprintegrate/dtprintegrate.src | 127 +++-- 3 files changed, 321 insertions(+), 348 deletions(-) diff --git a/cde/programs/dtprintegrate/dtlp.src b/cde/programs/dtprintegrate/dtlp.src index c930a093..45895e1f 100755 --- a/cde/programs/dtprintegrate/dtlp.src +++ b/cde/programs/dtprintegrate/dtlp.src @@ -65,7 +65,6 @@ XCOMM Exit/Return codes XCOMM CANCEL_EXIT=-1 SUCCESS=0 -NO_PRINT_MESSAGE=1 USAGE_EXIT=2 NO_FILE_ERR=3 NO_INIT_FILE_ERR=4 @@ -81,8 +80,6 @@ NOT_POS_INTEGER=12 XCOMM XCOMM For string processing XCOMM -DOUBLE_QUOTE=\" -SINGLE_QUOTE=\' MINUS_T="-t" XCOMM ################################################################# @@ -116,7 +113,6 @@ Initialize() other_options_flag=0 other_options="" - print_command_flag=0 print_command=lp print_cwd_flag=0 @@ -125,13 +121,11 @@ Initialize() HASH HASH Assume print file is stdin, unless told otherwise... HASH - print_file_flag=1 print_file="-" print_page_allowed=1 print_man_flag=0 - print_man="" printer_name_flag=0 printer_name="" @@ -145,7 +139,6 @@ Initialize() silent_flag=0 test_flag=0 - test_output_file="" verbose_flag=0 @@ -223,7 +216,6 @@ SetPreEnvironment() if (( ${#DTPRINTTESTOUTPUT} )) then - test_output_file=$DTPRINTTESTOUTPUT test_flag=1 fi @@ -243,7 +235,7 @@ ReconcileOptions() HASH HASH The RAW option takes precedence over all others. HASH - if (( $print_raw_flag )) + if (( print_raw_flag )) then format_flag=0 print_man_flag=0 @@ -252,7 +244,7 @@ ReconcileOptions() HASH HASH Next, this MAN option comes into play HASH - elif (( $print_man_flag )) + elif (( print_man_flag )) then format_flag=0 print_page_allowed=0 @@ -272,17 +264,17 @@ DoParameterCollectionSilent() HASH printer_name has to be set at this point so no need to check LPOPTIONS=-d${printer_name} - if (( $banner_title_flag )) + if (( banner_title_flag )) then LPOPTIONS=${LPOPTIONS}" "${MINUS_T}${SINGLE_QUOTE}${banner_title}${SINGLE_QUOTE} fi - if (( $copy_count_flag )) + if (( copy_count_flag )) then LPOPTIONS=${LPOPTIONS}" -n${copy_count}" fi - if (( $other_options_flag )) + if (( other_options_flag )) then LPOPTIONS=${LPOPTIONS}" ${other_options}" fi @@ -292,9 +284,9 @@ DoParameterCollectionSilent() LPOPTIONS=${LPOPTIONS}" -m" fi - if (( $verbose_flag )) + if (( verbose_flag )) then - echo Print Command is $print_command and Options are $LPOPTIONS + echo "Print Command is $print_command and Options are $LPOPTIONS" fi } @@ -310,45 +302,45 @@ XCOMM ## XCOMM ################################################################# EchoDtlpSetupOptions() { - if (( $remove_flag )) + if (( remove_flag )) then echo Remove file flag is SET. fi - if (( $print_man_flag )) + if (( print_man_flag )) then echo Manpage flag is SET. fi - if (( $print_raw_flag )) + if (( print_raw_flag )) then echo Raw print flag is SET. fi - if (( $print_cwd_flag )) + if (( print_cwd_flag )) then - echo Print working directory is $print_cwd. + echo "Print working directory is $print_cwd." fi - if (( $print_page_allowed )) + if (( print_page_allowed )) then echo Page printing is allowed. else echo Page printing is NOT allowed. fi - if (( $format_flag )) + if (( format_flag )) then echo Format flag is SET. fi - if (( $silent_flag )) + if (( silent_flag )) then echo Silent flag is SET. fi - if (( $user_filename_flag )) + if (( user_filename_flag )) then echo User-visible filename is \"$user_filename\". fi - if (( $verbose_flag )) + if (( verbose_flag )) then echo Verbose flag is SET. fi - if (( $other_options_flag )) + if (( other_options_flag )) then echo Other options include \"$other_options\". fi @@ -368,12 +360,12 @@ XCOMM ## If possible, log the results. XCOMM ################################################################# PrintIt() { - if (( $print_cwd_flag )) && [[ (-d "$print_cwd") && (-x "$print_cwd") ]] + if (( print_cwd_flag )) && [[ (-d "$print_cwd") && (-x "$print_cwd") ]] then - cd $print_cwd + cd "$print_cwd" || exit fi - if (( $test_flag )) + if (( test_flag )) then HASH then don't do any printing--instead log the results EchoDtlpSetupOptions @@ -384,19 +376,19 @@ PrintIt() INVOKER='eval' fi - if (( $print_raw_flag )) + if (( print_raw_flag )) then HASH Nothing special is required for raw mode on this platform. LPOPTIONS="${LPOPTIONS}" fi - if (( $format_flag )) + if (( format_flag )) then HASH set page header - if (( $banner_title_flag )) + if (( banner_title_flag )) then PAGEHEADER="$banner_title" - elif (( $user_filename_flag )) + elif (( user_filename_flag )) then PAGEHEADER="$user_filename" else @@ -404,7 +396,7 @@ PrintIt() fi $INVOKER "cat $print_file | pr -f -h '${PAGEHEADER}' | ${print_command} ${LPOPTIONS}" - elif (( $print_man_flag )) + elif (( print_man_flag )) then $INVOKER "cat $print_file | tbl | nroff -man | col | ${print_command} ${LPOPTIONS}" @@ -425,12 +417,12 @@ XCOMM ## End the show XCOMM ################################################################# CleanUp() { - if (( $remove_flag )) && [[ "$print_file" != "-" ]] + if (( remove_flag )) && [[ "$print_file" != "-" ]] then rm -f $print_file >/dev/null 2>&1 fi - if (( $verbose_flag )) + if (( verbose_flag )) then PrintEndLog fi @@ -475,7 +467,7 @@ XCOMM ## Returns true or false. XCOMM ################################################################# CheckValidPrinter() { - catgets CAT_MESG_STRING $CAT_ID 1 10 "Default" + catgets CAT_MESG_STRING "$CAT_ID" 1 10 "Default" if [[ "$printer_name" = "" ]] then @@ -485,7 +477,7 @@ CheckValidPrinter() if [[ "$printer_name" = "$CAT_MESG_STRING" ]] then GetDefaultPrinter - if (( $failure_flag == $SUCCESS )) + if (( failure_flag == SUCCESS )) then printer_name=$default_printer else @@ -494,35 +486,33 @@ CheckValidPrinter() fi tmpfile=$DTLPDIR/$printer_name$$ - LANG=C lpstat -p$printer_name > $tmpfile 2>&1 - if [[ $? != $SUCCESS ]] + LANG=C lpstat -p"$printer_name" > "$tmpfile" 2>&1 + if [[ $? != "$SUCCESS" ]] then HASH printer does not exist failure_flag=$PRINTER_DOES_NOT_EXIST - rm -f $tmpfile + rm -f "$tmpfile" return $failure_flag else - grep disabled $tmpfile > /dev/null 2>&1 - if [ $? -eq 0 ] + if grep disabled "$tmpfile" > /dev/null 2>&1 then failure_flag=$PRINTER_NOT_ENABLED - rm -f $tmpfile + rm -f "$tmpfile" return $failure_flag else status=$DTLPDIR/status$$ - LANG=C lpstat -a > $tmpfile 2>&1 - grep $printer_name $tmpfile > $status 2>&1 - grep "not accepting" $status > /dev/null 2>&1 - if [ $? -eq 0 ] + LANG=C lpstat -a > "$tmpfile" 2>&1 + grep "$printer_name" "$tmpfile" > "$status" 2>&1 + if grep "not accepting" "$status" > /dev/null 2>&1 then failure_flag=$PRINTER_NOT_ACCEPT_REQ - rm -f $status + rm -f "$status" return $failure_flag fi - rm -f $status + rm -f "$status" fi fi - rm -f $tmpfile + rm -f "$tmpfile" failure_flag=$SUCCESS return $failure_flag @@ -554,16 +544,16 @@ GetDefaultPrinter() #if defined(_AIX) t1="`LANG=C lpstat -d | head -3 | tail -1`" #else - t1="`LANG=C lpstat -d`" + t1="$(LANG=C lpstat -d)" #endif - t2="`echo $t1 | cut -d' ' -f1`" + t2="$(echo "$t1" | cut -d' ' -f1)" HASH HASH "no system default destination" is expected if no default is defined; HASH otherwise, "system default destination: " is expected. HASH if [[ "$t2" != "no" ]] then - default_printer="`echo $t1 | cut -f$prfld -d"$flddelim"`" + default_printer="$(echo "$t1" | cut -f"$prfld" -d"$flddelim")" HASH remove leading space default_printer=${default_printer##+( )} fi @@ -621,9 +611,9 @@ XCOMM ## XCOMM ################################################################# GetErrorMessageString() { - catgets CAT_MESG_STRING $CAT_ID 1 130 "Sorry--Unable to print:" + catgets CAT_MESG_STRING "$CAT_ID" 1 130 "Sorry--Unable to print:" - if (( $user_filename_flag )) + if (( user_filename_flag )) then CAT_MESG_STRING=${CAT_MESG_STRING}" \"$user_filename\"." else @@ -632,35 +622,35 @@ GetErrorMessageString() case $failure_flag in $NO_REGULAR_FILE_ERR) - catgets TEMP_MESG_STRING $CAT_ID 1 210 "That file is either not printable or it does not exist." + catgets TEMP_MESG_STRING "$CAT_ID" 1 210 "That file is either not printable or it does not exist." ;; $NO_READABLE_FILE_ERR) - catgets TEMP_MESG_STRING $CAT_ID 1 134 "You don't have permission to read that file." + catgets TEMP_MESG_STRING "$CAT_ID" 1 134 "You don't have permission to read that file." ;; $NO_PRINTER_AVAILABLE) - catgets TEMP_MESG_STRING $CAT_ID 1 220 "There is either no printer defined for this system or no printer is enabled." + catgets TEMP_MESG_STRING "$CAT_ID" 1 220 "There is either no printer defined for this system or no printer is enabled." ;; $PRINTER_DOES_NOT_EXIST) - catgets TEMP_MESG_STRING $CAT_ID 1 230 "The printer does not exist." + catgets TEMP_MESG_STRING "$CAT_ID" 1 230 "The printer does not exist." ;; $PRINTER_NOT_ENABLED) - catgets TEMP_MESG_STRING $CAT_ID 1 240 "The printer is not enabled." + catgets TEMP_MESG_STRING "$CAT_ID" 1 240 "The printer is not enabled." ;; $NO_DEFAULT_PRINTER) - catgets TEMP_MESG_STRING $CAT_ID 1 250 "There is no default printer destination." + catgets TEMP_MESG_STRING "$CAT_ID" 1 250 "There is no default printer destination." ;; $PRINTER_NOT_ACCEPT_REQ) - catgets TEMP_MESG_STRING $CAT_ID 1 260 "The printer is currently not accepting requests." + catgets TEMP_MESG_STRING "$CAT_ID" 1 260 "The printer is currently not accepting requests." ;; $NOT_POS_INTEGER) - catgets TEMP_MESG_STRING $CAT_ID 1 270 "Number of copies must be a positive number." + catgets TEMP_MESG_STRING "$CAT_ID" 1 270 "Number of copies must be a positive number." ;; *) echo "" ;; esac - if (( $failure_flag == $NO_PRINTER_AVAILABLE )) + if (( failure_flag == NO_PRINTER_AVAILABLE )) then CAT_MESG_STRING="${TEMP_MESG_STRING}" else @@ -679,12 +669,12 @@ XCOMM ## XCOMM ################################################################# DisplayErrorMessage() { - catgets CAT_MESG_STRING $CAT_ID 1 130 "Sorry--Unable to print:" + catgets CAT_MESG_STRING "$CAT_ID" 1 130 "Sorry--Unable to print:" GetErrorMessageString print "" - print `date` + print "$(date)" print "${CAT_MESG_STRING}" print "" } @@ -698,7 +688,7 @@ XCOMM ## XCOMM ################################################################# PrintEndLog() { print "" - if (( $failure_flag == $SUCCESS )) + if (( failure_flag == SUCCESS )) then print "...successfully completed." else @@ -741,7 +731,7 @@ PrintUsage() { print " Specifies the title of the file to display to the user." print "" print " -a" - print " Formats the file with "man" before printing." + print " Formats the file with \"man\" before printing." print "" print " -e" print " Removes the file after printing." @@ -777,7 +767,7 @@ XCOMM ## XCOMM ################################################################# Exit() { - exit $1 + exit "$1" } XCOMM ################# GUI Callbacks #################### @@ -804,11 +794,11 @@ XCOMM ## XCOMM ################################################################# DoParameterCollection() { - catgets CAT_MESG_STRING $CAT_ID 1 10 "Default" + catgets CAT_MESG_STRING "$CAT_ID" 1 10 "Default" GetCurrentPrinterName CheckValidPrinter - if (( $failure_flag != $SUCCESS )) + if (( failure_flag != SUCCESS )) then DisplayErrorMessageDialog return $failure_flag @@ -826,11 +816,11 @@ DoParameterCollection() HASH HASH We must make sure the value is a positive integer in this case. HASH - XtGetValues $COPIES_SB textField:COPIES_TF - XmTextFieldGetString copy_val $COPIES_TF + XtGetValues "$COPIES_SB" textField:COPIES_TF + XmTextFieldGetString copy_val "$COPIES_TF" - CheckIsPosInteger $copy_val - if (( $failure_flag == $NOT_POS_INTEGER )) + CheckIsPosInteger "$copy_val" + if (( failure_flag == NOT_POS_INTEGER )) then DisplayErrorMessageDialog return $failure_flag @@ -847,7 +837,7 @@ DoParameterCollection() LPOPTIONS=${LPOPTIONS}" -n$copy_count" fi - XmTextGetString banner_title $BANNER_TF + XmTextGetString banner_title "$BANNER_TF" HASH Strip any leading or trailing spaces banner_title=${banner_title##+( )} @@ -857,7 +847,7 @@ DoParameterCollection() LPOPTIONS=${LPOPTIONS}" "${MINUS_T}${SINGLE_QUOTE}${banner_title}${SINGLE_QUOTE} fi - XmTextGetString other_options $OPTIONS_TF + XmTextGetString other_options "$OPTIONS_TF" HASH Strip any leading or trailing spaces other_options=${other_options##+( )} @@ -867,14 +857,14 @@ DoParameterCollection() LPOPTIONS=${LPOPTIONS}" $other_options" fi - XtGetValues $SEND_MAIL_BTN set:send_mail_flag + XtGetValues "$SEND_MAIL_BTN" set:send_mail_flag if [[ "$send_mail_flag" == "true" ]] then LPOPTIONS=${LPOPTIONS}" -m" fi - if (( $verbose_flag )) + if (( verbose_flag )) then echo The LP options are \"${LPOPTIONS}\". fi @@ -893,9 +883,9 @@ DestroyDialogs() { if [[ "$SELECT_PRINTER_FORM" != "" ]] then - XtDestroyWidget $(XtParent "-" $SELECT_PRINTER_FORM) + XtDestroyWidget "$(XtParent "-" "$SELECT_PRINTER_FORM")" fi - XtDestroyWidget $(XtParent "-" $PDIALOG) + XtDestroyWidget "$(XtParent "-" "$PDIALOG")" } XCOMM ################################################################# @@ -907,7 +897,7 @@ XCOMM ## XCOMM ################################################################# PrintCB() { - XSync $DISPLAY True + XSync "$DISPLAY" True DoParameterCollection if [ $? != $SUCCESS ] @@ -944,14 +934,14 @@ XCOMM ################################################################# UpdatePrinterDescription() { CheckValidPrinter - if (( $failure_flag != $SUCCESS )) + if (( failure_flag != SUCCESS )) then - XtSetValues $PRINTER_DESC_LABEL labelString:"" + XtSetValues "$PRINTER_DESC_LABEL" labelString:"" return fi - GetPrinterInfo $printer_name - XtSetValues $PRINTER_DESC_LABEL labelString:"$printer_info" + GetPrinterInfo "$printer_name" + XtSetValues "$PRINTER_DESC_LABEL" labelString:"$printer_info" } XCOMM ################################################################# @@ -964,10 +954,10 @@ XCOMM ## XCOMM ################################################################# SelectPrinterCB() { - XtSetValues $PRINTER_TF value:$selected_printer + XtSetValues "$PRINTER_TF" value:"$selected_printer" printer_name=$selected_printer UpdatePrinterDescription - XtUnmanageChild $SELECT_PRINTER_FORM + XtUnmanageChild "$SELECT_PRINTER_FORM" } XCOMM ################################################################# @@ -992,8 +982,8 @@ XCOMM ## XCOMM ################################################################# ListSelectCB() { - GetPrinterInfo ${CB_CALL_DATA.ITEM} - XtSetValues $INFO_TEXT value:"$printer_info" + GetPrinterInfo "${CB_CALL_DATA.ITEM}" + XtSetValues "$INFO_TEXT" value:"$printer_info" selected_printer=${CB_CALL_DATA.ITEM} } @@ -1007,9 +997,9 @@ XCOMM ## XCOMM ################################################################# ListDblSelectCB() { - if [ ${CB_CALL_DATA.EVENT.TYPE} != KeyPress ] + if [ "${CB_CALL_DATA.EVENT.TYPE}" != KeyPress ] then - XtCallCallbacks $SELECT_PRINTER_BTN activateCallback + XtCallCallbacks "$SELECT_PRINTER_BTN" activateCallback fi } @@ -1022,7 +1012,7 @@ XCOMM ## XCOMM ################################################################# GetCurrentPrinterName() { - XmTextFieldGetString printer_name $PRINTER_TF + XmTextFieldGetString printer_name "$PRINTER_TF" HASH Strip any leading or trailing spaces printer_name=${printer_name##+( )} @@ -1052,19 +1042,19 @@ GetAvailPrinters() #else LANG=C lpstat -p | \ grep enabled | cut -f2 -d" " | \ - sort | uniq > $tmpfile 2>&1 + sort | uniq > "$tmpfile" 2>&1 #endif if [ -s "$tmpfile" ] then - for i in `cat $tmpfile` + while read -r "$tmpfile" do - printer_items=`echo $printer_items$comma$i` + printer_items=$printer_items$comma$i comma=',' ((num_printers=num_printers+1)) done fi - rm -f $tmpfile + rm -f "$tmpfile" } XCOMM ################################################################# @@ -1105,78 +1095,78 @@ SelectPrinterProc() GetCurrentPrinterName HASH get index of printer in the list - XmListItemPos index $PRINTER_LIST $printer_name + XmListItemPos index "$PRINTER_LIST" "$printer_name" HASH HASH If printer is in the list, select it and display info. on it; HASH otherwise, just re-manage the dialog. HASH - if [[ $index > 0 ]] + if [[ $index -gt 0 ]] then - GetPrinterInfo $printer_name + GetPrinterInfo "$printer_name" HASH HASH display printer information and select the printer specified in HASH the Printer Name textfield HASH - XmTextSetString $INFO_TEXT "$printer_info" - XmListSelectItem $PRINTER_LIST $printer_name true - XmListSetPos $PRINTER_LIST $index + XmTextSetString "$INFO_TEXT" "$printer_info" + XmListSelectItem "$PRINTER_LIST" "$printer_name" true + XmListSetPos "$PRINTER_LIST" "$index" fi - XtManageChild $SELECT_PRINTER_FORM + XtManageChild "$SELECT_PRINTER_FORM" return fi GetAvailPrinters - XmCreateFormDialog SELECT_PRINTER_FORM $TOPLEVEL form + XmCreateFormDialog SELECT_PRINTER_FORM "$TOPLEVEL" form - catgets CAT_MESG_STRING $CAT_ID 1 180 "Select Printer" + catgets CAT_MESG_STRING "$CAT_ID" 1 180 "Select Printer" - XmInternAtom DEL_ATOM $DISPLAY WM_DELETE_WINDOW false - XmAddWMProtocolCallback $(XtParent "-" $SELECT_PRINTER_FORM) \ - $DEL_ATOM SelectPrinterCancelCB + XmInternAtom DEL_ATOM "$DISPLAY" WM_DELETE_WINDOW false + XmAddWMProtocolCallback "$(XtParent "-" "$SELECT_PRINTER_FORM")" \ + "$DEL_ATOM" SelectPrinterCancelCB - XtSetValues $(XtParent "-" $SELECT_PRINTER_FORM) \ + XtSetValues "$(XtParent "-" "$SELECT_PRINTER_FORM")" \ title:"$CAT_MESG_STRING" \ allowShellResize:False \ deleteResponse:DO_NOTHING - XtSetValues $SELECT_PRINTER_FORM \ + XtSetValues "$SELECT_PRINTER_FORM" \ noResize:True \ autoUnmanage:False \ helpCallback:SelectPrinterHelpCB - XmCreateWorkArea WORK_AREA $SELECT_PRINTER_FORM work_area \ + XmCreateWorkArea WORK_AREA "$SELECT_PRINTER_FORM" work_area \ orientation:XmVERTICAL - XmCreateWorkArea LIST_RC $WORK_AREA list_rc orientation:XmHORIZONTAL + XmCreateWorkArea LIST_RC "$WORK_AREA" list_rc orientation:XmHORIZONTAL - catgets CAT_MESG_STRING $CAT_ID 1 190 "Available Printers:" + catgets CAT_MESG_STRING "$CAT_ID" 1 190 "Available Printers:" - XmCreateLabelGadget LIST_LABEL $LIST_RC list_label \ + XmCreateLabelGadget LIST_LABEL "$LIST_RC" list_label \ labelString:"$CAT_MESG_STRING" - XtManageChild $LIST_LABEL + XtManageChild "$LIST_LABEL" - XmCreateScrolledList PRINTER_LIST $LIST_RC printer_list \ + XmCreateScrolledList PRINTER_LIST "$LIST_RC" printer_list \ selectionPolicy:XmSINGLE_SELECT \ singleSelectionCallback:ListSelectCB \ defaultActionCallback:ListDblSelectCB \ itemCount:$num_printers \ - items:$printer_items \ + items:"$printer_items" \ visibleItemCount:5 - XtManageChild $PRINTER_LIST + XtManageChild "$PRINTER_LIST" - XmCreateWorkArea INFO_RC $WORK_AREA info_rc orientation:XmVERTICAL + XmCreateWorkArea INFO_RC "$WORK_AREA" info_rc orientation:XmVERTICAL - catgets CAT_MESG_STRING $CAT_ID 1 200 "Printer Information:" + catgets CAT_MESG_STRING "$CAT_ID" 1 200 "Printer Information:" - XmCreateLabelGadget INFO_LABEL $INFO_RC info_label \ + XmCreateLabelGadget INFO_LABEL "$INFO_RC" info_label \ labelString:"$CAT_MESG_STRING" - XtManageChild $INFO_LABEL + XtManageChild "$INFO_LABEL" printer_info="" - XmCreateScrolledText INFO_TEXT $INFO_RC info_text \ + XmCreateScrolledText INFO_TEXT "$INFO_RC" info_text \ editMode:XmMULTI_LINE_EDIT \ value:"$printer_info" \ rows:5 \ @@ -1184,82 +1174,82 @@ SelectPrinterProc() wordWrap:True \ editable:False - XmCreateSeparator BTN_SEP $SELECT_PRINTER_FORM sep \ + XmCreateSeparator BTN_SEP "$SELECT_PRINTER_FORM" sep \ separatorType:XmSHADOW_ETCHED_IN \ - $(DtkshUnder $WORK_AREA 4) \ - $(DtkshSpanWidth) + "$(DtkshUnder "$WORK_AREA" 4)" \ + "$(DtkshSpanWidth)" - catgets CAT_MESG_STRING $CAT_ID 1 180 "Select Printer" + catgets CAT_MESG_STRING "$CAT_ID" 1 180 "Select Printer" - XmCreatePushButtonGadget SELECT_PRINTER_BTN $SELECT_PRINTER_FORM \ + XmCreatePushButtonGadget SELECT_PRINTER_BTN "$SELECT_PRINTER_FORM" \ ok_button \ labelString:"$CAT_MESG_STRING" \ - $(DtkshUnder $BTN_SEP 5) \ - $(DtkshFloatLeft 10) \ - $(DtkshFloatRight 30) \ - $(DtkshAnchorBottom 5) + "$(DtkshUnder "$BTN_SEP" 5)" \ + "$(DtkshFloatLeft 10)" \ + "$(DtkshFloatRight 30)" \ + "$(DtkshAnchorBottom 5)" - XtAddCallback $SELECT_PRINTER_BTN activateCallback "SelectPrinterCB" + XtAddCallback "$SELECT_PRINTER_BTN" activateCallback "SelectPrinterCB" - catgets CAT_MESG_STRING $CAT_ID 1 110 "Cancel" + catgets CAT_MESG_STRING "$CAT_ID" 1 110 "Cancel" - XmCreatePushButtonGadget CANCEL_BTN $SELECT_PRINTER_FORM cancel_button \ + XmCreatePushButtonGadget CANCEL_BTN "$SELECT_PRINTER_FORM" cancel_button \ labelString:"$CAT_MESG_STRING" \ - $(DtkshUnder $BTN_SEP 5) \ - $(DtkshFloatLeft 40) \ - $(DtkshFloatRight 60) \ - $(DtkshAnchorBottom 5) + "$(DtkshUnder "$BTN_SEP" 5)" \ + "$(DtkshFloatLeft 40)" \ + "$(DtkshFloatRight 60)" \ + "$(DtkshAnchorBottom 5)" - XtAddCallback $CANCEL_BTN activateCallback "SelectPrinterCancelCB" + XtAddCallback "$CANCEL_BTN" activateCallback "SelectPrinterCancelCB" - catgets CAT_MESG_STRING $CAT_ID 1 120 "Help" + catgets CAT_MESG_STRING "$CAT_ID" 1 120 "Help" - XmCreatePushButtonGadget HELP_BTN $SELECT_PRINTER_FORM help_button \ + XmCreatePushButtonGadget HELP_BTN "$SELECT_PRINTER_FORM" help_button \ labelString:"$CAT_MESG_STRING" \ - $(DtkshUnder $BTN_SEP 5) \ - $(DtkshFloatLeft 70) \ - $(DtkshFloatRight 90) \ - $(DtkshAnchorBottom 5) + "$(DtkshUnder "$BTN_SEP" 5)" \ + "$(DtkshFloatLeft 70)" \ + "$(DtkshFloatRight 90)" \ + "$(DtkshAnchorBottom 5)" - XtAddCallback $HELP_BTN activateCallback "SelectPrinterHelpCB" + XtAddCallback "$HELP_BTN" activateCallback "SelectPrinterHelpCB" - XtSetValues $SELECT_PRINTER_FORM \ - initialFocus:$SELECT_PRINTER_BTN \ - defaultButton:$SELECT_PRINTER_BTN \ - cancelButton:$CANCEL_BTN \ + XtSetValues "$SELECT_PRINTER_FORM" \ + initialFocus:"$SELECT_PRINTER_BTN" \ + defaultButton:"$SELECT_PRINTER_BTN" \ + cancelButton:"$CANCEL_BTN" \ navigationType:EXCLUSIVE_TAB_GROUP - XtManageChild $BTN_SEP - XtManageChild $SELECT_PRINTER_BTN - XtManageChild $CANCEL_BTN - XtManageChild $HELP_BTN - XtManageChild $INFO_TEXT - XtManageChild $LIST_RC - XtManageChild $INFO_RC - XtManageChild $WORK_AREA - XtManageChild $SELECT_PRINTER_FORM + XtManageChild "$BTN_SEP" + XtManageChild "$SELECT_PRINTER_BTN" + XtManageChild "$CANCEL_BTN" + XtManageChild "$HELP_BTN" + XtManageChild "$INFO_TEXT" + XtManageChild "$LIST_RC" + XtManageChild "$INFO_RC" + XtManageChild "$WORK_AREA" + XtManageChild "$SELECT_PRINTER_FORM" - if (( $num_printers )) + if (( num_printers )) then GetCurrentPrinterName CheckValidPrinter - if (( $failure_flag == $SUCCESS )) + if (( failure_flag == SUCCESS )) then - GetPrinterInfo $printer_name + GetPrinterInfo "$printer_name" HASH HASH display printer information and select the printer specified in HASH the Printer Name textfield HASH - XmTextSetString $INFO_TEXT "$printer_info" - XmListSelectItem $PRINTER_LIST $printer_name true - XmListSetItem $PRINTER_LIST $printer_name + XmTextSetString "$INFO_TEXT" "$printer_info" + XmListSelectItem "$PRINTER_LIST" "$printer_name" true + XmListSetItem "$PRINTER_LIST" "$printer_name" fi else HASH HASH no available printer, desensitize Select Printer button in HASH the Select Printer dialog HASH - XtSetSensitive $SELECT_PRINTER_BTN false + XtSetSensitive "$SELECT_PRINTER_BTN" false failure_flag=$NO_PRINTER_AVAILABLE DisplayErrorMessageDialog fi @@ -1274,7 +1264,7 @@ XCOMM ## XCOMM ################################################################# SelectPrinterCancelCB() { - XtUnmanageChild $SELECT_PRINTER_FORM + XtUnmanageChild "$SELECT_PRINTER_FORM" } XCOMM ################################################################# @@ -1291,12 +1281,12 @@ PrinterNameFocusCB() HASH When it loses focus, compare the saved printer name with the new one HASH to determine if the user has changed it. If so, update the printer HASH description. - if [ ${CB_CALL_DATA.REASON} = CR_FOCUS ] + if [ "${CB_CALL_DATA.REASON}" = CR_FOCUS ] then GetCurrentPrinterName old_printer=$printer_name else - if [ ${CB_CALL_DATA.REASON} = CR_LOSING_FOCUS ] + if [ "${CB_CALL_DATA.REASON}" = CR_LOSING_FOCUS ] then GetCurrentPrinterName if [ "$old_printer" != "$printer_name" ] @@ -1315,14 +1305,14 @@ XCOMM ## XCOMM ################################################################# UseGui() { - catgets CAT_MESG_STRING $CAT_ID 1 10 "Default" + catgets CAT_MESG_STRING "$CAT_ID" 1 10 "Default" - if (( $printer_name_flag )) + if (( printer_name_flag )) then printer=$printer_name else GetDefaultPrinter - if (( $failure_flag == $SUCCESS )) + if (( failure_flag == SUCCESS )) then printer=$default_printer printer_name=$default_printer @@ -1333,12 +1323,12 @@ UseGui() if [[ "$printer_name" != "" ]] then - GetPrinterInfo $printer_name + GetPrinterInfo "$printer_name" else printer_info="" fi - DtCreatePrintSetupDialog PDIALOG $TOPLEVEL pdialog \ + DtCreatePrintSetupDialog PDIALOG "$TOPLEVEL" pdialog \ printCallback:PrintCB \ cancelCallback:PrintCancelCB \ helpCallback:PrintHelpCB \ @@ -1349,83 +1339,83 @@ UseGui() printerName:"$printer" \ description:"$printer_info" - catgets CAT_MESG_STRING $CAT_ID 1 20 "Print" + catgets CAT_MESG_STRING "$CAT_ID" 1 20 "Print" - XmInternAtom DEL_ATOM $DISPLAY WM_DELETE_WINDOW false - XmAddWMProtocolCallback $(XtParent "-" $PDIALOG) $DEL_ATOM PrintCancelCB + XmInternAtom DEL_ATOM "$DISPLAY" WM_DELETE_WINDOW false + XmAddWMProtocolCallback "$(XtParent "-" "$PDIALOG")" "$DEL_ATOM" PrintCancelCB - XtSetValues $(XtParent "-" $PDIALOG) \ + XtSetValues "$(XtParent "-" "$PDIALOG")" \ title:"$CAT_MESG_STRING" \ allowShellResize:False \ deleteResponse:DO_NOTHING - XtSetValues $PDIALOG autoUnmanage:False + XtSetValues "$PDIALOG" autoUnmanage:False - XmCreateWorkArea FILE_NAME_RC $PDIALOG file_name_rc \ + XmCreateWorkArea FILE_NAME_RC "$PDIALOG" file_name_rc \ marginWidth:0 \ marginHeight:0 \ orientation:XmHORIZONTAL - catgets CAT_MESG_STRING $CAT_ID 1 170 "File Name(s): " + catgets CAT_MESG_STRING "$CAT_ID" 1 170 "File Name(s): " - XmCreateLabel FILE_NAME_LABEL $FILE_NAME_RC file_name_label \ + XmCreateLabel FILE_NAME_LABEL "$FILE_NAME_RC" file_name_label \ labelString:"$CAT_MESG_STRING" - if (( $user_filename_flag )) + if (( user_filename_flag )) then LABEL_STRING="${user_filename}" else LABEL_STRING="${print_file}" fi - XmCreateLabel FILE_NAME $FILE_NAME_RC file_name \ + XmCreateLabel FILE_NAME "$FILE_NAME_RC" file_name \ labelString:"$LABEL_STRING" - XtManageChild $FILE_NAME_RC - XtManageChild $FILE_NAME_LABEL - XtManageChild $FILE_NAME + XtManageChild "$FILE_NAME_RC" + XtManageChild "$FILE_NAME_LABEL" + XtManageChild "$FILE_NAME" HASH HASH Unmanage unneeded widgets HASH - XtNameToWidget TOP_SEP $PDIALOG "TopWorkAreaSeparator" - XtUnmanageChild $TOP_SEP + XtNameToWidget TOP_SEP "$PDIALOG" "TopWorkAreaSeparator" + XtUnmanageChild "$TOP_SEP" - XtNameToWidget INFO_BTN $PDIALOG "Info" - XtUnmanageChild $INFO_BTN + XtNameToWidget INFO_BTN "$PDIALOG" "Info" + XtUnmanageChild "$INFO_BTN" - XtNameToWidget SELECT_FILE_BTN $PDIALOG "SelectFile" - XtUnmanageChild $SELECT_FILE_BTN + XtNameToWidget SELECT_FILE_BTN "$PDIALOG" "SelectFile" + XtUnmanageChild "$SELECT_FILE_BTN" - XtNameToWidget SETUP_BTN $PDIALOG "Setup" - XtUnmanageChild $SETUP_BTN + XtNameToWidget SETUP_BTN "$PDIALOG" "Setup" + XtUnmanageChild "$SETUP_BTN" - DtCreatePDMJobSetup JOB $PDIALOG + DtCreatePDMJobSetup JOB "$PDIALOG" HASH HASH Get widget handles HASH - XtNameToWidget PRINTER_COMBO $PDIALOG "Name" - XtNameToWidget PRINTER_TF $PRINTER_COMBO "Text" - XtNameToWidget PRINTER_DESC_LABEL $PDIALOG "Description" - XtNameToWidget COPIES_SB $PDIALOG "*Copies" - XtNameToWidget SEND_MAIL_CB $JOB "*SendMail" - XtNameToWidget BANNER_TF $JOB "*Banner" - XtNameToWidget OPTIONS_TF $JOB "*Options" - XtNameToWidget SEND_MAIL_BTN $SEND_MAIL_CB "button_0" - XtNameToWidget PRINT_BTN $PDIALOG "Print" - XtNameToWidget PRINT_CANCEL_BTN $PDIALOG "Cancel" + XtNameToWidget PRINTER_COMBO "$PDIALOG" "Name" + XtNameToWidget PRINTER_TF "$PRINTER_COMBO" "Text" + XtNameToWidget PRINTER_DESC_LABEL "$PDIALOG" "Description" + XtNameToWidget COPIES_SB "$PDIALOG" "*Copies" + XtNameToWidget SEND_MAIL_CB "$JOB" "*SendMail" + XtNameToWidget BANNER_TF "$JOB" "*Banner" + XtNameToWidget OPTIONS_TF "$JOB" "*Options" + XtNameToWidget SEND_MAIL_BTN "$SEND_MAIL_CB" "button_0" + XtNameToWidget PRINT_BTN "$PDIALOG" "Print" + XtNameToWidget PRINT_CANCEL_BTN "$PDIALOG" "Cancel" HASH HASH move cursor to end of printer name HASH - XtSetValues $PRINTER_TF cursorPosition:${#PRINTER} + XtSetValues "$PRINTER_TF" cursorPosition:${#PRINTER} HASH HASH set focus callbacks to track printer name changes HASH - XtAddCallback $PRINTER_TF focusCallback "PrinterNameFocusCB" - XtAddCallback $PRINTER_TF losingFocusCallback "PrinterNameFocusCB" + XtAddCallback "$PRINTER_TF" focusCallback "PrinterNameFocusCB" + XtAddCallback "$PRINTER_TF" losingFocusCallback "PrinterNameFocusCB" HASH HASH initialize SELECT_PRINTER_FORM to be used in SelectPrinterProc @@ -1433,32 +1423,32 @@ UseGui() HASH SELECT_PRINTER_FORM="" - if (( $banner_title_flag )) + if (( banner_title_flag )) then - XtSetValues $BANNER_TF value:"$banner_title" + XtSetValues "$BANNER_TF" value:"$banner_title" fi - if (( $other_options_flag )) + if (( other_options_flag )) then - XtSetValues $OPTIONS_TF value:"$other_options" + XtSetValues "$OPTIONS_TF" value:"$other_options" fi - XtManageChild $PDIALOG + XtManageChild "$PDIALOG" - if (( $copy_count_flag )) + if (( copy_count_flag )) then - XtSetValues $COPIES_SB position:$copy_count + XtSetValues "$COPIES_SB" position:"$copy_count" fi if [[ "$send_mail_flag" == "true" ]] then - XtSetValues $SEND_MAIL_BTN set:true + XtSetValues "$SEND_MAIL_BTN" set:true fi - XtGetValues $COPIES_SB textField:COPIES_TF + XtGetValues "$COPIES_SB" textField:COPIES_TF - DtkshSetReturnKeyControls $PRINTER_TF $COPIES_TF $PDIALOG $PRINT_BTN - DtkshSetReturnKeyControls $COPIES_TF $BANNER_TF $PDIALOG $PRINT_BTN - DtkshSetReturnKeyControls $BANNER_TF $OPTIONS_TF $PDIALOG $PRINT_BTN + DtkshSetReturnKeyControls "$PRINTER_TF" "$COPIES_TF" "$PDIALOG" "$PRINT_BTN" + DtkshSetReturnKeyControls "$COPIES_TF" "$BANNER_TF" "$PDIALOG" "$PRINT_BTN" + DtkshSetReturnKeyControls "$BANNER_TF" "$OPTIONS_TF" "$PDIALOG" "$PRINT_BTN" XtMainLoop @@ -1474,7 +1464,7 @@ XCOMM ## XCOMM ################################################################# BadFileCB() { - Exit $bad_file_flag + Exit "$bad_file_flag" } XCOMM ################################################################# @@ -1487,7 +1477,7 @@ XCOMM ## XCOMM ################################################################# ErrorDialogCB() { - XtDestroyWidget $INFORMATION + XtDestroyWidget "$INFORMATION" } XCOMM ################################################################# @@ -1501,17 +1491,17 @@ XCOMM ## XCOMM ################################################################# DisplayErrorMessageDialog() { - XmCreateErrorDialog INFORMATION $TOPLEVEL information + XmCreateErrorDialog INFORMATION "$TOPLEVEL" information - catgets CAT_MESG_STRING $CAT_ID 1 160 "Print Information" + catgets CAT_MESG_STRING "$CAT_ID" 1 160 "Print Information" - XtSetValues $(XtParent "-" $INFORMATION) title:"$CAT_MESG_STRING" + XtSetValues "$(XtParent "-" "$INFORMATION")" title:"$CAT_MESG_STRING" GetErrorMessageString - if (($failure_flag == $NO_FILE_ERR )) || - (( $failure_flag == $NO_REGULAR_FILE_ERR )) || - (( $failure_flag == $NO_READABLE_FILE_ERR )) + if ((failure_flag == NO_FILE_ERR )) || + (( failure_flag == NO_REGULAR_FILE_ERR )) || + (( failure_flag == NO_READABLE_FILE_ERR )) then bad_file_flag=$failure_flag cb="BadFileCB" @@ -1519,7 +1509,7 @@ DisplayErrorMessageDialog() cb="ErrorDialogCB" fi - XtSetValues $INFORMATION \ + XtSetValues "$INFORMATION" \ okCallback:$cb \ messageString:"${CAT_MESG_STRING}" \ noResize:True \ @@ -1527,13 +1517,13 @@ DisplayErrorMessageDialog() dialogStyle:DIALOG_FULL_APPLICATION_MODAL \ messageAlignment:ALIGNMENT_CENTER - XtUnmanageChild $(XmMessageBoxGetChild "-" $INFORMATION \ - DIALOG_CANCEL_BUTTON) + XtUnmanageChild "$(XmMessageBoxGetChild "-" "$INFORMATION" \ + DIALOG_CANCEL_BUTTON)" - XtUnmanageChild $(XmMessageBoxGetChild "-" $INFORMATION \ - DIALOG_HELP_BUTTON) + XtUnmanageChild "$(XmMessageBoxGetChild "-" "$INFORMATION" \ + DIALOG_HELP_BUTTON)" - XtManageChild $INFORMATION + XtManageChild "$INFORMATION" XtMainLoop } @@ -1568,7 +1558,6 @@ do i) send_mail_flag=true ;; m) print_command=$OPTARG - print_command_flag=1 ;; n) copy_count=$OPTARG copy_count_flag=1 @@ -1597,7 +1586,7 @@ done let npf=0 -if (( $shift_positions < $# )) +if (( shift_positions < $# )) then XCOMM XCOMM We have at least one remaining non-switch command line argument @@ -1608,11 +1597,10 @@ XCOMM HASH At some later point, may want to parse a list of filenames. HASH print_file="" - print_file_flag=1 while (($# > 0)) do - nw=`echo $1 | wc -w` + nw=$(echo "$1" | wc -w) if ((nw > 1)) then file="\"$1\"" @@ -1635,10 +1623,10 @@ fi XCOMM XCOMM make sure copy_count is a positive integer XCOMM -if (( $copy_count_flag )) +if (( copy_count_flag )) then - CheckIsPosInteger $copy_count - if (( $failure_flag != $SUCCESS )) + CheckIsPosInteger "$copy_count" + if (( failure_flag != SUCCESS )) then DisplayErrorMessage Exit $USAGE_EXIT @@ -1650,7 +1638,7 @@ XCOMM Make sure all these settings line up consistently. XCOMM ReconcileOptions -if (( $verbose_flag )) +if (( verbose_flag )) then PrintStartLog fi @@ -1668,7 +1656,7 @@ while ((i < npf)) do CheckValidFile "${files[$i]}" failure_flag=$? - if (( $failure_flag != $SUCCESS )) + if (( failure_flag != SUCCESS )) then print_file="\"${files[$i]}\"" break @@ -1676,13 +1664,13 @@ do let i=i+1 done -if (( $silent_flag )) +if (( silent_flag )) then - if (( $failure_flag == $SUCCESS )) + if (( failure_flag == SUCCESS )) then CheckValidPrinter failure_flag=$? - if (( $failure_flag != $SUCCESS )) + if (( failure_flag != SUCCESS )) then DisplayErrorMessage Exit $failure_flag @@ -1707,9 +1695,9 @@ else fi XtInitialize TOPLEVEL printerConfig Dtlp "${@:-}" - XtDisplay DISPLAY $TOPLEVEL + XtDisplay DISPLAY "$TOPLEVEL" - if (( $failure_flag == $SUCCESS )) + if (( failure_flag == SUCCESS )) then UseGui else diff --git a/cde/programs/dtprintegrate/dtlpsetup.src b/cde/programs/dtprintegrate/dtlpsetup.src index 53830782..a9537caf 100755 --- a/cde/programs/dtprintegrate/dtlpsetup.src +++ b/cde/programs/dtprintegrate/dtlpsetup.src @@ -20,10 +20,6 @@ XCOMM NLSPATH=/usr/dt/lib/nls/msg/%L/%N.cat:$NLSPATH export NLSPATH -XCOMM Return Codes -NO_VALID_FILE_ERR=7 -NO_READ_FILE_ERR=8 - usage="$0 [-b banner_title] [-d lpdest] [-f print_file] [-m print_command] [-n copy_count] [-o other_options] [-u user_filename] [-a] [-e] [-h] [-r] [-s] [-v] [-w]" @@ -31,7 +27,7 @@ usage="$0 [-b banner_title] [-d lpdest] [-f print_file] while [ $# -gt 0 ]; do case "$1" in -b) - if [ $2 ]; then + if [ "$2" ]; then banner_title="$1 $2" shift; shift; else @@ -40,11 +36,11 @@ while [ $# -gt 0 ]; do fi ;; -b*) - banner_title="-b `expr "$1" : '-b\(.*\)'`" + banner_title="-b $(expr "$1" : '-b\(.*\)')" shift ;; -d) - if [ $2 ]; then + if [ "$2" ]; then lpdest="$1 $2" shift; shift; else @@ -53,13 +49,13 @@ while [ $# -gt 0 ]; do fi ;; -d*) - lpdest="-d `expr "$1" : '-d\(.*\)'`" + lpdest="-d $(expr "$1" : '-d\(.*\)')" shift ;; -c) NOT_SUPPORTED=true ARGS="$ARGS $1" - if [ $2 ]; then + if [ "$2" ]; then shift; shift; else shift @@ -73,7 +69,7 @@ while [ $# -gt 0 ]; do -t) NOT_SUPPORTED=true ARGS="$ARGS $1" - if [ $2 ]; then + if [ "$2" ]; then shift; shift; else shift @@ -87,7 +83,7 @@ while [ $# -gt 0 ]; do -i) NOT_SUPPORTED=true ARGS="$ARGS $1" - if [ $2 ]; then + if [ "$2" ]; then shift; shift; else shift @@ -101,7 +97,7 @@ while [ $# -gt 0 ]; do -l) NOT_SUPPORTED=true ARGS="$ARGS $1" - if [ $2 ]; then + if [ "$2" ]; then shift; shift; else shift @@ -113,7 +109,7 @@ while [ $# -gt 0 ]; do shift ;; -f) - if [ $2 ]; then + if [ "$2" ]; then print_file=$2 shift; shift; else @@ -122,11 +118,11 @@ while [ $# -gt 0 ]; do fi ;; -f*) - print_file=`expr "$1" : '-f\(.*\)'` + print_file=$(expr "$1" : '-f\(.*\)') shift ;; -m) - if [ $2 ]; then + if [ "$2" ]; then print_command="$1 $2" shift; shift; else @@ -135,11 +131,11 @@ while [ $# -gt 0 ]; do fi ;; -m*) - print_command="-m `expr "$1" : '-m\(.*\)'`" + print_command="-m $(expr "$1" : '-m\(.*\)')" shift ;; -n) - if [ $2 ]; then + if [ "$2" ]; then copy_count="$1 $2" shift; shift; else @@ -148,11 +144,11 @@ while [ $# -gt 0 ]; do fi ;; -n*) - copy_count="-n `expr "$1" : '-n\(.*\)'`" + copy_count="-n $(expr "$1" : '-n\(.*\)')" shift ;; -o) - if [ $2 ]; then + if [ "$2" ]; then other_options="$1 $2" shift; shift; else @@ -161,11 +157,11 @@ while [ $# -gt 0 ]; do fi ;; -o*) - other_options="-o `expr "$1" : '-o\(.*\)'`" + other_options="-o $(expr "$1" : '-o\(.*\)')" shift ;; -u) - if [ $2 ]; then + if [ "$2" ]; then user_filename="$1 $2" shift; shift; else @@ -174,7 +170,7 @@ while [ $# -gt 0 ]; do fi ;; -u*) - user_filename="-u `expr "$1" : '-u\(.*\)'`" + user_filename="-u $(expr "$1" : '-u\(.*\)')" shift ;; -a) @@ -217,22 +213,22 @@ if [ $# -gt 0 ]; then fi if [ $NOT_SUPPORTED ]; then - dspmsg -s 1 dtmigrate 2 'dtlpsetup: dtlpsetup has been replaced with dtlp.\ + dspmsg -s 1 dtmigrate 2 "dtlpsetup: dtlpsetup has been replaced with dtlp.\ \tdtlp will be automatically called in its place. \ \tThe following flags and parameters on the dtlpsetup call \ \thave been ignored because dtlp does not support these flags: \ -\t%1$s \n' "$ARGS" +\t%1$s \n" "$ARGS" fi -/usr/dt/bin/dtlp $banner_title $lpdest $print_command $copy_count $other_options $user_filename $a $e $h $r $s $v $w $print_file +/usr/dt/bin/dtlp "$banner_title" "$lpdest" "$print_command" "$copy_count" "$other_options" "$user_filename" "$a" "$e" "$h" "$r" "$s" "$v" "$w" "$print_file" status=$? XCOMM dtlp return code of 5 maps to return code 7 of dtlpsetup -if [[ $status -eq 5 ]] +if [ $status -eq 5 ] then exit NO_VALID_FILE_ERR XCOMM dtlp return code of 6 maps to return code 8 of dtlpsetup -elif [[ $status -eq 6 ]] +elif [ $status -eq 6 ] then exit NO_READ_FILE_ERR else XCOMM all others are synonomous diff --git a/cde/programs/dtprintegrate/dtprintegrate.src b/cde/programs/dtprintegrate/dtprintegrate.src index b5215f4f..7cd75b47 100755 --- a/cde/programs/dtprintegrate/dtprintegrate.src +++ b/cde/programs/dtprintegrate/dtprintegrate.src @@ -43,10 +43,8 @@ base_icon_name="Fpprnt" XCOMM XCOMM Return codes XCOMM -SUCCESS=0 USAGE_ERR=1 CREATE_ERR=2 -NO_WRITE_ERR=3 XCOMM ################################################################# XCOMM ## Initialize() @@ -56,13 +54,6 @@ XCOMM ## XCOMM ################################################################# Initialize() { - if (( ${#LANG} )) - then - if [[ $LANG != C ]] - then - non_default_lang=1 - fi - fi HASH HASH Location for Print action files... @@ -75,9 +66,9 @@ Initialize() DTPRINTERFOLDER="$DTUSERPRINTERFOLDER" fi - if [ ! -d $DTPRINTERFOLDER ] + if [ ! -d "$DTPRINTERFOLDER" ] then - mkdir -p $DTPRINTERFOLDER > /dev/null 2>/dev/null + mkdir -p "$DTPRINTERFOLDER" > /dev/null 2>/dev/null fi HASH @@ -86,9 +77,9 @@ Initialize() DEFAULT_FOLDER=/etc/dt/appconfig/types/C DTPRINTACTIONFOLDER=${DTPRINTACTIONFOLDER:-$DEFAULT_FOLDER} - if [ ! -d $DTPRINTACTIONFOLDER ] + if [ ! -d "$DTPRINTACTIONFOLDER" ] then - mkdir -p $DTPRINTACTIONFOLDER > /dev/null 2>/dev/null + mkdir -p "$DTPRINTACTIONFOLDER" > /dev/null 2>/dev/null fi HASH @@ -124,7 +115,7 @@ XCOMM ## XCOMM ################################################################# CheckOptions() { - if (( $printer_flag == "0" )) + if (( printer_flag == "0" )) HASH HASH We require a printer specification HASH @@ -149,21 +140,21 @@ AddHelpFileContents() print " \"$help_file\"." print "" failure_flag=1 - if (( $verbose_flag )) + if (( verbose_flag )) then PrintEndLog fi Exit $CREATE_ERR fi - echo " DESCRIPTION \\" >> $databasefile_path + echo " DESCRIPTION \\" >> "$databasefile_path" - exec 8< $help_file + exec 8< "$help_file" - while read -u8 this_line + while read -r -u8 this_line do - print $this_line " \\" >> $databasefile_path + print "$this_line" " \\" >> "$databasefile_path" done - print "**" >> $databasefile_path + print "**" >> "$databasefile_path" exec 8<&- } @@ -177,15 +168,15 @@ XCOMM ################################################################# MakeDatabaseFile() { - touch $databasefile_path > /dev/null 2>/dev/null + touch "$databasefile_path" > /dev/null 2>/dev/null - chmod +w $databasefile_path > /dev/null 2>/dev/null + chmod +w "$databasefile_path" > /dev/null 2>/dev/null if [[ ! -f $databasefile_path || ! -w $databasefile_path ]] then failure_flag=1 PrintCreateError "$DTPRINTACTIONFOLDER" "$database_file" - if (( $verbose_flag )) + if (( verbose_flag )) then PrintEndLog fi @@ -204,11 +195,11 @@ MakeDatabaseFile() echo "# " echo "# This file created by the \"dtprintegrate\" utility." echo "# " - echo "# Date of integration: `date`. " + echo "# Date of integration: $(date). " echo "# " echo "################################################################" echo " " - ) > $databasefile_path + ) > "$databasefile_path" HASH HASH Now, create the Print action for the printer @@ -230,17 +221,17 @@ MakeDatabaseFile() fi echo " /usr/dt/bin/dtaction Print %(File)Arg_1%" - ) >> $databasefile_path + ) >> "$databasefile_path" - if (( $help_flag )) + if (( help_flag )) then - echo " DESCRIPTION $help_text" >> $databasefile_path - elif (( $helpfile_flag )) + echo " DESCRIPTION $help_text" >> "$databasefile_path" + elif (( helpfile_flag )) then - AddHelpFileContents $databasefile_path + AddHelpFileContents "$databasefile_path" fi - echo "}" >> $databasefile_path + echo "}" >> "$databasefile_path" HASH HASH Next, create the print manager action for the printer @@ -260,21 +251,20 @@ MakeDatabaseFile() fi echo " /usr/dt/bin/dtaction Dtqueueinfo" echo "}" - ) >> $databasefile_path + ) >> "$databasefile_path" } XCOMM ################################################################# XCOMM ## XCOMM ## TraversePath() XCOMM ## -XCOMM ## Parse a given search path, using comma (,) and colon (:) as +XCOMM ## Parse a given search path, using comma (,) and colon (:) as XCOMM ## delimiters. Pass each path element to another XCOMM ## function. XCOMM ## XCOMM ################################################################# TraversePath () { - gotahost=0 typeset -i path=0 IFSsave=$IFS search_path=$1 @@ -285,10 +275,10 @@ TraversePath () HASH look for colon and comma delimiters HASH IFS=':,' - set -A dir_array $search_path + set -A dir_array "$search_path" while ((path<=${#dir_array[*]}-1)) ;do - $dir_function ${dir_array[$path]} - path=path+1 + $dir_function "${dir_array[$path]}" + path=$((path+1)) done else return fi @@ -299,19 +289,19 @@ XCOMM ################################################################# XCOMM ## XCOMM ## GetIconBaseName() XCOMM ## -XCOMM ## Given a file name of the form "base.l.bm" where size +XCOMM ## Given a file name of the form "base.l.bm" where size XCOMM ## can be ".l", ".m", ".s.", or ".t" and visual type can be XCOMM ## ".bm" or ".pm", set $base_icon_name to just the base. XCOMM ## XCOMM ################################################################# GetIconBaseName() { - base_icon_name=`basename $1 .bm` - base_icon_name=`basename $base_icon_name .pm` - base_icon_name=`basename $base_icon_name .l` - base_icon_name=`basename $base_icon_name .m` - base_icon_name=`basename $base_icon_name .s` - base_icon_name=`basename $base_icon_name .t` + base_icon_name=$(basename "$1" .bm) + base_icon_name=$(basename "$base_icon_name" .pm) + base_icon_name=$(basename "$base_icon_name" .l) + base_icon_name=$(basename "$base_icon_name" .m) + base_icon_name=$(basename "$base_icon_name" .s) + base_icon_name=$(basename "$base_icon_name" .t) } XCOMM ################################################################# @@ -327,18 +317,18 @@ DoTheActualIconCopy() { for i in $1/${base_icon_name}.* do - if [ -f $i ] + if [ -f "$i" ] then simple_icon_name=${i##*/} - if [ -f $DTPRINTERICONFOLDER/$simple_icon_name ] + if [ -f "$DTPRINTERICONFOLDER/$simple_icon_name" ] then - mv -f $DTPRINTERICONFOLDER/$simple_icon_name $DTPRINTERICONFOLDER/#$simple_icon_name + mv -f "$DTPRINTERICONFOLDER/$simple_icon_name" "$DTPRINTERICONFOLDER/#$simple_icon_name" fi - cp $i $DTPRINTERICONFOLDER + cp "$i" "$DTPRINTERICONFOLDER" - if (( $verbose_flag )) + if (( verbose_flag )) then print " Copied icon file $i " print " to $DTPRINTERICONFOLDER." @@ -359,22 +349,22 @@ XCOMM ################################################################# CopyIconFiles() { -GetIconBaseName $icon_name +GetIconBaseName "$icon_name" -touch $DTPRINTERICONFOLDER/$icon_name.install > /dev/null 2>/dev/null +touch "$DTPRINTERICONFOLDER/$icon_name.install" > /dev/null 2>/dev/null if [[ ! -f $DTPRINTERICONFOLDER/$icon_name.install ]] then failure_flag=1 PrintCreateError "$DTPRINTERICONFOLDER" "$DTPRINTERICONFOLDER/$icon_name.*" - if (( $verbose_flag )) + if (( verbose_flag )) then PrintEndLog fi Exit $CREATE_ERR fi -rm -f $DTPRINTERICONFOLDER/$icon_name.install +rm -f "$DTPRINTERICONFOLDER/$icon_name.install" TraversePath "$DTPRINTICONPATH" DoTheActualIconCopy @@ -392,15 +382,15 @@ XCOMM ################################################################# MakeActionFile() { - touch $action_path > /dev/null 2>/dev/null + touch "$action_path" > /dev/null 2>/dev/null - chmod +x $action_path > /dev/null 2>/dev/null + chmod +x "$action_path" > /dev/null 2>/dev/null if [[ ! -f $action_path || ! -x $action_path ]] then failure_flag=1 PrintCreateError "$DTPRINTERFOLDER" "$action_file" - if (( $verbose_flag )) + if (( verbose_flag )) then PrintEndLog fi @@ -414,7 +404,7 @@ MakeActionFile() else failure_flag=1 PrintCreateError "$DTPRINTERFOLDER" "$action_file" - if (( $verbose_flag )) + if (( verbose_flag )) then PrintEndLog fi @@ -444,7 +434,7 @@ PrintEndLog() { print "" print " DTPRINTERFOLDER == $DTPRINTERFOLDER" print "" - if (( $failure_flag == 0 )) && (( $unintegrate_flag == 0)) + if (( failure_flag == 0 )) && (( unintegrate_flag == 0)) then print " Created one database file," print " \"$databasefile_path\"," @@ -452,7 +442,7 @@ PrintEndLog() { print " \"$action_path\"." print "" fi - if (( $failure_flag ==0 )) + if (( failure_flag ==0 )) then print "...successfully completed." else @@ -515,7 +505,7 @@ ReloadActions() { HASH HASH Shorten forms like "host.dom.com" to "host" HASH - session_host=`uname -n` + session_host=$(uname -n) session_host=${session_host%%.*} if (( reloadactions_flag )) @@ -557,7 +547,7 @@ UnintegratePrinter() { if [[ -f $action_path ]] then - rm -fr $action_path + rm -fr "$action_path" if (( verbose_flag )) then print " Removed one action file: " @@ -567,7 +557,7 @@ UnintegratePrinter() { if [[ -f $databasefile_path ]] then - rm -fr $databasefile_path + rm -fr "$databasefile_path" if (( verbose_flag )) then print " Removed one database file:" @@ -584,7 +574,7 @@ XCOMM ## XCOMM ## XCOMM ################################################################# Exit() { - exit $1 + exit "$1" } XCOMM ################################################################# @@ -599,7 +589,6 @@ printer_flag=0 help_flag=0 helpfile_flag=0 icon_flag=0 -language_flag=0 verbose_flag=0 unintegrate_flag=0 failure_flag=0 @@ -638,7 +627,7 @@ done ((shift_positions = OPTIND - 1)) -if (( $shift_positions < $# )) +if (( shift_positions < $# )) then XCOMM XCOMM We have at least one remaining non-switch command line argument @@ -658,21 +647,21 @@ XCOMM Time to get to work. XCOMM Initialize -if (( $verbose_flag )) +if (( verbose_flag )) then PrintStartLog fi CheckOptions -if (( $unintegrate_flag )) +if (( unintegrate_flag )) then UnintegratePrinter else - if (( $icon_flag )) + if (( icon_flag )) then CopyIconFiles HASH Doing so will set the $base_icon_name for inclusion in the @@ -687,7 +676,7 @@ else fi -if (( $verbose_flag )) +if (( verbose_flag )) then PrintEndLog fi -- 2.25.1