www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/10/13/17:50:07

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <416DA2E5.1080004@robinbowes.com>
Date: Wed, 13 Oct 2004 22:49:25 +0100
From: Robin Bowes <robin-lists AT robinbowes DOT com>
Organization: robinbowes.com
User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913)
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: Backup script not working properly
References: <loom DOT 20041013T121143-79 AT post DOT gmane DOT org> <416D07C8 DOT 42C3EB0F AT dessent DOT net>
In-Reply-To: <416D07C8.42C3EB0F@dessent.net>
X-IsSubscribed: yes

Brian Dessent wrote:
> Fredrik Persson wrote:
> 
> 
>>All works but for the last for-loop which is responsible for deleting old
>>backups such that only NUMBKPS=4 of the last backups are stored.
>>
>>The problem is in 'if [ ${num} -le 0 ]' and 'else num=$((${num}-1))'. It seems
>>like the num-variable can't be used as an integer. Any suggestions how to fix
>>this???
> 
> 
> On Linux, /bin/sh is /bin/bash.  This is not the case on Cygwin and
> other *nixs.  The "$((...))" thing is a bash feature/extension I think,
> and not found in the standard Bourne shell.  Try using the expr command
> instead to do math, or change the shebang to call bash explicitly.

Indeed.

man bash
/Arithmetic Expansion

  Arithmetic expansion allows the evaluation of an arithmetic  expression
  and  the  substitution of the result.  The format for arithmetic expan-
  sion is:

        $((expression))

  The expression is treated as if it were within  double  quotes,  but  a
  double  quote  inside  the  parentheses  is not treated specially.  All
  tokens in the expression undergo parameter expansion, string expansion,
  command  substitution, and quote removal.  Arithmetic substitutions may
  be nested.

  The evaluation is performed according to the rules listed  below  under
  ARITHMETIC EVALUATION.  If expression is invalid, bash prints a message
  indicating failure and no substitution occurs.

R.
-- 
http://robinbowes.com

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019