简体   繁体   中英

bash and ash shell returns different error message for same command

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.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM