bashrc if:表达式语法错误
发布时间:2020-12-15 21:58:30 所属栏目:安全 来源:网络整理
导读:我写了以下.bashrc: # .bashrc# Source global definitionsif [ -f /etc/bashrc ]; then . /etc/bashrcfi# User specific aliases and functionsfunction up( ){LIMIT=$1P=$PWDfor ((i=1; i = LIMIT; i++))do P=$P/..donecd $Pexport MPWD=$P}function back
我写了以下.bashrc:
# .bashrc # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi # User specific aliases and functions function up( ) { LIMIT=$1 P=$PWD for ((i=1; i <= LIMIT; i++)) do P=$P/.. done cd $P export MPWD=$P } function back( ) { LIMIT=$1 P=$MPWD for ((i=1; i <= LIMIT; i++)) do P=${P%/..} done cd $P export MPWD=$P } 但是,保存后,当我执行源.bashrc时,我收到以下错误:if:Expression Syntax. 我究竟做错了什么 ?我用谷歌搜索了一段时间但没有用. 解决方法if: Expression Syntax 不是bash会给你的错误.也许你的shell不是bash.事实上,只要是独立,任何错误都不会与自己一起: $if [somethingswrong]; then fail; fi # error,then `[` command must have space around it. -bash: [somethingswrong]: command not found 您可以通过回显$SHELL来检查shell,并且可以使用$BASH_VERSION检查哪个版本的bash. (如果后者未设置,则shell不是bash.) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |