read命令不解析双引号

  • 本文关键字:命令 read bash
  • 更新时间 :
  • 英文 :


当我使用这个函数时:

function get_firefox_default_profile_path {
local firefox_profiles_path="/Users/whatever/Library/Application Support/Firefox/Profiles"
local IFS=$'n'
local profiles_found
read -r -d '' profiles_found <<EOF
$(/usr/bin/find "$firefox_profiles_path" 
-type d 
-maxdepth 1 
-regex "$FIREFOX_DEFAULT_PROFILE_REGEX")
EOF
echo "${profiles_found[0]#.*}"
}

我得到以下结果:

find: /Users/whatever/Library/Application Support/Firefox/Profiles: No such file or directory

是,文件夹本身存在…为什么读时不考虑双引号?

谢谢!

从第一个变量中删除反斜杠修复了这个问题。

最新更新