fix rm - dossier - console collection manager DIR Log DIR Files DIR Refs DIR Tags DIR README DIR LICENSE --- DIR commit 3fa51a1818b5f603993f6f2833abb21e46d6e90e DIR parent 93f007a2d82cf9b5dd1068a99f74f290385b7132 HTML Author: Solene Rapenne <solene@perso.pw> Date: Sat, 14 Jul 2018 22:47:08 +0200 fix rm Diffstat: M cdb | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) --- DIR diff --git a/cdb b/cdb @@ -1,6 +1,7 @@ #!/bin/sh : ${REPO:=/home/solene/dev/cbd/games/} +mkdir -p "${REPO}" || exit 1 # displays the values of an identifier # $1 identifier @@ -69,18 +70,25 @@ export_csv() { # $1 identifier delete() { cd "${REPO}" + SEEN=0 for attribute in * do if [ -f "${attribute}/${1}" ] then rm "${attribute}/${1}" rmdir "${attribute}" 2> /dev/null - else - printf "%s is not in the library!\n" "$1" - exit 1 + SEEN=1 fi done - exit 0 + + # did we find it? + if [ "$SEEN" -eq 0 ] + then + printf "%s is not in the library!\n" "$1" + exit 1 + else + exit 0 + fi } # displays list of identifiers