X-Git-Url: https://git.llucax.com/z.facultad/75.08/llamadas.git/blobdiff_plain/a544d76b16b2bb4ce84c3d9f45a464c4cc0498a2..87be67dc181732bc1d164f616d0490d8438e0704:/inst/util.sh diff --git a/inst/util.sh b/inst/util.sh index 1d9219c..136ab7c 100755 --- a/inst/util.sh +++ b/inst/util.sh @@ -1,5 +1,10 @@ #/bin/sh +## Los scrips que incluyan deben definir BASE_DIR antes de incluirme! +#BASE_DIR="$PWD" + +LOCK_DIR="$BASE_DIR/lock" + # Lee del teclado un valor # # parĂ¡metros : @@ -32,6 +37,10 @@ preguntar () { OPCIONES=$2 while [ true ] ; do read -p "$PREGUNTA [$OPCIONES]: " RTA + + # Escapeo el caracter '-' por '\-' + RTA=$(echo $RTA | sed "s/\-/\\\-/") + IS_OK=`echo "$OPCIONES" | grep "$RTA"` if [ ! -z "$IS_OK" ] && [ ! -z "$RTA" ] ; then eval "$3=$RTA" @@ -57,18 +66,18 @@ lock () { echo "No" return fi - echo "lero lero" > "$INST_DIR/lock/$1.pid" + echo "$$" > "$LOCK_DIR/$1.pid" } # Desbloquea el script unlock () { - rm -rf "$INST_DIR/lock/$1.pid" + rm -rf "$LOCK_DIR/$1.pid" } # Consulta si un script esta lockeado is_lock () { - if [ -e "$INST_DIR/lock/$1.pid" ] ; then + if [ -e "$LOCK_DIR/$1.pid" ] ; then # Lock file encontrado! return 0 fi