我最近升级了我的FreeBSD盒子,现在pythonbrew似乎被打破了。它从这行上的.pythonbrew / etc / bashrc文件中解脱出来:
PATH_WITHOUT_PYTHONBREW=$(printf "$PATH" | awk -v RS=: -v ORS=: "/${PATH_ROOT//\//\/}/ {next} {print}" | sed -e 's#:$##')
给出错误:
awk: syntax error at source line 1
context is
>>> //home/myusername/. <<< pythonbrew/ {next} {print}
awk: bailing out at source line 1
PATH_ROOT变量是
/home/myusername/.pythonbrew
答案 0 :(得分:4)
printf "%s" "$PATH"
代替printf "$PATH"
。'/'"${PATH_ROOT//\//\/}"'/{...}'
代替"/${PATH_ROOT//\//\/}/{...}"
awk -v path_root="${PATH_ROOT//\//\/}" '$0 ~ path_root{...}'
代替'/'"${PATH_ROOT//\//\/}"'/{...}'
。所以,总之,作为一个起点,你的脚本将是:
PATH_WITHOUT_PYTHONBREW=$(printf "%s" "$PATH" |
awk -v path_root="${PATH_ROOT//\//\/}" 'BEGIN{RS=ORS=":"} $0 !~ path_root' |
sed -e 's#:$##')
假设您的PATH_ROOT操作有意义。
可以进一步改进,但这应该足以摆脱你的错误。