Add error handling: exit if cd fails

This commit is contained in:
practicalswift 2017-10-04 21:19:45 +02:00 committed by Jack Grigg
parent d6012677ea
commit 8cd66cf690
2 changed files with 2 additions and 2 deletions

View File

@ -1,7 +1,7 @@
#!/bin/bash
if [ -d "$1" ]; then
cd "$1"
cd "$1" || exit 1
else
echo "Usage: $0 <datadir>" >&2
echo "Removes obsolete Bitcoin database files" >&2

View File

@ -7,7 +7,7 @@
export LC_ALL=C
if [ $# -gt 1 ]; then
cd "$2"
cd "$2" || exit 1
fi
if [ $# -gt 0 ]; then
FILE="$1"