A shell alias is something that your shell deals with. The aliases only exist as shortcuts in your shell white the shell is executing.

These aliases do not exist as program files in the filesystem. When you run system("tt") from perl the directories in your PATH environment variable are searched for a program file named tt. In this case no program named tt is being found.

The man page for BASH indicates alias expansion takes place after one full line of text is read in. This could mean that aliases are only expanded when BASH is reading from a terminal and not when it has been passed a command to run.

Normally BASH runs in a terminal and executes a loop where it reads a command and runs the command then repeats. It might be that aliases are only expaned inside of that loop but I'm not sure that is the case.

I tried running perl -e 'system("bash --login -c l");' where I have a BASH alias mapping "l" to "ls -l" and I got back: "bash: line 1: l: command not found".

As an aside the man page for BASH has this text in the BUGS section:
  Aliases are confusing in some uses.

In reply to Re: system calls and shell aliases by superfrink
in thread system calls and shell aliases by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.