Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 Mar 2000 22:45:21 -0800
From:      Doug Barton <Doug@gorean.org>
To:        freebsd-hackers@freebsd.org
Subject:   Proposed new Bourne shell init files
Message-ID:  <38E2F801.548AAAF1@gorean.org>

next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------9ABA32D60C072BD381454706
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

	Still no comment on this, so here's to a wider audience.

Doug

-------- Original Message --------
Subject: Re: cvs commit: src/share/skel dot.cshrc dot.login
src/etc/rootdot.cshrc dot.login
Date: Sun, 26 Mar 2000 00:55:40 -0800
From: Doug Barton <Doug@gorean.org>
Organization: Triborough Bridge & Tunnel Authority
To: Robert Watson <rwatson@FreeBSD.ORG>
CC: cvs-committers@FreeBSD.ORG, cvs-all@FreeBSD.ORG
References: <200003252023.MAA76070@freefall.freebsd.org>

	I'm really glad someone is taking a look at this. Please don't take any
of my comments as criticism. :)  

Robert Watson wrote:
> 
> rwatson     2000/03/25 12:23:40 PST
> 
>   Modified files:
>     share/skel           dot.cshrc dot.login
>     etc/root             dot.cshrc dot.login
>   Log:
>   o Migrate path, umask from dot.login to dot.cshrc

	I'm a little confused about moving umask. Doesn't it make more sense in
dot.login, since it mostly applies to login shells? Maybe it has some
application in non-interactive shells I'm not aware of. 

>   o Comment out display of fortune by default.

	Good move. This made my boss nuts when we started using freebsd at
work.

>   o Synch root's .cshrc/.login and non-root's .cshrc/.login in terms of
>     gratuitous variables set (EDITOR).

	Another good move. FWIW, you have two small gratuitous differences. 

--- /usr/src/share/skel/dot.cshrc       Sat Mar 25 15:23:36 2000
+++ /usr/src/etc/root/dot.cshrc Sat Mar 25 15:23:43 2000
@@ -1,4 +1,4 @@
-# $FreeBSD: src/share/skel/dot.cshrc,v 1.11 2000/03/25 20:23:34 rwatson
Exp $
+# $FreeBSD: src/etc/root/dot.cshrc,v 1.26 2000/03/25 20:23:38 rwatson
Exp $
 #
 # .cshrc - csh resource script, read at beginning of execution by each
shell
 #
@@ -22,6 +22,7 @@
 
 if ($?prompt) then
        # An interactive shell -- set some stuff up
+       set prompt = "`hostname -s`# "
        set filec
        set history = 100
        set savehist = 100


--- /usr/src/share/skel/dot.login       Sat Mar 25 15:23:36 2000
+++ /usr/src/etc/root/dot.login Sat Mar 25 15:23:43 2000
@@ -1,4 +1,4 @@
-# $FreeBSD: src/share/skel/dot.login,v 1.15 2000/03/25 20:23:34 rwatson
Exp $
+# $FreeBSD: src/etc/root/dot.login,v 1.21 2000/03/25 20:23:39 rwatson
Exp $
 #
 # .login - csh login script, read by login shell, after `.cshrc' at
login.
 #
@@ -6,4 +6,4 @@
 #
 
 # Uncomment to display a random cookie each login:
-# [ -x /usr/games/fortune ] && /usr/games/fortune -s
+# [ -x /usr/games/fortune ] && /usr/games/fortune


	Also, one thing that's bugged me forever about the csh files is that
"righteous" is misspelled. :) I also think that using "022" instead of
just "22" would be less confusing to the user, since the man page says
that the values should be specified in octal. 

>   Similar changes probably need to be made in other dot.* files for root
>   and skel, as all of these files seem to set different aliases, environmental
>   variables, prompts, and have different semantics.

	I'm a bash/sh user, so I've taken the liberty of making up some new
files. The intention is that you can do with these files what you've
done with the csh ones, namely synch src/share/skel and src/etc/root,
with the one exception mentioned below. Rather than submit patches, I've
just attached them since the differences are pretty substantial in terms
of organization. I used the existing files as a basis, and added the
'unlimit' function I've used for years. It's the one thing that csh has
that I'm jealous of. :) Printing out what's being set helps unprivileged
user understand what items aren't being changed. 

	For root's dot.profile you need to add the following:

--- dot.profile Sat Mar 25 23:24:25 2000
+++ dot.profile.root    Sat Mar 25 23:41:15 2000
@@ -8,6 +8,8 @@
 # Export all the environment variables to clean things up a bit
 set -o allexport
 
+HOME=/root
+
 # Remove /usr/games and /usr/X11R6/bin if you want

PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin:/usr/X11R6/bin:/usr/games:$HOME/bin
 
If it turns out that putting the umask setting in the profile (roughly
equal to dot.cshrc) then here is a patch for that:

--- dot.profile.mine    Sat Mar 25 23:24:25 2000
+++ dot.profile Sun Mar 26 00:14:52 2000
@@ -24,6 +24,9 @@
 # Turn off allexport to prevent possible foot-shooting
 set +o allexport
 
+# Allows permissions of -rwxr-xr-x
+umask 022
+
 # Set ENV to a file invoked each time sh is started for interactive
