当我使用这个函数时:
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
是,文件夹本身存在…为什么读时不考虑双引号?
谢谢!
从第一个变量中删除反斜杠修复了这个问题。