> pn] Is there an elegant way to test a positional parameter for
> being numeric (so that I don't
> assign a string to a numeric variable)?

You could try test -eq, it returns an error if non-integer parameters are
used:

#!/bin/sh

test $1 -eq $1 2>/dev/null

if test $? -eq 2; then
  echo non integer
else
  echo integer
fi

- Alex



-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01
------------------------------------------------------------------------
leaf-user mailing list: [EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/leaf-user
SR FAQ: http://leaf-project.org/pub/doc/docmanager/docid_1891.html

Reply via email to