0

I wanted to use kill --verbose ... in a bash script but I got the error kill: -verbose: invalid signal specification. This was weird as it worked fine in fish. My investigation has lead me to this weird behaviour:

$ which kill
/usr/bin/kill
$ sleep 5 & kill --verbose $!
[1] 33730
bash: kill: -verbose: invalid signal specification
... wait for sleep to finish ... 
[1]+  Done                    sleep 5
$ sleep 5 & /usr/bin/kill --verbose $!
[1] 33964
sending signal 15 to pid 33964
[1]+  Terminated              sleep 5

What is going on? Why does kill not recognise the --verbose flag, but /usr/bin/kill does, when which kill == /usr/bin/kill?

1 Answer 1

5

which is misleading; try type instead:

$ type kill
kill is a shell builtin

When you run kill, bash uses its built-in command, which doesn’t recognise --verbose. When you specify the full path, the external command /usr/bin/kill is run instead, and that does support --verbose (in your case).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.