Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Odd Behaviour with initial and subsequent xterm launches



On Sun, Jun 15, 2003 at 06:29:32PM +0100, Tim Haigh wrote:
> you need to edit this file
> 
> 
> sudo pico /usr/share/tcsh/examples/aliases
> 
> and edit this paragraph
> 
> if ("$TERM_PROGRAM" == "Apple_Terminal") then
>     alias settermtitle 'echo -n ""'
> endif

> and insert a ? between $ and Term like this
> 
> if ("$?TERM_PROGRAM" == "Apple_Terminal") then
>     alias settermtitle 'echo -n ""'
> endif

I don't think that's quite correct.  That alias will never be created,
because $?VARIABLE evaluates to 1 or 0.  So if TERM_PROGRAM was
Apple_Terminal, tcsh would run:

if ("1" == "Apple_Terminal") then...

which is not what you want.  The correct way to fix this is to check
that the variable is defined first, and then check that the variable
contains what you think:

if ( $?TERM_PROGRAM ) then
  if ( "$TERM_PROGRAM" == "Apple_Terminal") then
    alias settermtitle 'echo -n ""'
  endif
endif

This is an unfortunate side-effect of the way csh-family shells work.
In Bourne shell families, you can use simpler syntax:

if [ "$TERM_PROGRAM" == "Apple_Terminal" ]; then
  alias settermtitle='echo -n ""'
fi

This is because in bourne shells variables that are undefined evaluate
to empty strings without an error.

I think there's a way to stop tcsh treating undefined variables as
errors, but some scripts may depend on it, so I've never changed it.

Tim

-- 
Dr Tim Cutts
Informatics Systems Group
Wellcome Trust Sanger Institute, Hinxton, Cambridge, CB10 1SA, UK
_______________________________________________
x11-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/x11-users
X11 for Mac OS X FAQ: http://developer.apple.com/qa/qa2001/qa1232.html
Report issues, request features, feedback: http://developer.apple.com/bugreporter
Do not post admin requests to the list. They will be ignored.

References: 
 >Odd Behaviour with initial and subsequent xterm launches (From: Al Szymanski <email@hidden>)
 >Re: Odd Behaviour with initial and subsequent xterm launches (From: Tim Haigh <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.