文件夹中的空格,终端不能cd

时间:2018-01-31 04:55:57

标签: bash terminal macbookpro-touch-bar

Macbook Pro 13“2016,High Sierra 10.13.2

我知道终端无法使用空格打开/ cd文件夹,除非在空格或整个文件夹名称周围有exis符号\" "。然而,终端和iTerm仍然存在问题。

*****:~ #######$ cd /Users/#######Google\ Drive -bash: cd: /Users/#######/Google: No such file or directory *****:~ #######$ cd Google\ Drive/ -bash: cd: Google: No such file or directory *****:~ #######$ cd Google' 'Drive/ -bash: cd: Google: No such file or directory *****:~ #######$ cd 'Google Drive'/ -bash: cd: Google: No such file or directory *****:~ #######$ cd "Google Drive" -bash: cd: Google: No such file or directory *****:~ #######$ cd Google" "Drive -bash: cd: Google: No such file or directory

使用ls可以看到Google云端硬盘。

Google云端硬盘也会输入自动完成功能(输入Goo并按回车键)并将文件夹从Finder拖放到终端,终端会在其中插入\本身,它会为您提供{ {1}}。

此行为可能与我的Mac上的所有文件夹相关。这已经发生了一段时间,我想解决它。

P.S。问题主要发生在Google\ Drive/命令。

UPD。

根据要求,这是输出     stivens〜$ ls -d Google * Drive | XXD     00000000:476f 6f67 6c65 2044 7269 7665 0a Google Drive。

cd

type cd

stivens ~ $ type cd cd is a function cd () { unset RETVAL; if __gvm_is_function __gvm_oldcd; then __gvm_oldcd $*; fi; local dot_go_version dot_go_pkgset rslt; local defaults_go_name defaults_go_pkgset; local defaults_resolved=false; local defaults_hash; defaults_hash=(); if [[ "$GVM_ROOT" == "" ]]; then __gvm_display_error "GVM_ROOT not set. Please source \$GVM_ROOT/scripts/gvm"; return $?; fi; [[ "${GVM_DEBUG}" -eq 1 ]] && echo "Resolving defaults..."; __gvm_read_environment_file "${GVM_ROOT}/environments/default" > /dev/null; rslt=$?; defaults_hash=(${RETVAL}); if [[ $rslt -eq 0 ]]; then defaults_resolved=true; else [[ "${GVM_DEBUG}" -eq 1 ]] && echo "Can't find default environment. Falling back to system."; __gvm_read_environment_file "${GVM_ROOT}/environments/system" > /dev/null; rslt=$?; defaults_hash=(${RETVAL}); if [[ $rslt -eq 0 ]]; then defaults_resolved=true; else [[ "${GVM_DEBUG}" -eq 1 ]] && echo "Can't find system environment."; fi; fi; if [[ "${defaults_resolved}" == false ]]; then [[ "${GVM_DEBUG}" -eq 1 ]] && echo "Resolving fallback go version and pkgset from all available."; local fallback_go_version=""; __gvm_resolve_fallback_version > /dev/null; fallback_go_version="${RETVAL}"; local fallback_go_pkgset=""; __gvm_resolve_fallback_pkgset "${fallback_go_version}" > /dev/null; fallback_go_pkgset="${RETVAL}"; { setValueForKeyFakeAssocArray "gvm_go_name" "${fallback_go_version}" "${defaults_hash[*]}" > /dev/null; defaults_hash=(${RETVAL}); setValueForKeyFakeAssocArray "gvm_pkgset_name" "${fallback_go_pkgset}" "${defaults_hash[*]}" > /dev/null; defaults_hash=(${RETVAL}) }; unset fallback_go_version; unset fallback_go_pkgset; defaults_resolved=true; fi; defaults_go_name=""; defaults_go_pkgset=""; { valueForKeyFakeAssocArray "gvm_go_name" "${defaults_hash[*]}" > /dev/null; defaults_go_name="${RETVAL}"; valueForKeyFakeAssocArray "gvm_pkgset_name" "${defaults_hash[*]}" > /dev/null; defaults_go_pkgset="${RETVAL}" }; if [[ "${GVM_DEBUG}" -eq 1 ]]; then echo "Resolved default go: ${defaults_go_name:-[EMPTY]}"; echo "Resolved default pkgset: ${defaults_go_pkgset:-[EMPTY]}"; fi; __gvmp_find_closest_dot_go_version > /dev/null; rslt=$?; dot_go_version="${RETVAL}"; if [[ $rslt -eq 0 ]]; then [[ "${GVM_DEBUG}" -eq 1 ]] && echo "Found dot_go_version: ${dot_go_version}"; local use_goversion=""; __gvmp_read_dot_go_version "${dot_go_version}" > /dev/null; use_goversion="${RETVAL}"; [[ "${GVM_DEBUG}" -eq 1 ]] && echo "Switching to: ${use_goversion}"; \gvm use --quiet "${use_goversion}" || return 1; unset use_goversion; else if [[ -n "${defaults_go_name}" ]]; then [[ "${GVM_DEBUG}" -eq 1 ]] && echo "No .go-version found. Using system or default go."; \gvm use --quiet "${defaults_go_name}" || return 1; else if [[ "${GVM_DEBUG}" -eq 1 ]]; then local installed_hash; installed_hash=(); __gvm_find_installed "" "${GVM_ROOT}/gos" > /dev/null; installed_hash=(${RETVAL}); local go_archive_path="$GVM_ROOT/archive/go"; echo "No fallback go version could be found."; if [[ ${#installed_hash[@]} -eq 0 && ! -d "${go_archive_path}" ]]; then __gvm_locale_text_for_key "go_install_prompt" > /dev/null; __gvm_display_error "${RETVAL}"; return 1; fi; unset go_archive_path; unset installed_hash; fi; return 0; fi; fi; __gvmp_find_closest_dot_go_pkgset > /dev/null; rslt=$?; dot_go_pkgset="${RETVAL}"; if [[ $rslt -eq 0 ]]; then [[ "${GVM_DEBUG}" -eq 1 ]] && echo "Found .go-pkgset: ${dot_go_pkgset}"; local use_gopkgset=""; __gvmp_read_dot_go_pkgset "${dot_go_pkgset}" > /dev/null; use_gopkgset="${RETVAL}"; [[ "${GVM_DEBUG}" -eq 1 ]] && echo "Switching to: ${use_gopkgset}"; \gvm pkgset use --quiet "${use_gopkgset}" || return 1; unset use_gopkgset; else if [[ -n "${defaults_go_pkgset}" ]]; then [[ "${GVM_DEBUG}" -eq 1 ]] && echo "No .go-pkgset found. Using system or default pkgset."; \gvm pkgset use --quiet "${defaults_go_pkgset}" || return 1; else [[ "${GVM_DEBUG}" -eq 1 ]] && echo "No fallback pkgset could be found."; fi; fi; return 0 } 确实有效,command cd Google\ Drive/不行。

1 个答案:

答案 0 :(得分:0)

好的,我想出了导致这个问题的原因。

我注意到GVM中出现了type cd,并回想起我在某些时候安装了Go Version Manager,即GVM,并在.bash_profile [[ -s "/Users/stivens/.gvm/scripts/gvm" ]] && source "/Users/stivens/.gvm/scripts/gvm"中找到了一个脚本解析器。

我刚评论过,现在cd正常工作。

Bazinga!