0byt3m1n1
Path:
/
data
/
sbin
/
[
Home
]
File: inquent-fileman-localize.sh
#!/bin/ksh # # Inquent Fileman Localization # Generic localization is invoked via: # $ <locscript> generic <key> <delimeter> <new_value> <file_name> # PATH=/bin:/usr/bin:/usr/local/bin:. export PATH loc_generic () { key=$1; shift delim=$1; shift value=$1; shift file="$@" perl -pi -e "\$v = q{$value};" \ -e "\$k = q{$key};" \ -e "\$d = q{$delim};" \ -e 's/^($k\s*$d[ \t]*).*$/$1$v/;' $file } # Append a comma (,) and the value at the end of the record, # before any trailing whitespace. loc_commaAppend () { key=$1; shift delim=$1; shift value=$1; shift file="$@" perl -pi -e "\$v = q{$value};" \ -e "\$k = q{$key};" \ -e "\$d = q{$delim};" \ -e 's/^($k\s*$d\s*\S*)/$1,$v/;' $file } loc_quoted_shell_var() { key=$1; shift delim=$1; shift value=$1; shift file="$@" perl -pi -e "\$v = q{$value};" \ -e "\$k = q{$key};" \ -e "\$d = q{$delim};" \ -e 's/^($k\s*$d\s*).*$/$1"$v"/;' $file } loc_index () { #add the environment name to the <title> of a .html/.jhtml page env=$1; shift files="$@" /usr/local/bin/perl -pi -e "\$e = q{$env};" \ -e 's/(<title>)(.*)/$1$e- $2/;' \ $files } loc_replace () { #replace one string with another key=$1; shift value=$1; shift file="$@"; shift perl -pi -e "\$k = q{$key};" \ -e "\$v = q{$value};" \ -e 's/$k/$v/;' $file } usage() { echo usage: $0 type [ args... ] exit } ### MAIN if [ $# -eq 0 ]; then usage else cmd=$1 && shift real_cmd="loc_$cmd" $real_cmd "$@" || usage fi