我试图搜索如何在Bash函数中传递参数,但是出现的是如何从命令行传递参数.
我想在我的脚本中传递参数.我试过了:
myBackupFunction("..", "...", "xx")
function myBackupFunction($directory, $options, $rootPassword) {
...
}
Run Code Online (Sandbox Code Playgroud)
但是语法不正确,如何将参数传递给我的函数?
我希望我的脚本能够获取可选输入,
例如,目前我的剧本是
#!/bin/bash
somecommand foo
Run Code Online (Sandbox Code Playgroud)
但我想说:
#!/bin/bash
somecommand [ if $1 exists, $1, else, foo ]
Run Code Online (Sandbox Code Playgroud)