C: List aliases of current shell (not subshell!) -
i'm trying find aliases current shell possesses (in c program). i've tried system("alias")
, popen("alias", "r")
, execvp("alias", ...)
, latter of doesn't work @ (because alias
shell-specific command) , first 2 of run command in subshell (which sh
, not bash
) -> there, aliases disabled because defined in ~/.bashrc
. executing bash
, reading output of alias
isn't possible either because bash
go alias definitions if in interactive mode.
if do run bash
in interactive mode, huge delay time , prompt output want avoid.
basically, want, have similar behaviour time(1)
. looks current aliases without executing command! (it fork once, is, passed command)
crawling internet no avail.
question: how aliases in current shell? there portability issues? if yes, how avoid them?
regards.
you can't. time built-in , can access aliases stored internally shell instance running. if need work out shell execute, need run or similar.
time isn't doing clever or secret. it's prefix command make shell print out timing information.
Comments
Post a Comment