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
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

View file

@ -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