为什么shell case语句中的第一个模式不能为多重模式? [英] Why can't the first pattern in a shell case statement be a multiple pattern?
本文介绍了为什么shell case语句中的第一个模式不能为多重模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
case
语句的标准说明说: :
The format for the case construct is as follows:
case word in
[(]pattern1) compound-list;;
[[(]pattern[ | pattern] ... ) compound-list;;] ...
[[(]pattern[ | pattern] ... ) compound-list]
esac
The ";;" is optional for the last compound-list.
为什么pattern1
也不能成为多重模式?似乎相当武断,尽管我敢肯定它一定不会.
Why can't be pattern1
be a multiple pattern as well? It seems rather arbitrary, though I'm pretty sure it must not be.
谢谢!
推荐答案
我认为您在误解他们在说什么.您链接到的页面上的语法没有这种区别:
I think you're misinterpreting what they're saying. The grammar on the page you link to does not show such a distinction:
case_clause : Case WORD linebreak in linebreak case_list Esac
| Case WORD linebreak in linebreak case_list_ns Esac
| Case WORD linebreak in linebreak Esac
;
case_list_ns : case_list case_item_ns
| case_item_ns
;
case_list : case_list case_item
| case_item
;
case_item_ns : pattern ')' linebreak
| pattern ')' compound_list linebreak
| '(' pattern ')' linebreak
| '(' pattern ')' compound_list linebreak
;
case_item : pattern ')' linebreak DSEMI linebreak
| pattern ')' compound_list DSEMI linebreak
| '(' pattern ')' linebreak DSEMI linebreak
| '(' pattern ')' compound_list DSEMI linebreak
;
pattern : WORD /* Apply rule 4 */
| pattern '|' WORD /* Do not apply rule 4 */
这篇关于为什么shell case语句中的第一个模式不能为多重模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文