use.
 ENV=$HOME/.shrc; export ENV


	Commentary on my files. . . Using allexport instead of an explicit
'export' for every variable makes the file easier to read, and gives a
novice user one less thing to worry about. The PATH may be a little
much, but I wanted to bring it in line with the one you're using for
csh. I also rearranged the order to try and put the most frequently used
directories first. login sets the initial PATH to '/usr/bin:/bin' so I
thought it would be a good idea to emulate that. Also, I checked 'hash'
for a while as a rough statistical analysis, and this is the PATH that
made the most sense. I don't have games in my path, but everything else
is what I use. It might make sense to choose one "canonical" version of
PATH and use that in dot.* and /etc/login.conf so the user has a
reasonable expectation of a consistent environment. 

	I added 'set -o emacs' to dot.shrc, it makes life much easier, and I
don't see any reason not to use it. I also took the best of both worlds
for the 'ls' aliases. The biggest difference is the 'll' alias. I tend
to agree with the existing sh files that 'll' should show everything, so
I used -a instead of -A. I also added the commented out version of the
fortune command, since sh users have a sense of humor too. :) The
_USERNAME gymnastics are necessary to take into account logging in as an
unprivileged user, then su'ing.

	I would like to see dot.shrc added to src/etc/root, and
src/etc/Makefile. If that happens I'd like to suggest uncommenting the
first two "paranoid" aliases in the file. I use these every day for all
of my login shells and they have saved my ass many a time. :)  The 'rm'
alias is too paranoid even for my tastes though. If this file gets added
to /root, it's not necessary to link it into / since setting $HOME in
root's dot.profile will take care of that (which is the reason for the
patch above). 	

	I fully realize that treading in this area is likely to provoke lenghty
arguments, goring of cows, etc. :) I tried to be as conservative as
possible in terms of preserving what's in the existing files, etc. I'm
hoping that the fact that someone was willing to step forward and get
the ball rolling indicates that we're willing to finish the job. :) 

Doug
-- 
    "So, the cows were part of a dream that dreamed itself into
existence? Is that possible?" asked the student incredulously.
    The master simply replied, "Mu."
--------------9ABA32D60C072BD381454706
Content-Type: text/plain; charset=us-ascii;
 name="dot.shrc"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="dot.shrc"

# $FreeBSD$
#
# .shrc - Bourne shell startup file
#
# This file will be used if the shell is invoked for interactive use and
# the environment variable ENV is set to the name of this file.
#
# See also sh(1), environ(7).
#

# Make interactive shells a little more friendly
set -o emacs

# Search path for cd(1)
CDPATH=.:$HOME

# Prompt
_USERNAME=`whoami`
PS1="$_USERNAME@`hostname -s`"
case "$_USERNAME" in
	root) PS1="${PS1}# " ;;
	*) PS1="${PS1}$ " ;;
esac

# Allows permissions of -rwxr-xr-x
umask 022

# General aliases
alias la='ls -A'
alias lf='ls -AF'
alias ll='ls -loaF'
alias m=$PAGER
alias g='egrep -i'

# Shell specific aliases
alias h='fc -l'
alias j=jobs

# For the paranoid
#alias cp='cp -ip'
#alias mv='mv -i'
#alias rm='rm -i'

# Implement a csh-like unlimit command.  Unpriviliged users may
# not be able to change some of these limits.
unlimit ( ) {
	echo '   Setting sock buf size';	ulimit -b unlimited
	echo '   Setting core file size';	ulimit -c unlimited
	echo '   Setting data size';		ulimit -d unlimited
	echo '   Setting file size';		ulimit -f unlimited
	echo '   Setting locked mem size';	ulimit -l unlimited
	echo '   Setting res size';		ulimit -m unlimited
	echo '   Setting fds';			ulimit -n unlimited
	echo '   Setting stack size';		ulimit -s unlimited
	echo '   Setting cpu time';		ulimit -t unlimited
	echo '   Setting max processes';	ulimit -u unlimited
}

# Uncomment to display a random cookie each login:
#[ -x /usr/games/fortune ] && /usr/games/fortune



--------------9ABA32D60C072BD381454706
Content-Type: text/plain; charset=us-ascii;
 name="dot.profile"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="dot.profile"

# $FreeBSD$
#
# .profile - Bourne shell startup script for login shells
#
# See also sh(1), environ(7).
#

# Export all the environment variables to clean things up a bit
set -o allexport

# Remove /usr/games and /usr/X11R6/bin if you want
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin:/usr/X11R6/bin:/usr/games:$HOME/bin

# Setting TERM is normally done through /etc/ttys.  Only override
# if you're sure that you'll never log in via telnet, xterm or a
# serial line.
# Use cons25l1 for iso-* fonts
TERM=${TERM:-cons25}

EDITOR=vi
PAGER=more
BLOCKSIZE=K

# Turn off allexport to prevent possible foot-shooting
set +o allexport

# Allows permissions of -rwxr-xr-x
umask 022

# Set ENV to a file invoked each time sh is started for interactive use.
ENV=$HOME/.shrc; export ENV



--------------9ABA32D60C072BD381454706--



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?38E2F801.548AAAF1>