求大神解释一下这一段shell编程的意思!!!!
#!/bin/bash#-------------CopyRight-------------# Name:Mine Sweeping# Version Number:1.00# Type:game# Language:bash shell# Date:2005-10-26#------------Environment------------# Terminal: column 80 line 24# Linux 2.6.9 i686# GNU Bash 3.00.15#----------------------------------- #---------------Define--------------ECHO="echo-ne"ESC="\033[" OK=0FALSE=1#--------------Variable--------------#ANSIESC actionFLASH=5REV=7 #NULL=0BLACK=30RED=31GREEN=32ORANGE=33BLUE=34PURPLE=35SBLUE=36GREY=37 #BBLACK=40BRED=41BGREEN=42BORANGE=43BBLUE=44BPURPLE=45BSBLUE=46BGREY=47 MINE='@'FLAG='F'NUL=' 'SHADOW='X' X=0Y=0CurX=1#cur's XCurY=1#cur's YOCurX=1#old cur's XOCurY=1#old cur's YMCount=0#count mineFCount=0#count flagSCount=0#count shadowMXYp=0#MXY Array's ptr#---------------Array---------------- #if${XY[]} == M { mine }#if${XY[]} == F { flag }#if${XY[]} == N { null }#if${XY[]} == S { shadow }#if${XY[]} == { tip_num }#${XY[]}init in XYInit(i) MXY="" #--------------Function--------------# functionSttyInit (){ stty_save=$(stty -g) #backup stty clear trap "GameExit;" 2 15 stty -echo $ECHO "${ESC}?25l" #hiddencursor return $OK} functionGameExit (){ stty $stty_save stty echo clear trap 2 15 $ECHO"${ESC}?25h${ESC}0;0H${ESC}0m" exit $OK} #printhelpfunctionHelp (){ msg="Move:w s a d Dig:j Flag:fNewGame:n Exit:x --CopyRight---2005-10-28 BitBull--" $ECHO"${ESC}${REV};${RED}m${ESC}24;1H${msg}${ESC}${NULL}m" return $OK} #问题1:粗体字部分功能是什么?(10分)function PMsg (){ localtitle="$1" content="$2" greeting="$3" $ECHO"${ESC}${RED}m" $ECHO"${ESC}11;20H ------------------------------------------- " $ECHO"${ESC}12;20H| ======>$title<====== |" $ECHO"${ESC}13;20H| $content |" $ECHO"${ESC}14;20H| ======>$greeting<====== |" $ECHO"${ESC}15;20H ------------------------------------------- " $ECHO"${ESC}${NULL}m" return $OK} #function Menu (){ local key $ECHO "${ESC}6;1H${ESC}${RED}m"cat<<MENUEND +++++++++++++++++++++++++++++ + (1) Easy + + (2) Normal + + (3) Hardly + + (4) Exit + +++++++++++++++++++++++++++++MENUEND $ECHO "${ESC}${NULL}m" while read -s -n 1 key do case$key in 1)X=10;Y=10;MCount=10;FCount=10;SCount=100;break ;; 2)X=20;Y=14;MCount=28;FCount=28;SCount=280;break ;; 3)X=36;Y=18;MCount=65;FCount=65;SCount=648;break ;; 4)GameExit ;; esac done return $OK} #receiveCurX CurY,put it into XY#if $#== 3;write into XY[]#if $#== 2;read from XY[]functionXYFormat (){ local XTmp=$1 YTmp=$2 if [[ $# -eq 3 ]] then XY[$XTmp+$X*($YTmp-1)]=$3 else echo ${XY[$XTmp+$X*($YTmp-1)]} fi return $OK} functionDrawInit (){ local DIline DIline2 DIline=$( for (( i=1; i<$((X*2)); i++)) do $ECHO '-';done ) DIline2=$( for (( i=0; i<X; i++ )) do$ECHO "|${ESC}${SBLUE}mX${ESC}${NULL}m";done ) clear Help $ECHO "${ESC}1;1H+${DIline}+" for (( i=0; i<Y; i++ )) do $ECHO"${ESC}$((i+2));1H${DIline2}|" done $ECHO"${ESC}$((Y+2));1H+${DIline}+" return $OK} #${XY[*]}=SfunctionXYInit (){ for (( i=1; i<=$X; i++ )) do for(( j=1; j<=$Y; j++ )) do XYFormat $i $j S done done return $OK} #check XYfunctionCheckXY (){ local XYTmp="$1 $2" for(( i=0; i<MXYp; i++ )) do if[[ "${MXY}" == "$XYTmp" ]] thenreturn $FALSE fi done return $OK} #RANDOMmine's X YfunctionXYRand (){ local XTmp YTmp for(( i=0; i<MCount; i++ )) do while: do XTmp=$(( RANDOM % ( X - 1 ) + 1 )) YTmp=$(( RANDOM % ( Y - 1 ) + 1 )) CheckXY $XTmp $YTmp if [[ "$?" == "$OK"]] then XYFormat$XTmp $YTmp M MXY="$XTmp$YTmp" ((++MXYp )) break else continue fi done done return $OK}{:5_597:},显示信息,$ECHO"${ESC}11;20H,ECHO="echo-ne".11;20H是颜色的规范编码,esc在开头也有定义{:5_586:}其他不懂,请linux君出场 媛懒如此 发表于 2013-4-1 22:50 static/image/common/back.gif
,显示信息,,ECHO="echo-ne".11;20H是颜色的规范编码,esc在开头也有定义其他不懂,请 ...
谢谢你的解答
页:
[1]