/etc/csh.cshrc is not extensible (like csh.login).

Bug #1318343 reported by rew
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
tcsh (Ubuntu)
New
Undecided
Unassigned

Bug Description

The "csh.login" file checks for extensions in /etc/csh/login.d . By adding:

set dir=/etc/csh/cshrc.d
if (-e $dir && `/bin/ls $dir` != "") then
  foreach FILE (`/bin/ls $dir/*`)
    source $FILE;
  end;
endif
unset dir

to /etc/csh.cshrc I now have the same feature for csh.cshrc. This means that by putting my "csh.aliases" file in the proper directory I now have my aliases available in a "sudo -s" shell too.

I got bored typing out the directory name three times, and it's bad software engineering to have the same string there three times. I set the variable and then use the variable three times.

I personally thing that the foreach line should read:
  foreach FILE ($dir/*)
which would work for files containing spaces whereas the code above executes an unneccessary external program and fails should there be files with spaces in the directory.

I also think that the "if" should be:
 if (-d $dir .... )
to test for a directory.

But.... Either someone incompetent at shell programming wrote this, or there are reasons I don't understand.

For minimal invasiveness: use the code snippet near the top.....

irrelevant details:
Description: Ubuntu 14.04 LTS
Release: 14.04
(I've been anoyed at this for quite a while now, only now got around to fixing/reporting it. I'd say: fix in 14.10).

rew (r-e-wolff)
description: updated
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.