Submitted by khaledhosny on Sun, 04/12/2005 - 23:58.
( categories: )

as I can't configure man to use "groff-utf8" instead of "groff", I wrote that silly script to use it as a man program for Arabic man pages (untill I found a better solution).

but my scripting skills sucks (even if bash),so I need some help here (note that: the script works, but I think it could be better)


#!/bin/bash
#this is a silly script to be used as a "man" programe,
#I wrote it as I faild to configure "man" to use groff-utf8 instead of groff
#NOTE:this script depends on groff-utf8 extension available from http://www.haible.de/bruno/packages-groff-utf8.html

#uncomment that to use "more" as your pager

#PAGER=/bin/more

#ask "man" for the path to manpage
MAN_PAGE=`LC_ALL=ar man -wc $1`

#tray to check if the file is compressed or not, 
#and the type of compression
Z=`file $MAN_PAGE | grep zip`
GZ=`file $MAN_PAGE | grep gzip`
PZ=`file $MAN_PAGE | grep bzip2`

#groff command to use
GROFF='/usr/local/bin/groff-utf8 -Tutf8 -mandoc'

#if not compressed
if [ -z "$Z" ]; then
	$GROFF $MAN_PAGE | $PAGER
else
	#if gzipped
	if [ -z "$PZ" ]; then
		zcat $MAN_PAGE | $GROFF | $PAGER
	else
		#if bzipped2
		bzcat $MAN_PAGE | $GROFF | $PAGER
	fi
fi


اتحلت خلاص

khaledhosny's picture

although ther is'nt any replys, the proplem is solved now, it was less proplem and there is no need to that script

anyhow, I rewrote it and it seems to be better now


#!/bin/bash 
#this is a silly script to be used as a "man" programe,
#I wrote it as I faild to configure "man" to use groff-utf8 instead of groff
#NOTE:this script depends on groff-utf8 extension available from http://www.haible.de/bruno/packages-groff-utf8.html

#groff command to use
GROFF_BIN=$(which groff-utf8 2>/dev/null)
GROFF="$GROFF_BIN -Tutf8 -mandoc"

#uncomment that to use "more" as your pager
#PAGER=/bin/more

#ask "man" for the path to manpage
MAN_PAGE=$(LC_ALL=ar man -wc $* 2>/dev/null)

function Usage()
{
echo -e "This is a man program for Arabic manpages"
echo -e "usage: aman [file]                       "
echo -e "where file is the name of manpage to be displayed"
}

function ERR_no_manpage()
{
echo -e "$0 $1: No manual entry for $*"
}

function ERR_no_groff-utf8()
{
echo -e "Can't find groff-utf8"
echo -e "Get it from:"
echo -e "http://www.haible.de/bruno/packages-groff-utf8.html"
}
#check for args
function Args_CHK()
{
if [ -z "$1" ]; then
	Usage;exit
fi
}
#check the presence of groff-utf8
function Groff_CHK()
{
if [ -z "$GROFF_BIN" ]; then
	ERR_no_groff-utf8;exit
fi
}

#check the presence of the manpage
function Man_CHK()
{
if [ -z "$MAN_PAGE" ]; then
	 ERR_no_manpage;exit 
fi
}

#tray to check if the file is compressed or not, 
#and the type of compression
GZ=$(file $MAN_PAGE 2>/dev/null | grep gzip)
PZ=$(file $MAN_PAGE 2>/dev/null | grep bzip)
Z=$(file $MAN_PAGE 2>/dev/null | grep zip)

function Core()
{
if [ -z "$Z" ]; then
        $GROFF $MAN_PAGE | $PAGER
else
	#if gzipped
	if [ -z "$PZ" ]; then
		zcat $MAN_PAGE | $GROFF | $PAGER
	else
		#if bzipped2
		bzcat $MAN_PAGE | $GROFF | $PAGER
	fi
fi										
}

#do it
Args_CHK $1
Groff_CHK
Man_CHK
Core

My blog

أنا عمال أغنى ور

khaledhosny's picture

أنا عمال أغنى ورد على نفسى ;)

المهم, الحكاية طلعت فى less مش فى man أصل أنا من سرحانى كنت باعمل


$LC_ALL=ar man katoob

وعمال أقول يخويا less ده ما كان شغال مع اليونيكود حلو ايه اللى جرى ,وأتارى ان أنا ناسى أحط UTF-8

يعنى كل السكريبت مبقاش له لزمة خلاص


My blog

و أنت مستني ايه

Alaa's picture

و أنت مستني ايه يعني؟ متخيل كام واحد فينا استخدم groff قبل كده؟

cheers,
Alaa


http://www.manalaa.net "context is over-rated. who are you anyway?"

سكربت شغال كون

MSameer's picture

سكربت شغال

كون انه وحش او حلو من وجهة نظرك لا يعنى ان يتطوع اىشخص للمساعده مادام السكربت شغال

لو مكانش شغال كان اى حد ممكن يبص

!!!


WWW: The place for organized randoms!
EGLUG Admin..
Arabeyes X-Core Member.
Free Software Foundation Associate Member.

ياعم أنا مش زعلا

khaledhosny's picture

ياعم أنا مش زعلان

يظهر المفروض ده كنت احطه فى البلوج مش فى المنتدى


My blog

انا قلت انك زعلا

MSameer's picture

انا قلت انك زعلان ؟؟


WWW: The place for organized randoms!
EGLUG Admin..
Arabeyes X-Core Member.
Free Software Foundation Associate Member.

لأ طبعا أنت عملت

Alaa's picture

لأ طبعا أنت عملت الصح لما حطيته هنا، محمد يقصد يوضحلك أنه محدش قصده يطنشك ولا حاجة، و زي ما قلت موضوع أصلا محدش اتعرضله قبل كده (بحيث أن أنا لحد دلوقتي مقريتش السكريبت ولا حاولت أفهم الموضوع كفاية على أنه groff و دي حاجة مستخدمتهاش و لا هستخدمها قريب).

cheers,
Alaa


http://www.manalaa.net "context is over-rated. who are you anyway?"

أنا مقولتش ان حد

khaledhosny's picture

أنا مقولتش ان حد يقصد يطنش ولا حاجة لا سمح الله

أنا بس حبيت اتريق على نفسى شوية لما لقيت ان انا عمال اكتب ورد على اللى أنا كتبته


My blog

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.