ruby – 如何计算和检查传递的参数?
发布时间:2020-12-16 22:59:02 所属栏目:百科 来源:网络整理
导读:如何将以下 Ruby代码翻译为Bash? if ARGV.length == 0 abort "nError: The project name is required. Aborting...nn"elsif ARGV.length 2 abort "nError: The program takes two arguments maximum. Aborting...nn"end 解决方法 #!/bin/bashUSAGE="$
如何将以下
Ruby代码翻译为Bash?
if ARGV.length == 0 abort "nError: The project name is required. Aborting...nn" elsif ARGV.length > 2 abort "nError: The program takes two arguments maximum. Aborting...nn" end 解决方法#!/bin/bash USAGE="$0: <project name> [subproject attribute]" if [ $# -lt 1 ]; then echo -e "Error: The project name is required.n$USAGE" >&2; exit 1; fi if [ $# -gt 2 ]; then echo -e "Error: Two arguments maximum.n$USAGE" >&2; exit 1; fi (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |