Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I was trying to change my shell from bash to csh by typing "csh" and got this error "if: Empty if." I figured it is because if and then do show up in the same line in the cshell source file. However there is no .cshrc in my home directory. I looked at the /etc/csh.cshrc and everything seems correct. No "empty if". Any suggestions?
I'm going to have a lil fun with this, so please forgive me
/me dons my best Drill Instructor voice
Everybody repeat after me: "This is my man command. There are many like it, but this one is important. I must read the man page before posting, or my post will show my noobies."
From "man csh"
Code:
A login shell begins by executing commands from the system files /etc/csh.cshrc and /etc/csh.login. It then exe-
cutes commands from files in the user’s home directory: first ~/.tcshrc (+) or, if ~/.tcshrc is not found,
~/.cshrc, then ~/.history (or the value of the histfile shell variable), then ~/.login, and finally ~/.cshdirs
(or the value of the dirsfile shell variable) (+). The shell may read /etc/csh.login before instead of after
/etc/csh.cshrc, and ~/.login before instead of after ~/.tcshrc or ~/.cshrc and ~/.history, if so compiled; see
the version shell variable. (+)
Check to see if the two files highlighted above exist on your system, and see what they contain.
I'm going to have a lil fun with this, so please forgive me
/me dons my best Drill Instructor voice
Everybody repeat after me: "This is my man command. There are many like it, but this one is important. I must read the man page before posting, or my post will show my noobies."
From "man csh"
Code:
A login shell begins by executing commands from the system files /etc/csh.cshrc and /etc/csh.login. It then exe-
cutes commands from files in the user’s home directory: first ~/.tcshrc (+) or, if ~/.tcshrc is not found,
~/.cshrc, then ~/.history (or the value of the histfile shell variable), then ~/.login, and finally ~/.cshdirs
(or the value of the dirsfile shell variable) (+). The shell may read /etc/csh.login before instead of after
/etc/csh.cshrc, and ~/.login before instead of after ~/.tcshrc or ~/.cshrc and ~/.history, if so compiled; see
the version shell variable. (+)
Check to see if the two files highlighted above exist on your system, and see what they contain.
Only two of the files you mentioned exist in my system. /etc/csh.cshrc and /etc/csh.login. It seems to me all the if-then's are in the same line.
Attached is the content of the two files. I never used csh on this machine, so I don't think these files have ever been touched.
/etc/csh.login
Code:
# /etc/cshrc
#
# csh configuration for all shell invocations.
# By default, we want this to get set.
# Even for non-interactive, non-login shells.
if ($uid > 99 && "`id -gn`" == "`id -un`") then
umask 002
else
umask 022
endif
if ($?prompt) then
if ($?tcsh) then
set promptchars='$#'
set prompt=\[$user'@%m %c]%# '
else
set prompt=\[$user@`hostname -s`\]\$\
endif
endif
if ( $?tcsh ) then
bindkey "^[[3~" delete-char
endif
bindkey "^R" i-search-back
set echo_style = both
set histdup = erase
set savehist = (1024 merge)
setenv MAIL "/var/spool/mail/$USER"
limit coredumpsize 0
# Check if we aren't a loginshell and do stuff if we aren't
if (! $?loginsh) then
if ( -d /etc/profile.d ) then
set nonomatch
foreach i ( /etc/profile.d/*.csh )
if ( -r $i ) then
if ($?prompt) then
source $i
else
source $i >&/dev/null
endif
endif
end
unset i nonomatch
endif
endif
/etc/csh.login
Code:
# /etc/csh.login
# System wide environment and startup programs, for login setup
if ($?PATH) then
if ( "${path}" !~ */usr/X11R6/bin* ) then
setenv PATH "${PATH}:/usr/X11R6/bin"
endif
else
if ( $uid == 0 ) then
setenv PATH "/sbin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin"
else
setenv PATH "/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin"
endif
endif
setenv HOSTNAME `/bin/hostname`
set history=1000
if ( ! -f $HOME/.inputrc ) then
setenv INPUTRC /etc/inputrc
endif
if ( -d /etc/profile.d ) then
set nonomatch
foreach i ( /etc/profile.d/*.csh )
if ( -r $i ) then
if ($?prompt) then
source $i
else
source $i >& /dev/null
endif
endif
end
unset i nonomatch
endif
# Set umask consistently with bash for loginshells (csh.login sourced
# after csh.cshrc unlike with bash profile/bashrc scripts and umask
# might be modified in profile.d csh scripts)
if ($?loginsh) then
if ($uid > 99 && "`id -gn`" == "`id -un`") then
umask 002
else
umask 022
endif
endif
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.