How can I validate numeric input arguments to a tcsh script?
#!/usr/bin/tcsh
if ( $1 < 0.0 ) then
echo "ERROR: first input argument is less than zero."
exit 1
endif
The above snippet shows what I’m trying to do but doesn’t work. I have tried MANY combinations based on using the expr command or the @ operator to no avail. The man page and the web have turned up nothing yet. No matter what I try I keep getting errors like “Badly formed number” or “set: Variable name must begin with a letter”.
Is there a tcsh-ish way of doing this? I could certainly hack something up using awk or watever but that seems kind of silly.
Tcsh doesn’t do floats. You can use
bcorawk:or