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

dtappintegrate.src and dtopen.src: fix shellcheck warnings

This commit is contained in:
chase 2018-08-25 10:06:45 -05:00 committed by Jon Trulson
parent 5e96644596
commit 6f2d38aaa0
2 changed files with 108 additions and 88 deletions

View file

@ -47,7 +47,7 @@ XCOMM #
XCOMM ------------------------------------------------------------------# XCOMM ------------------------------------------------------------------#
function ShowSyntax function ShowSyntax
{ {
echo "Usage: $SCRIPT_NAME -s <source> [-t <target>] [-l <language>] [-u]" | tee -a $LOGFILE echo "Usage: $SCRIPT_NAME -s <source> [-t <target>] [-l <language>] [-u]" | tee -a "$LOGFILE"
return 0 return 0
} }
XCOMM ------------------------------------------------------------------# XCOMM ------------------------------------------------------------------#
@ -66,15 +66,15 @@ XCOMM ------------------------------------------------------------------#
function GetAbsolutePath function GetAbsolutePath
{ {
if [ "/" = "$1" ]; then if [ "/" = "$1" ]; then
echo $2 echo "$2"
elif [ -L $1 ]; then elif [ -L "$1" ]; then
GetAbsolutePath `ls -l $1 | awk '{print $NF}'` $2 GetAbsolutePath "$(find . -name "$1" | awk '{print $NF}')" "$2"
else else
{ {
if [ "." = "$1" -o ".." = "$1" ]; then if [ "." = "$1" ] || [ ".." = "$1" ]; then
GetAbsolutePath / /`basename $1`$2 GetAbsolutePath / /"$(basename "$1")""$2"
else else
GetAbsolutePath `dirname $1` /`basename $1`$2 GetAbsolutePath "$(dirname "$1")" /"$(basename "$1")""$2"
fi fi
} }
fi fi
@ -116,7 +116,7 @@ function GetRelativePath
for (i = 2 + s; i <= b; i++) { for (i = 2 + s; i <= b; i++) {
printf("%s%s", B[i], (i < b) ? "/":"\n"); printf("%s%s", B[i], (i < b) ? "/":"\n");
} }
}' $2 $1 }' "$2" "$1"
} }
XCOMM ------------------------------------------------------------------# XCOMM ------------------------------------------------------------------#
XCOMM LinkCfgs # XCOMM LinkCfgs #
@ -136,46 +136,52 @@ function LinkCfgs
typeset pattern="" files="" typeset pattern="" files=""
shift;shift;shift shift;shift;shift
if [[ -L $source || -L $(dirname $source) ]] then if [[ -L $source || -L $(dirname "$source") ]]
spath=$(GetAbsolutePath $source) then
spath=$(GetAbsolutePath "$source")
else else
spath=$source spath=$source
fi fi
if [[ -L $target || -L $(dirname $target) ]] then if [[ -L $target || -L $(dirname "$target") ]]
tpath=$(GetAbsolutePath $target) then
tpath=$(GetAbsolutePath "$target")
else else
tpath=$target tpath=$target
fi fi
rpath="" rpath=""
for pattern in "$@" for pattern in "$@"
do do
if [[ $pattern = "(*)" ]] then if [[ $pattern = "(*)" ]]
files=$(ls -d $source/COMMENT_STAR 2>/dev/null) then
files=$(ls -d "$source"/COMMENT_STAR 2>/dev/null)
else else
files=$(ls -d $source/$pattern 2>/dev/null) files=$(ls -d "$source"/"$pattern" 2>/dev/null)
fi fi
if [[ $? = 0 ]] then if $files
count=$(echo $files | wc -w) then
count=$(echo "$files" | wc -w)
for cfgfile in $files for cfgfile in $files
do do
basecfg=$(basename $cfgfile) basecfg=$(basename "$cfgfile")
if [[ $torf = TRUE ]] then if [[ $torf = TRUE ]]
if [[ $rpath = "" ]] then then
rpath=$(GetRelativePath $spath $tpath) if [[ $rpath = "" ]]
then
rpath=$(GetRelativePath "$spath" "$tpath")
fi fi
rm -f $tpath/$basecfg rm -f "$tpath"/"$basecfg"
echo "ln -sf $rpath/$basecfg $tpath/$basecfg" >> $LOGFILE echo "ln -sf $rpath/$basecfg $tpath/$basecfg" >> "$LOGFILE"
ln -sf $rpath/$basecfg $tpath/$basecfg >> $LOGFILE 2>&1 ln -sf "$rpath/$basecfg" "$tpath/$basecfg" >> "$LOGFILE" 2>&1
else else
rm $tpath/$basecfg >/dev/null 2>&1 if rm "$tpath"/"$basecfg" >/dev/null 2>&1
if [[ $? = 0 ]] then then
echo "rm $tpath/$basecfg" >> $LOGFILE echo "rm $tpath/$basecfg" >> "$LOGFILE"
fi fi
fi fi
done done
fi fi
done done
return $count return "$count"
} }
XCOMM ------------------------------------------------------------------# XCOMM ------------------------------------------------------------------#
@ -195,12 +201,12 @@ XCOMM #
XCOMM ------------------------------------------------------------------# XCOMM ------------------------------------------------------------------#
function IntegrateUnintegrate function IntegrateUnintegrate
{ {
typeset torf=$1 srcs="" trgs="" fpats="" langs="" tpath="" spath="" rpath="" k="" languages="" lang="" typeset torf=$1 srcs="" trgs="" fpats="" tpath="" spath="" rpath="" languages="" lang=""
typeset cfgs="" srcabs="" trgabs="" typeset srcabs="" trgabs=""
integer i=0 icons=0 types=1 help=2 appmgr=3 integer i=0 icons=0 types=1 help=2 appmgr=3
srcabs=$(GetAbsolutePath $APP_ROOT) srcabs=$(GetAbsolutePath "$APP_ROOT")
trgabs=$(GetAbsolutePath $APP_TARGET) trgabs=$(GetAbsolutePath "$APP_TARGET")
srcs[0]=$srcabs$ICONS$APP_LANG srcs[0]=$srcabs$ICONS$APP_LANG
srcs[1]=$srcabs$TYPES$APP_LANG srcs[1]=$srcabs$TYPES$APP_LANG
@ -220,32 +226,36 @@ function IntegrateUnintegrate
rc=1 rc=1
while (( i < 4 )) while (( i < 4 ))
do do
if [[ $APP_LANG = "" ]] then if [[ $APP_LANG = "" ]]
languages=$(ls -d ${srcs[i]}/COMMENT_STAR 2>/dev/null) then
if [[ $? = 0 ]] then if languages=$(ls -d "${srcs[i]}"/COMMENT_STAR 2>/dev/null)
then
for lang in $languages for lang in $languages
do do
baselang=$(basename $lang) baselang=$(basename "$lang")
if [[ -d $lang ]] then if [[ -d $lang ]]
if [[ $torf = TRUE ]] then then
if [[ ! -d ${trgs[i]}/$baselang ]] then if [[ $torf = TRUE ]]
mkdir -p ${trgs[i]}/$baselang then
if [[ ! -d ${trgs[i]}/$baselang ]]
then
mkdir -p "${trgs[i]}"/"$baselang"
fi fi
fi fi
LinkCfgs ${srcs[i]}/$baselang ${trgs[i]}/$baselang $torf ${fpats[i]} if ! LinkCfgs "${srcs[i]}/$baselang" "${trgs[i]}/$baselang" "$torf" "${fpats[i]}"
if [[ $? != 0 ]] then then
rc=0 rc=0
fi fi
fi fi
done done
fi fi
else else
LinkCfgs ${srcs[i]} ${trgs[i]} $torf ${fpats[i]} if ! LinkCfgs "${srcs[i]}" "${trgs[i]}" "$torf" "${fpats[i]}"
if [[ $? != 0 ]] then then
rc=0 rc=0
fi fi
fi fi
i=i+1 i=$((i+1))
done done
return $rc return $rc
} }
@ -261,10 +271,10 @@ XCOMM ------------------------------------------------------------------#
function ExitOut function ExitOut
{ {
typeset retcode=$1 typeset retcode=$1
echo "<<<<<<< END OF APPLICATION INTEGRATION >>>>>>>" >> $LOGFILE echo "<<<<<<< END OF APPLICATION INTEGRATION >>>>>>>" >> "$LOGFILE"
echo "See $LOGFILE file for more information" echo "See $LOGFILE file for more information"
exit $retcode exit "$retcode"
} }
XCOMM ----<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>----- XCOMM ----<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>-----
XCOMM ----<<<<<<<<<<<.-------------------------.>>>>>>>>>>>----- XCOMM ----<<<<<<<<<<<.-------------------------.>>>>>>>>>>>-----
@ -278,7 +288,6 @@ XCOMM Initialize variables
XCOMM ------------------------------------------------------------------- XCOMM -------------------------------------------------------------------
sFLAG=0 sFLAG=0
tFLAG=0 tFLAG=0
lFLAG=0
uFLAG=0 uFLAG=0
TYPES=/types TYPES=/types
@ -287,16 +296,15 @@ ICONS=/icons
HELP=/help HELP=/help
APPCONFIG=/dt/appconfig APPCONFIG=/dt/appconfig
CONFIG_TOP=CDE_CONFIGURATION_TOP CONFIG_TOP=CDE_CONFIGURATION_TOP
DT=`basename $CONFIG_TOP` DT=$(basename $CONFIG_TOP)
APP_TARGET=${CONFIG_TOP%/$DT}$APPCONFIG APP_TARGET=${CONFIG_TOP%/$DT}$APPCONFIG
PIXMAP_FILES=*.pm PIXMAP_FILES="*.pm"
BITMAP_FILES=*.bm BITMAP_FILES="*.bm"
HELPVOLUME_FILES_OLD=*.hv HELPVOLUME_FILES_OLD="*.hv"
HELPVOLUME_FILES_NEW=*.sdl HELPVOLUME_FILES_NEW="*.sdl"
HELPFAMILY_FILES=*.hf HELPFAMILY_FILES="*.hf"
ACTIONDB_FILES=*.dt ACTIONDB_FILES="*.dt"
FRONTPANEL_FILES=*.fp
APPMAN_FILES="(*)" APPMAN_FILES="(*)"
ID=$(id) ID=$(id)
@ -314,7 +322,8 @@ XCOMM -------------------------------------------------------------------
ID=${ID##*uid=} ID=${ID##*uid=}
ID=${ID#*\(} ID=${ID#*\(}
ID=${ID%%\)*} ID=${ID%%\)*}
if [[ $ID != root ]] then if [[ $ID != root ]]
then
echo "Error: Must be root user to run $0!" >&2 echo "Error: Must be root user to run $0!" >&2
exit 3 exit 3
fi fi
@ -322,23 +331,24 @@ fi
XCOMM ------------------------------------------------------------------- XCOMM -------------------------------------------------------------------
XCOMM Put prolog into log file. XCOMM Put prolog into log file.
XCOMM ------------------------------------------------------------------- XCOMM -------------------------------------------------------------------
echo "<<<<<<< START OF APPLICATION INTEGRATION >>>>>>>" > $LOGFILE echo "<<<<<<< START OF APPLICATION INTEGRATION >>>>>>>" > "$LOGFILE"
XCOMM ------------------------------------------------------------------- XCOMM -------------------------------------------------------------------
XCOMM Put the date of application integration into the log file. XCOMM Put the date of application integration into the log file.
XCOMM ------------------------------------------------------------------- XCOMM -------------------------------------------------------------------
echo $(date) >> $LOGFILE date >> "$LOGFILE"
XCOMM ------------------------------------------------------------------- XCOMM -------------------------------------------------------------------
XCOMM Put the command line into the log file. XCOMM Put the command line into the log file.
XCOMM ------------------------------------------------------------------- XCOMM -------------------------------------------------------------------
echo "$SCRIPT_NAME $*" >> $LOGFILE echo "$SCRIPT_NAME $*" >> "$LOGFILE"
XCOMM ------------------------------------------------------------------- XCOMM -------------------------------------------------------------------
XCOMM Check if there are no command line arguments. XCOMM Check if there are no command line arguments.
XCOMM If none, then display the command syntax. XCOMM If none, then display the command syntax.
XCOMM ------------------------------------------------------------------- XCOMM -------------------------------------------------------------------
if [[ $# = 0 ]] then if [[ $# = 0 ]]
then
ShowSyntax ShowSyntax
ExitOut 0 ExitOut 0
fi fi
@ -353,8 +363,7 @@ do
APP_ROOT="$OPTARG";; APP_ROOT="$OPTARG";;
t) tFLAG=1 t) tFLAG=1
APP_TARGET="$OPTARG";; APP_TARGET="$OPTARG";;
l) lFLAG=1 l) APP_LANG="$OPTARG";;
APP_LANG="$OPTARG";;
u) uFLAG=1;; u) uFLAG=1;;
?) echo " " ?) echo " "
ShowSyntax ShowSyntax
@ -365,42 +374,50 @@ done
XCOMM ------------------------------------------------------------------- XCOMM -------------------------------------------------------------------
XCOMM Check if application's root was specified and is valid. XCOMM Check if application's root was specified and is valid.
XCOMM ------------------------------------------------------------------- XCOMM -------------------------------------------------------------------
if [[ $sFLAG = 0 ]] then if [[ $sFLAG = 0 ]]
then
echo "Error: Did not specify -s option!" >&2 echo "Error: Did not specify -s option!" >&2
ExitOut 4 ExitOut 4
else else
if [[ ! -d $APP_ROOT ]] then if [[ ! -d $APP_ROOT ]]
then
APP_PATH=$APP_ROOT APP_PATH=$APP_ROOT
echo "Error: $APP_PATH is not a directory!" >&2 echo "Error: $APP_PATH is not a directory!" >&2
ExitOut 4 ExitOut 4
fi fi
if [[ ! -r $APP_ROOT ]] || [[ ! -x $APP_ROOT ]] then if [[ ! -r $APP_ROOT ]] || [[ ! -x $APP_ROOT ]]
then
APP_PATH=$APP_ROOT APP_PATH=$APP_ROOT
echo "Error: Can not read $APP_PATH directory!" >&2 echo "Error: Can not read $APP_PATH directory!" >&2
ExitOut 4 ExitOut 4
fi fi
fi fi
if [[ ${APP_ROOT%%/COMMENT_STAR} != "" ]] then if [[ ${APP_ROOT%%/COMMENT_STAR} != "" ]]
then
APP_ROOT=$(pwd)/$APP_ROOT APP_ROOT=$(pwd)/$APP_ROOT
fi fi
XCOMM ------------------------------------------------------------------- XCOMM -------------------------------------------------------------------
XCOMM If target is specified, do some sanity checks on this path. XCOMM If target is specified, do some sanity checks on this path.
XCOMM ------------------------------------------------------------------- XCOMM -------------------------------------------------------------------
if [[ $tFLAG = 1 ]] then if [[ $tFLAG = 1 ]]
if [[ ! -d $APP_TARGET ]] then then
if [[ ! -d $APP_TARGET ]]
then
APP_PATH=$APP_TARGET APP_PATH=$APP_TARGET
echo "Error: $APP_PATH is not a directory!" >&2 echo "Error: $APP_PATH is not a directory!" >&2
ExitOut 4 ExitOut 4
fi fi
if [[ ! -r $APP_TARGET ]] || [[ ! -x $APP_TARGET ]] then if [[ ! -r $APP_TARGET ]] || [[ ! -x $APP_TARGET ]]
then
APP_PATH=$APP_TARGET APP_PATH=$APP_TARGET
echo "Error: Can not read $APP_PATH directory!" >&2 echo "Error: Can not read $APP_PATH directory!" >&2
ExitOut 4 ExitOut 4
fi fi
if [[ ${APP_TARGET%%/COMMENT_STAR} != "" ]] then if [[ ${APP_TARGET%%/COMMENT_STAR} != "" ]]
then
APP_TARGET=$(pwd)/$APP_TARGET APP_TARGET=$(pwd)/$APP_TARGET
fi fi
fi fi
@ -410,16 +427,18 @@ XCOMM Set up variables.
XCOMM ------------------------------------------------------------------- XCOMM -------------------------------------------------------------------
APP_ROOT=$APP_ROOT$APPCONFIG APP_ROOT=$APP_ROOT$APPCONFIG
if [[ $APP_LANG != "" ]] then if [[ $APP_LANG != "" ]]
then
APP_LANG=/$APP_LANG APP_LANG=/$APP_LANG
fi fi
XCOMM ------------------------------------------------------------------- XCOMM -------------------------------------------------------------------
XCOMM Unintegrate the application by un-doing the integration steps. XCOMM Unintegrate the application by un-doing the integration steps.
XCOMM ------------------------------------------------------------------- XCOMM -------------------------------------------------------------------
if [[ $uFLAG = 1 ]] then if [[ $uFLAG = 1 ]]
IntegrateUnintegrate FALSE then
if [[ $? = 0 ]] then if IntegrateUnintegrate FALSE
then
echo "Unintegration Complete" echo "Unintegration Complete"
else else
echo "No files to unintegrate" echo "No files to unintegrate"
@ -432,16 +451,17 @@ XCOMM See if these directories exist. If they don't, then create them.
XCOMM ------------------------------------------------------------------- XCOMM -------------------------------------------------------------------
for i in $APP_TARGET$ICONS$APP_LANG $APP_TARGET$TYPES$APP_LANG $APP_TARGET$APPMANAGER$APP_LANG $APP_TARGET$HELP$APP_LANG for i in $APP_TARGET$ICONS$APP_LANG $APP_TARGET$TYPES$APP_LANG $APP_TARGET$APPMANAGER$APP_LANG $APP_TARGET$HELP$APP_LANG
do do
if [[ ! -d $i ]] then if [[ ! -d $i ]]
mkdir -p $i then
mkdir -p "$i"
fi fi
done done
XCOMM ------------------------------------------------------------------- XCOMM -------------------------------------------------------------------
XCOMM Determine which awk to use. XCOMM Determine which awk to use.
XCOMM ------------------------------------------------------------------- XCOMM -------------------------------------------------------------------
$(type nawk > /dev/null 2>&1) if ! type nawk > /dev/null 2>&1
if [[ $? != 0 ]] then then
AWK="awk" AWK="awk"
else else
AWK="nawk" AWK="nawk"
@ -450,8 +470,8 @@ fi
XCOMM ------------------------------------------------------------------- XCOMM -------------------------------------------------------------------
XCOMM Integrate the application. XCOMM Integrate the application.
XCOMM ------------------------------------------------------------------- XCOMM -------------------------------------------------------------------
IntegrateUnintegrate TRUE if IntegrateUnintegrate TRUE
if [[ $? = 0 ]] then then
echo "Integration Complete" echo "Integration Complete"
else else
echo "No files to integrate" echo "No files to integrate"

