函数传参 数组: 放弃了,读全局变量
$cat gg.sh
#! /bin/bash
group1=([0]="apple orange" [1]="pear")
group2=([0]="apple orange" [1]="pear")
function gg() {
tmp=$1
echo ${tmp[0]}
echo ${tmp[1]}
for i in ${tmp[*]}; do
echo $i
done
tmp=$2
echo ${tmp[0]}
echo ${tmp[1]}
for i in ${tmp[*]}; do
echo $i
done
}
gg "${group1[*]}" "${group2[@]}"
$./gg.sh
$apple orange pear $ $apple
$orange $pear
$apple orange
$
$apple
$orange
#双引号传参失败
posted on 2021-07-13 18:21 toughcactus 阅读(29) 评论(0) 编辑 收藏 举报