I have just upgraded one of my systems to Precise Pangolin (Ubuntu 12.04). (A long-overdue upgrade from Lucid. Youch!)
When I try to login to X Windows, I get a ~/.xsession-errors file with these contents:
/etc/gdm/Xsession: Beginning session setup...
/etc/gdm/Xsession: 11: /home/username/.profile: function: not found
/etc/gdm/Xsession: 19: /home/username/.profile: RC: not found
Warning: unknown mime-type for "0" -- using "application/octet-stream"
Error: no such file "0"
/etc/gdm/Xsession: 23: /home/username/.profile: Syntax error: "}" unexpected
My normal login shell is ksh, and within .profile I have a function defined - and that function is used within the script a few times. All of the above messages have to do with that function. Definition looks like:
function checkFile {
#<stuff here>
print "${RC}"
}
I cannot seem to find a way around this; don't see a way to make X-windows login recognize an advanced .profile file, and don't see a way to make it ignore .profile nor any lines within it. I've tried creating a .bash_profile and .bash_rc, but still .profile is read when logging in. I also tried wrapping the function (and its callers) around tests for interactive shell.. that just changes the error message to "{ found - expecting fi" or similar.
I don't like being forced into a 1970s box by any software.... what options do I have besides not using these sorts of functions in .profile, and not using X-windows?
Here's a log of what happens when I use a more portable syntax:
username@hpmicro1:/home/username> cat .xsession\-errors
/etc/gdm/Xsession: Beginning session setup...
/etc/gdm/Xsession: 12: /home/username/.profile: Syntax error: "(" unexpected (expecting "fi")
username@hpmicro1:/home/username> more .profile
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022
if [ "${SHELL}" = "/bin/ksh" ]; then
function checkFile() {