"type" builtin - inconsistent behaviour for non-executable files

Bug #1744397 reported by William Andrea
This bug affects 1 person
Affects Status Importance Assigned to Milestone
bash (Ubuntu)

Bug Description

If you have a non-executable file in the PATH, the "type" builtin will show it, just like an executable file. However, "type -a" does not. Is this expected behaviour, or is it a bug?

For example:

$ touch non-exec
$ PATH=.
$ type non-exec
non-exec is ./non-exec
$ type -a non-exec
bash: type: non-exec: not found

The manpage describes this behaviour, but it doesn't explain why it exists. Personally, I would have expected "type" and "type -a" to behave the same.

I stumbled on this while writing a Bash function that expands on "type", providing info like whether a function is marked for export, executable file type, etc, and this behaviour makes it difficult to parse "type -at".

This occurs on 17.10 with Bash 4.4.12, though I'm running 14.04 with Bash 4.3.11.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.