Re: problems with .bashrc

From: Viktor Lazlo (viktorlazlo_at_telus.net)
Date: 04/14/04

  • Next message: Jeffrey P. Toth: "PCI Graphic card install"
    Date: Tue, 13 Apr 2004 20:02:58 -0700 (PDT)
    To: fudo <fudo@spamblocked.com>
    
    

    On Tue, 13 Apr 2004, fudo wrote:

    > I'm new to FreeBSD, and to bash. I'm running FreeBSD 5.0, and added
    > bash from the cd during install. There are .profile and .shrc files in
    > my home directory; .profile references .shrc with ENV=$HOME/.shrc;
    > export ENV. There are several uncommented alias lines in the .shrc
    > file, but none of them work. From what I've read, bash should read
    > .profile and .shrc, but just in case, I tried copying them to
    > .bash_profile and .bashrc, changing ENV to =$HOME/.bashrc, and renaming
    > the original files, but the aliases still don't work. Aliases are
    > formatted: alias ll='ls -laFo'; entering that at the prompt and it
    > works fine. Seems like bash isn't reading the rc file. Obviously, I'm
    > missing something; any suggestions appreciated. Thanks.

    I think what is happening is the aliases in .shrc are not read directly by
    bash unless invoked as sh, and the .shrc assigned to ENV is only read for
    non-login shells; I'm not sure why they wouldn't work when entered in
    .bash_profile, but the fact that they don't suggests a conflict between
    the files the commands are entered in and the order in which they are
    read.

    When invoked as bash (not sh) the start-up files that bash reads for a
    login shell are, in order:

      i) /etc/profile

    and then the first of any of the following that exists:

     ii) ~/.bash_profile OR
    iii) ~/.bash_login OR
     iv) ~/.profile

    Non-login interactive bash shells (when changing or starting new shells
    during a session) read only ~/.bashrc.

    Non-login non-interactive bash shells (ie-when launched from inside a
    script) check the startup file in $BASH_ENV, or $ENV if that doesn't
    exist.

    An easy way to make sure all three invocations of bash reference the same
    start-up file is:

     i) use .bashrc as your customized startup file

    ii) create a .bash_profile containing only:

            export BASH_ENV=~/.bashrc
            if [ -f ~/.bashrc ]; then source ~/.bashrc; fi

    This way, after reading /etc/profile a login shell will read the first
    file found, ~/.bash_profile, which in turn reads ~/.bashrc

    Non-login interactive shells will read ~/.bashrc as usual

    Non-login non-interactive shells will read the ~/.bashrc assigned in
    $BASH_ENV.

    Cheers,

    Viktor
    _______________________________________________
    freebsd-questions@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-questions
    To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org"


  • Next message: Jeffrey P. Toth: "PCI Graphic card install"

    Relevant Pages

    • Re: [ Attn: Randy ] Ad-hoc Parsing?
      ... One of the biggest advantages of Unix-like shells ... > flexible as the Unix scripts using the more powerful ... about bash, which being a fully-capable shell, can launch programs ... > execute the com program itself). ...
      (alt.lang.asm)
    • Re: [ Attn: Randy ] Ad-hoc Parsing?
      ... > if people have been discussing the unix ... One of the biggest advantages of Unix-like shells ... better Unix-like shells (sh, csh, bash, ...) used in Unix/Linux ... that scripts in DOS/Windows (using the less ...
      (alt.lang.asm)
    • Re: Shell Games
      ... Here is a link that explains shells ... >Scripting languages like PERL and Bash serve diffrent ... I do alot of Bash scripting to automate alot ... Switch to Netscape Internet Service. ...
      (freebsd-newbies)
    • bash
      ... GNU bash, version 2.05b.0-release- ... executed by bashfor login shells. ... # include .bashrc if it exists ... However this makes the meta key not work as a meta key, ...
      (Debian-User)
    • problems with .bashrc
      ... I'm new to FreeBSD, and to bash. ... I'm running FreeBSD 5.0, and added ... my home directory; .profile references .shrc with ENV=$HOME/.shrc; ...
      (freebsd-questions)