In our makefiles, we call shell commands like printf. Makefiles are internally executing that command through /bin/sh like /bin/sh -c printf hi. In my newly installed solaris machine, I have observed that some commands [printf] are running very slow. Then, I have seen the main reason as printf is not built-in function in the shell. But, in /bin/bash, it is built-in. The same command is running very fast in bash. As I know, /bin/bash [BASH] is advanced than /bin/sh [Bourne shell]. So, I have created a soft link from /bin/bash to /bin/sh. Now, whenever I execute /bin/sh, automatically bash will be executed. As of now, I did not get any problem with this approach and it seems bash has many built-in commands and fast.
some problems when commands are hashed
July 9, 2007 at 2:32 pm (Linux, solaris)
In Unix systems, commands are hashed for performance reasons [man hash]. Today, I got a problem related to this and wasted so much time for resolving. In my solaris machine, patch command is in /usr/bin/patch and its version is very old. So, I have installed a new patch version using pkgadd and it has installed patch command in /usr/local/bin/. In PATH variable, /usr/local/bin/ is before /usr/bin directory. So, `which patch` command is showing /usr/local/bin/patch. But, when I execute patch on command prompt, it is executing old version of patch [/usr/bin/patch]. After some time, I tried type command `type patch` and it is showing /usr/bin/patch is hashed. Then, I came to know about hash command in solaris. After rehashing, every thing started working fine.