Ellebasi Ellebasi - 1 year ago 81
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

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download