On 2005-06-07, Tong wrote:
> Hi, 
>
> How can I use my aliases in my bash script?

   This has been answered more than adequately in the comp.unix.shell
   newsgroup.

   The correct answer, which you seem not to like, is, "Don't use
   aliases; use functions."

   When given advice on how to do the inadvisable, you disregarded
   that.


> This seems a very simple question but I just can't get it working. For
> example, I have an alias 
>
> alias acpl='apt-cache policy'
>
> and this test file:
>
> $ cat cmd.bash
> shopt
> alias
>
> acpl apt-cache
>
> Now, no matter how I invoke the script, I always get the error:
> cmd.bash: line 4: acpl: command not found
>
> Here is how I invoked:
>
> bash -O expand_aliases cmd.bash 

   As I said before, this works for me in both 2.05b and 3.0.

> bash -i cmd.bash 
>
> bash -i -O expand_aliases cmd.bash 
> bash -O expand_aliases -i cmd.bash 

   I also suggested adding "shopt -s expand_aliases" to the script.
   You replied that is wasn't necessary. You didn't try it and still
   complained that your script didn't work.

-- 
    Chris F.A. Johnson                     <http://cfaj.freeshell.org>
    ==================================================================
    Shell Scripting Recipes: A Problem-Solution Approach, 2005, Apress
    <http://www.torfree.net/~chris/books/cfaj/ssr.html>


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to