Re: /bin/sh does not read profile

2009-03-05 Thread Bertram Scharpf
Hi Frank,

Am Donnerstag, 05. Mär 2009, 04:15:05 + schrieb Frank Shute:
 On Wed, Mar 04, 2009 at 04:08:03PM +0100, Bertram Scharpf wrote:
  from man sh:
  
 Invocation
   [...]  the shell inspects
   argument 0, and if it begins with a dash (`-'), the shell is also 
  consid-
   ered a login shell.  [...] A login shell first reads commands from the
   files /etc/profile and then .profile in a user's home directory, if 
  they
   exist.  [...]
  
  I use Slim (X login manager) which calls
  
exec /bin/sh - ~/.xinitrc
 
 I've never before seen the syntax you've used and I think it comes
 from a misunderstanding of the manpage for sh and/or it's a bashism or
 a typo.

It's the original FreeBSD port.

 E.g:
 
 /bin/sh -c somecommand (login shell - arg 0 starts with a dash)

Sorry, this doesn't call /etc/profile either.

  $ uname -v
  FreeBSD 7.1-RELEASE #0: Thu Jan  1 14:37:25 UTC 2009 
r...@logan.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC

Bertram


-- 
Bertram Scharpf
Stuttgart, Deutschland/Germany
http://www.bertram-scharpf.de
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: /bin/sh does not read profile

2009-03-05 Thread Frank Shute
On Thu, Mar 05, 2009 at 02:23:52PM +0100, Bertram Scharpf wrote:

 Hi Frank,

Hi Bertram,

 
 Am Donnerstag, 05. Mär 2009, 04:15:05 + schrieb Frank Shute:
  On Wed, Mar 04, 2009 at 04:08:03PM +0100, Bertram Scharpf wrote:
   from man sh:
   
  Invocation
[...]  the shell inspects
argument 0, and if it begins with a dash (`-'), the shell is also 
   consid-
ered a login shell.  [...] A login shell first reads commands from 
   the
files /etc/profile and then .profile in a user's home directory, if 
   they
exist.  [...]
   
   I use Slim (X login manager) which calls
   
 exec /bin/sh - ~/.xinitrc
  
  I've never before seen the syntax you've used and I think it comes
  from a misunderstanding of the manpage for sh and/or it's a bashism or
  a typo.
 
 It's the original FreeBSD port.

I suggest you take up your problem with the maintainer. (Mentioned at
top of /usr/ports/x11/slim/Makefile). It should just work if that's
the case.

 
  E.g:
  
  /bin/sh -c somecommand (login shell - arg 0 starts with a dash)
 
 Sorry, this doesn't call /etc/profile either.

You're right. This is what my investigations reveal:

$ /bin/sh date
date: Can't open date: No such file or directory

Not reading /etc/profile or ~/.profile

$ /bin/sh -c date
Thu Mar  5 16:33:17 GMT 2009

Reading ~/.profile but not /etc/profile

I'm afraid I'm not a shell guru so I don't understand that particular
weirdness. I think we need a shell wizard to explain it to us - these
shells and sub-shells etc. are notoriously weird in my experience and
half the time I just sacrifice goats to make it work.

It could be that the manpage is wrong and the shell is just meant to
read ~/.profile (or I'm reading it wrong).

If nobody replies on this list, I suggest you post with your problem
to hackers@

 
   $ uname -v
   FreeBSD 7.1-RELEASE #0: Thu Jan  1 14:37:25 UTC 2009 
 r...@logan.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC

$ uname -v
FreeBSD 7.1-RELEASE-p2 #0: Wed Jan 28 21:45:37 GMT 2009
r...@orange.esperance-linux.co.uk:/usr/obj/usr/src/sys/ORANGE_MP2

BTW, my user shell is ksh.

 
 Bertram
 

Regards,

-- 

 Frank 


 Contact info: http://www.shute.org.uk/misc/contact.html 

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


Re: /bin/sh does not read profile

2009-03-05 Thread Polytropon
Good evening Betram et al.

I've read the discussion thread as far as it went and would like
to share my own solution to a similar problem, mapped onto the
sh topic. Maybe it works.

A little background:

First of all, because my standard dialog shell is the system's
C shell, the files important are /etc/cshrc with the settings,
such as setenv, alias and path, furthermore /etc/csh.login to
be executed after login, and /etc/csh.logout, executed after
logout. Local to the user exist ~/.cshrc, ~/.login and ~/.logout
which are used if present.

In order to make X work properly with these settings, I have
a kind of two stages mechanism which consists of the files
~/.xinitrc and ~/.xsession. The first one is used by X (xdm)
to determine what to do after successful user login, e. g.
start some programs and then exec the window manager / desktop
environment.

Note that both files are chmodded executable:

% ll .xsession .xinitrc
-rwxr-xr-x  1 poly  pgm  807 Mar  3 02:46 .xinitrc*
-rwxr-xr-x  1 poly  pgm   43 Apr 27  2006 .xsession*

The ~/.xsession doesn't do anything besides first incorporate
settings from ~/.cshrc and then execute ~/.xinitrc.

#!/bin/csh
source ~/.cshrc
exec ~/.xinitrc

It is shebanged with the shell I want to use, which is the C shell.

If ~/.xsession is called, it's last action is to execute ~/.xinitrc.
If ~/.xsession is NOT called, ~/.xinitrc will be executed anyway.
It does the following:

#!/bin/sh
[ -f ~/.xmodmaprc ]  xmodmap ~/.xmodmaprc
xrandr --size 1400x1050 
xrandr --fb 1400x1050 
xsetroot -solid rgb:3b/4c/7a

# ... your initializations 'n stuff here ...

exec wmaker

Note that this script is shebanged for sh again. Any X terminals
started now (with csh inside) have the settings from ~/.cshrc.



Mapped onto the initial sh problem, I'd suggest to create the
two files mentioned as follows:

~/.xsession:

#!/bin/sh
[ -f ~/.shrc ]  . ~/.shrc
[ -f ~/.profile ]  . ~/.profile
exec ~/.xinitrc

~/.xinitrc:

#!/bin/sh
[ -f ~/.shrc ]  . ~/.shrc
[ -f ~/.profile ]  . ~/.profile
my_init_stuff_1
my_init_stuff_2
my_init_stuff_3
exec my_wm_startup

Now any instance of sh started should be aware of the settings.



Finally, please note that I'm not a guru for sh (or bash) because
I do use sh only for scripting, and bash never. :-)



-- 
Polytropon
From Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: /bin/sh does not read profile

2009-03-05 Thread J65nko
On Wed, Mar 4, 2009 at 4:08 PM, Bertram Scharpf
li...@bertram-scharpf.de wrote:
 Hi,

 from man sh:

   Invocation
 [...]  When first starting, the shell inspects
 argument 0, and if it begins with a dash (`-'), the shell is also consid-
 ered a login shell.  This is normally done automatically by the system
 when the user first logs in.  A login shell first reads commands from the
 files /etc/profile and then .profile in a user's home directory, if they
 exist.  [...]

 I use Slim (X login manager) which calls

  exec /bin/sh - ~/.xinitrc

 I first wondered why none of my commands in /etc/profile and
 ~/.profile got executed.  Finally, I modified
 /usr/src/bin/sh/main.c to trace what files are read, recompiled
 the sh command and: the only file that is executed is ~/.shrc.

 I just cannot believe that FreeBSD has such a severe bug. What is
 going wrong here?


Put the following in a file called .Xresources :
   XTerm*loginShell: true

=Adriaan=
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: /bin/sh does not read profile

2009-03-05 Thread Peter Steele
I first wondered why none of my commands in /etc/profile and 
~/.profile got executed. Finally, I modified 
/usr/src/bin/sh/main.c to trace what files are read, recompiled 
the sh command and: the only file that is executed is ~/.shrc. 
 
I just cannot believe that FreeBSD has such a severe bug. What is 
going wrong here? 

I have a similar problem, but with bash. I have both my personal account and 
root set to use bash instead of sh and when I login the .bashrc file is not 
read. My system does not have an X environment, it's plain old BSD. How can I 
get it to load .bashrc when I login? I'm using a 7.0 binary release. 


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


Re: /bin/sh does not read profile

2009-03-05 Thread Polytropon
On Thu, 5 Mar 2009 18:11:18 -0800 (PST), Peter Steele pste...@maxiscale.com 
wrote:
 I have a similar problem, but with bash. I have both my personal
 account and root set to use bash instead of sh and when I login
 the .bashrc file is not read. My system does not have an X
 environment, it's plain old BSD. How can I get it to load .bashrc
 when I login? I'm using a 7.0 binary release. 

I read from the manpage bash-3.2.25 according to the FILES section:

   /etc/profile
  The systemwide initialization file, executed for login shells
   ~/.bash_profile
  The personal initialization file, executed for login shells
   ~/.bashrc
  The individual per-interactive-shell startup file

When the shell is the login shell (prefixed with - in the process
list), it seems that it needs to read ~/.bash_profile (and not
the ~/.bashrc file). So you could put

. ~/.bashrc

into ~/.bash_profile to get a workaround.



-- 
Polytropon
From Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: /bin/sh does not read profile

2009-03-05 Thread Frank Shute
On Thu, Mar 05, 2009 at 06:11:18PM -0800, Peter Steele wrote:

 I first wondered why none of my commands in /etc/profile and 
 ~/.profile got executed. Finally, I modified 
 /usr/src/bin/sh/main.c to trace what files are read, recompiled 
 the sh command and: the only file that is executed is ~/.shrc. 
  
 I just cannot believe that FreeBSD has such a severe bug. What is 
 going wrong here? 
 
 I have a similar problem, but with bash. I have both my personal
 account and root set to use bash instead of sh and when I login the
 .bashrc file is not read. My system does not have an X environment,
 it's plain old BSD. How can I get it to load .bashrc when I login?
 I'm using a 7.0 binary release. 

You should be able to put:

source $HOME/.bashrc

in ~/.bash_profile

That's if $HOME is set. Otherwise use the full path.


Regards,

-- 

 Frank 


 Contact info: http://www.shute.org.uk/misc/contact.html 

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


/bin/sh does not read profile

2009-03-04 Thread Bertram Scharpf
Hi,

from man sh:

   Invocation
 [...]  When first starting, the shell inspects
 argument 0, and if it begins with a dash (`-'), the shell is also consid-
 ered a login shell.  This is normally done automatically by the system
 when the user first logs in.  A login shell first reads commands from the
 files /etc/profile and then .profile in a user's home directory, if they
 exist.  [...]

I use Slim (X login manager) which calls

  exec /bin/sh - ~/.xinitrc

I first wondered why none of my commands in /etc/profile and
~/.profile got executed.  Finally, I modified
/usr/src/bin/sh/main.c to trace what files are read, recompiled
the sh command and: the only file that is executed is ~/.shrc.

I just cannot believe that FreeBSD has such a severe bug. What is
going wrong here?

Thanks in advance,

Bertram


-- 
Bertram Scharpf
Stuttgart, Deutschland/Germany
http://www.bertram-scharpf.de
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: /bin/sh does not read profile

2009-03-04 Thread Frank Shute
On Wed, Mar 04, 2009 at 04:08:03PM +0100, Bertram Scharpf wrote:

 Hi,
 
 from man sh:
 
Invocation
  [...]  When first starting, the shell inspects
  argument 0, and if it begins with a dash (`-'), the shell is also consid-
  ered a login shell.  This is normally done automatically by the system
  when the user first logs in.  A login shell first reads commands from the
  files /etc/profile and then .profile in a user's home directory, if they
  exist.  [...]
 
 I use Slim (X login manager) which calls
 
   exec /bin/sh - ~/.xinitrc

Usually ~/.xinitrc is parsed by the X server when it starts (startx is
just a Bourne shell script) and you exec the last command (the window
manager) in your ~/.xinitrc

I've never before seen the syntax you've used and I think it comes
from a misunderstanding of the manpage for sh and/or it's a bashism or
a typo.

E.g:

/bin/sh -c somecommand (login shell - arg 0 starts with a dash)

/bin/sh somecommand(not a login shell)

 
 I first wondered why none of my commands in /etc/profile and
 ~/.profile got executed.  Finally, I modified
 /usr/src/bin/sh/main.c to trace what files are read, recompiled
 the sh command and: the only file that is executed is ~/.shrc.
 
 I just cannot believe that FreeBSD has such a severe bug. What is
 going wrong here?
 
 Thanks in advance,
 
 Bertram
 

Regards,

-- 

 Frank 


 Contact info: http://www.shute.org.uk/misc/contact.html 

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