Bug 19926

Summary: tcsh has strange login shell detection
Product: [Retired] Red Hat Linux Reporter: Tobias Ringstrom <tobias>
Component: tcshAssignee: Eido Inoue <havill>
Status: CLOSED CURRENTRELEASE QA Contact: Aaron Brown <abrown>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2001-02-06 21:36:55 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Tobias Ringstrom 2000-10-27 16:39:39 UTC
All shells I know of start as a login shell (reading .profile, .login or
whatever) when the first character of argv[0] is a dash ('-'). However,
tcsh does become a login shell if there are any arguments. I cannot see any
good reason for this. The following patch makes tcsh behave, and
automatically fixes the bugs with gdm not reading .login for tcsh users.

/Tobias

--- sh.c.orig	Fri Aug 13 18:32:51 1999
+++ sh.c	Fri Oct 27 18:29:09 2000
@@ -297,7 +297,6 @@
     gid = getgid();
     euid = geteuid();
     egid = getegid();
-#if defined(OREO) || defined(DT_SUPPORT)
     /*
      * We are a login shell if: 1. we were invoked as -<something> with
      * optional arguments 2. or we were invoked only with the -l flag
@@ -305,15 +304,6 @@
     loginsh = (**tempv == '-') || (argc == 2 &&
 				   tempv[1][0] == '-' && tempv[1][1] == 'l' &&
 						tempv[1][2] == '\0');
-#else
-    /*
-     * We are a login shell if: 1. we were invoked as -<something> and we
had
-     * no arguments 2. or we were invoked only with the -l flag
-     */
-    loginsh = (**tempv == '-' && argc == 1) || (argc == 2 &&
-				   tempv[1][0] == '-' && tempv[1][1] == 'l' &&
-						tempv[1][2] == '\0');
-#endif
 
 #ifdef _VMS_POSIX
     /* No better way to find if we are a login shell */

Comment 1 Eido Inoue 2001-02-06 21:36:51 UTC
bash will also allow optional arguments even when arg0 is '-', so this seems
resonable. Will allowing the login shell to accept arguments break any tcsh
scripts out there?