📄 356.html
字号:
}<br>
else<br>
{#XXX quoted text may get changed!!<br>
$0=" " $0 " "<br>
gsub("[ ]+", " ")<br>
gsub(" [A-Za-z_0-9]+ ", " &= ")<br>
gsub(" +=", "=")<br>
sub("^ +", "") #XXX<br>
print "DEBUG: |" $0 "|" >"/dev/tty"<br>
# "set echo/ignoreeof/noclobber/noglob/nonomatch/notify/verbose"<br>
sub("echo=", ";set -o xtrace ;")<br>
sub("ignoreeof=", ";set -o ignoreeof ;")<br>
sub("noglob=", ";set -o noglob ;")<br>
sub("nonomatch=", ";set -o verbose ;")<br>
sub("verbose=", ";set -o verbose ;")<br>
}<br>
}<br>
<br>
/(^|[ ;&|])source[ ]/ {# source script<br>
#XXX either this or function _source defined above!<br>
if (nopreamble=="ON")<br>
gsub("source[ ]+", ". ")<br>
}<br>
<br>
/(^|[ ;&|])echo($|[ ])/ {# echo -> print<br>
gsub("echo[ ]*", "print -- ")<br>
sub("print -- -n[ ]", "print -n -- ")<br>
}<br>
<br>
/(^|[ ;&|])foreach[ ].*(.*)/ {# foreach -> for ... do<br>
# warning! (.*) must appear on the same line<br>
#XXX must appear before (.*) part<br>
#XXX $2 alert! (foreach must then be BOL)<br>
gsub("foreach", "for ")<br>
sub($2, $2 " in ")<br>
gsub("(", "")<br>
gsub(")", " ; do ")<br>
}<br>
<br>
/(^|[ ;&|])while[ ]+(.*)/ {# while -> while ... do<br>
# warning! (.*) must appear on the same line<br>
gsub("(", "")<br>
gsub(")", " ; do ")<br>
}<br>
<br>
/(^|[ ;&|])goto[ ]/ {# goto -> funct call (see docs)<br>
#XXX must appear before "case" part<br>
#XXX can goto's be right semi delimited ?<br>
# _Back_ reference(s) and/or _one_ skip-to-EOF<br>
# label ("_bailout") are the only ones permitted.<br>
gsub("goto[ ]+_?", "_")<br>
label[$1]=$1<br>
}<br>
<br>
/(^|[ ;&|])case[ ].*/ {# case -> case-pattern<br>
# warning! must appear rightmost<br>
#XXX must appear before label part<br>
if (prevcase!=NR-1)<br>
gsub("case[ ]+", "")<br>
else<br>
gsub("case[ ]+", "|")<br>
gsub(":", "")<br>
# for multiple "case" statements having appeared on same line: #XXX<br>
gsub("\[ ]+|?", " | ")<br>
prevcase=NR<br>
}<br>
<br>
/(^|[ ;&|])switch[ ]+(.*)/ {# switch -> case ... {<br>
# warning! must not appear with another (.*)<br>
#XXX (.*) must appear on the same line<br>
gsub("switch[ ]+", "case ")<br>
gsub("(", " ")<br>
gsub(")", " { ")<br>
}<br>
<br>
/(^|[ ;&|])breaksw$/ {# breaksw -> ;;<br>
# warning! you _must_ use the (optional!) "breaksw" command<br>
#XXX can this be right semi delimited?<br>
gsub("breaksw", " ;; ")<br>
}<br>
<br>
/(^|[ ;&|])endsw$/ {# endsw -> esac<br>
#XXX can this be right semi delimited ?<br>
gsub("endsw", "}")<br>
}<br>
<br>
/(^|[ ;&|])alias[ ]/ {# alias syntax<br>
#XXX $0 alert! (must then be EOL)<br>
# unalias is meant to pass through<br>
# "csh: alias var 1 2" -> "alias var (1 2)"<br>
sub("alias[ ]+[A-Za-z_0-9]+[ ]", "&!<!") #XXX<br>
sub(" !<!", "='")<br>
$0=$0 "'"<br>
}<br>
<br>
/(^|[ ;&|])setenv($|[ ])/ {# setenv -> export<br>
#XXX $2 alert! (must then be BOL)<br>
#XXX $0 alert! (must then be EOL)<br>
#XXX can this be right semi delimited ?<br>
gsub("setenv", "export ")<br>
if ($2!="")<br>
{sub($2, $2 "=")<br>
sub("=[ ]*", "='")<br>
$0=$0 "'"<br>
}<br>
}<br>
<br>
/(^|[ ;&|])end$/ {# end -> done<br>
#XXX can this be right semi delimited ?<br>
gsub("end", "done")<br>
}<br>
<br>
/(^|[ ;&|])endif$/ {# endif -> fi<br>
# csh: must be the first word on the line<br>
#XXX can this be right semi delimited ?<br>
gsub("endif", "fi")<br>
}<br>
<br>
/(^|[ ;&|])(else[ ]+)?if[ ]*(/ {# else if -> elif<br>
# csh: must be the first word on the line<br>
#XXX must appear before "if" part<br>
gsub("else[ ]+if[ ]*", "elif ")<br>
}<br>
<br>
/(^|[ ;&|])(el)?if[ ]*(.*)/ {# (else)if/then syntax<br>
# warning! (.*) must appear on the same line<br>
#XXX except when their is no "then" part!<br>
#XXX $0 alert! (must then be EOL) ??<br>
if ($0~/)[ ]+then($|[ ])/)<br>
{gsub(")[ ]+then($|[ ])", ") ; then ")<br>
}<br>
else<br>
{# if ... syntax -> ... &&<br>
gsub("if[ ]+(", "( ")<br>
gsub(")[ ]+", ") && ")<br>
}<br>
}<br>
<br>
/(.*)/ {# expression syntax<br>
# warning! (.*) part must appear on the same line<br>
#XXX need to convert to ((...)) when applicable<br>
#gsub("&&", " ]] &&[[ ")<br>
#gsub("||", " ]] ||[[ ")<br>
#<br>
# (...)grouping<br>
# ~one's complement<br>
# !logicalnegation<br>
# * / %multiplication,division, remainder (These are<br>
# right associative, which can lead to<br>
# unexpected results. Group combinations<br>
# explicitly withparentheses.)<br>
# + -addition, subtraction (also right associative)<br>
# << >>bitwiseshift left, bitwise shift right<br>
# < > <= >=less than, greater than, less than or equal<br>
# to, greater than or equal to<br>
# == != =~ !~equal to, not equal to,filename-substitution<br>
# patternmatch (described below), filename-<br>
# substitution pattern mismatch<br>
# &bitwiseAND<br>
# ^bitwiseXOR (exclusive or)<br>
# |bitwiseinclusive OR<br>
# &&logicalAND<br>
# ||logicalOR<br>
#<br>
#XXX change into ((...)) or [[ ... ]], where appropriate.<br>
gsub("(", " [[ ")<br>
gsub(")", " ]] ")<br>
gsub("==", "=")<br>
gsub("=~", "=")<br>
gsub("!~", "!=")<br>
gsub("<=", "-le")<br>
gsub(">=", "-ge")<br>
gsub(">", "-lt")<br>
gsub("<", "-gt")<br>
}<br>
<br>
/[ ="']`.*`/ {# command substitution syntax<br>
#XXX must be after expression part<br>
#XXX do csh bquotes need to both be on the same line?<br>
while (sub("`", "$("))<br>
sub("`", ")")<br>
}<br>
<br>
/$</ {# $< -> read ...<br>
#XXX must appear after expression syntax<br>
#XXX set var = ($<) ??<br>
gsub("$<", "$(line)")<br>
#gsub("=$<", "")<br>
#gsub($1, "read " $1)<br>
}<br>
<br>
/(^|[ ;&|])unalias[ ]/ {# unalias syntax<br>
#XXX unalias with no arguments is meant to pass through<br>
#XXX will choke on escaped file substitution words!<br>
gsub("*", ".*", $2)<br>
gsub("?", ".", $2)<br>
gsub("unalias[ ]+", "unalias $(typeset +|grep '^" $2 "$')")<br>
}<br>
<br>
/(^|[ ;&|])unset[ ]/ {# unset syntax<br>
#XXX must appear after `.*` and expression parts<br>
#XXX will choke on escaped file substitution words!<br>
gsub("*", ".*", $2)<br>
gsub("?", ".", $2)<br>
gsub("unset[ ]", "unset $(typeset +|grep '^" $2 "$')")<br>
}<br>
<br>
#XXX<br>
/XXX(^|[ ;&|)@($|[ ])/ {# @ -> let<br>
#XXX must appear after expresssion part<br>
#XXX does "@" have a significance to a "nawk" r.e. ??<br>
if ($2!="")<br>
{sub("@[ ]+", "(( ")<br>
$0=$0 " ))"<br>
}<br>
else<br>
{sub("@", "typeset -")<br>
}<br>
}<br>
<br>
/(^|[ ;&|])onintr($|[ ])/ {# interrupt trapping<br>
#XXX $0 alert (must then be EOL!)<br>
if ($0~/onintr$/)<br>
{$0="trap -"<br>
}<br>
else if ($0~/[ ]-$/)<br>
{$0="trap ''"<br>
}<br>
else<br>
{gsub("onintr[ ]+", "trap _")<br>
$0=$0 " INT"<br>
}<br>
}<br>
<br>
/^[ ]*default:$/ {# default: -> *)<br>
#XXX must appear before "label" part<br>
gsub("default:", "*)")<br>
}<br>
<br>
/(^|[ ;&|])[A-Za-z_][A-Za-z_0-9]*:$/ {# goto label -> function definition<br>
#XXX $0 alert! (must then be EOL)<br>
# The special label "_bailout" should be used<br>
# for the usual purpose of breaking to EOF.<br>
if ($0~/(^|[ ]+)_?bailout:$/)<br>
next# already defined as function above<br>
sub("[A-Za-z_0-9]+:", "_&")<br>
sub(":", " () { eval ${1:+trap "set -- $@; set -A argv "$@"" EXIT}")<br>
}<br>
<br>
/>&?(?!)?/ {# redirection operators syntax<br>
# > >! >& >&!<br>
# >> >>& >>! >>&!<br>
gsub(">>&", " 2!#!&1 !#!>")<br>
gsub(">&", " 2>&1 >")<br>
gsub("!#!", ">")<br>
gsub(">(\)?!", ">|")<br>
gsub(">>|", ">>")# because ">>|" is ksh syntax error<br>
}<br>
<br>
{gsub(" +", " ")# strip redundant spaces<br>
#XXX this should be subsumed by escnl rejoined in prior pass<br>
if ($0~/[&|][ ]+$/)<br>
# "|", "||", "&&" operators don't need escaped newline<br>
$0=substr($0, 1, length($0)-2)<br>
sub(" ", " ")<br>
sub("[ ]+$", "")# strip any trailing whitespace<br>
sub("[^;];$", "")# strip any trailing semicolon<br>
sub("[^;];$", "")# and do it again (#XXXtry "@" feature)<br>
if (!prevcase || prevcase==NR-1)<br>
# append right paren delimiting multi-line case patterns<br>
$0=")" $0<br>
print<br>
#printf "%2d,%2d: %s", NR, prevcase, $0<br>
}<br>
<br>
END {<br>
#XXX undefined hash print order!<br>
# for every "onintr" label turned into a function...<br>
for (key in label)<br>
if (key!="_bailout")<br>
print "}; " label[key]<br>
}<br>
<br>
偶觉得不太会有这种自动转换程序吧,其实自己手工转换一下,正好熟悉几种shell的区别,乐事也<br>
</FONT><br>
</TD>
</TR>
<TR>
<TD colSpan=2><FONT
class=middlefont></FONT><BR>
<FONT
class=normalfont>全文结束</FONT> </TD>
</TR>
<TR>
<TD background="images/dot.gif" tppabs="http://www.linuxhero.com/docs/images/dot.gif" colSpan=2
height=10></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></DIV></TD>
<TD vAlign=top width="20%"
background="images/line.gif" tppabs="http://www.linuxhero.com/docs/images/line.gif" rowSpan=2>
<DIV align=center>
<table class=tableoutline cellspacing=1 cellpadding=4
width="100%" align=center border=0>
<tr class=firstalt>
<td noWrap background="images/bgline.gif" tppabs="http://www.linuxhero.com/docs/images/bgline.gif" colspan=2 height=21>
<font class=normalfont><b>所有分类</b></font></td>
</tr>
<tr class=secondalt> <td noWrap width=27%> <font class=normalfont>1:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type1.html" tppabs="http://www.linuxhero.com/docs/type1.html">非技术类</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>2:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type2.html" tppabs="http://www.linuxhero.com/docs/type2.html">基础知识</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>3:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type3.html" tppabs="http://www.linuxhero.com/docs/type3.html">指令大全</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>4:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type4.html" tppabs="http://www.linuxhero.com/docs/type4.html">shell</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>5:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type5.html" tppabs="http://www.linuxhero.com/docs/type5.html">安装启动</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>6:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type6.html" tppabs="http://www.linuxhero.com/docs/type6.html">xwindow</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>7:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type7.html" tppabs="http://www.linuxhero.com/docs/type7.html">kde</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>8:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type8.html" tppabs="http://www.linuxhero.com/docs/type8.html">gnome</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>9:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type9.html" tppabs="http://www.linuxhero.com/docs/type9.html">输入法类</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>10:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type10.html" tppabs="http://www.linuxhero.com/docs/type10.html">美化汉化</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>11:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type11.html" tppabs="http://www.linuxhero.com/docs/type11.html">网络配置</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>12:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type12.html" tppabs="http://www.linuxhero.com/docs/type12.html">存储备份</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>13:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type13.html" tppabs="http://www.linuxhero.com/docs/type13.html">杂项工具</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>14:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type14.html" tppabs="http://www.linuxhero.com/docs/type14.html">编程技术</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>15:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type15.html" tppabs="http://www.linuxhero.com/docs/type15.html">网络安全</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>16:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type16.html" tppabs="http://www.linuxhero.com/docs/type16.html">内核技术</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>17:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type17.html" tppabs="http://www.linuxhero.com/docs/type17.html">速度优化</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>18:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type18.html" tppabs="http://www.linuxhero.com/docs/type18.html">apache</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>19:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type19.html" tppabs="http://www.linuxhero.com/docs/type19.html">email</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>20:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type20.html" tppabs="http://www.linuxhero.com/docs/type20.html">ftp服务</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>21:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type21.html" tppabs="http://www.linuxhero.com/docs/type21.html">cvs服务</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>22:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type22.html" tppabs="http://www.linuxhero.com/docs/type22.html">代理服务</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>23:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type23.html" tppabs="http://www.linuxhero.com/docs/type23.html">samba</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>24:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type24.html" tppabs="http://www.linuxhero.com/docs/type24.html">域名服务</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>25:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type25.html" tppabs="http://www.linuxhero.com/docs/type25.html">网络过滤</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>26:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type26.html" tppabs="http://www.linuxhero.com/docs/type26.html">其他服务</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>27:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type27.html" tppabs="http://www.linuxhero.com/docs/type27.html">nfs</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>28:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type28.html" tppabs="http://www.linuxhero.com/docs/type28.html">oracle</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>29:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type29.html" tppabs="http://www.linuxhero.com/docs/type29.html">dhcp</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>30:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type30.html" tppabs="http://www.linuxhero.com/docs/type30.html">mysql</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>31:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type31.html" tppabs="http://www.linuxhero.com/docs/type31.html">php</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>32:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type32.html" tppabs="http://www.linuxhero.com/docs/type32.html">ldap</a></font></td> </tr> </table></td></tr> </table>
</DIV></TD></TR>
<TR vAlign=top>
<TD width="80%">
<DIV align=center><BR>
</DIV>
</TD></TR></TBODY></TABLE></TD></TR>
</TABLE></TD></TR>
</TABLE>
<TABLE cellSpacing=0 cellPadding=4 width="100%" bgColor=#eeeeee
border=0><TBODY>
<TR>
<TD width="50%">
<P><FONT class=middlefont>版权所有 © 2004 <A
href="mailto:bjchenxu@sina.com">linux知识宝库</A><BR>
违者必究. </FONT></P>
</TD>
<TD width="50%">
<DIV align=right><FONT class=middlefont>Powered by: <A
href="mailto:bjchenxu@sina.com">Linux知识宝库</A> Version 0.9.0 </FONT></DIV>
</TD></TR></TBODY></TABLE>
<CENTER></CENTER></TD></TR>
</TABLE></CENTER></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -