Magellan Linux

Contents of /trunk/mage/usr/lib/mage/writeprotected

Parent Directory Parent Directory | Revision Log Revision Log


Revision 77 - (show annotations) (download)
Wed Jun 1 15:47:06 2005 UTC (18 years, 11 months ago) by niro
File size: 910 byte(s)
remove usage of expr; using $((foo + 1)) now

1 #!/bin/bash
2 # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/writeprotected,v 1.8 2005-06-01 15:47:06 niro Exp $
3
4 FILE="$1"
5 DIR="$(dirname "${FILE}")"
6 FILENAME="$(basename "${FILE}")"
7
8 # check if there are already protected file
9 # set counter to HIGHEST FILE +1
10 for oldpretected in $(find ${DIR} -iname "._cfg????_${FILENAME}" |
11 sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" |
12 sort -t'%' -k3 -k2 | cut -f1 -d'%')
13 do
14 COUNTER=$(echo ${oldpretected}|cut -d_ -f2|sed -e "s:cfg::")
15 done
16
17 #if counter is zero than set to 0001 else to ${COUNTER}+1
18 if [ -z "${COUNTER}" ]
19 then
20 COUNTER=0001
21 else
22 #set COUNTER +1
23 #this is a tricky one:
24 #exp COUNTER may be 0901
25 # exp ${COUNTER} + 1 is 902 NOT 0902
26
27 #COUNTER=${COUNTER/$(expr ${COUNTER} + 0)/$(expr ${COUNTER} + 0001)}
28
29 # the same without need of expr
30 COUNTER=${COUNTER/$((${COUNTER} + 0))/$((${COUNTER} + 0001))}
31 fi
32
33 echo ${COUNTER}

Properties

Name Value
svn:executable *