1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

dtprintegrate: fix shellcheck warnings

This commit is contained in:
chase 2018-08-25 23:03:02 -05:00 committed by Jon Trulson
parent 6f2d38aaa0
commit d002967908
3 changed files with 321 additions and 348 deletions

File diff suppressed because it is too large Load diff

View file

@ -20,10 +20,6 @@ XCOMM
NLSPATH=/usr/dt/lib/nls/msg/%L/%N.cat:$NLSPATH NLSPATH=/usr/dt/lib/nls/msg/%L/%N.cat:$NLSPATH
export 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] usage="$0 [-b banner_title] [-d lpdest] [-f print_file]
[-m print_command] [-n copy_count] [-o other_options] [-m print_command] [-n copy_count] [-o other_options]
[-u user_filename] [-a] [-e] [-h] [-r] [-s] [-v] [-w]" [-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 while [ $# -gt 0 ]; do
case "$1" in case "$1" in
-b) -b)
if [ $2 ]; then if [ "$2" ]; then
banner_title="$1 $2" banner_title="$1 $2"
shift; shift; shift; shift;
else else
@ -40,11 +36,11 @@ while [ $# -gt 0 ]; do
fi fi
;; ;;
-b*) -b*)
banner_title="-b `expr "$1" : '-b\(.*\)'`" banner_title="-b $(expr "$1" : '-b\(.*\)')"
shift shift
;; ;;
-d) -d)
if [ $2 ]; then if [ "$2" ]; then
lpdest="$1 $2" lpdest="$1 $2"
shift; shift; shift; shift;
else else
@ -53,13 +49,13 @@ while [ $# -gt 0 ]; do
fi fi
;; ;;
-d*) -d*)
lpdest="-d `expr "$1" : '-d\(.*\)'`" lpdest="-d $(expr "$1" : '-d\(.*\)')"
shift shift
;; ;;
-c) -c)
NOT_SUPPORTED=true NOT_SUPPORTED=true
ARGS="$ARGS $1" ARGS="$ARGS $1"
if [ $2 ]; then if [ "$2" ]; then
shift; shift; shift; shift;
else else
shift shift
@ -73,7 +69,7 @@ while [ $# -gt 0 ]; do
-t) -t)
NOT_SUPPORTED=true NOT_SUPPORTED=true
ARGS="$ARGS $1" ARGS="$ARGS $1"
if [ $2 ]; then if [ "$2" ]; then
shift; shift; shift; shift;
else else
shift shift
@ -87,7 +83,7 @@ while [ $# -gt 0 ]; do
-i) -i)
NOT_SUPPORTED=true NOT_SUPPORTED=true
ARGS="$ARGS $1" ARGS="$ARGS $1"
if [ $2 ]; then if [ "$2" ]; then
shift; shift; shift; shift;
else else
shift shift
@ -101,7 +97,7 @@ while [ $# -gt 0 ]; do
-l) -l)
NOT_SUPPORTED=true NOT_SUPPORTED=true
ARGS="$ARGS $1" ARGS="$ARGS $1"
if [ $2 ]; then if [ "$2" ]; then
shift; shift; shift; shift;
else else
shift shift
@ -113,7 +109,7 @@ while [ $# -gt 0 ]; do
shift shift
;; ;;
-f) -f)
if [ $2 ]; then if [ "$2" ]; then
print_file=$2 print_file=$2
shift; shift; shift; shift;
else else
@ -122,11 +118,11 @@ while [ $# -gt 0 ]; do
fi fi
;; ;;
-f*) -f*)
print_file=`expr "$1" : '-f\(.*\)'` print_file=$(expr "$1" : '-f\(.*\)')
shift shift
;; ;;
-m) -m)
if [ $2 ]; then if [ "$2" ]; then
print_command="$1 $2" print_command="$1 $2"
shift; shift; shift; shift;
else else
@ -135,11 +131,11 @@ while [ $# -gt 0 ]; do
fi fi
;; ;;
-m*) -m*)
print_command="-m `expr "$1" : '-m\(.*\)'`" print_command="-m $(expr "$1" : '-m\(.*\)')"
shift shift
;; ;;
-n) -n)
if [ $2 ]; then if [ "$2" ]; then
copy_count="$1 $2" copy_count="$1 $2"
shift; shift; shift; shift;
else else
@ -148,11 +144,11 @@ while [ $# -gt 0 ]; do
fi fi
;; ;;
-n*) -n*)
copy_count="-n `expr "$1" : '-n\(.*\)'`" copy_count="-n $(expr "$1" : '-n\(.*\)')"
shift shift
;; ;;
-o) -o)
if [ $2 ]; then if [ "$2" ]; then
other_options="$1 $2" other_options="$1 $2"
shift; shift; shift; shift;
else else
@ -161,11 +157,11 @@ while [ $# -gt 0 ]; do
fi fi
;; ;;
-o*) -o*)
other_options="-o `expr "$1" : '-o\(.*\)'`" other_options="-o $(expr "$1" : '-o\(.*\)')"
shift shift
;; ;;
-u) -u)
if [ $2 ]; then if [ "$2" ]; then
user_filename="$1 $2" user_filename="$1 $2"
shift; shift; shift; shift;
else else
@ -174,7 +170,7 @@ while [ $# -gt 0 ]; do
fi fi
;; ;;
-u*) -u*)
user_filename="-u `expr "$1" : '-u\(.*\)'`" user_filename="-u $(expr "$1" : '-u\(.*\)')"
shift shift
;; ;;
-a) -a)
@ -217,22 +213,22 @@ if [ $# -gt 0 ]; then
fi fi
if [ $NOT_SUPPORTED ]; then 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. \ \tdtlp will be automatically called in its place. \
\tThe following flags and parameters on the dtlpsetup call \ \tThe following flags and parameters on the dtlpsetup call \
\thave been ignored because dtlp does not support these flags: \ \thave been ignored because dtlp does not support these flags: \
\t%1$s \n' "$ARGS" \t%1$s \n" "$ARGS"
fi 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=$? status=$?
XCOMM dtlp return code of 5 maps to return code 7 of dtlpsetup 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 then exit NO_VALID_FILE_ERR
XCOMM dtlp return code of 6 maps to return code 8 of dtlpsetup 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 then exit NO_READ_FILE_ERR
else else
XCOMM all others are synonomous XCOMM all others are synonomous

View file

@ -43,10 +43,8 @@ base_icon_name="Fpprnt"
XCOMM XCOMM
XCOMM Return codes XCOMM Return codes
XCOMM XCOMM
SUCCESS=0
USAGE_ERR=1 USAGE_ERR=1
CREATE_ERR=2 CREATE_ERR=2
NO_WRITE_ERR=3
XCOMM ################################################################# XCOMM #################################################################
XCOMM ## Initialize() XCOMM ## Initialize()
@ -56,13 +54,6 @@ XCOMM ##
XCOMM ################################################################# XCOMM #################################################################
Initialize() Initialize()
{ {
if (( ${#LANG} ))
then
if [[ $LANG != C ]]
then
non_default_lang=1
fi
fi
HASH HASH
HASH Location for Print action files... HASH Location for Print action files...
@ -75,9 +66,9 @@ Initialize()
DTPRINTERFOLDER="$DTUSERPRINTERFOLDER" DTPRINTERFOLDER="$DTUSERPRINTERFOLDER"
fi fi
if [ ! -d $DTPRINTERFOLDER ] if [ ! -d "$DTPRINTERFOLDER" ]
then then
mkdir -p $DTPRINTERFOLDER > /dev/null 2>/dev/null mkdir -p "$DTPRINTERFOLDER" > /dev/null 2>/dev/null
fi fi
HASH HASH
@ -86,9 +77,9 @@ Initialize()
DEFAULT_FOLDER=/etc/dt/appconfig/types/C DEFAULT_FOLDER=/etc/dt/appconfig/types/C
DTPRINTACTIONFOLDER=${DTPRINTACTIONFOLDER:-$DEFAULT_FOLDER} DTPRINTACTIONFOLDER=${DTPRINTACTIONFOLDER:-$DEFAULT_FOLDER}
if [ ! -d $DTPRINTACTIONFOLDER ] if [ ! -d "$DTPRINTACTIONFOLDER" ]
then then
mkdir -p $DTPRINTACTIONFOLDER > /dev/null 2>/dev/null mkdir -p "$DTPRINTACTIONFOLDER" > /dev/null 2>/dev/null
fi fi
HASH HASH
@ -124,7 +115,7 @@ XCOMM ##
XCOMM ################################################################# XCOMM #################################################################
CheckOptions() CheckOptions()
{ {
if (( $printer_flag == "0" )) if (( printer_flag == "0" ))
HASH HASH
HASH We require a printer specification HASH We require a printer specification
HASH HASH
@ -149,21 +140,21 @@ AddHelpFileContents()
print " \"$help_file\"." print " \"$help_file\"."
print "" print ""
failure_flag=1 failure_flag=1
if (( $verbose_flag )) if (( verbose_flag ))
then then
PrintEndLog PrintEndLog
fi fi
Exit $CREATE_ERR Exit $CREATE_ERR
fi 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 do
print $this_line " \\" >> $databasefile_path print "$this_line" " \\" >> "$databasefile_path"
done done
print "**" >> $databasefile_path print "**" >> "$databasefile_path"
exec 8<&- exec 8<&-
} }
@ -177,15 +168,15 @@ XCOMM #################################################################
MakeDatabaseFile() 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 ]] if [[ ! -f $databasefile_path || ! -w $databasefile_path ]]
then then
failure_flag=1 failure_flag=1
PrintCreateError "$DTPRINTACTIONFOLDER" "$database_file" PrintCreateError "$DTPRINTACTIONFOLDER" "$database_file"
if (( $verbose_flag )) if (( verbose_flag ))
then then
PrintEndLog PrintEndLog
fi fi
@ -204,11 +195,11 @@ MakeDatabaseFile()
echo "# " echo "# "
echo "# This file created by the \"dtprintegrate\" utility." echo "# This file created by the \"dtprintegrate\" utility."
echo "# " echo "# "
echo "# Date of integration: `date`. " echo "# Date of integration: $(date). "
echo "# " echo "# "
echo "################################################################" echo "################################################################"
echo " " echo " "
) > $databasefile_path ) > "$databasefile_path"
HASH HASH
HASH Now, create the Print action for the printer HASH Now, create the Print action for the printer
@ -230,17 +221,17 @@ MakeDatabaseFile()
fi fi
echo " /usr/dt/bin/dtaction Print %(File)Arg_1%" echo " /usr/dt/bin/dtaction Print %(File)Arg_1%"
) >> $databasefile_path ) >> "$databasefile_path"
if (( $help_flag )) if (( help_flag ))
then then
echo " DESCRIPTION $help_text" >> $databasefile_path echo " DESCRIPTION $help_text" >> "$databasefile_path"
elif (( $helpfile_flag )) elif (( helpfile_flag ))
then then
AddHelpFileContents $databasefile_path AddHelpFileContents "$databasefile_path"
fi fi
echo "}" >> $databasefile_path echo "}" >> "$databasefile_path"
HASH HASH
HASH Next, create the print manager action for the printer HASH Next, create the print manager action for the printer
@ -260,21 +251,20 @@ MakeDatabaseFile()
fi fi
echo " /usr/dt/bin/dtaction Dtqueueinfo" echo " /usr/dt/bin/dtaction Dtqueueinfo"
echo "}" echo "}"
) >> $databasefile_path ) >> "$databasefile_path"
} }
XCOMM ################################################################# XCOMM #################################################################
XCOMM ## XCOMM ##
XCOMM ## TraversePath() XCOMM ## TraversePath()
XCOMM ## 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 ## delimiters. Pass each path element to another
XCOMM ## function. XCOMM ## function.
XCOMM ## XCOMM ##
XCOMM ################################################################# XCOMM #################################################################
TraversePath () TraversePath ()
{ {
gotahost=0
typeset -i path=0 typeset -i path=0
IFSsave=$IFS IFSsave=$IFS
search_path=$1 search_path=$1
@ -285,10 +275,10 @@ TraversePath ()
HASH look for colon and comma delimiters HASH look for colon and comma delimiters
HASH HASH
IFS=':,' IFS=':,'
set -A dir_array $search_path set -A dir_array "$search_path"
while ((path<=${#dir_array[*]}-1)) ;do while ((path<=${#dir_array[*]}-1)) ;do
$dir_function ${dir_array[$path]} $dir_function "${dir_array[$path]}"
path=path+1 path=$((path+1))
done done
else return else return
fi fi
@ -299,19 +289,19 @@ XCOMM #################################################################
XCOMM ## XCOMM ##
XCOMM ## GetIconBaseName() XCOMM ## GetIconBaseName()
XCOMM ## 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 ## 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 ## ".bm" or ".pm", set $base_icon_name to just the base.
XCOMM ## XCOMM ##
XCOMM ################################################################# XCOMM #################################################################
GetIconBaseName() GetIconBaseName()
{ {
base_icon_name=`basename $1 .bm` base_icon_name=$(basename "$1" .bm)
base_icon_name=`basename $base_icon_name .pm` base_icon_name=$(basename "$base_icon_name" .pm)
base_icon_name=`basename $base_icon_name .l` base_icon_name=$(basename "$base_icon_name" .l)
base_icon_name=`basename $base_icon_name .m` base_icon_name=$(basename "$base_icon_name" .m)
base_icon_name=`basename $base_icon_name .s` base_icon_name=$(basename "$base_icon_name" .s)
base_icon_name=`basename $base_icon_name .t` base_icon_name=$(basename "$base_icon_name" .t)
} }
XCOMM ################################################################# XCOMM #################################################################
@ -327,18 +317,18 @@ DoTheActualIconCopy()
{ {
for i in $1/${base_icon_name}.* for i in $1/${base_icon_name}.*
do do
if [ -f $i ] if [ -f "$i" ]
then then
simple_icon_name=${i##*/} simple_icon_name=${i##*/}
if [ -f $DTPRINTERICONFOLDER/$simple_icon_name ] if [ -f "$DTPRINTERICONFOLDER/$simple_icon_name" ]
then then
mv -f $DTPRINTERICONFOLDER/$simple_icon_name $DTPRINTERICONFOLDER/#$simple_icon_name mv -f "$DTPRINTERICONFOLDER/$simple_icon_name" "$DTPRINTERICONFOLDER/#$simple_icon_name"
fi fi
cp $i $DTPRINTERICONFOLDER cp "$i" "$DTPRINTERICONFOLDER"
if (( $verbose_flag )) if (( verbose_flag ))
then then
print " Copied icon file $i " print " Copied icon file $i "
print " to $DTPRINTERICONFOLDER." print " to $DTPRINTERICONFOLDER."
@ -359,22 +349,22 @@ XCOMM #################################################################
CopyIconFiles() 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 ]] if [[ ! -f $DTPRINTERICONFOLDER/$icon_name.install ]]
then then
failure_flag=1 failure_flag=1
PrintCreateError "$DTPRINTERICONFOLDER" "$DTPRINTERICONFOLDER/$icon_name.*" PrintCreateError "$DTPRINTERICONFOLDER" "$DTPRINTERICONFOLDER/$icon_name.*"
if (( $verbose_flag )) if (( verbose_flag ))
then then
PrintEndLog PrintEndLog
fi fi
Exit $CREATE_ERR Exit $CREATE_ERR
fi fi
rm -f $DTPRINTERICONFOLDER/$icon_name.install rm -f "$DTPRINTERICONFOLDER/$icon_name.install"
TraversePath "$DTPRINTICONPATH" DoTheActualIconCopy TraversePath "$DTPRINTICONPATH" DoTheActualIconCopy
@ -392,15 +382,15 @@ XCOMM #################################################################
MakeActionFile() 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 ]] if [[ ! -f $action_path || ! -x $action_path ]]
then then
failure_flag=1 failure_flag=1
PrintCreateError "$DTPRINTERFOLDER" "$action_file" PrintCreateError "$DTPRINTERFOLDER" "$action_file"
if (( $verbose_flag )) if (( verbose_flag ))
then then
PrintEndLog PrintEndLog
fi fi
@ -414,7 +404,7 @@ MakeActionFile()
else else
failure_flag=1 failure_flag=1
PrintCreateError "$DTPRINTERFOLDER" "$action_file" PrintCreateError "$DTPRINTERFOLDER" "$action_file"
if (( $verbose_flag )) if (( verbose_flag ))
then then
PrintEndLog PrintEndLog
fi fi
@ -444,7 +434,7 @@ PrintEndLog() {
print "" print ""
print " DTPRINTERFOLDER == $DTPRINTERFOLDER" print " DTPRINTERFOLDER == $DTPRINTERFOLDER"
print "" print ""
if (( $failure_flag == 0 )) && (( $unintegrate_flag == 0)) if (( failure_flag == 0 )) && (( unintegrate_flag == 0))
then then
print " Created one database file," print " Created one database file,"
print " \"$databasefile_path\"," print " \"$databasefile_path\","
@ -452,7 +442,7 @@ PrintEndLog() {
print " \"$action_path\"." print " \"$action_path\"."
print "" print ""
fi fi
if (( $failure_flag ==0 )) if (( failure_flag ==0 ))
then then
print "...successfully completed." print "...successfully completed."
else else
@ -515,7 +505,7 @@ ReloadActions() {
HASH HASH
HASH Shorten forms like "host.dom.com" to "host" HASH Shorten forms like "host.dom.com" to "host"
HASH HASH
session_host=`uname -n` session_host=$(uname -n)
session_host=${session_host%%.*} session_host=${session_host%%.*}
if (( reloadactions_flag )) if (( reloadactions_flag ))
@ -557,7 +547,7 @@ UnintegratePrinter() {
if [[ -f $action_path ]] if [[ -f $action_path ]]
then then
rm -fr $action_path rm -fr "$action_path"
if (( verbose_flag )) if (( verbose_flag ))
then then
print " Removed one action file: " print " Removed one action file: "
@ -567,7 +557,7 @@ UnintegratePrinter() {
if [[ -f $databasefile_path ]] if [[ -f $databasefile_path ]]
then then
rm -fr $databasefile_path rm -fr "$databasefile_path"
if (( verbose_flag )) if (( verbose_flag ))
then then
print " Removed one database file:" print " Removed one database file:"
@ -584,7 +574,7 @@ XCOMM ##
XCOMM ## XCOMM ##
XCOMM ################################################################# XCOMM #################################################################
Exit() { Exit() {
exit $1 exit "$1"
} }
XCOMM ################################################################# XCOMM #################################################################
@ -599,7 +589,6 @@ printer_flag=0
help_flag=0 help_flag=0
helpfile_flag=0 helpfile_flag=0
icon_flag=0 icon_flag=0
language_flag=0
verbose_flag=0 verbose_flag=0
unintegrate_flag=0 unintegrate_flag=0
failure_flag=0 failure_flag=0
@ -638,7 +627,7 @@ done
((shift_positions = OPTIND - 1)) ((shift_positions = OPTIND - 1))
if (( $shift_positions < $# )) if (( shift_positions < $# ))
then then
XCOMM XCOMM
XCOMM We have at least one remaining non-switch command line argument XCOMM We have at least one remaining non-switch command line argument
@ -658,21 +647,21 @@ XCOMM Time to get to work.
XCOMM XCOMM
Initialize Initialize
if (( $verbose_flag )) if (( verbose_flag ))
then then
PrintStartLog PrintStartLog
fi fi
CheckOptions CheckOptions
if (( $unintegrate_flag )) if (( unintegrate_flag ))
then then
UnintegratePrinter UnintegratePrinter
else else
if (( $icon_flag )) if (( icon_flag ))
then then
CopyIconFiles CopyIconFiles
HASH Doing so will set the $base_icon_name for inclusion in the HASH Doing so will set the $base_icon_name for inclusion in the
@ -687,7 +676,7 @@ else
fi fi
if (( $verbose_flag )) if (( verbose_flag ))
then then
PrintEndLog PrintEndLog
fi fi