Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: a simple translation to tcsh?



On Dec 28,  3:59pm, William Scott wrote:
} Subject: a simple translation to tcsh?
}
} I use the conditional test
} 
} [[  $(sw_vers -productVersion) < 10.5  ]]
} 
} on Mac OS X to test whether the current OS version (in my case 10.5.1)  
} is 10.4.11 or earlier. This takes advantage of a property of zsh that  
} I haven't figured out how to replicate in a tcsh script.

This is just a string comparison.  If the left side was, say, 9.3 instead
of 10.4.something, your test would fail because "9" is lexically greater
than "1".  That's probably fine because the odds of any MacOS prior to
OSX running zsh are pretty small, but note that [[ 10.10 < 10.5 ]] is
also true because "1" is lexically less than "5", so you're going to be
in trouble eventually.

What you really need is

    autoload -U is-at-least
    if is-at-least 10.5 $(sw_vers -productVersion) ; then
 
} Is there a simple way to do this, as it is a small nightmare to  
} implement as an arithmetic test.

The is-at-least function is only about 15 lines long (not counting the
large comment block at the top) and if you don't try to handle the odd
version strings that contain hyphens it should be possible to translate
it into tcsh and run it as a script.  Or you could leave it as a zsh
script, put it in one of your $path directories, and run it from tcsh ...



Messages sorted by: Reverse Date, Date, Thread, Author