There are tons of small differences between bash and sh. Some you will never encounter. The one I get ever so often is !, the exclamation point. It is also the logical not operator.
We have a script that runs Suns' explorer and it tells explorer not to run nbu and fma designated by !nbu,!fma.
The script is a sh script. I had typed the command on another machine that was missing the script but kept getting the error, 'event not found.' It took me a few seconds to figure out what was happening. The ! has special meaning in bash shell and in some occurrences it has to be escaped depending on it's usage.
! can be used for history expansion. Example: 400 commands ago, number 398 of history it was something quite complex. You could retype it, copy it, or just run it again doing !398. So when I typed the command for explorer and did !fmu,!fma its trying to find that event, and it won't exist.
Be mindful using this. A few days ago you were in /tmp/some-directory and did sudo rm -rf ./ to remove some things. That's now on line 189 of your history. Now you're now in the /etc directory and accidentally did '!189', bad things would happen.
Give the bash manual a read regarding history expansion.
http://www.gnu.org/software/bash/manual/bashref.html#Bash-History-Facilities
No comments:
Post a Comment