質問

I am using Perlbrew in a brand new server (CentOs 6).

In my previous system (RedHat 4) WiTHOUT Perlbrew I used to use some aliases in the bash shell, like alias nreload='/usr/local/nginx/sbin/nginx -s reload' for example, to restart Nginx just putting the line in the .bash_profile file.

Now, with Perlbrew, I tried it in .bash_profile and in .bashrc, with no luck. I can make aliases on the fly, but I can't have them permanently available.

I followed the Perlbrew installation tips and copied the line source ~/perl5/perlbrew/etc/bashrc in the .bashrc file. I thought it should activate the Perlbrew Perl just by logging-in to the server, but it doesn't. So I must write source ~/perl5/perlbrew/etc/bashrc; everytime I need to use the Perlbrew Perl. It doesn't seems to be the right way.

Maybe the real problem is how I run Perlbrew. Maybe I do not understand the concept of Perlbrew opening another shell. If there is another shell, a subshell, how can I use alias in it?

Here is the content of my .bash_profile:

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin
source ~/perl5/perlbrew/etc/bashrc
export PATH

alias nreload='/usr/local/nginx/sbin/nginx -s reload'

BTW: the server is a remote one, and I control it from a local Macintosh, using Terminal. I have read something about Terminal is more a visual tool than a real Unix terminal, but I do not completely understand it.

役に立ちましたか?

解決

I have found the way: aliases must be in .bashrc

I connect using (Macintosh) Terminal, and when logged to the online server I just "activate" a new shell typing "/bin/bash".

In this new shell I have the right Perlbrew Perl, an all the alias, because this new shell takes everything from the .bashrc file.

What confused me was that "a new shell" is not really "a new terminal window" as I was expecting, but a new "process", and this new process, obviously uses .bashrc as a start point.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top