{"id":135286,"date":"2019-02-25T08:38:02","date_gmt":"2019-02-25T00:38:02","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=135286"},"modified":"2019-01-30T09:39:42","modified_gmt":"2019-01-30T01:39:42","slug":"bash-posix-shell","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/bash-posix-shell.html","title":{"rendered":"Bash 5.0 \u53d1\u5e03\u53ca\u5176\u65b0\u529f\u80fd"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u90ae\u4ef6\u5217\u8868\u8bc1\u5b9e\u6700\u8fd1\u53d1\u5e03\u4e86 Bash-5.0\u3002\u800c\u4e14\uff0c\u4ee4\u4eba\u5174\u594b\u7684\u662f\u5b83\u8fd8\u6709\u65b0\u7684\u529f\u80fd\u548c\u53d8\u91cf\u3002\u5982\u679c\u4f60\u4e00\u76f4\u5728\u4f7f\u7528 Bash 4.4.XX\uff0c\u90a3\u4e48\u4f60\u4e00\u5b9a\u4f1a\u559c\u6b22 Bash \u7684\u7b2c\u4e94\u4e2a\u4e3b\u8981\u7248\u672c\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u7b2c\u4e94\u4e2a\u7248\u672c\u4fa7\u91cd\u4e8e\u65b0\u7684 shell \u53d8\u91cf\u548c\u8bb8\u591a\u91cd\u5927\u6f0f\u6d1e\u4fee\u590d\u3002\u5b83\u8fd8\u5f15\u5165\u4e86\u4e00\u4e9b\u65b0\u529f\u80fd\uff0c\u4ee5\u53ca\u4e00\u4e9b\u4e0e bash-4.4 \u4e0d\u517c\u5bb9\u7684\u66f4\u6539\u3002<\/p>\n

\u65b0\u529f\u80fd\u600e\u4e48\u6837\uff1f<\/strong><\/div>\n

\u5728\u90ae\u4ef6\u5217\u8868\u89e3\u91ca\u4e86\u6b64\u7248\u672c\u4e2d\u4fee\u590d\u7684 bug\uff1a<\/p>\n

\u6b64\u7248\u672c\u4fee\u590d\u4e86 bash-4.4 \u4e2d\u7684\u51e0\u4e2a\u4e3b\u8981\u9519\u8bef\uff0c\u5e76\u5f15\u5165\u4e86\u51e0\u4e2a\u65b0\u529f\u80fd\u3002\u6700\u91cd\u8981\u7684 bug \u4fee\u590d\u662f\u5bf9 nameref \u53d8\u91cf\u7684\u89e3\u6790\u4ee5\u53ca\u901a\u8fc7\u6a21\u7cca\u6d4b\u8bd5\u53d1\u73b0\u7684\u8bb8\u591a\u6f5c\u5728\u7684\u5185\u5b58\u8d8a\u754c\u9519\u8bef\u3002\u5728\u4e3a\u4e86\u7b26\u5408 Posix \u6807\u51c6\u89e3\u91ca\u800c\u4e0d\u8fdb\u884c\u5355\u8bcd\u62c6\u5206\u7684\u4e0a\u4e0b\u6587\u4e2d\uff0c\u5bf9 $@<\/span> \u548c $* <\/span>\u7684\u5c55\u5f00\u505a\u4e86\u8bb8\u591a\u6539\u53d8\uff0c\u53e6\u5916\u8fd8\u6709\u89e3\u51b3\u6781\u7aef\u60c5\u51b5\u4e2d Posix \u4e00\u81f4\u6027\u7684\u4fee\u6539\u3002<\/p>\n

\u5b83\u8fd8\u5f15\u5165\u4e86\u4e00\u4e9b\u65b0\u529f\u80fd\u3002\u6839\u636e\u5176\u53d1\u5e03\u8bf4\u660e\uff0c\u6700\u503c\u5f97\u6ce8\u610f\u7684\u65b0\u529f\u80fd\u662f\u51e0\u4e2a\u65b0\u7684 shell \u53d8\u91cf\uff1a<\/p>\n

BASH_ARGV0<\/span>\u3001EPOCHSECONDS<\/span> \u548c EPOCHREALTIME<\/span>\u3002\u5185\u7f6e\u547d\u4ee4 history \u53ef\u4ee5\u5220\u9664\u6307\u5b9a\u8303\u56f4\u7684\u6761\u76ee\uff0c\u5e76\u80fd\u5c06\u8d1f\u6570\u7406\u89e3\u4e3a\u4ece\u5386\u53f2\u672b\u7aef\u5f00\u59cb\u7684\u504f\u79fb\u91cf\u3002\u6709\u4e00\u4e2a\u9009\u9879\u5141\u8bb8\u5c40\u90e8\u53d8\u91cf\u7ee7\u627f\u524d\u4e00\u4e2a\u8303\u56f4\u5185\u5177\u6709\u76f8\u540c\u540d\u79f0\u7684\u53d8\u91cf\u7684\u503c\u3002\u6709\u4e00\u4e2a\u65b0\u7684 shell \u9009\u9879\uff0c\u5728\u542f\u7528\u5b83\u65f6\uff0c\u4f1a\u5bfc\u81f4 shell \u53ea\u5c1d\u8bd5\u4e00\u6b21\u6269\u5c55\u5173\u8054\u6570\u7ec4\u4e0b\u6807\uff08\u8fd9\u5728\u7b97\u672f\u8868\u8fbe\u5f0f\u4e2d\u4f7f\u7528\u65f6\u4f1a\u51fa\u73b0\u95ee\u9898\uff09\u3002globasciiranges<\/span> \u8fd9\u4e2a shell \u9009\u9879\u73b0\u5728\u9ed8\u8ba4\u542f\u7528\u3002\u53ef\u4ee5\u5728\u914d\u7f6e\u65f6\u9ed8\u8ba4\u5173\u95ed\u5b83\u3002<\/p>\n

Bash-4.4 \u548c Bash-5.0 \u4e4b\u95f4\u6709\u54ea\u4e9b\u53d8\u5316\uff1f<\/strong><\/div>\n

\u5176\u66f4\u65b0\u65e5\u5fd7\u63d0\u5230\u4e86\u4e0d\u517c\u5bb9\u7684\u66f4\u6539\u548c\u6240\u652f\u6301\u7684 readline \u7248\u672c\u5386\u53f2\u8bb0\u5f55\u3002\u5b83\u662f\u8fd9\u4e48\u8bf4\u7684\uff1a<\/p>\n

bash-4.4 \u548c bash-5.0 \u4e4b\u95f4\u5b58\u5728\u4e00\u4e9b\u4e0d\u517c\u5bb9\u7684\u53d8\u5316\u3002\u5c3d\u7ba1\u6211\u5df2\u7ecf\u5c3d\u91cf\u6700\u5c0f\u5316\u517c\u5bb9\u6027\u95ee\u9898\uff0c\u4f46\u662f\u5bf9 nameref<\/span> \u53d8\u91cf\u89e3\u6790\u7684\u66f4\u6539\u610f\u5473\u7740\u5bf9\u53d8\u91cf\u540d\u5f15\u7528\u7684\u67d0\u4e9b\u4f7f\u7528\u4f1a\u6709\u4e0d\u540c\u7684\u884c\u4e3a\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u542f\u7528\u4e86\u6269\u5c55\u8c03\u8bd5\u6a21\u5f0f\uff0cshell \u4ec5\u5728\u542f\u52a8\u65f6\u8bbe\u7f6e BASH_ARGC<\/span> \u548c BASH_ARGV<\/span>\u3002\u5b83\u88ab\u65e0\u6761\u4ef6\u5730\u8bbe\u7f6e\u662f\u4e00\u4e2a\u758f\u5ffd\uff0c\u5e76\u4e14\u5728\u811a\u672c\u4f20\u9012\u5927\u91cf\u53c2\u6570\u65f6\u4f1a\u5bfc\u81f4\u6027\u80fd\u95ee\u9898\u3002<\/p>\n

\u5982\u679c\u9700\u8981\uff0c\u53ef\u4ee5\u5c06 Bash \u94fe\u63a5\u5230\u5df2\u5b89\u88c5\u7684 Readline \u5e93\uff0c\u800c\u4e0d\u662f lib\/readline \u4e2d\u7684\u79c1\u6709\u7248\u672c\u3002\u53ea\u6709 readline-8.0 \u53ca\u66f4\u9ad8\u7248\u672c\u80fd\u591f\u63d0\u4f9b bash-5.0 \u6240\u9700\u7684\u6240\u6709\u7b26\u53f7\u3002\u65e9\u671f\u7248\u672c\u7684 Readline \u5e93\u65e0\u6cd5\u6b63\u5e38\u5de5\u4f5c\u3002<\/p>\n

\u6211\u76f8\u4fe1\u4e00\u4e9b\u6dfb\u52a0\u7684\u529f\u80fd\/\u53d8\u91cf\u975e\u5e38\u6709\u7528\u3002\u6211\u6700\u559c\u6b22\u7684\u4e00\u4e9b\u662f\uff1a<\/p>\n

\u6709\u4e00\u4e2a\u65b0\u7684\uff08\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u7981\u7528\uff0c\u6587\u6863\u4e2d\u6ca1\u6709\u8bf4\u660e\uff09shell \u9009\u9879\uff0c\u7528\u4e8e\u5728\u8fd0\u884c\u65f6\u542f\u7528\/\u7981\u7528\u5411 syslog \u53d1\u9001\u5386\u53f2\u8bb0\u5f55\u3002
\n\u6b63\u5982\u6587\u6863\u4e00\u76f4\u6240\u8bf4\u7684\u90a3\u6837\uff0c\u9664\u975e shell \u5904\u4e8e\u8c03\u8bd5\u6a21\u5f0f\uff0c\u5426\u5219\u5b83\u4e0d\u4f1a\u5728\u542f\u52a8\u65f6\u81ea\u52a8\u8bbe\u7f6e BASH_ARGC<\/span> \u548c BASH_ARGV<\/span>\uff0c\u4f46\u5982\u679c\u811a\u672c\u5728\u4e0a\u5c42\u5f15\u7528\u5b83\u4eec\u4e14\u6ca1\u6709\u542f\u7528\u8c03\u8bd5\u6a21\u5f0f\uff0c\u90a3\u4e48 shell \u5c06\u52a8\u6001\u521b\u5efa\u5b83\u4eec\u3002
\n\u73b0\u5728\u53ef\u4ee5\u4f7f\u7528 -d start-end<\/span> \u5220\u9664\u6307\u5b9a\u8303\u56f4\u7684 history<\/span> \u6761\u76ee\u3002
\n\u5982\u679c\u542f\u7528\u4e86\u4f5c\u4e1a\u63a7\u5236\u7684\u975e\u4ea4\u4e92\u5f0f shell \u68c0\u6d4b\u5230\u524d\u53f0\u4f5c\u4e1a\u56e0 SIGINT \u800c\u6b7b\u4ea1\uff0c\u5219\u5176\u884c\u4e3a\u5c31\u50cf\u63a5\u6536\u5230 SIGINT \u4e00\u6837\u3002
\nBASH_ARGV0<\/span>\uff1a\u4e00\u4e2a\u65b0\u53d8\u91cf\uff0c\u6269\u5c55\u4e3a $0<\/span>\uff0c\u5e76\u5728\u8d4b\u503c\u65f6\u8bbe\u7f6e\u4e3a $0<\/span>\u3002
\n\u8981\u67e5\u770b\u5b8c\u6574\u7684\u66f4\u6539\u548c\u529f\u80fd\u5217\u8868\uff0c\u8bf7\u53c2\u9605\u90ae\u4ef6\u5217\u8868\u6587\u7ae0\u3002<\/p>\n

\u603b\u7ed3<\/strong><\/div>\n

\u4f60\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u68c0\u67e5\u4f60\u5f53\u524d\u7684 Bash \u7248\u672c\uff1a<\/p>\n

bash --version<\/pre>\n

\u4f60\u5f88\u53ef\u80fd\u5b89\u88c5\u4e86 Bash 4.4\u3002\u5982\u679c\u4f60\u60f3\u83b7\u5f97\u65b0\u7248\u672c\uff0c\u6211\u5efa\u8bae\u7b49\u5f85\u4f60\u7684\u53d1\u884c\u7248\u63d0\u4f9b\u5b83\u3002<\/p>\n

\u4f60\u600e\u4e48\u770b\u5f85 Bash-5.0 \u53d1\u5e03\uff1f\u4f60\u5728\u4f7f\u7528\u5176\u4ed6 bash \u7684\u66ff\u4ee3\u54c1\u4e48\uff1f\u5982\u679c\u6709\u7684\u8bdd\uff0c\u8fd9\u4e2a\u66f4\u65b0\u4f1a\u6539\u53d8\u4f60\u7684\u60f3\u6cd5\u4e48\uff1f<\/p>\n


\n

via:\u00a0https:\/\/itsfoss.com\/bash-5-release<\/a><\/p>\n

\u4f5c\u8005\uff1aAnkush Das<\/a>\u00a0\u9009\u9898\uff1alujun9972<\/a>\u00a0\u8bd1\u8005\uff1ageekpi<\/a>\u00a0\u6821\u5bf9\uff1awxy<\/a><\/p>\n

\u672c\u6587\u7531\u00a0LCTT<\/a>\u00a0\u539f\u521b\u7f16\u8bd1\uff0cLinux\u4e2d\u56fd<\/a>\u00a0\u8363\u8a89\u63a8\u51fa<\/p>\n","protected":false},"excerpt":{"rendered":"

\u7b2c\u4e94\u4e2a\u7248\u672c\u4fa7\u91cd\u4e8e\u65b0\u7684 shell \u53d8\u91cf\u548c\u8bb8\u591a\u91cd\u5927\u6f0f\u6d1e\u4fee\u590d\u3002\u5b83\u8fd8\u5f15\u5165\u4e86\u4e00\u4e9b\u65b0\u529f\u80fd\uff0c\u4ee5\u53ca\u4e00\u4e9b\u4e0e bash-4.4 […]<\/p>\n","protected":false},"author":1890,"featured_media":135287,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[21],"tags":[],"class_list":["post-135286","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/135286","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1890"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=135286"}],"version-history":[{"count":5,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/135286\/revisions"}],"predecessor-version":[{"id":135497,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/135286\/revisions\/135497"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/135287"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=135286"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=135286"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=135286"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}