View file

@ -8,7 +8,7 @@ XCOMM ###############################################################
XCOMM Init XCOMM Init
DTOPEN="dtopen" # Identity crisis DTOPEN="dtopen" # Identity crisis
APPNAME="$(basename $0)" # the app to locate/run APPNAME="$(basename "$0")" # the app to locate/run
XCOMM apps to look for, given an action (based on APPNAME - see MAIN) XCOMM apps to look for, given an action (based on APPNAME - see MAIN)
@ -53,7 +53,7 @@ FindProg()
# FindProg "program" # FindProg "program"
# - returns full path, or "" # - returns full path, or ""
whence $1 whence "$1"
return 0 return 0
} }
@ -88,7 +88,7 @@ DoSimpleCmd()
for i in $cmds for i in $cmds
do do
thecmd="$(FindProg $i)" thecmd="$(FindProg "$i")"
if [ ! -z "$thecmd" ] if [ ! -z "$thecmd" ]
then # it's there then # it's there
@ -119,16 +119,16 @@ COMMANDS="dtopen_image dtopen_pdf dtopen_ps dtopen_video"
case $APPNAME in case $APPNAME in
dtopen_image) dtopen_image)
DoSimpleCmd "$VIMAGE" $* DoSimpleCmd "$VIMAGE" "$*"
;; ;;
dtopen_pdf) dtopen_pdf)
DoSimpleCmd "$VPDF" $* DoSimpleCmd "$VPDF" "$*"
;; ;;
dtopen_ps) dtopen_ps)
DoSimpleCmd "$VPS" $* DoSimpleCmd "$VPS" "$*"
;; ;;
dtopen_video) dtopen_video)
DoSimpleCmd "$VVIDEO" $* DoSimpleCmd "$VVIDEO" "$*"
;; ;;
*) *)
# Unknown # Unknown