This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Backup script not working properly

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

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.


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:


 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.


Unsubscribe info:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]