首页 > 解决方案 > Bash 使用“?” 作为调用帮助函数的参数

问题描述

我正在尝试使用“-help”或“?” 作为调用我的帮助函数的参数。我的代码如下所示:

#Variablen deklarieren
declare +a source_dir="$1" 
declare +a target_dir="$2"


#Aufruf help-function
if [ "$1" = "?" ] || [ "$1" = "-help" ] ; then
    help_function
    exit 0
fi

使用 -help 调用我的脚本会返回帮助功能,但我在使用“?”时遇到问题 作为参数。

标签: bashshellubuntuparameters

解决方案


推荐阅读