diff --git a/sns.sh b/sns.sh index 509ee1e..2359cd7 100755 --- a/sns.sh +++ b/sns.sh @@ -98,7 +98,7 @@ function decrypt(){ #} function create(){ - if [ -e "$NOTE" -o -e "${NOTE%.*}" ]; then + if [ -e "$NOTE" ] || [ -e "${NOTE%.*}" ]; then printf "\nERROR: Note already exists\nHint: use -e to edit the note.\n" exit else @@ -117,7 +117,7 @@ function create(){ } function delete(){ if [ "$DELETE" == "TRUE" ]; then - if [ -e "$NOTE" -o -e "${NOTE%.*}" ]; then + if [ -e "$NOTE" ] || [ -e "${NOTE%.*}" ]; then if [ "$ENCRYPTION" == "TRUE" ]; then rm "${NOTE%.*}" else @@ -154,7 +154,7 @@ if [ "$ENCRYPTION" == "TRUE" ]; then encrypt; fi } function print(){ if [ "$PRINT" == "TRUE" ]; then - if [ -r "$NOTE" -o -r "${NOTE%.*}" ]; then + if [ -r "$NOTE" ] || [ -r "${NOTE%.*}" ]; then if [ -z "$CREATE" ]; then if [ "$ENCRYPTION" == "TRUE" ]; then openssl enc -d -aes-256-cbc -in "${NOTE%.*}" -pass pass:"$ENC_KEY" @@ -234,7 +234,7 @@ if [ -n "$ERR_NO_KEY" ]; then echo " Warning: No encryption key was provided. Encryption disabled." fi -if [ -n "$ERR_NO_SSL" -o -n "$ERR_NO_KEY" ]; then +if [ -n "$ERR_NO_SSL" ] || [ -n "$ERR_NO_KEY" ]; then pause fi @@ -252,22 +252,22 @@ if [ -z "$1" ]; then help; exit 20 else ARGS=( "$@" ) for ARG in "${ARGS[@]}"; do - if [ "$ARG" = "-c" -o "$ARG" = "--create" ]; then CREATE="TRUE" - elif [ "$ARG" = "-d" -o "$ARG" = "--delete" ]; then DELETE="TRUE" - elif [ "$ARG" = "-e" -o "$ARG" = "--edit" ]; then EDIT="TRUE" - elif [ "$ARG" = "-ce" -o "$ARG" = "-ec" ]; then EDIT="TRUE"; CREATE="TRUE" - elif [ "$ARG" = "-p" -o "$ARG" = "--print" ]; then PRINT="TRUE" - elif [ "$ARG" = "-l" -o "$ARG" = "--list" ]; then LIST="TRUE" - elif [ "$ARG" = "-h" -o "$ARG" == "--help" ]; then help; exit 0 - elif [ "$ARG" = "-w" -o "$ARG" == "--wconf" ]; then w_conf; exit 0 + if [ "$ARG" = "-c" ] || [ "$ARG" = "--create" ]; then CREATE="TRUE" + elif [ "$ARG" = "-d" ] || [ "$ARG" = "--delete" ]; then DELETE="TRUE" + elif [ "$ARG" = "-e" ] || [ "$ARG" = "--edit" ]; then EDIT="TRUE" + elif [ "$ARG" = "-ce" ] || [ "$ARG" = "-ec" ]; then EDIT="TRUE"; CREATE="TRUE" + elif [ "$ARG" = "-p" ] || [ "$ARG" = "--print" ]; then PRINT="TRUE" + elif [ "$ARG" = "-l" ] || [ "$ARG" = "--list" ]; then LIST="TRUE" + elif [ "$ARG" = "-h" ] || [ "$ARG" == "--help" ]; then help; exit 0 + elif [ "$ARG" = "-w" ] || [ "$ARG" == "--wconf" ]; then w_conf; exit 0 else - if [ -z "$NAME" -a -n "$ARG" ]; then NAME="$ARG" - elif [ -z "$NOTEBOOK" -a -n "$ARG" ]; then NOTEBOOK="$ARG" - elif [ -z "$SECTION" -a -n "$ARG" ]; then SECTION="$ARG" + if [ -z "$NAME" ] && [ -n "$ARG" ]; then NAME="$ARG" + elif [ -z "$NOTEBOOK" ] && [ -n "$ARG" ]; then NOTEBOOK="$ARG" + elif [ -z "$SECTION" ] && [ -n "$ARG" ]; then SECTION="$ARG" fi fi done - if [ -n "$NAME" -a -z "$NOTEBOOK" -a -n "$LIST" ]; then + if [ -n "$NAME" ] && [ -z "$NOTEBOOK" ] && [ -n "$LIST" ]; then # If we got a note title above, but no notebook, and the list option # was specified, we assume that the detected note title is actually a # notebook name. diff --git a/src/includes/create.sns.sh b/src/includes/create.sns.sh index bcec402..5559417 100644 --- a/src/includes/create.sns.sh +++ b/src/includes/create.sns.sh @@ -25,7 +25,7 @@ #} function create(){ - if [ -e "$NOTE" -o -e "${NOTE%.*}" ]; then + if [ -e "$NOTE" ] || [ -e "${NOTE%.*}" ]; then printf "\nERROR: Note already exists\nHint: use -e to edit the note.\n" exit else diff --git a/src/includes/delete.sns.sh b/src/includes/delete.sns.sh index 25f3608..2efdcd6 100644 --- a/src/includes/delete.sns.sh +++ b/src/includes/delete.sns.sh @@ -1,6 +1,6 @@ function delete(){ if [ "$DELETE" == "TRUE" ]; then - if [ -e "$NOTE" -o -e "${NOTE%.*}" ]; then + if [ -e "$NOTE" ] || [ -e "${NOTE%.*}" ]; then if [ "$ENCRYPTION" == "TRUE" ]; then rm "${NOTE%.*}" else diff --git a/src/includes/print.sns.sh b/src/includes/print.sns.sh index 4d99e02..6058435 100644 --- a/src/includes/print.sns.sh +++ b/src/includes/print.sns.sh @@ -1,6 +1,6 @@ function print(){ if [ "$PRINT" == "TRUE" ]; then - if [ -r "$NOTE" -o -r "${NOTE%.*}" ]; then + if [ -r "$NOTE" ] || [ -r "${NOTE%.*}" ]; then if [ -z "$CREATE" ]; then if [ "$ENCRYPTION" == "TRUE" ]; then openssl enc -d -aes-256-cbc -in "${NOTE%.*}" -pass pass:"$ENC_KEY" diff --git a/src/main/stage1.sns.sh b/src/main/stage1.sns.sh index 6b701fb..9a4b12d 100644 --- a/src/main/stage1.sns.sh +++ b/src/main/stage1.sns.sh @@ -32,7 +32,7 @@ if [ -n "$ERR_NO_KEY" ]; then echo " Warning: No encryption key was provided. Encryption disabled." fi -if [ -n "$ERR_NO_SSL" -o -n "$ERR_NO_KEY" ]; then +if [ -n "$ERR_NO_SSL" ] || [ -n "$ERR_NO_KEY" ]; then pause fi diff --git a/src/main/stage2.sns.sh b/src/main/stage2.sns.sh index 48f63fe..debc0fa 100644 --- a/src/main/stage2.sns.sh +++ b/src/main/stage2.sns.sh @@ -9,22 +9,22 @@ if [ -z "$1" ]; then help; exit 20 else ARGS=( "$@" ) for ARG in "${ARGS[@]}"; do - if [ "$ARG" = "-c" -o "$ARG" = "--create" ]; then CREATE="TRUE" - elif [ "$ARG" = "-d" -o "$ARG" = "--delete" ]; then DELETE="TRUE" - elif [ "$ARG" = "-e" -o "$ARG" = "--edit" ]; then EDIT="TRUE" - elif [ "$ARG" = "-ce" -o "$ARG" = "-ec" ]; then EDIT="TRUE"; CREATE="TRUE" - elif [ "$ARG" = "-p" -o "$ARG" = "--print" ]; then PRINT="TRUE" - elif [ "$ARG" = "-l" -o "$ARG" = "--list" ]; then LIST="TRUE" - elif [ "$ARG" = "-h" -o "$ARG" == "--help" ]; then help; exit 0 - elif [ "$ARG" = "-w" -o "$ARG" == "--wconf" ]; then w_conf; exit 0 + if [ "$ARG" = "-c" ] || [ "$ARG" = "--create" ]; then CREATE="TRUE" + elif [ "$ARG" = "-d" ] || [ "$ARG" = "--delete" ]; then DELETE="TRUE" + elif [ "$ARG" = "-e" ] || [ "$ARG" = "--edit" ]; then EDIT="TRUE" + elif [ "$ARG" = "-ce" ] || [ "$ARG" = "-ec" ]; then EDIT="TRUE"; CREATE="TRUE" + elif [ "$ARG" = "-p" ] || [ "$ARG" = "--print" ]; then PRINT="TRUE" + elif [ "$ARG" = "-l" ] || [ "$ARG" = "--list" ]; then LIST="TRUE" + elif [ "$ARG" = "-h" ] || [ "$ARG" == "--help" ]; then help; exit 0 + elif [ "$ARG" = "-w" ] || [ "$ARG" == "--wconf" ]; then w_conf; exit 0 else - if [ -z "$NAME" -a -n "$ARG" ]; then NAME="$ARG" - elif [ -z "$NOTEBOOK" -a -n "$ARG" ]; then NOTEBOOK="$ARG" - elif [ -z "$SECTION" -a -n "$ARG" ]; then SECTION="$ARG" + if [ -z "$NAME" ] && [ -n "$ARG" ]; then NAME="$ARG" + elif [ -z "$NOTEBOOK" ] && [ -n "$ARG" ]; then NOTEBOOK="$ARG" + elif [ -z "$SECTION" ] && [ -n "$ARG" ]; then SECTION="$ARG" fi fi done - if [ -n "$NAME" -a -z "$NOTEBOOK" -a -n "$LIST" ]; then + if [ -n "$NAME" ] && [ -z "$NOTEBOOK" ] && [ -n "$LIST" ]; then # If we got a note title above, but no notebook, and the list option # was specified, we assume that the detected note title is actually a # notebook name.