diff --git a/vmcreate1.sh b/vmcreate1.sh index 4ed85c0..24ed010 100644 --- a/vmcreate1.sh +++ b/vmcreate1.sh @@ -42,7 +42,7 @@ while getopts "a:f:h" opt; do p) password="$OPTARG";; d) size="$OPTARG";; t) tag="$OPTARG";; - # *) noopts=true + *) echo "Invalid option. Use `-h` for help." esac done @@ -55,7 +55,7 @@ if [[ -v pubkey ]]; then echo "Public key: $pubkey"; fi if [[ -v username ]]; then echo "User: $file"; fi # Если файл не задан, но флаг есть -if [[ $# -eq 0 && -v "$file" && ! -f "$file" ]]; then +if [[ $# -eq 0 && -v "$file" && ! -e "$file" ]]; then input=y read -p "File `$file` does not exist. Use default `hosts` file? Y/n: " input case $input in @@ -63,9 +63,9 @@ if [[ $# -eq 0 && -v "$file" && ! -f "$file" ]]; then Y) file=hosts;; n) read -p "Enter file name: " file;; N) read -p "Enter file name: " file;; - *) echo "Use '-f' flag for help"; exit 0;; + *) echo "Use `-h` flag for help"; exit 0;; esac - if [[ ! -f "$file" ]]; then + if [[ ! -e "$file" ]]; then echo "File `$file` does not exist. Exiting." exit 1 fi @@ -99,6 +99,7 @@ if [[ -e "$file" ]]; then exit 4 fi done + fi # Если заданы аргументы, то создаем временный файл