Alien-Judy
view release on metacpan or search on metacpan
src/judy-1.0.5/test/jbgraph view on Meta::CPAN
-E use embedded options, default, Turn off with -NE.
Sets TITLE, COLHEAD, GETOPT from the FIRST data file encountered.
Example: embedded options in the data file begin in column 1:
# TITLE This is the title to pass to gnuplot
# COLHEAD 1 This is the heading for column 1.
# XLABEL This is the x-axis label
# YLABEL This is the y-axis label
# GETOPT -c2 -c3 -G # These are the options to use.
-p print the plot.
-o LP_OPT printer option(s); default \"${LP_OPT_DEF}\".
Example: \"-ootray2\" will print on clear slides, emits \"-otray2\"
Example: \"-on2\" will print two copies, emits \"-n2\"
-D LP_DEV printer device; default \"${LP_DEV_DEF}\".
-C GNU_CMDFILE name; default is generated and removed:
${OUTPUT_DIR}/{DATE_TIME}.GNU_CMDFILE
Useful to do your own gnuplot command editing and debugging.
-P GNU_PSFILE name. default is generated and removed:
${OUTPUT_DIR}/{DATE_TIME}.GNU_PSFILE
-S Save files.
Generated and working file names are deleted unless -S or -C is on.
User provided file names are not deleted in any case (-C, -P).
-q quiet mode, verbose mode off; default.
-v verbose mode on.
-V vi the plot file.
quit using \"q\"
-N not option; Turn specified option off. Example: -NL
Note, -N is not available for all options.
-NL Turn off: -L set logscale axis; default
-NH Turn off: -H default column headings.
-u Usage message.
Sample usage:
${C} -i -f data/datafile # -i is the same as -c1.
${C} -c1 -f data/datafile # -i is the same as -c1.
"
${v}echo "${C}.${0}: OPTIONS=${*}"
# Parse options, using getopt:
#
# - "a" option, no parameter; "b:" indicates a parameter.
# - Order of options is "man 5 ascii".
getopt_PARM="?C:D:EGIL:MN:P:SVc:d:g:ilmno:prsuvx:y:"
set -- `getopt ${getopt_PARM} $*` # Place options in argc/argv.
if [ "${?}" != "0" ]; then # If getopt returns an errror.
${v}echo "${C}.${0}: \${?}=${?}, USAGE message from return code."
echo "${USAGE}"
exit 1
fi
while [ ${#} -gt 0 ] # while there are options...
do # ( for vi parenthesis matching
${v}echo "${C}.${0}: parsing option \"${1}\", then \"${2}\""
case ${1} in
-C)
OPT_C="${1}"
OPT_C_PARM="${2}" # GNU_CMDFILE name.
${v}echo "${C}.${0}: OPT_C=${OPT_C}, # -C GNU_CMDFILE name."
${v}echo "${C}.${0}: OPT_C_PARM=${OPT_C_PARM}, # GNU_CMDFILE name."
export GNU_CMDFILE="${OPT_C_PARM}"
MSG="# GNU_CMDFILE name."
${v}echo "${C}.${0}: GNU_CMDFILE=${GNU_CMDFILE}, ${MSG}"
shift
;; # ( for vi parenthesis matching
-D)
OPT_D="${1}"
OPT_D_PARM="${2}" # LP_DEV name.
${v}echo "${C}.${0}: OPT_D=${OPT_D}, # -D LP_DEV printer device."
#${v}echo "${C}.${0}: OPT_D_PARM=${OPT_D_PARM}, # LP_DEV name."
LP_DEV="${OPT_D_PARM}"
${v}echo "${C}.${0}: LP_DEV=${LP_DEV}, # LP_DEV name."
shift
;; # ( for vi parenthesis matching
-E)
OPT_E="${1}"
${v}echo "${C}.${0}: OPT_E=${OPT_E}, # -E use embedded options"
;; # ( for vi parenthesis matching
-G)
OPT_G="${1}"
${v}echo "${C}.${0}: OPT_G=${OPT_G}, # -G grid lines on."
;; # ( for vi parenthesis matching
-H)
OPT_H="${1}"
${v}echo "${C}.${0}: OPT_H=${OPT_H}, # -H default column headings."
;; # ( for vi parenthesis matching
-I)
OPT_I="${1}"
${v}echo "${C}.${0}: OPT_I=${OPT_I}, # -I Memory used / index."
CMN="12"
COL[$CMN]="${CMN}"
${v}echo "${C}.${0}: COL[$CMN]=${COL[$CMN]}"
;; # ( for vi parenthesis matching
-L)
OPT_L="${1}"
${v}echo "${C}.${0}: OPT_L=${OPT_L}, -L set logscale axis"
OPT_L_PARM="${2}" # axis name, x or y
if [ ${OPT_L_PARM} = "x" ]; then
OPT_L_xaxis="${OPT_L_PARM}"
elif [ ${OPT_L_PARM} = "y" ]; then
OPT_L_yaxis="${OPT_L_PARM}"
else
MSG="must be either \"x\" or \"y\" axis. exit 5"
echo "${C}.${0}: ERROR, OPT_L_PARM=${OPT_L_PARM} ${MSG}"
exit 5
fi
OPT_NL="" # -L turn off -NL.
shift
;; # ( for vi parenthesis matching
-M)
OPT_M="${1}"
${v}echo "${C}.${0}: OPT_M=${OPT_M}, # -M Memory used and free."
CMN="8"
COL[$CMN]="${CMN}"
${v}echo "${C}.${0}: COL[$CMN]=${COL[$CMN]}"
;; # ( for vi parenthesis matching
-N)
OPT_N="${1}"
OPT_N_PARM="${2}" # LP_DEV name.
${v}echo "${C}.${0}: OPT_N=${OPT_N}, # -N not option"
${v}echo "${C}.${0}: OPT_N_PARM=${OPT_N_PARM}, # Turn option off."
if [ "${OPT_N_PARM}" = "E" ]; then
OPT_E="" # -E use embedded options
OPT_NE="-NE" # -NE turn off -E.
elif [ "${OPT_N_PARM}" = "L" ]; then
OPT_L="" # -L set logscale axis
OPT_L_xaxis=""
OPT_L_yaxis=""
OPT_NL="-NL" # -NL turn off -L.
elif [ "${OPT_N_PARM}" = "G" ]; then
OPT_G="" # -G grid lines on.
OPT_NG="-NG" # -NG turn off -G.
elif [ "${OPT_N_PARM}" = "H" ]; then
OPT_H="" # -H default column headings.
OPT_NH="-NH" # -NH turn off -H.
fi
shift
;; # ( for vi parenthesis matching
-P)
OPT_P="${1}"
OPT_P_PARM="${2}" # GNU_PSFILE name.
${v}echo "${C}.${0}: OPT_P=${OPT_P}, # -P GNU_PSFILE name."
#${v}echo "${C}.${0}: OPT_P_PARM=${OPT_P_PARM}, # GNU_PSFILE name."
GNU_PSFILE="${OPT_P_PARM}"
${v}echo "${C}.${0}: GNU_PSFILE=${GNU_PSFILE}, # GNU_PSFILE name."
shift
;; # ( for vi parenthesis matching
-S)
OPT_S="${1}"
${v}echo "${C}.${0}: OPT_S=${OPT_S}, # -S save files."
;; # ( for vi parenthesis matching
-V)
OPT_V="${1}"
${v}echo "${C}.${0}: OPT_V=${OPT_V}, # -V vi the plot file."
;; # ( for vi parenthesis matching
-c)
OPT_c="${1}"
OPT_c_PARM="${2}" # COLUMN_NUMBER.
${v}echo "${C}.${0}: OPT_c=${OPT_c}, # -c plot column number."
${v}echo "${C}.${0}: OPT_c_PARM=${OPT_c_PARM}, # COLUMN_NUMBER."
if [ ${OPT_c_PARM} -ge ${#CHA[*]} ] ||
[ ${OPT_c_PARM} -le 0 ]; then
MSG="must be greater than 0 and less than ${#CHA[*]}. exit 6"
echo "${C}.${0}: ERROR, OPT_c_PARM=${OPT_c_PARM} ${MSG}"
exit 6
fi
CMN="${OPT_c_PARM}"
COL[$CMN]="${CMN}"
${v}echo "${C}.${0}: COL[$CMN]=${COL[$CMN]}"
shift
;; # ( for vi parenthesis matching
-d)
OPT_d="${1}"
OPT_d_PARM="${2}" # DERIVATIVE_TYPE
${v}echo "${C}.${0}: OPT_d=${OPT_d}, # -d plot derivative type."
${v}echo "${C}.${0}: OPT_d_PARM=${OPT_d_PARM}, # DERIVITIVE_TYPE"
if [ "${OPT_d_PARM}" = "i" ]; then
OPT_di="${OPT_d_PARM}"
CMN="3"
elif [ "${OPT_d_PARM}" = "m" ]; then
OPT_dm="${OPT_d_PARM}"
CMN="7"
elif [ "${OPT_d_PARM}" = "r" ]; then
OPT_dr="${OPT_d_PARM}"
CMN="5"
else
echo "${C}.${0}: ERROR, ${OPT_d_PARM} must be one of i, m, r."
fi
COL[$CMN]="${CMN}"
${v}echo "${C}.${0}: COL[$CMN]=${COL[$CMN]}"
shift
;; # ( for vi parenthesis matching
-g)
OPT_g="${1}"
OPT_g_PARM="${2}" # Option parameter
${v}echo "${C}.${0}: OPT_g=${OPT_g}, # -g geometry description."
${v}echo "${C}.${0}: OPT_g_PARM=${OPT_g_PARM}, # window geometry"
GNU_GEOMETRY="-geometry ${OPT_g_PARM}" # Environment geometry.
MSG="# window geometry"
${v}echo "${C}.${0}: GNU_GEOMETRY=${GNU_GEOMETRY}, ${MSG}"
shift
;; # ( for vi parenthesis matching
-i)
OPT_i="${1}"
${v}echo "${C}.${0}: OPT_i=${OPT_i}, # -i plot insert."
CMN="2"
COL[$CMN]="${CMN}"
${v}echo "${C}.${0}: COL[$CMN]=${COL[$CMN]}"
;; # ( for vi parenthesis matching
-l)
OPT_l="${1}"
${v}echo "${C}.${0}: OPT_l=${OPT_l}, # -l plot leaf data."
CMN="10"
COL[$CMN]="${CMN}"
${v}echo "${C}.${0}: COL[$CMN]=${COL[$CMN]}"
CMN="11"
COL[$CMN]="${CMN}"
${v}echo "${C}.${0}: COL[$CMN]=${COL[$CMN]}"
;; # ( for vi parenthesis matching
-m)
OPT_m="${1}"
${v}echo "${C}.${0}: OPT_m=${OPT_m}, # -m plot memory malloced."
CMN="9"
COL[$CMN]="${CMN}"
${v}echo "${C}.${0}: COL[$CMN]=${COL[$CMN]}"
;; # ( for vi parenthesis matching
-n)
OPT_n="${1}"
MSG="# -n number plot descriptions."
${v}echo "${C}.${0}: OPT_n=${OPT_n}, ${MSG}"
;; # ( for vi parenthesis matching
-o)
OPT_o="${1}"
OPT_o_PARM="${2}" # Option parameter
MSG="# -o LP_OPT printer option(s)."
${v}echo "${C}.${0}: OPT_o=${OPT_o}, ${MSG}"
MSG="# -o LP_OPT printer option(s)."
${v}echo "${C}.${0}: OPT_o_PARM=${OPT_o_PARM}, ${MSG}"
# Check for duplicates, only add to LP_OPT if not a duplicate.
LP_SET="`echo ${LP_OPT} | adjust -m1 | grep -- -${OPT_o_PARM}`"
if [ "${LP_SET}" != "-${OPT_o_PARM}" ];
then
LP_OPT="${LP_OPT} -${OPT_o_PARM}"
fi
unset LP_SET
${v}echo "${C}.${0}: LP_OPT=${LP_OPT}, # LP_OPT printer option(s)."
shift
;; # ( for vi parenthesis matching
-p)
OPT_p="${1}"
${v}echo "${C}.${0}: OPT_p=${OPT_p}, # -p print the plot."
;; # ( for vi parenthesis matching
-q)
OPT_v="${1}"
v='eval #' # Set verbose off (quiet).
${v}echo "${C}.${0}: OPT_v=${OPT_v}, # -q quiet mode."
;; # ( for vi parenthesis matching
-r)
OPT_r="${1}"
${v}echo "${C}.${0}: OPT_r=${OPT_r}, # -r plot retrieve."
CMN="4"
COL[$CMN]="${CMN}"
${v}echo "${C}.${0}: COL[$CMN]=${COL[$CMN]}"
;; # ( for vi parenthesis matching
-v)
OPT_v="${1}"
v="" # Set verbose on.
${v}echo "${C}.${0}: OPT_v=${OPT_v}, # -v verbose mode."
${v}echo
;; # ( for vi parenthesis matching
-x)
OPT_x="${1}"
OPT_x_PARM="${2}" # Option parameter
${v}echo "${C}.${0}: OPT_x=${OPT_x}, # -x xRANGE, scale range."
#${v}echo "${C}.${0}: OPT_x_PARM=${OPT_x_PARM}, # parameter desc."
xRANGE="${OPT_x_PARM}"
${v}echo "${C}.${0}: xRANGE=${xRANGE}, # parameter desc."
shift
;; # ( for vi parenthesis matching
-y)
OPT_y="${1}"
OPT_y_PARM="${2}" # Option parameter
${v}echo "${C}.${0}: OPT_y=${OPT_y}, # -y yRANGE, scale range."
#${v}echo "${C}.${0}: OPT_y_PARM=${OPT_y_PARM}, # parameter desc."
yRANGE="${OPT_y_PARM}"
${v}echo "${C}.${0}: yRANGE=${yRANGE}, # parameter desc."
shift
;; # ( for vi parenthesis matching
-u)
OPT_u="-u"
${v}echo "${C}.${0}: OPT_u=${OPT_u}, # -u Usage message."
echo "${USAGE}"
exit 4
;; # ( for vi parenthesis matching
-a)
OPT_a="${1}"
${v}echo "${C}.${0}: OPT_a=${OPT_a}, # -a Option description."
;; # ( for vi parenthesis matching
-b)
OPT_b="${1}"
OPT_b_PARM="${2}" # Option parameter
${v}echo "${C}.${0}: OPT_b=${OPT_b}, # -b Option description."
${v}echo "${C}.${0}: OPT_b_PARM=${OPT_b_PARM}, # parameter desc."
shift
;; # ( for vi parenthesis matching
--)
shift # Remove the "--".
break
;; # ( for vi parenthesis matching
*)
echo "${C}.${0}: Option not understood. \"${1}\""
echo "USAGE message follows: "
echo "${USAGE}" # USAGE message
exit 2
;;
esac
shift
done
# The rest of the command line parameters are files:
# If FILES is already set, leave it alone, else set it.
# This is necessary due running getopt twice, to support parameters
# embedded in the data files.
if [ "${FILES}" = "" ]; then
FILES="${FILES} ${*}" # May result in a blank, " ".
if [ "${FILES}" = " " ]; then # If blank, " ", make it empty.
FILES="" # Make FILES empty again.
fi
${v}echo "${C}.${0}: FILES=${FILES}"
fi
# Set default options, if no applicable plot options were set.
COL_CTR="${#COL[*]}" # Columns were turned on.
${v}echo "COL_CTR=${COL_CTR}, COL=${COL[*]}"
if [ "${COL_CTR}" = "0" ]; then # Option not set
${v}echo "${C}.${0}: Setting default options."
FUNCTION__getopt -c2 -c4 # Set default, if no options set.
fi
if [ "${OPT_C}" = "-C" ] || # If -C or -P, ensure -S.
[ "${OPT_P}" = "-P" ]; then
if [ "${OPT_S}" != "-S" ]; then
FUNCTION__getopt -S # -S save files.
fi
fi
# Save a shar copy of this script, if -S and -v are both on.
# Turned off, may be useful later.
# if [ ! -z "${OPT_S}" ] && # -S save files.
# [ "${OPT_v}" = "-v" ]; then # -v verbose mode.
# ${v}echo "${C}.${0}: start of shar of script"
# shar -b ${C_PATH} >>${COMMAND}.shar
# ${v}echo "${C}.${0}: end of shar of script\n"
# fi
${v}echo "${C}.${0}: completed at `date`\n" # end of function
} # FUNCTION__getopt() # Use function getopt.
FUNCTION_gnuplot_init() # Initialize gnuplot command file.
{
# INITIALIZE GNU_CMDFILE
#
# - Pass options to gnuplot.
# - Some options for gnuplot are set here (logscale, autoscale).
( run in 0.435 second using v1.01-cache-2.11-cpan-2398b32b56e )