{"id":305244,"date":"2020-06-11T21:00:31","date_gmt":"2020-06-11T21:00:31","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=305244"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=305244","title":{"rendered":"\u0418\u0433\u0440\u0430\u044e\u0447\u0438 BASH&#8217;\u0438\u043c \u0434\u043e\u043c\u0430"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/504462\/\">\u041a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f: \u00ab\u041d\u0435 \u0431\u044b\u043b\u043e \u0431\u044b \u0441\u0447\u0430\u0441\u0442\u044c\u044f, \u0434\u0430 \u043d\u0435\u0441\u0447\u0430\u0441\u0442\u044c\u0435 \u043f\u043e\u043c\u043e\u0433\u043b\u043e.\u00bb \u0412\u043d\u0435\u0437\u0430\u043f\u043d\u043e \u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u044f\u0432\u0438\u043b\u043e\u0441\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438 \u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u043b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043f\u0438\u0443-\u043f\u0438\u0443.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/4ed\/c0c\/1fe\/4edc0c1fe18d8841e72feb454090673e.png\" alt=\"image\"><br \/>  <a name=\"habracut\"><\/a><br \/>  \u041d\u0435 \u0441\u043b\u044b\u0448\u0430\u043b\u0438 \u043f\u0440\u043e \u043f\u0438\u0443-\u043f\u0438\u0443? \u041c\u043e\u0436\u043d\u043e \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0442\u0443\u0442:<br \/>  \u041f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f <a href=\"https:\/\/habrahabr.ru\/post\/335960\" rel=\"nofollow\">\u0418. BASH&#8217;\u0438\u043c \u0432 \u043d\u0430\u0447\u0430\u043b\u043e<\/a><br \/>  \u0412\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f <a href=\"https:\/\/habr.com\/ru\/post\/337896\">\u0418. BASH&#8217;\u0438\u043c \u0434\u0430\u043b\u044c\u0448\u0435<\/a><br \/>  \u0422\u0440\u0435\u0442\u044c\u044f \u0441\u0442\u0430\u0442\u044c\u044f <a href=\"https:\/\/habr.com\/ru\/post\/339268\">\u0418. BASH&#8217;\u0438\u043c \u0432\u043c\u0435\u0441\u0442\u0435<\/a><\/p>\n<p>  \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c\\\u043f\u043e\u0438\u0433\u0440\u0430\u0442\u044c \u043c\u043e\u0436\u043d\u043e, \u0441\u043a\u0430\u0447\u0430\u0432 \u0438\u0433\u0440\u0443 <a href=\"https:\/\/github.com\/vaniacer\/piu-piu-SH\" rel=\"nofollow\">\u0442\u0443\u0442<\/a>, \u0438\u043b\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0438\u0433\u0440\u0443 apt&#8217;\u043e\u043c:  <\/p>\n<pre><code class=\"bash\">sudo apt install -y piu-piu <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0412\u043e\u0440\u043d\u0438\u043d\u0433, \u0442\u044f\u0436\u0435\u043b\u0430\u044f \u0433\u0438\u0444\u043a\u0430!<\/b>                         <\/p>\n<div class=\"spoiler_text\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/b06\/98b\/94b\/b0698b94beeda5e0974eca11a6f36381.gif\" alt=\"image\">  <\/div>\n<\/p><\/div>\n<p>  \u0427\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c? \u0412\u043d\u0435\u0448\u043d\u0435 \u043d\u0435 \u0437\u0430\u043c\u0435\u0442\u043d\u043e, \u043d\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c \u0432\u0441\u0435. \u0414\u0432\u0438\u0436\u043e\u043a \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u043d \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e. \u0415\u0441\u043b\u0438 \u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043f\u0440\u0430\u0439\u0442\u0430 \u0431\u044b\u043b\u043e \u0434\u0432\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430. \u00ab\u041c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0439\u00bb \u0441\u043f\u0440\u0430\u0439\u0442 \u0434\u043b\u044f \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u0437-\u0437\u0430 \u044d\u043a\u0440\u0430\u043d\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0431\u0438\u0440\u0430\u043b\u0441\u044f \u0438\u0437 \u043e\u0431\u0440\u0435\u0437\u043a\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432, \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0441 \u0441\u0438\u043c\u0432\u043e\u043b\u0430\u043c\u0438 \u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0441 \u0446\u0432\u0435\u0442\u0430\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u043a\u043e\u0434\u044b \u0440\u0430\u0437\u0443\u043a\u0440\u0430\u0448\u0438\u0432\u0430\u043d\u0438\u044f \u043d\u0435 \u043e\u0431\u0440\u0435\u0437\u0430\u043b\u0438\u0441\u044c \u043f\u0440\u0438 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0438. \u0418 \u00ab\u0431\u044b\u0441\u0442\u0440\u044b\u0439\u00bb, \u0432\u0435\u0441\u044c \u0441\u043f\u0440\u0430\u0439\u0442 \u0440\u0438\u0441\u043e\u0432\u0430\u043b\u0441\u044f \u0441\u0440\u0430\u0437\u0443 \u0441 \u043a\u043e\u0434\u0430\u043c\u0438 \u0440\u0430\u0437\u0443\u043a\u0440\u0430\u0448\u0438\u0432\u0430\u043d\u0438\u044f \u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u043f\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u044d\u043a\u0440\u0430\u043d\u0430. \u042d\u0442\u043e \u0431\u044b\u043b\u0430 \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0431\u043e\u043b\u044c, \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0443\u0439\u0442\u0438. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043d\u043e\u0432\u043e\u0439 \u0441\u0445\u0435\u043c\u0435 \u043f\u0440\u043e\u043f\u0430\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0434\u0432\u0443\u0445 \u0432\u0435\u0440\u0441\u0438\u0439 \u0441\u043f\u0440\u0430\u0439\u0442\u0430. \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u044d\u0442\u043e \u0442\u0430\u043a \u0436\u0435 \u0431\u044b\u0441\u0442\u0440\u043e, \u0430 \u043d\u0430 \u0443\u0437\u043a\u043e\u043c \u044d\u043a\u0440\u0430\u043d\u0435 \u0434\u0430\u0436\u0435 \u0431\u044b\u0441\u0442\u0440\u0435\u0439, \u0438 \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0430 \u0441\u043f\u0440\u0430\u0439\u0442\u0430 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u043b\u0430\u0441\u044c \u0432 \u0440\u0430\u0437\u044b. \u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u043f\u0440\u0430\u0439\u0442\u0430 \u00ab\u0434\u0435\u0440\u0435\u0432\u0446\u04352\u00bb:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/3_\/i3\/lc\/3_i3lc9c7rvxoe60ljsxys3qysu.png\" align=\"right\"><\/p>\n<pre><code class=\"bash\">sprite_tree2 () {     mov - &amp;&amp; BP2[i]=&quot;tree2 $OX $OY $OH $OW $SC $SM $CS $CL $AS $AL&quot; \\           || { unset BP2[i]; return; }     X1=&quot;_Y_$[OX+1]H&quot; X2=&quot;_Y_$[OX+1]H&quot; X3=&quot;_Y_$[OX+2]H&quot; X4=&quot;_Y_$[OX+2]H&quot;     #0123456     #1 _._       #2\/   \\      #3\\ | \/      #4 \\\u2551\/\\      #5  \u2551_\/      #6  \u2551        ####################  1     2        3       4       5    6  #0     cut $SX  $OY    $T2C '' $X1'_'      '.'     '_'     ' '      #1     cut $SX $[OY+1] $T2C '\/'   ' '      ' '     ' '     '\\\\' ' ' #2     cut $SX $[OY+2] $T2C '\\\\'  ' '  $blk'|'     ' ' $T2C'\/'  ' ' #3     cut $SX $[OY+3] $T2C '' $X2'\\\\' $blk'\u2551' $T2C'\/' $T2C'\\\\' ' ' #4     cut $SX $[OY+4] $blk ''    ''    $X3'\u2551' $T2C'_' $T2C'\/'  ' ' #5     cut $SX $[OY+5] $blk ''    ''    $X4'\u2551'     ' ';;            #6 } <\/code><\/pre>\n<p>  \u0418 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 &#8216;mov&#8217; \u0438 &#8216;cut&#8217;:  <\/p>\n<pre><code class=\"bash\">mov () {     case $1  in -) cuter=++;; +) cuter=--;; esac     case $SC in         0) [[ $OX -le -$OW   ]] &amp;&amp; return 1            [[ $OX -gt  $endx ]] &amp;&amp; return 1            [[ $AS -ge  $AL   ]] &amp;&amp; AS=0  || ((AS++))            [[ $OX -le  1     ]] &amp;&amp; ((CS++))            ((OX$1$1)); ((CL$cuter)); SC=$SM            [[ $CL -lt 0 ]] &amp;&amp; CL=0;;         *) ((SC--));;     esac     [[ $OX -le 1 ]] &amp;&amp; SX=0 || SX=$OX }  cut () {     xcord=$1 ycord=$2 color=$3; shift 3     screen+=&quot;\\e[$ycord;${xcord}H$color&quot;     printf -v spr %s &quot;${@:$CS:$CL}&quot;     spr=&quot;${spr\/\/_Y_\/'\\e['$ycord;}&quot;     screen+=&quot;${spr\/\/\u2395\/ }&quot; } <\/code><\/pre>\n<p>  \u041d\u043e \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0437\u0430\u043d\u043e\u0432\u043e \u00ab\u043f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c\u00bb \u0432\u0441\u0435 \u0441\u043f\u0440\u0430\u0439\u0442\u044b\u2026 \u043e\u043f\u044f\u0442\u044c\u2026 \u041e_\u043e<br \/>  \u0417\u0430\u0442\u043e \u0431\u044b\u043b\u0438 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u044b \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043a\u043e\u0441\u044f\u0447\u043a\u0438 \u0432 \u0441\u0442\u0430\u0440\u044b\u0445 \u0441\u043f\u0440\u0430\u0439\u0442\u0430\u0445 <s> \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u043d\u043e\u0432\u044b\u0435 \u0432 \u043d\u043e\u0432\u044b\u0445<\/s>.<br \/>  \u00ab\u041c\u043e\u0434\u0435\u043b\u044c\u00bb \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u043b\u0430\u0441\u044c, \u0432\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0442\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043e\u0431\u044a\u0435\u043a\u0442. \u041e\u0431\u044a\u0435\u043a\u0442 \u2014 \u044d\u0442\u043e \u043c\u0430\u0441\u0441\u0438\u0432 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435, \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0442\u043e\u0433\u043e \u0436\u0435 \u0434\u0435\u0440\u0435\u0432\u0446\u04302:  <\/p>\n<pre><code class=\"bash\">&quot;tree2 $OX $OY $OH $OW $SC $SM $CS $CL $AS $AL&quot; <\/code><\/pre>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432:  <\/p>\n<pre><code class=\"bash\">print_sprite () {     OT=${OI[0]}   # object type     OX=${OI[1]}   # X coordinate     OY=${OI[2]}   # Y coordinate     OH=${OI[3]}   # object hight     OW=${OI[4]}   # object width     SC=${OI[5]}   # speed counter     SM=${OI[6]}   # speed max     CS=${OI[7]}   # cuting start     CL=${OI[8]}   # cuting lenght     AS=${OI[9]}   # animation start     AL=${OI[10]}  # animation lenght     C1=${OI[11]}  # custom obj parameter 1     C2=${OI[12]}  # custom obj parameter 2     [[ $OT ]] &amp;&amp; sprite_$OT } <\/code><\/pre>\n<p>  \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u044d\u0442\u043e \u0442\u0430\u043a: \u0441\u043e\u0437\u0434\u0430\u043d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432: <i>BP1-3<\/i> \u0434\u043b\u044f \u0444\u043e\u043d\u043e\u0432\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, <i>PIU<\/i> \u0434\u043b\u044f \u0441\u043d\u0430\u0440\u044f\u0434\u043e\u0432 \u0433\u0435\u0440\u043e\u0435\u0432, <i>HER<\/i> \u0441\u0430\u043c\u0438 \u0433\u0435\u0440\u043e\u0438 \u0438 <i>ENM<\/i> \u0432\u0440\u0430\u0433\u0438 \u0438 \u0431\u043e\u043d\u0443\u0441\u044b. \u041c\u0430\u0441\u0441\u0438\u0432\u044b \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (\u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0438\u0436\u0435), \u0437\u0430 \u0441\u0447\u0435\u0442 \u044d\u0442\u043e\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e \u00ab\u0441\u043b\u043e\u0435\u043d\u043e\u0435\u00bb \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0431\u043e\u043b\u0435\u0435 \u043a\u0440\u0443\u043f\u043d\u044b\u0435 (\u0431\u043b\u0438\u0436\u0435 \u043a \u043d\u0430\u043c) \u0441\u043f\u0440\u0430\u0439\u0442\u044b \u0440\u0438\u0441\u0443\u044e\u0442\u0441\u044f \u043d\u0430 \u043f\u0435\u0440\u0435\u0434\u043d\u0435\u043c \u043f\u043b\u0430\u043d\u0435, \u043f\u0435\u0440\u0435\u043a\u0440\u044b\u0432\u0430\u044f \u0431\u043e\u043b\u0435\u0435 \u043c\u0435\u043b\u043a\u0438\u0435 (\u0434\u0430\u043b\u044c\u0448\u0435 \u043e\u0442 \u043d\u0430\u0441). \u041d\u043e\u0432\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u0441\u043e\u043e\u0442\u0432. \u043c\u0430\u0441\u0441\u0438\u0432\u044b, \u0432\u043e\u0442 \u043a\u0443\u0441\u043e\u0447\u0435\u043a \u0434\u0432\u0438\u0436\u043a\u0430 \u0441 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432:  <\/p>\n<pre><code class=\"bash\">#-{ Move bitplans }---------------------------------------------------- BP1=(&quot;${BP1[@]}&quot;); for i in ${!BP1[@]}; { OI=(${BP1[i]}); print_sprite; } # small(far) background objects BP2=(&quot;${BP2[@]}&quot;); for i in ${!BP2[@]}; { OI=(${BP2[i]}); print_sprite; } # medium background objects PIU=(&quot;${PIU[@]}&quot;); for i in ${!PIU[@]}; { OI=(${PIU[i]}); print_sprite; } # heroes fire HER=(&quot;${HER[@]}&quot;); for i in ${!HER[@]}; { OI=(${HER[i]}); print_sprite; } # heroes ENM=(&quot;${ENM[@]}&quot;); for i in ${!ENM[@]}; { OI=(${ENM[i]}); print_sprite; } # enemies BP3=(&quot;${BP3[@]}&quot;); for i in ${!BP3[@]}; { OI=(${BP3[i]}); print_sprite; } # big(closer) background objects <\/code><\/pre>\n<p>  \u041f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u043d\u043e\u0432\u044b\u0435 \u0444\u043e\u043d\u043e\u0432\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b(\u0434\u043e\u043c\u0438\u043a\u0438 \u0438 \u043f\u0442\u0438\u0447\u043a\u0438):<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/fa\/mt\/bm\/famtbmms21f46_6qwu0yfb0oygu.png\" align=\"right\"><\/p>\n<pre><code class=\"bash\">#0123456 #1\u2581\u2582\u2583\u2582\u2581  #2\u2502\u2598\u259d\u259d|  ######## <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/a6\/t0\/hq\/a6t0hqwfdctcbqyqed3-rglpqy0.png\" align=\"right\"><\/p>\n<pre><code class=\"bash\">#0123456789ABCDEFJHI #1     \u2596             #2  \u2582\u2584\u2586\u2588\u2588\u2586\u2584\u2582         #3  \u2503\u2552\u2555\u2552\u2555\u2552\u2555\u2503 \u252e\u2501\u252d     #4\u2560\u256c\u2503\u2535\u2518\u2535\u2536\u2514\u2536\u2503\u256c\u2563\u2593\u2560\u256c\u2563\u2596  #################### <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/jj\/ha\/_l\/jjha_lyujjsd9yh1rby6ug61iqm.png\" align=\"right\"><\/p>\n<pre><code class=\"bash\">#0123456789ABCDEFJHIJKLMNOPQRST #1         \u2542                     #2         \u2567                     #3        \u2571 \u2572                    #4        |\u2590|                    #5       \u252e\u2537\u2501\u2537\u252d                   #6       \u2502 \u2588 |                   #7      \u252e\u2537\u2501\u2501\u2501\u2537\u252d                  #8      \u2502 \u259b\u2594\u259c \u2502\u2584\u2584\u2584\u2584\u2582\u2581            #9\u2582 \u256c \u2583 \u2503 \u258c\u2592\u2590 \u2503 \u2598\u2597\u2598\u253f\u2503\u2597 \u2542 \u256a \u2584  \u2596  ############################### <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/e6\/ef\/u2\/e6efu2umrmpladcj4cm5e1uneos.png\" align=\"right\"><\/p>\n<pre><code class=\"bash\"># \u2304 _  #     ^ <\/code><\/pre>\n<p>  \u0418 \u043a\u0430\u043a \u0432\u044b \u0443\u0436\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438 \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0434\u043b\u044f \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u0432 \u0432\u0440\u0430\u0433\u043e\u0432 \u0438 \u0431\u043e\u0441\u0441\u0430 \u2014 \u0432\u0438\u0440\u0443\u0441:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/sq\/jo\/ey\/sqjoeygvchdn0firwlmlz3tnhiq.png\" align=\"right\"><\/p>\n<pre><code class=\"bash\">#0123456 #1 ._,   #2-(*)-  #3 \u00b4\u203e`   ######## <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/wf\/aj\/pj\/wfajpjbumq1x5rzhqtfby5ht1ay.png\" align=\"right\"><\/p>\n<pre><code class=\"bash\">#0123456789ABCD #1              #2   . ___,    #3   \/`   `\\   #4 +| *   o |+ #5  \\   +   \/   #6  *`-.,.-`+   #7              ############### <\/code><\/pre>\n<p>  \u0413\u0435\u0439\u043c\u043f\u043b\u0435\u0439 \u043e\u0441\u0442\u0430\u043b\u0441\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0440\u0435\u0436\u043d\u0438\u043c, \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0430\u0441\u044c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u0448\u0435\u043b\u044c\u0446\u0435\u0432, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0432\u0438\u0436\u0443\u0442\u0441\u044f \u0431\u044b\u0441\u0442\u0440\u0435\u0439. \u0418 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0434\u0443\u044d\u043b\u0438 \u0442\u043e\u0436\u0435 \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u0431\u043e\u043d\u0443\u0441\u044b. \u041d\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0431\u043e\u043d\u0443\u0441\u043e\u0432 \u0432 \u0434\u0443\u044d\u043b\u0438 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u0440\u0435\u0436\u0438\u043c\u0430. \u0411\u043e\u043d\u0443\u0441 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u043e\u044f\u0432\u043b\u044f\u0442\u0441\u044f \u043d\u0430 \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0435 \u044d\u043a\u0440\u0430\u043d\u0430, \u0447\u0442\u043e\u0431\u044b \u0443 \u043e\u0431\u043e\u0438\u0445 \u0438\u0433\u0440\u043e\u043a\u043e\u0432 \u0431\u044b\u043b\u0438 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u0448\u0430\u043d\u0441\u044b \u0434\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0434\u043e \u043d\u0435\u0433\u043e \u0440\u0430\u043d\u044c\u0448\u0435 \u0441\u043e\u043f\u0435\u0440\u043d\u0438\u043a\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0445 \u0441\u043a\u0438\u0434\u044b\u0432\u0430\u044e\u0442 \u0432 \u0446\u0435\u043d\u0442\u0440\u0435 \u044d\u043a\u0440\u0430\u043d\u0430 \u0441 \u043f\u0440\u043e\u043b\u0435\u0442\u0430\u044e\u0449\u0435\u0433\u043e \u043c\u0438\u043c\u043e \u0441\u0430\u043c\u043e\u043b\u0435\u0442\u0430 \u0432 \u0432\u0438\u0434\u0435 \u044f\u0449\u0438\u043a\u0430 \u043d\u0430 \u043f\u0430\u0440\u0430\u0448\u044e\u0442\u0435 \u0441\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c \u0431\u043e\u043d\u0443\u0441\u043e\u043c \u0432\u043d\u0443\u0442\u0440\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f\\\u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u0432<s>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u0438\u0433\u0440\u044b&#8230;<\/s><br \/>  \u0421\u043f\u0440\u0430\u0439\u0442 \u044f\u0449\u0438\u043a\u0430:  <\/p>\n<pre><code class=\"bash\">sprite_crate () {     movy &amp;&amp; ENM[$i]=&quot;crate $OX $OY $OH $OW $SC $SM $CS $CL 0 0 0 0 $i&quot; \\          || { unset ENM[$i]; boom $OX $boomendy; boom $OX $[boomendy-3]; crate=0; }     CM1=$SKY$ylw CM2=$SKY$blk CM3=$SKY$BLU SS=&quot;$RED ? $CM3&quot;     ########################1234567###01234567     cuty  $OX    $OY 7 $SKY'       ' #1            cuty  $OX    $OY 6 $CM1' \u00b8.\u2014.\u00b8 ' #2 \u00b8.\u2014.\u00b8      cuty  $OX    $OY 5 $CM1'(\ufe39_\ufe39)'  #3(\ufe39_\ufe39)     cuty $[OX+1] $OY 4  $CM2'\u2572\u2571 \u2572\u2571'  #4 \u2572\u2571 \u2572\u2571      cuty $[OX+1] $OY 3  $CM3'\u2554\u2567\u2566\u2567\u2557'  #5 \u2554\u2567\u2566\u2567\u2557      cuty $[OX+1] $OY 2  $CM3&quot;\u2560$SS\u2563&quot;  #6 \u2560 ? \u2563      cuty $[OX+1] $OY 1  $CM3'\u255a\u2550\u2569\u2550\u255d'  #7 \u255a\u2550\u2569\u2550\u255d  } <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/at\/bm\/6o\/atbm6ofzydlee5ovmoeljopv-u4.png\"><\/p>\n<p>  \u0418 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 &#8216;movy&#8217; \u0438 &#8216;cuty&#8217;:  <\/p>\n<pre><code class=\"bash\">movy () {     case $SC in         0) [[ $OY -ge $[endy-2] ]]    &amp;&amp; return 1            [[ $AS -ge $AL  ]] &amp;&amp; AS=0 || ((AS++))            [[ $CS -le $OH  ]] &amp;&amp; ((CS++))            ((OY++)); SC=$SM;;         *) ((SC--));;     esac }  cuty () {     xcord=$1 ycord=$2 cuter=$3; shift 3     [[ $CS -ge $cuter ]] &amp;&amp; screen+=&quot;\\e[$[ycord-cuter];${xcord}H$@&quot; } <\/code><\/pre>\n<p>  \u0420\u043e\u043b\u044c \u043f\u043e\u0447\u0442\u0430\u043b\u044c\u043e\u043d\u0430 \u0432\u0437\u044f\u043b \u043d\u0430 \u0441\u0435\u0431\u044f \u0440\u0435\u043a\u043b\u0430\u043c\u043d\u044b\u0439 \u0441\u0430\u043c\u043e\u043b\u0451\u0442, \u044f\u0449\u0438\u043a\u0438 \u0432\u044b\u043b\u0435\u0442\u0430\u044e\u0442 \u0438\u0437 \u043d\u0435\u0433\u043e, \u0438 \u043e\u043d \u0442\u043e\u0436\u0435 \u043f\u0440\u0435\u0442\u0435\u0440\u043f\u0435\u043b \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f. \u0422\u0435\u043a\u0441\u0442 \u043f\u0438\u0448\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439, \u043d\u043e \u0440\u0430\u0437\u043c\u0435\u0440 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d \u043d\u0438\u0447\u0435\u043c, \u043a\u0440\u043e\u043c\u0435 \u0437\u0434\u0440\u0430\u0432\u043e\u0433\u043e \u0441\u043c\u044b\u0441\u043b\u0430 \u0442.\u0435. \u043d\u0438\u0447\u0435\u043c, \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u044d\u0442\u043e \u043a\u0430\u043a-\u0442\u043e \u0442\u0430\u043a:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/rj\/_-\/x7\/rj_-x7l7evwkk28k-1dx6rjsbhy.png\"><br \/>  \u0420\u0435\u043b\u0438\u0437 \u0443\u0436\u0435 \u0441\u043a\u043e\u0440\u043e, \u0432\u0430\u0448\u0430 \u0440\u0435\u043a\u043b\u0430\u043c\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0442\u0443\u0442)<\/p>\n<p>  \u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u043d\u043e\u0432\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0439, \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 <i>$BASH_REMATCH<\/i>. \u0420\u0430\u043d\u044c\u0448\u0435 \u043a\u043e\u043b\u0438\u0437\u0438\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u043b\u0438\u0441\u044c \u0446\u0438\u043a\u043b\u043e\u043c. \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u0438\u0448\u0435\u043b\u044c\u0446\u0430 \u0432 \u0446\u0438\u043a\u043b\u0435 \u043f\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c \u0438\u0437 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u00abPIU\u00bb(\u043f\u0443\u043b\u044c\u043a\u0438) \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u043b\u043e\u0441\u044c \u0435\u0441\u0442\u044c \u043b\u0438 \u043f\u043e\u043f\u0430\u0434\u0430\u043d\u0438\u0435, \u044d\u0442\u0438 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u0446\u0438\u043a\u043b\u044b \u043e\u0447\u0435\u043d\u044c \u0441\u0438\u043b\u044c\u043d\u043e \u0441\u043d\u0438\u0436\u0430\u043b\u0438 \u0444\u043f\u0441. \u0421\u0435\u0439\u0447\u0430\u0441 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u0443\u043b\u0435\u043a (\u043f\u043e\u043f\u0430\u0434\u0430\u043d\u0438\u0435 \u0432 \u0447\u0443\u0436\u0438\u0445) \u0438 \u0434\u043b\u044f \u0433\u0435\u0440\u043e\u0435\u0432 (\u0441\u0442\u043e\u043b\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u044f \u0441 \u0447\u0443\u0436\u0438\u043c\u0438, \u0431\u043e\u043d\u0443\u0441\u044b), \u0438 \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u043e\u0434\u043d\u043e\u0439 (\u043f\u043e\u0447\u0442\u0438) \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u043e\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0437\u0430\u043c\u0435\u0442\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0439, \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044f \u0432\u043b\u0438\u044f\u043d\u0438\u044f \u043d\u0430 \u0444\u043f\u0441. \u0420\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0439 \u0433\u0435\u0440\u043e\u044f:  <\/p>\n<pre><code class=\"bash\"> re=&quot;(life|ammo|gunup) ($[OX+12]|$[OX+13]) ($[OY+1]|$[OY+2]|$[OY+3]|$[OY+4]).*|&quot; re+=&quot;alien ($[OX+12]|$[OX+13]) ($[OY+1]|$[OY+2]).*|&quot; re+=&quot;bfire ($[OX+12]|$[OX+13]) ($[OY+2]|$[OY+3]).*|&quot; re+=&quot;boss ($[OX+12]|$[OX+13]) $[OY-1].*&quot; <\/code><\/pre>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f:  <\/p>\n<pre><code class=\"bash\">collision 1 &quot;$re&quot; &amp;&amp; { BOOM $OX $OY; ((life--)); }  collision () {     hero=$1 re=&quot;$2&quot;     case $type in         'duel') target=(&quot;${HER[@]}&quot; &quot;${ENM[@]}&quot;);;              *) target=(&quot;${ENM[@]}&quot;);;     esac     [[ ${target[@]} =~ $re ]] &amp;&amp; {         match=($BASH_REMATCH)         obj_i=${match[@]:11:1}         obj_x=${match[@]:1:1}         obj_y=${match[@]:2:1}         case $match:$hero in               bfire:*) collbooom; return 0;;                boss:*) ((bhealth--)); boom $3 $4; return 0;;                life:1) collbooom; ((life++))    ; return 1;;                life:2) collbooom; ((life2++))   ; return 1;;                ammo:1) collbooom; ((ammo+=100)) ; return 1;;                ammo:2) collbooom; ((ammo2+=100)); return 1;;               gunup:1) collbooom; [[ $G  -lt 5 ]] &amp;&amp; ((G++))  ; return 1;;               gunup:2) collbooom; [[ $G2 -lt 5 ]] &amp;&amp; ((G2++)) ; return 1;;               alien:1) collbooom; ((enumber--)) ; ((frags++)) ; bonus; return 0;;               alien:2) collbooom; ((enumber--)) ; ((frags2++)); bonus; return 0;;               hero1:2) ((frags2++)); ((life--)) ; BOOM $obj_x $obj_y ; return 0;;               hero2:1) ((frags++)) ; ((life2--)); BOOM $obj_x $obj_y ; return 0;;               crate:*) collbooom; crate=0; boom $obj_x $[obj_y-3]; boom $obj_x $[obj_y-6]; rndmbonus $hero; return 1;;         esac     } } <\/code><\/pre>\n<p>  \u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0431\u044b\u043b\u043e \u043e\u043a\u043e\u043b\u043e 2\u041a \u0441\u0442\u0440\u043e\u043a, \u0441\u0435\u0439\u0447\u0430\u0441 1491, \u0434\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u044f \u0440\u0430\u0437\u0431\u0438\u043b \u0441\u043a\u0440\u0438\u043f\u0442 \u043d\u0430 4 \u0447\u0430\u0441\u0442\u0438: main(\u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f), functions(\u0444\u0443\u043d\u043a\u0446\u0438\u0438), sprites(\u0441\u043f\u0440\u0430\u0439\u0442\u044b), messages(\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f). \u0424\u0443\u043d\u043a\u0446\u0438\u0438, \u0441\u043f\u0440\u0430\u0439\u0442\u044b \u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0441\u043e\u0440\u0441\u044f\u0442\u0441\u044f \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u0432\u043e\u0442 \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"bash\">. .\/messages  #_MESSAGES_ . .\/sprites   #_SPRITES_ . .\/functions #_FUNCTIONS_ <\/code><\/pre>\n<p>  \u0410 \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 <i>piu-piu<\/i> \u00ab\u0441\u043a\u043b\u0435\u0438\u0432\u0430\u0435\u0442\u0441\u044f\u00bb \u0432\u043e\u0435\u0434\u0438\u043d\u043e \u0432\u043e\u0442 \u0442\u0430\u043a\u0438\u043c \u0441\u043a\u0440\u0438\u043f\u0442\u0438\u043a\u043e\u043c:  <\/p>\n<pre><code class=\"bash\">#!\/bin\/bash target=piu-piu sed -n '1,\/_SPRITES_\/p'   main    &gt;  $target sed '1d' messages                 &gt;&gt; $target sed '1d' sprites                  &gt;&gt; $target sed '1d' functions                &gt;&gt; $target sed -n '\/_FUNCTIONS_\/,$p' main    &gt;&gt; $target sed -i '\/_SPRITES_\/d;\/_FUNCTIONS_\/d;\/_MESSAGES_\/d' $target chmod +x $target <\/code><\/pre>\n<p>  \u041e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0446\u0438\u043a\u043b \u0434\u043b\u044f \u0440\u0435\u0436\u0438\u043c\u0430 \u0434\u0443\u044d\u043b\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f, \u0432\u0441\u0435 \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0438\u0433\u0440\u043e\u0432\u043e\u043c \u0446\u0438\u043a\u043b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043c\u0435\u0441\u0442\u0438\u043b\u0441\u044f \u0432 33 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043a\u043e\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u043c\u0438:  <\/p>\n<pre><code class=\"bash\">#-{ Empty screen, print game status adnd FPS }------------------------- screen=; status; [[ $showfps ]] &amp;&amp; fps_counter #-{ Add background }--------------------------------------------------- [[ $background ]] &amp;&amp; add_backgound #-{ Move bitplans }---------------------------------------------------- BP1=(&quot;${BP1[@]}&quot;); for i in ${!BP1[@]}; { OI=(${BP1[i]}); print_sprite; } # small(far) background objects BP2=(&quot;${BP2[@]}&quot;); for i in ${!BP2[@]}; { OI=(${BP2[i]}); print_sprite; } # medium background objects PIU=(&quot;${PIU[@]}&quot;); for i in ${!PIU[@]}; { OI=(${PIU[i]}); print_sprite; } # heroes fire HER=(&quot;${HER[@]}&quot;); for i in ${!HER[@]}; { OI=(${HER[i]}); print_sprite; } # heroes ENM=(&quot;${ENM[@]}&quot;); for i in ${!ENM[@]}; { OI=(${ENM[i]}); print_sprite; } # enemies BP3=(&quot;${BP3[@]}&quot;); for i in ${!BP3[@]}; { OI=(${BP3[i]}); print_sprite; } # big(closer) background objects #-{ BOSS }------------------------------------------------------------- if [[ $[frags+frags2] -ge $tillboss ]]; then # add boss object     [[ $bossborn ]] || { ENM+=(&quot;boss $endx $halfendy 6 14 0 0 1 0 $[RANDOM%3] 3 20 10&quot;); bossborn=true; }     boss_health # Print boss' health bar     #-{ Add aliens }---------------------------------------------------     [[ $bhealth -gt 0 ]] &amp;&amp; add_enm $EX $EY 5 # aliens come out from boss else                                          #     add_enm $endx $[4+RANDOM%enmyendy]        # aliens come out from edge fi #-{ Print everything }------------------------------------------------- printf &quot;$screen&quot; #-{ Check the end and send data to client }---------------------------- case $game$type in       *team) [[ ${HER[@]} ]] || the_end=lose;;&amp;       *duel) [[ ${HER[1]} ]] || if [[ $life -gt 0 ]]; then listener; sender $caddr $cport lose; mess win                                                       else listener; sender $caddr $cport win ; mess lose; fi;;&amp;     server*) listener; sender $caddr $cport &quot;$screen&quot;;; esac if [[ $the_end ]]; then     case $game in 'server') listener; sender $caddr $cport $the_end;; esac     mess $the_end fi <\/code><\/pre>\n<p>  \u041a\u043b\u0438\u0435\u043d\u0442 7 \u0441\u0442\u0440\u043e\u043a:  <\/p>\n<pre><code class=\"bash\">read_input sender $saddr $sport $input screen=&quot;$(nc -l -p $cport)&quot; case $screen in     'win' | 'lose') mess   &quot;$screen&quot;;;     *             ) printf &quot;$screen&quot;;; esac <\/code><\/pre>\n<p>  \u0421\u043f\u0440\u0430\u0432\u0435\u0434\u043b\u0438\u0432\u043e\u0441\u0442\u0438 \u0440\u0430\u0434\u0438 \u043d\u0430\u0434\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u043a\u043b\u0438\u0435\u043d\u0442 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f). \u0412\u044b\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u044b\u0435\u0442\u0441\u044f \u0432\u043f\u043e\u043b\u043d\u0435 \u0441\u0435\u0431\u0435 \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u0438\u0433\u0440\u043e\u0432\u043e\u0439 \u0434\u0432\u0438\u0436\u043e\u043a \u043d\u0430 bash&#8217;\u0435, \u0435\u0449\u0435 \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440 \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u0432, \u043a\u0430\u0442 \u0441\u0446\u0435\u043d\u044b, \u0434\u0438\u0430\u043b\u043e\u0433\u0438, \u0441\u044e\u0436\u0435\u0442\u2026 \u041d\u043e \u044d\u0442\u043e \u0443\u0436\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u0434\u0440\u0443\u0433\u0430\u044f \u0438\u0441\u0442\u043e\u0440\u0438\u044f. \u0418\u0434\u0435\u0438 \u043f\u043e \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c\u0443 \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u044e \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0432 piu-piu \u0435\u0441\u0442\u044c, \u043d\u043e \u044d\u043f\u0438\u0434\u0435\u043c\u0438\u044f \u043f\u043e\u0442\u0438\u0445\u043e\u043d\u044c\u043a\u0443 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u043d\u0430\u043a\u043e\u043d\u0435\u0446-\u0442\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u043b\u0435\u0442\u043e, \u0434\u0430\u0447\u0438 \u0438 \u0432\u043e\u0442 \u044d\u0442\u043e \u0432\u043e\u0442 \u0432\u0441\u0435). \u0422\u0430\u043a \u0447\u0442\u043e \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0436\u0434\u0430\u0442\u044c \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0433\u043e \u0430\u043f\u043e\u043a\u0430\u043b\u0438\u043f\u0441\u0438\u0441\u0430 \u0434\u043b\u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u044f, \u0430 \u043f\u043e\u043a\u0430 \u0437\u0430\u043a\u043e\u043d\u0447\u0443 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044e piu-piu. \u0411\u0435\u0440\u0435\u0433\u0438\u0442\u0435 \u0441\u0435\u0431\u044f \u0438 \u0441\u0432\u043e\u0438\u0445 \u0431\u043b\u0438\u0437\u043a\u0438\u0445, \u043e\u0441\u0442\u0430\u0432\u0430\u0439\u0442\u0435\u0441\u044c \u0434\u043e\u043c\u0430 \u0438 \u0438\u0433\u0440\u0430\u0439\u0442\u0435 \u0432 <a href=\"https:\/\/github.com\/vaniacer\/piu-piu-SH\" rel=\"nofollow\">piu-piu<\/a>)<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0420\u0435\u043a\u043b\u0430\u043c\u043d\u0430\u044f \u0430\u043a\u0446\u0438\u044f<\/b>                         <\/p>\n<div class=\"spoiler_text\">\u041f\u043e\u043b\u044c\u0437\u0443\u044f\u0441\u044c \u0441\u043b\u0443\u0447\u0430\u0435\u043c \u0445\u043e\u0447\u0443 \u043f\u043e\u043f\u0438\u0430\u0440\u0438\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u043d\u0443 \u0441\u0432\u043e\u044e \u043f\u043e\u0434\u0435\u043b\u043a\u0443 <a href=\"https:\/\/github.com\/vaniacer\/sshto\" rel=\"nofollow\">sshto<\/a>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0442\u043e\u0436\u0435 \u043f\u043e\u0442\u0438\u0445\u043e\u043d\u044c\u043a\u0443 \u043d\u0430\u0431\u0438\u0440\u0430\u0435\u0442 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u044c \u043d\u0430 github&#8217;\u0435(92 \u0437\u0432\u0435\u0437\u0434\u044b)<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/e75\/9df\/bfa\/e759dfbfaf03b0c9bcca0baae75aa163.png\" alt=\"image\"><\/p>\n<p>  \u042d\u0442\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u0438\u043a \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043c\u0435\u043d\u044e(\u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 dialog&#8217;\u0430) \u0438\u0437 \u0432\u0430\u0448\u0435\u0433\u043e <i>~\/.ssh\/config<\/i> \u0444\u0430\u0439\u043b\u0430, \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438 \u0441 \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u043e\u043c \u043d\u043e \u0434\u043b\u044f \u043f\u043e\u043b\u043d\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u043a \u0445\u043e\u0441\u0442\u0430\u043c \u0432\u043e\u0442 \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"bash\">#Host DUMMY #Rybinsk#  Host rybserver1 #First server HostName localhost  Host rybserver2 #Second server HostName localhost  Host rybserver3 #Third server HostName localhost  #Host DUMMY #Moscow#  Host moserver1 #First server HostName localhost  Host moserver2 #Second server HostName localhost  Host moserver3 #Third server HostName localhost<\/code><\/pre>\n<p>  \u041a\u0440\u043e\u043c\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0445\u043e\u0441\u0442\u0430\u043c \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0440\u044f\u0434 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/cbb\/306\/9d6\/cbb3069d677183882aae86b49b0239d0.png\" alt=\"image\"><\/p>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043b\u0435\u0433\u043a\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0444\u0430\u0439\u043b <i>~\/.sshtorc<\/i> \u0430 \u0446\u0432\u0435\u0442\u0430 \u0434\u0438\u0430\u043b\u043e\u0433\u0430 \u043c\u0436\u043d\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"bash\">dialog --create-rc ~\/.dialogrc nano ~\/.dialogrc<\/code><\/pre>\n<p>  \u0422\u0432\u043e\u0440\u0438\u0442\u0435, \u0432\u044b\u0434\u0443\u043c\u044b\u0432\u0430\u0439\u0442\u0435, \u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435!)  <\/div>\n<\/p><\/div>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/504462\/\"> https:\/\/habr.com\/ru\/post\/504462\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/504462\/\">\u041a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f: \u00ab\u041d\u0435 \u0431\u044b\u043b\u043e \u0431\u044b \u0441\u0447\u0430\u0441\u0442\u044c\u044f, \u0434\u0430 \u043d\u0435\u0441\u0447\u0430\u0441\u0442\u044c\u0435 \u043f\u043e\u043c\u043e\u0433\u043b\u043e.\u00bb \u0412\u043d\u0435\u0437\u0430\u043f\u043d\u043e \u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u044f\u0432\u0438\u043b\u043e\u0441\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438 \u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u043b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043f\u0438\u0443-\u043f\u0438\u0443.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/4ed\/c0c\/1fe\/4edc0c1fe18d8841e72feb454090673e.png\" alt=\"image\">  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-305244","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/305244","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=305244"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/305244\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=305244"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=305244"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=305244"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}