为什么我一直得到`bash:local:command not found`

时间:2014-10-09 22:50:36

标签: bash

继续收到此错误:

bash:   local: command not found
bash:   local: command not found
bash:   local: command not found
bash:   local: command not found
bash:   local: command not found
bash:   local: command not found
bash:   local: command not found
bash:   local: command not found
bash:   local: command not found
bash:   local: command not found
bash:   local: command not found
bash:   local: command not found
bash:   local: command not found
bash:   local: command not found
bash:   local: command not found
bash:   local: command not found
bash:   local: command not found
bash:   export: command not found
bash:   export: command not found
bash: ~/.bash_profile: No such file or directory

这是我的bash_profile:

当我注释掉提示功能时,错误消失了,除了最后一个!

alias ngrok=/Users/mmahalwy/Desktop/Code/ngrok

export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced

alias ls='ls -GFh'

function prompt {
  local BLACK="\[\033[0;30m\]"
  local BLACKBOLD="\[\033[1;30m\]"
  local RED="\[\033[0;31m\]"
  local REDBOLD="\[\033[1;31m\]"
  local GREEN="\[\033[0;32m\]"
  local GREENBOLD="\[\033[1;32m\]"
  local YELLOW="\[\033[0;33m\]"
  local YELLOWBOLD="\[\033[1;33m\]"
  local BLUE="\[\033[0;34m\]"
  local BLUEBOLD="\[\033[1;34m\]"
  local PURPLE="\[\033[0;35m\]"
  local PURPLEBOLD="\[\033[1;35m\]"
  local CYAN="\[\033[0;36m\]"
  local CYANBOLD="\[\033[1;36m\]"
  local WHITE="\[\033[0;37m\]"
  local WHITEBOLD="\[\033[1;37m\]"
  local RESETCOLOR="\[\e[00m\]"

  export PS1="\n$RED\u $PURPLE@ $GREEN\w $BLUE[\#] → $RESETCOLOR"
  export PS2="| → $RESETCOLOR"
}

# prompt

export PATH=/usr/local/bin:$PATH

source ~/.git-completion.bash

1 个答案:

答案 0 :(得分:6)

如果local确实无法使用(例如,使用enable -n local停用),您会看到:

bash: local: command not found

而不是:

bash:   local: command not found

那些额外的空间是一个线索。仔细查看您的文件(如果必须,使用十六进制编辑器),并找出那些不是空格或制表符的字节 ...并将它们更改为真正的ASCII空间字符。

Unicode中有几种不间断的空间变体;我猜他们以某种方式进入你的剧本。从网络上复制和粘贴代码可能很危险。 :)