--- zenencfs-0.2.1/zenencfs	2016-08-06 10:15:19.000000000 +0200
+++ zenencfs-0.2.2/zenencfs	2016-08-27 12:24:26.000000000 +0200
@@ -6,27 +6,21 @@
 # or (at your option) any later version. Please take a look at http://www.gnu.org/copyleft/gpl.htm
 
 # zenencfs is a simple GTK/NCURSES frontend to encfs
-# Version 0.1 - Thu Aug  4 10:35:57 CEST 2016
-# Version 0.2 - Fri Aug  5 22:54:25 CEST 2016
-# Version 0.2.1 - Sat Aug  6 10:12:42 CEST 2016
 
 
-# Default CLI options
-ENCFS="/usr/bin/encfs --standard"
-
 # Take a look at "Xdialog" and use it instead of "dialog" in case X is running
 if [[ "$DISPLAY" && "$(which Xdialog 2>&1 | grep -v "which: no")" ]]; then
 	dialog="Xdialog --wrap --left --icon security"
 	shortttl='3000'
 	longttl='8000'
 	xflag='yes'
-	pwdialogoptions="--stdout --wrap --ignore-eof --password --icon security --inputbox"
+	securedialog='Xdialog --title Password --stdout --wrap --ignore-eof --password --icon security --inputbox'
 else
 	dialog="dialog"
 	shortttl=''
 	longttl=''
 	xflag='no'
-	pwdialogoptions="--stdout --insecure --fixed-font --smooth --passwordbox"
+	securedialog='dialog --title Password --stdout --insecure --fixed-font --smooth --passwordbox'
 fi
 
 # Gettext internationalization
@@ -34,73 +28,48 @@
 export TEXTDOMAINDIR="/usr/share/locale"
 . gettext.sh
 
-inputfolder="$@"
 
-if [ ! "$inputfolder" ]; then 
-	inputfolder="$($dialog \
-				--title "$(eval_gettext 'Zen ENCFS')" \
-				--stdout --inputbox "$(eval_gettext 'Enter the full path of ENCFS Folder or relative to') \"$HOME\"" 12 75)"
-	[ $? != 0 ] && exit 1
-fi
-
-if [ ! "$inputfolder" ]; then 
-	$dialog --title "$(eval_gettext 'No folder')" --msgbox "$(eval_gettext 'ENCFS Folder path is needed, exiting...')" 10 75
+if [ ! "$@" ]; then
+	$dialog --title "$(eval_gettext 'Bad folder name')" --msgbox "$(eval_gettext 'You must provide an ENCFS Folder')" 8 65 
 	exit 1
 fi
 
-if [ -e "$inputfolder" ] ; then
-	folder="$inputfolder"
-else
-	folder="$HOME/$(basename "$inputfolder")"
-fi
-
-pathfolder="$(dirname "$folder"/.)"
+arg="$(dirname "$@"/.)"
 
-if [ "$(echo "$pathfolder" | grep "\.encfs$")" ]; then
-	foldernoext="$(basename -s .encfs "$pathfolder")"
-	folderext="$(basename "$pathfolder")"
-	path="$(dirname "$pathfolder")"
+if [ "$(echo "$arg" | grep "\.encfs$")" ]; then
+	# $dialog --title "$(eval_gettext 'Bad folder name')" --msgbox "$(eval_gettext 'ENCFS Folder must have ".encfs" suffix')" 8 65 
+	foldernoext="$(basename -s .encfs "$arg")"
+	folderext="$(basename "$arg")"
+	pathtofolder="$(dirname "$arg")"
 else
-	foldernoext="$(basename "$pathfolder")"
-	folderext="$(basename "$pathfolder").encfs"
-	path="$(dirname "$pathfolder")"
+	foldernoext="$(basename "$arg")"
+	folderext="$(basename "$arg").encfs"
+	pathtofolder="$(dirname "$arg")"
 fi
 
 
-if [ "$(/bin/mount | grep "^encfs.*$path/$foldernoext.*" )" ] ; then
-	$dialog \
-			--title "$(eval_gettext 'ENCFS Close')" \
-			--ok-label "OK" \
-			--cancel-label "Cancel" \
-			--yesno "$(eval_gettext 'Closing ENCFS Folder') \"$path/$foldernoext\"" 10 75 
+if [ "$(/bin/mount | grep "^encfs.*$pathtofolder/$foldernoext.*" )" ] ; then
+	$dialog --title "$(eval_gettext 'Closing')" --ok-label "$(eval_gettext 'OK')" --cancel-label "$(eval_gettext 'Cancel')" --yesno "$(eval_gettext 'Closing ENCFS Folder') \"$foldernoext\"" 8 65 
 	[ $? != 0 ] && exit 1
