简体   繁体   中英

Using type -t command in linux c.?

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

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM