- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我试转优秀范例docker-haproxy从 centos 到 alpine。
shell 脚本用于将作为参数给定的值列表处理到数组中,然后将这些值及其索引写入某个文件。
bash 中的以下构建工作:
ServerArray=${SERVERS:=$1}
...
for i in ${ServerArray[@]}
do
echo " " server SERVER_$COUNT $i >> /haproxy/haproxy.cfg
let "COUNT += 1"
done
但不是在 ash(或 sh)中:
syntax error: bad substitution
错误指的是行
for i in ${ServerArray[@]}
这里正确的语法是什么?我猜线
ServerArray=${SERVERS:=$1}
没有按预期定义数组,但长时间谷歌搜索对我没有帮助。
sh apparently has no arrays.
如果是,那怎么解决呢?
最佳答案
我想我可以用这个结构来做:
#!/bin/sh
# test.sh
while [ $# -gt 0 ]
do
echo $1
shift
done
交付
/ # ./test 172.17.0.2:3306 172.17.0.3:3306
172.17.0.2:3306
172.17.0.3:3306
这是我需要继续的事情
关于arrays - 从 bash 到 ash shell : how to handle arrays defined by input? 的翻译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36264733/
由于某种原因,我无法使用 bash 构建我的脚本,唯一的方法是使用 ash,我有这个短信自动回复脚本,每个回复的长度不得超过 160 个字符,如下所示: #!/bin/sh reply="th
我正在尝试将脚本从 BASH 移植到 ASH (Almquist SHell),但遇到了间接引用问题。下面的函数 cmd() { # first argument is the index t
我有一个使用 ash 的小型发行版(不是 busybox),我不确定点文件结构是如何处理的。 .ashrc 似乎没有被拾起,我也没有看到 .bash_profile 类似物。 shell 启动文件是否
以下代码适用于 bash,但现在我需要它用于 busybox ash,它显然没有“=~” keyword="^Cookie: (.*)$" if [[ $line =~ $keyword ]] the
已结束。此问题正在寻求书籍、工具、软件库等的推荐。它不满足Stack Overflow guidelines 。目前不接受答案。 我们不允许提出寻求书籍、工具、软件库等推荐的问题。您可以编辑问题,以便
我正在尝试制作一个用于条形码扫描仪的应用程序。问题是我现在在相机中感到困惑,红线是垂直的,我想使其水平,我该如何改变它。我尝试在 ViewfinderView.java 文件中执行此操作,但该文件已锁
这个问题在这里已经有了答案: Getting the last argument passed to a shell script (29 个答案) 关闭 7 年前。 要访问函数的第一个参数,我使用
我正在尝试将 Linux 脚本安装到我的 WD 世界版驱动器上。 该脚本是为 Bash (debian) 编写的,但我的 WD 只运行 busybox(带有 ash)。尽管如此,我还是通过使用 Goo
这是我第一次使用 stackoverflow。我目前面临一个问题,在这里分享详细信息。 我目前正在构建 POS 自动化脚本。 POS 终端有 Shell Busybox ash 。这就是为什么我不能使
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a software
我需要通过 SSH 连接到嵌入式设备,启动后台程序,然后断开连接并保持后台进程运行。问题是嵌入式设备正在使用 ash shell(不是 bash 或其他任何东西),所以 nohup 和 screen
我是 Java 新手,或者说是编程新手。我是通过观看 Bucky 教程开始学习 Java 的。这是我的代码。 import java.util.Scanner; class apples {
我将十进制数字存储在字符串中。 <100 的数字以这种方式存储 "045" 或 "005"。 当在 let A="045"+"009" 等算术运算中使用这些数字字符串时,这些数字将被视为八进制数字,如
我尝试使用 diff 命令来比较在 bash 中运行良好的目录列表: diff <(cd alpha ; find . -type f) <(cd beta; find . -type f) 但是,
出于特定原因,我必须在函数内执行无限循环,然后将函数作为守护进程运行, #!/bin/sh lol(){ while true do echo "looping..." sleep 2
我有 url (www.blabla.web.id/proses_data.php) 在线。我想从我的 bash 脚本向该 url 提交数据。我在 OpenWRT 中使用 ash、bash。 我正在尝
所以,我现在正在阅读 Land of Lisp,事实证明 Lisp 与我所见过的其他编程语言完全不同。 无论如何,本书提供了一些我们打算输入到 CLISP REPL 中的代码: (defparamet
我在我的嵌入式系统中使用 ash 和 bash shell,对于使用这两种 shell 的同一命令,我收到以下错误消息 For ash shell $ kill -9 sh: you need to
Android 在线文档 Android Debug Bridge说“亚行提供了一个灰壳”。果然,如果我 adb shell 到 AVD 模拟器,我会得到 ash,它基本上是一个精简的 Bourne
我有一个 .bashrc 文件,它有一个非常简单的功能,就像这样 function module() { .... } 我在命令提示符下键入“bash”,正如预期的那样,.bashrc 得到执
我是一名优秀的程序员,十分优秀!