USAGE: lampadasql command { language }

This will pipe the file <command> together with each <language>
through the m4 macro processor.
This commit is contained in:
alba 2002-07-04 20:03:16 +00:00
parent 32373438e5
commit df7686ca05
1 changed files with 49 additions and 0 deletions

49
LDP/lampadas/bin/lampadasql Executable file
View File

@ -0,0 +1,49 @@
#!/bin/sh
check_file()
{
[ -e "$1" ] && return
echo "File $1 does not exist." 1>&2
exit 1
}
all_files()
{
for lang in "$@"; do
lang="${lang%.m4}"
file="$lang.m4"
check_file "$file"
m4 -P "-DI18N_lang_code=$lang" "$COMMAND" "$file"
done
}
DEFAULT_LANG=$( echo "${LANG%_*}" | tr 'a-z' 'A-Z' )
if [ -z "$1" ]; then
echo "\
USAGE: lampadasql command { language }
This will pipe the file <command> together with each <language>
through the m4 macro processor. The suffix '.m4' will be appended
if not present.
If no value for <language> is given, the first two letters of variable
\$LANG are used. Right now that would be $DEFAULT_LANG.
Typically the output of lampadasql is further piped into /usr/bin/psql
to execute SQL statements:
lampadasql update EN | psql lampadas
" 1>&2
exit 1
fi
COMMAND="${1%.m4}.m4"
check_file "$COMMAND"
shift
if [ -z "$1" ]; then
all_files $DEFAULT_LANG
else
all_files "$@"
fi