From owner-freebsd-questions@freebsd.org Sun Jun 5 20:36:35 2016 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 82E13B6BFCE for ; Sun, 5 Jun 2016 20:36:35 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx01.qsc.de (mx01.qsc.de [213.148.129.14]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 49D8610CD for ; Sun, 5 Jun 2016 20:36:35 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from r56.edvax.de (port-92-195-81-198.dynamic.qsc.de [92.195.81.198]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx01.qsc.de (Postfix) with ESMTPS id D4F003CC6D; Sun, 5 Jun 2016 22:36:32 +0200 (CEST) Received: from r56.edvax.de (localhost [127.0.0.1]) by r56.edvax.de (8.14.5/8.14.5) with SMTP id u55KaWPl002315; Sun, 5 Jun 2016 22:36:32 +0200 (CEST) (envelope-from freebsd@edvax.de) Date: Sun, 5 Jun 2016 22:36:32 +0200 From: Polytropon To: Baho Utot Cc: freebsd-questions@freebsd.org Subject: Re: sh[it] and What am I missing here? Message-Id: <20160605223632.e263d041.freebsd@edvax.de> In-Reply-To: References: <57544c10.90e58c0a.cacbc.62fd@mx.google.com> <57545029.5060805@gmail.com> <6f157455-0bda-ef46-82dc-e97fb0c4a08b@columbus.rr.com> <5754550A.6020500@holgerdanske.com> <02a5bb3c-e19a-221c-d30f-0feacebbf928@columbus.rr.com> <20160605221320.ac3da346.freebsd@edvax.de> Reply-To: Polytropon Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Jun 2016 20:36:35 -0000 On Sun, 5 Jun 2016 16:21:19 -0400, Baho Utot wrote: > Looks like I need to reread how login/interactive shells are executed as > I don't remember when .profiles and .shrc are executed/read Oh, that's quite simple, if I remember correctly: For the C shell: /etc/csh.cshrc = global resource for all shells /etc/csh.login = global "auto-exec" for login shells /etc/csh.logout = global "auto-exec" at logout ~/.cshrc = user resource for all shells ~/.login = user "auto-exec" for login shells ~/.logout = user "auto-exec" at logout In .cshrc, you often find "if ($?prompt) then ... endif" blocks which make settings apply only for interactive shells (such as keyboard definitions, history settings or other things that do not matter for scripting); in such cases, $prompt is set. For sh: /etc/profile = global resource for interactive shells ~/.shrc = global resource for all shells ~/.profile = user resource for interactive shells For bash: ~/.bashrc = user resource for all shells ~/.bash_profile = same as .profile, but bash-specific Confusing... I hope I got it right this time. :-) Note that bash also reads sh's profile files. The files are in the corresonding shell's language. There also is a precedence in which order the files are read. Even though "read" and "execute" means the same for those files, there are suggestions to use, for example, .cshrc for settings such as prompt, history, aliases, path, mail ("internal stuff"), while .login is used to start actual programs, such as biff, mesg, fortune ("external stuff"). See "man csh", "man sh" and "man bash" for details. They contain more information about when a shell is considered an interactive or a login shell. -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...