Ellebasi Ellebasi - 9 months ago 49
Bash Question

Using type -t command in linux c.?

I use

to execute
type -t type
, this give me an error message
not found. When I perform
type -t type
in the shell this gives me builtin. Why doesn't this work with


POSIX specifies that the shell used with popen is /bin/sh. Your interactive shell is probably bash. The behaviour of the type command is different for sh and bash. sh does not support -t.

Your system probably has /bin/sh symbolically linked to /bin/dash, but that's just an implementation detail.

If you need bash behaviour, run bash explicitly:

   popen("/bin/bash -c 'type -t type'", "r")

Live demo.