I thought I knew unix/bash etc.

The compound statement


cd /lkjsdf ; source junk.1   

completes and then logs me off IF the cd directory does not exist. It works fine if the directory does exist. Why is this and how do I fix it.

It doesn't matter what is in junk.1, nothing will do.

cat junk.1  
echo hello  

cd /root ; source junk.1  

cd /xoot; source junk.1  
/xoot: no such file or directory  
Connection to vm2 closed.  

This has worked fine for 30 years across all kinds of unix, until Centos 7 came along.

  • 2
    Is tcsh being invoked with the -e command line option? – steeldriver Jul 6 at 21:26
  • 2
    Why do you keep including backslashes \ ? – roaima Jul 6 at 22:56
  • Sorry the \ are typos. The correct line that fails is cd /nonexistent-directory ; source ./junk.1 – Homer Wilson Smith Jul 9 at 2:05
  • tcsh is not called with -e, it is merely involved out of /etc/passwd, and the command is entered at the command line prompt. cd is not aliased to anything. The PURPOSE of the is to alias cd to this line so as to create a highly specialized prompt created by source ./junk.1 But what is in junk.1 is meaningless as the problem occurs when junk.1 is empty. The problem is the cd alias works perfect until I cd to a directory that doesn't exist, and then it logs me off. The used alias line is below, but does not need to be aliased in order to cause the log off – Homer Wilson Smith Jul 9 at 2:09
  • alias cd *! ; source /root/prompt where prompt is a tcsh script that builds a specialized line for the prompt. the script can be empty, I still get logged off if the cd directory fails. – Homer Wilson Smith Jul 9 at 2:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.