-	mountpoint="$(/bin/mount | grep "^encfs.*$path/$foldernoext.*" | sed -n 's|^encfs on \(.*\) type .*|\1|p')"
-	fusermount -u -z "$mountpoint" && rmdir "$mountpoint"  \
-		|| $dialog --title "$(eval_gettext 'Error')" --msgbox "$(eval_gettext 'Failed to close ENCFS Folder') \"$folderext\"" 10 75 
+	mountpoint="$(/bin/mount | grep "^encfs.*$pathtofolder/$foldernoext.*" | sed -n 's|^encfs on \(.*\) type .*|\1|p')"
+	fusermount -u "$mountpoint" && rmdir "$mountpoint"
 else
-	if [ -d "$path/$folderext" ]; then
-		password="$($dialog \
-				--title "$(eval_gettext 'ENCFS Open')" \
-				$pwdialogoptions "$(eval_gettext 'Enter password to open ENCFS Folder') \"$path/$folderext\"" 12 75)"
+	if [ -d "$pathtofolder/$folderext" ]; then
+		password="$(${securedialog} "$(eval_gettext 'Opening ENCFS Folder') \"$folderext\"" 12 80)"
 		[ $? != 0 ] && exit 1
-		mkdir -p "$path/$foldernoext"
-		echo -n "$password" |  $ENCFS --stdinpass "$path/$folderext" "$path/$foldernoext" \
-		|| $dialog --title "$(eval_gettext 'Error')" --msgbox "$(eval_gettext 'Failed to open ENCFS Folder') \"$folderext\"" 10 75 && rmdir "$path/$foldernoext"
+		mkdir -p "$pathtofolder/$foldernoext"
+		echo -n $password |  encfs --standard --stdinpass "$pathtofolder/$folderext" "$pathtofolder/$foldernoext"
 	else
-		password="$($dialog \
-				--title "$(eval_gettext 'ENCFS Create')" \
-				$pwdialogoptions "$(eval_gettext 'Enter password to create ENCFS Folder') \"$path/$folderext\"" 12 75)"
+		password="$(${securedialog} "$(eval_gettext 'Creating ENCFS Folder') \"$folderext\"" 12 80)"
 		[ $? != 0 ] && exit 1
-		[ ! "$password" ] && $dialog --title "$(eval_gettext 'Error')" --msgbox "$(eval_gettext 'Null passwords are not allowed')" 10 75 && exit 1
-		mkdir -p "$path/$folderext"
-		mkdir -p "$path/$foldernoext.TMP"
-		echo -n "$password" |  $ENCFS --stdinpass "$path/$folderext" "$path/$foldernoext.TMP" \
-		|| $dialog --title "$(eval_gettext 'Error')" --msgbox "$(eval_gettext 'Failed to create ENCFS Folder') \"$folderext\"" 10 75 
-		if [ -d "$path/$foldernoext" ]; then
-			cp -rf "$path/$foldernoext"/* "$path/$foldernoext.TMP"
-			mountpoint="$(/bin/mount | grep "^encfs.*$path/$foldernoext.*" | sed -n 's|^encfs on \(.*\) type .*|\1|p')"
-			fusermount -u -z "$mountpoint" && rmdir "$mountpoint"
-			$dialog --title "$(eval_gettext 'Done')" --msgbox "$(eval_gettext 'Done copying data to ENCFS Folder') \"$folderext\"" 10 75 
+		mkdir -p "$pathtofolder/$folderext"
+		mkdir -p "$pathtofolder/$foldernoext.TMP"
+		echo -n $password |  encfs --standard --stdinpass "$pathtofolder/$folderext" "$pathtofolder/$foldernoext.TMP"
+		if [ -d "$pathtofolder/$foldernoext" ]; then
+			cp -rf "$pathtofolder/$foldernoext"/* "$pathtofolder/$foldernoext.TMP"
+			mountpoint="$(/bin/mount | grep "^encfs.*$pathtofolder/$foldernoext.*" | sed -n 's|^encfs on \(.*\) type .*|\1|p')"
+			fusermount -u "$mountpoint" && rmdir "$mountpoint"
+			$dialog --title "$(eval_gettext 'Closing')" --msgbox "$(eval_gettext 'Done moving data to ENCFS Folder') \"$folderext\"" 8 65 
 		fi
 	fi
 fi
