This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: chere doesn't cd to directory


On Sat, 5 Mar 2005, Dave wrote:

> --- Igor Pechtchanski wrote:
>
> > On Fri, 4 Mar 2005, Dave wrote:
> > > The cd occurs in /etc/profile for bash, ash, and pdksh; /etc/zprofile
> > > for zsh; /etc/csh.login for tcsh.
>
> > I don't recall if this was part of the discussion, but any particular
> > reason you're not doing this in a /etc/profile.d script instead?  That
> > way, it would work even with a custom /etc/profile.
>
> I honestly hadn't thought of that... and I don't recall it being
> mentioned.
>
> The issue is that chere wants to stop the standard login script from
> doing the usual cd $(HOME). The profile.d scripts get run before the cd,
> and hence th cd happens anyway. If the order were changed, we'd have
> lost the directory we wanted anyway.

That's true.  However, bash, for example, remember the previous directory
that they were in at the shell level.  I just tried, and a newly-started
bash shell, when issued a "cd -", will go into /usr/bin.  If I add a
/etc/profile.d/test.sh that does "cd /var", the newly-started bash will go
to /var on "cd -".  FWIW, tcsh supports this too (just tried).  I don't
see off-hand how this could be utilized, but it looks promising.  I hadn't
tried zsh -- Peter?

If the "cd $HOME" were moved earlier, you could have a standard (part of
base-files) /etc/profile.d script that is executed last
(zzsomething.{c,}sh) that does a "cd -" if some variable is set.  Then the
CHere package could add a yysomething.{c,}sh that simply sets that
variable...

> The 'cd $(HOME)' could be removed from /etc/profile, but then the
> profile.d script would be required even when chere were not installed.

Another alternative is to wrap /etc/profile in another script and use
bash's --noprofile and --rcfile options (again, don't recall if this has
been discussed before).

> Also, tcsh reads the profile.d scripts from csh.cshrc rather than
> csh.login. So a non login tcsh shell would also run the snippet (and cd
> $(HOME)).

Ah, this one's easy to solve.  Just unset the variable after you do the
first "cd $(HOME)". :-)  Then subsequent invocations will skip the
snippet.

> That said, profile.d seems to be a good place for other generic startup
> that is done by base-files, since all the shells run them.

Yeah, except for the 'alias' problem (ash doesn't support it, and it's
used in 'mc.sh', so every invocation of a login /bin/sh results in an
"alias: not found" message).
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha@cs.nyu.edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor@watson.ibm.com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"The Sun will pass between the Earth and the Moon tonight for a total
Lunar eclipse..." -- WCBS Radio Newsbrief, Oct 27 2004, 12:01 pm EDT

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]