On 05/16/11 12:12, Eric Blake wrote:
> On the other hand, it only works with POSIX
> shells (Solaris /bin/sh doesn't understand the XSI notion of %% and ##).
> 

Another option might be something like this (untested)

lswords=`ls -1diL "$src" "$dst" 2>/dev/null` &&
inum= && \
for lsword in $lswords; do
  case $lsword in
    *[!0-9]*) ;;
    *) if test -z "$inum"; then
         inum=$lsword
       elif test $inum -ne $lsword; then
         inum=
         break
       fi ;;
  esac
done &&
test -n "$inum"

This uses just one fork+exec too, but it doesn't use the
XSI notion of %% and ##.  It can be fooled if "$src"
or "$dst" contains an integer surrounded by spaces, but
any such errors cause it to fail in a conservative way
(by doing needless remakes), and these errors should be
rare so that's not so bad.

It assumes [!0-9] works, though;
is that a safe assumption these days?

Reply via email to