将TXT文件读入变量失败

时间:2019-04-05 16:42:58

标签: bash shell

我尝试了解以下代码为何失败。首先,我使用

调用bash函数
smb_read $SMB_FILE $SMB_CONF

功能很简单

function smb_read {
  2="$(cat $1)"
  case $? in
    0) ;;
    *) return 1 ;;
  esac
}

结果是

func.sh: line 52: 2=[global]
workgroup = smb
security = user
...
public = no
writeable = no
guest ok = no
create mask = 0600
directory mask = 0700: No such file or directory

那是为什么?

0 个答案:

没有答案