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.
- #! /Bin/bash
- # Program:
- # This program shows the user's choice
- # History:
- #2005/08/25 VBird First release
- PATH =/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin :~ /Bin
- Export PATH
- Read-p "Please input (Y/N):" yn
- ["$ Yn" = "Y"-o "$ yn" = "y"] & echo "OK, continue" & exit 0
- ["$ Yn" = "N"-o "$ yn" = "n"] & echo "Oh, interrupt! "& Exit 0
- 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.
- Www.linuxidc.com @ linuxidc :~ /Bin $ ls-al/bin/sh
- 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:
- Sudo rm/bin/sh
- Sudo ln-s/bin/bash/bin/sh
Delete the reconstruction/bin/sh symbolic link and point it to the default/bin/bash.