On Tue, Aug 28, 2012 at 10:58 AM, Hong Yang <hyangfji@gmail.com> wrote:
I get a bunch of
        /bin/sh: lt: command not found,
while I expect it act the same as
        mapm    'ls -Alrt --color=auto $_'    ls,
because "lt" is aliased to "ls -Alrt --color=auto."

Notice "/bin/sh" above. My shell is actually tcsh. All the aliases are in ~/.cshrc.

"system"-like functions in most languages use /bin/sh specifically, regardless of the user's shell, because programs cannot be expected to adapt between the different redirection commands use by sh-like and csh-like shells.  Consistency is important here, if you run a shell command from a program you do not want to deal with the fact that csh speaks an incompatible language and fish uses XML, etc.

If you really want to run your/the user's shell, retrieve $SHELL from the environment and run it directly.

    system $ "${SHELL:-/bin/sh} -c '" ++ mycommand ++ "'"

--
brandon s allbery                                      allbery.b@gmail.com
wandering unix systems administrator (available)     (412) 475-9364 vm/sms