Default sh error in Ubuntu

Source: Internet
Author: User
Recently I learned shell programming and found that the default shell in Ubuntu is dash, which is very difficult to use. Some inexplicable errors will be reported when many scripts are executed. #! /Bin/bash # Program: # Thisprogramshowstheuser 'schice & nbsp

Recently I learned shell programming and found that the default shell in Ubuntu is dash, which is very difficult to use. Some inexplicable errors will be reported when many scripts are executed.

  1. #! /Bin/bash
  2. # Program:
  3. # This program shows the user's choice
  4. # History:
  5. #2005/08/25 VBird First release
  6. PATH =/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin :~ /Bin
  7. Export PATH
  8. Read-p "Please input (Y/N):" yn
  9. ["$ Yn" = "Y"-o "$ yn" = "y"] & echo "OK, continue" & exit 0
  10. ["$ Yn" = "N"-o "$ yn" = "n"] & echo "Oh, interrupt! "& Exit 0
  11. Echo "I don't know what your choice is" & exit 0

This script is taken from the script of Chapter p272 of laruence's private dish, which is no problem in other releases. However, in my computer's ubuntu 12.04, an error is reported.

[: 10: y: unexpected operator
I don't know what your choice is

I couldn't explain it until I found the information on the Internet and prompted me to say that the shell was used for testing.

  1. Www.linuxidc.com @ linuxidc :~ /Bin $ ls-al/bin/sh
  2. Lrwxrwxrwx 1 root 4 May 19 :13/bin/sh->Dash

It is found that sh is a symbolic link for executing dash, rather than bash.

So we found the solution:

  1. Sudo rm/bin/sh
  2. Sudo ln-s/bin/bash/bin/sh

Delete the reconstruction/bin/sh symbolic link and point it to the default/bin/bash.

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.