"type" builtin - inconsistent behaviour for non-executable files
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.
Question information
- Language:
- English Edit question
- Status:
- Answered
- For:
- Ubuntu bash Edit question
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Can you help with this problem?
Provide an answer of your own, or ask William Andrea for more information if necessary.