An alias error in the bash configuration file may cause shell exceptions.

Source: Internet
Author: User
Tags linux mint

1. first introduce the usage of Alias (alias)

Alias LA = 'LS-a' alias B = 'CD... 'and so on

Alias is a good thing. It can save a lot of time when using shell.


2. But one day I found that the if statement cannot be used when executing the shell script, the following error will be reported:

Bash: build/envsetup. sh: line 30: syntax error near unexpected token 'then'
Bash: build/envsetup. sh: line 30: 'If [! "$ T"]; then'

This occurs when I run source setenv during Android 4.2.2 compilation. It is very depressing!

(If there are other exceptions, enter some commands and press the tab key, for example, Apt-Get install XXX)


3. Various searches finally found that the shell script keyword if: alias if = 'ifconfig' appears in the alias file of. bashrc'

4. Summary

The shell should replace "if" with "ifconfig" when interpreting the script. An error is certainly returned. Therefore, when writing the configuration file,

Be sure not to use keywords or syntax errors.


5. Consequences

Previously, Linux mint was reinstalled due to this error, and the error still occurred.

I may not be able to find this error all my life, but some may not.

I am unfortunate and lucky!


6. Last

Appendix: My frequently-used alias

alias ls='ls --color=tty'alias l.='ls -d .* --color=tty'alias la='ls -a'alias ll='ls -l'alias llh='ls -l -h'alias l='ls'alias c='cd'alias mv='mv -i'alias rm='rm -i'alias vi='vim'alias b='cd ..'alias py='python'alias md='mkdir'alias mk='make'alias mkcl='make clean'alias m='man'alias t='top'alias cl='clear'alias sudo='sudo '# alias if='ifconfig' # I hate u!alias ip='ifconfig'alias mo='mount'alias um='umount'alias gcc='gcc -Wall'alias grep='grep --colour=auto'

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.