I'm using ash and bash shell in my embedded system, I got following error messages for same command using both shell
For ash shell
$ kill -9
sh: you need to specify whom to kill
For bash shell
$ kill -9
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
So,My question is why there are two different error messages for same command in two different shell? My understanding is error message return from command not from shell.
My question is why there are two different error messages for same command in two different shell?
Because kill
is a shell-builtin (at least on bash
). This implies that is using bash
, saying kill ...
would execute the shell builtin and not the binary that might reside in /bin
or /usr/bin
.
$ echo $SHELL
/bin/bash
$ type kill
kill is a shell builtin
$ kill
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
$ which kill
/bin/kill
$ /bin/kill
usage: kill [-s signal_name] pid ...
kill -l [exit_status]
kill -signal_name pid ...
kill -signal_number pid ...
You could disable the shell-builtins in bash
by making use of the enable
builtin:
$ enable -n kill
$ kill
usage: kill [-s signal_name] pid ...
kill -l [exit_status]
kill -signal_name pid ...
kill -signal_number pid ...
(Invoking kill
after disabling the builtin invokes the system /bin/kill
instead.)