--- platform.sh 2003/09/08 11:24:01 1.2
+++ platform.sh 2003/09/08 19:03:03 1.3
@@ -25,7 +25,7 @@
##
# program information
-prog_run="${prog_run}"
+prog_run="${0}"
prog_cmd="platform"
prog_name="OSSP platform"
prog_vers="0.1.0"
@@ -44,22 +44,22 @@
str_usage="$str_usage [-C|--conc STRING]"
str_usage="$str_usage [-L|--lower]"
str_usage="$str_usage [-U|--upper]"
-str_usage="$str_usage [-T|--type TYPE]"
str_usage="$str_usage [-v|--verbose]"
str_usage="$str_usage [-c|--concise]"
-str_usage="$str_usage [-n|--newline]"
+str_usage="$str_usage [-n|--no-newline]"
+str_usage="$str_usage [-t|--type TYPE]"
str_usage="$str_usage [-d|--debug]"
str_usage="$str_usage [-V|--version]"
str_usage="$str_usage [-h|--help]"
arg_spec="0="
-opt_spec="F:S:C:L.U.T:v.c.n.d.V.h."
-opt_alias="F:format,S:sep,C:conc,L:lower,U:upper,T:type,v:verbose,c:consise,n:newline,d:debug,V:version,h:help"
-opt_F="Class: %sc (%ac)\\nProduct: %sp (%ap)\\nTechnology: %st (%at)"
+opt_spec="F:S:C:L.U.v.c.n.t:d.V.h."
+opt_alias="F:format,S:sep,C:conc,L:lower,U:upper,v:verbose,c:consise,t:type,n:no-newline,d:debug,V:version,h:help"
+opt_F="%{sp} (%{ap})"
opt_S=" "
opt_C="/"
opt_L=no
opt_U=no
-opt_T=""
+opt_t=""
opt_v=no
opt_c=no
opt_n=no
@@ -68,7 +68,7 @@
opt_h=no
# commonly used ASCII values
-ASC_TAB=" "
+ASC_TAB=" "
ASC_NL="
"
@@ -202,6 +202,76 @@
## _________________________________________________________________________
##
+## OPTION POST-PROCESSING
+## _________________________________________________________________________
+##
+
+if [ ".$opt_t" != . ]; then
+ case "$opt_t" in
+ binary )
+ # binary package id (OpenPKG RPM)
+ opt_F="%<ap>-%<sp>"
+ opt_L=yes
+ opt_S=""
+ opt_C="+"
+ ;;
+ build )
+ # build time checking (OpenPKG RPM)
+ opt_F="%<at>-%<st>"
+ opt_L=yes
+ opt_S=""
+ opt_C="+"
+ ;;
+ gnu )
+ # GNU config.guess style <arch>-<vendor>-<os><osversion>
+ opt_F="%<at>-unknown-%<st>"
+ opt_L=yes
+ opt_S=""
+ opt_C="+"
+ ;;
+ web )
+ # non-whitespace HTTP Server-header id
+ opt_F="%<ap>-%<sp>"
+ opt_S="/"
+ opt_C="+"
+ ;;
+ summary)
+ # human readable verbose summary information
+ opt_F="Class: %[sc] (%[ac])\\nProduct: %[sp] (%[ap])\\nTechnology: %[st] (%[at])"
+ opt_S=" "
+ opt_C="/"
+ ;;
+ all-in-one )
+ # full-table all-in-one information
+ opt_F=""
+ opt_F="${opt_F}concise architecture class: %<ac>\\n"
+ opt_F="${opt_F}regular architecture class: %{ac}\\n"
+ opt_F="${opt_F}verbose architecture class: %[ac]\\n"
+ opt_F="${opt_F}concise architecture product: %<ap>\\n"
+ opt_F="${opt_F}regular architecture product: %{ap}\\n"
+ opt_F="${opt_F}verbose architecture product: %[ap]\\n"
+ opt_F="${opt_F}concise architecture technology: %<at>\\n"
+ opt_F="${opt_F}regular architecture technology: %{at}\\n"
+ opt_F="${opt_F}verbose architecture technology: %[at]\\n"
+ opt_F="${opt_F}concise system class: %<sc>\\n"
+ opt_F="${opt_F}regular system class: %{sc}\\n"
+ opt_F="${opt_F}verbose system class: %[sc]\\n"
+ opt_F="${opt_F}concise system product: %<sp>\\n"
+ opt_F="${opt_F}regular system product: %{sp}\\n"
+ opt_F="${opt_F}verbose system product: %[sp]\\n"
+ opt_F="${opt_F}concise system technology: %<st>\\n"
+ opt_F="${opt_F}regular system technology: %{st}\\n"
+ opt_F="${opt_F}verbose system technology: %[st]"
+ ;;
+ * )
+ echo "${prog_cmd}:Error: invalid type \`$opt_t'" 1>&2
+ exit 1
+ ;;
+ esac
+fi
+
+## _________________________________________________________________________
+##
## UTILITY FUNCTIONS
## _________________________________________________________________________
##
@@ -399,7 +469,11 @@
val_V=`echo ":$val" | \
sed -e 's/^://' \
-e 's;\[\([^]]*\)\];\1;g' \
- -e 's;<\([^>]*\)>;\1;'`
+ -e 's;<\([^>]*\)>;\1;' \
+ -e "s; ;§§;g" \
+ -e "s;/;%%;g" \
+ -e "s;§§;${opt_S};g" \
+ -e "s;%%;${opt_C};g"`
eval "${var_uc}_V=\"\${val_V}\""
;;
esac
@@ -408,7 +482,11 @@
val_N=`echo ":$val" | \
sed -e 's/^://' \
-e 's;\[\([^]]*\)\];;g' \
- -e 's;<\([^>]*\)>;\1;'`
+ -e 's;<\([^>]*\)>;\1;' \
+ -e "s; ;§§;g" \
+ -e "s;/;%%;g" \
+ -e "s;§§;${opt_S};g" \
+ -e "s;%%;${opt_C};g"`
eval "${var_uc}_N=\"\${val_N}\""
;;
esac
@@ -417,7 +495,11 @@
val_C=`echo ":$val" | \
sed -e 's/^://' \
-e 's;\[\([^]]*\)\];;g' \
- -e 's;[^<]*<\([^>]*\)>;\1;'`
+ -e 's;[^<]*<\([^>]*\)>;\1;' \
+ -e "s; ;§§;g" \
+ -e "s;/;%%;g" \
+ -e "s;§§;${opt_S};g" \
+ -e "s;%%;${opt_C};g"`
eval "${var_uc}_C=\"\${val_C}\""
;;
esac
@@ -462,12 +544,6 @@
output=`util_upper "$output"`
fi
-# support particular separator and concatenator strings
-output=`echo ":$output" |
- sed -e 's/^://' \
- -e "s; ;${opt_S};g" \
- -e "s;/;${opt_C};g"`
-
# display output string
if [ ".$opt_n" = .yes ]; then
echo . | awk '{ printf("%s", output); }' output="$output"
|