Vista combinada Visión Plana Vista de árbol
Discusiones [ Anterior | Siguiente ]
Validaciones para sinadura-console
toggle
Hola:

Como siempre, comienzo por agradeceros vuestro trabajo con sinadura. Al hilo de un error que cometí en la llamada a sinadura console, pensaba que quizá sería recomendable hacer más validaciones en el script (actualmente sólo valida que haya al menos un argumento). Os envío mi propuesta en forma de parche:

 1--- sinadura-console.orig    2010-01-12 20:20:28.000000000 +0100
 2+++ sinadura-console    2010-01-12 20:32:30.000000000 +0100
 3@@ -24,6 +24,38 @@
 4   exit
 5 fi
 6
 7+ARGS=$*
 8+for ARG ; do
 9+  case "$ARG" in
10+    -input )       INPUTPATH="$2"
11+                   shift ; shift ;;
12+    -output )      OUTPUTPATH="$2"
13+                   shift ; shift ;;
14+    -preferences ) PREFERENCESPATH="$2"
15+                   shift ; shift ;;
16+  esac
17+done
18+
19+if [ -z "$INPUTPATH" -o -z "$OUTPUTPATH" -o -z "$PREFERENCESPATH" ]; then
20+  echo "Usage: sinadura.sh -input xx.pdf -output xx-signed.pdf -preferences xx.properties"
21+  echo 
22+  exit
23+fi
24+
25+if ! [ -f "$INPUTPATH" ]; then
26+  echo "Usage: sinadura.sh -input xx.pdf -output xx-signed.pdf -preferences xx.properties"
27+  echo "Error: Input file not found"
28+  echo 
29+  exit
30+fi
31+
32+if ! [ -f "$PREFERENCESPATH" ]; then
33+  echo "Usage: sinadura.sh -input xx.pdf -output xx-signed.pdf -preferences xx.properties"
34+  echo "Error: Preferences file not found"
35+  echo 
36+  exit
37+fi
38+
39 BASEDIR=`dirname $0`/..
40 BASEDIR=`(cd "$BASEDIR"; pwd)`
41
42@@ -103,5 +135,5 @@
43   -Dapp.repo="$REPO" \
44   -Dbasedir="$BASEDIR" \
45   net.esle.sinadura.core.Sinadura \
46-  $1 $2 $3 $4 $5 $6 \
47+  $ARGS \
48   "$@"


Está probado con bash 3.2 sobre Debian GNU/Linux, en concreto Lenny.
RE: Validaciones para sinadura-console
13/01/10 8:28 en respuesta a Alfredo Esteban.
Gracias por la aportación, intentaremos incluirla en siguientes versiones.