• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: bash $PATH variable
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bash $PATH variable


  • Subject: Re: bash $PATH variable
  • From: Justin Walker <email@hidden>
  • Date: Fri, 20 Aug 2004 16:05:51 -0700

On Aug 20, 2004, at 15:31, Markian Hlynka wrote:


'.bashrc' is not a BSDism, nor is '.profile'. Read the man page ("man bash") for details about the startup protocol for 'bash' (the same holds for other shells as well; they tend to be fairly well documented, and largely system-independent).


All of your questions are answered in the man page.


I've read the man page before, when I first tried to figure this out. I was adding things to my bashrc file and it wasn't working.

The information is there.
 It said:

--norc Do not read and execute the personal initialization file
~/.bashrc if the shell is interactive. This option is on by
default if the shell is invoked as sh.



Which wasn't especially helpful. it said the option is on by default. I'm not sure how OS X invokes it, so this is a problem.

This is a login shell (for 'bash'; other shells may have different conventions):


" A login shell is one whose first character of argument zero is a -, or
one started with the --login option."


$ ps
  PID  TT  STAT      TIME COMMAND
  500 std  S      0:00.52 -bash

That's a login shell, as started by the login process.

similarly,

--noprofile
Do not read either the system-wide startup file /etc/profile or
any of the personal initialization files ~/.bash_profile,
~/.bash_login, or ~/.profile. By default, bash reads these
files when it is invoked as a login shell (see INVOCATION
below).

The flags are used to permit you to customize the behavior of shells you launch yourself.


So, is being invoked as a login shell different from being invoked as sh?

It ain't 'sh'; it's 'bash'.

looking up invocation is no help either...
A login shell is one whose first character of argument zero is a -, or
one started with the --login option.

See above.

When bash is invoked as an interactive login shell, or as a non-inter-
active shell with the --login option, it first reads and executes com-
mands from the file /etc/profile, if that file exists. After reading
that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile,
in that order, and reads and executes commands from the first one that
exists and is readable. The --noprofile option may be used when the
shell is started to inhibit this behavior.
...
When an interactive shell that is not a login shell is started, bash
reads and executes commands from ~/.bashrc, if that file exists. This
may be inhibited by using the --norc option. The --rcfile file option


so, the precedence is clear except I still don't know what a login shell is! So I still don't understand why .beshrc isn't being called.

Where does it say that "~/.bashrc" is read from a login shell?

nowhere in this file does it tell me what OS X does when I open a new terminal window... or does it? The terminal options say that I can "Execute the default login shell using /usr/bin/login" or I can "specify the complete path". So... that pretty much doesn't help at all.

Mac OS X doesn't do anything differently from other, similar systems.

Why doesn't Apple update the man pages to indicate what OS X does?

No need to.

More appropriately, why doesn't Terminal help say, "put files in .profile if you're using the default login"?

Terminal has no clue what you are running as a shell. You can have a terminal window that automatically logs you into a remote VM/CMS system, so that the first prompt presented to you will be from that remote system. VM/CMS doesn't work like Mac OS X, so it would have no way of telling you how to handle that. More realistically, each shell on Mac OS X has different conventions. Terminal isn't expected to keep track of them.


Or, am I being silly? Is it really all there in front of me?

It really is all there for you. I hope this helps show you specifics to get you going.


Regards,

Justin

--
Justin C. Walker, Curmudgeon-At-Large  *
Institute for General Semantics        |    Men are from Earth.
                                       |    Women are from Earth.
                                       |       Deal with it.
*--------------------------------------*-------------------------------*
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.


References: 
 >bash $PATH variable (From: Professor Leslie Smith <email@hidden>)
 >Re: bash $PATH variable (From: Michael Cashwell <email@hidden>)
 >Re: bash $PATH variable (From: Markian Hlynka <email@hidden>)
 >Re: bash $PATH variable (From: Justin Walker <email@hidden>)
 >Re: bash $PATH variable (From: Markian Hlynka <email@hidden>)

  • Prev by Date: Re: How do I set up a subversion server?
  • Next by Date: Errors and Warnings
  • Previous by thread: Re: bash $PATH variable
  • Next by thread: Xcode 1.5, Java, and Cryptography? New Mac Developer here
  • Index(es):
    • Date
    • Thread