Re: source from within a script

From: Bob (bob_at_dont.spam.me)
Date: 06/13/04


Date: Sun, 13 Jun 2004 14:38:59 GMT

On Sun, 13 Jun 2004 16:22:02 +0200, Bishara Sabbagh wrote:

> Hallo Bob,
> I tried your script and bash answers : bash: x: command not found
> that's why I appended the generated alias to .profile and tried to source
> it.

Be sure you source the "xxx" script. Use either of the following:

        . xxx
        source xxx

Don't execute the script:

        ./xxx # NO!

Also, in my script the first line ("#!/bin/bash") is not needed. I just
put it there by habbit.

<clip>

>> The following works for me...
>>
>> #!/bin/bash
>> echo -n "enter alias... "
>> read alias command
>> alias $alias="$command"
>>
>> I put the above in a scriped named xxx and used it like this:
>>
>> $ . xxx
>> enter alias... x ls -la
>> $ x
>>
>> the "x" command was properly aliased to "ls -la"
>>
>>
>>



Relevant Pages

  • Re: source from within a script
    ... > generate an alias with a script that appends aliases to my .profile so that ... > The script I wrote is quite simple: it reads the alias name and the command, ... > then it generates the alias and appends a line to my .profile file. ...
    (comp.unix.shell)
  • Re: source from within a script
    ... generate an alias with a script that appends aliases to my .profile so that ... The script I wrote is quite simple: it reads the alias name and the command, ... then it generates the alias and appends a line to my .profile file. ...
    (comp.unix.shell)
  • Re: Bash scripting problems
    ... I even created a new script with these two caommands and get the same ... alias rm='rm -i' ... # echo all aliases set ...
    (Fedora)
  • RE: regex one liner
    ... Timothy Johnson wrote: ... one-liner so compelling, especially when you are using it for ... See `man alias` for details. ... script, it may seem easier to you, but not necessarily ...
    (perl.beginners)
  • Re: oddity regarding execution
    ... and fired off a test message. ... > Well, when the alias fed the message to it, it barked. ... I modified the script to ... And is there anything I can do so the cwd will be the dir the ...
    (freebsd-questions)