Bash: How to avoid warning: here-document at line XX delimited by end-of-file (wanted `EOM') -


this question has answer here:

i running bash script fine on 1 of linux host(bash version version 3.2.25(1)), since have moved script host (bash verison version 4.2.25(1)) throwing warning as

line 36: warning: here-document @ line 30 delimited end-of-file (wanted `eom') (wanted `eom') 

the code in question is:-(not sure how eom works)

usage=$(cat <<eom usage:${basename} [-h] [-n] [-q] -h, --help        usage message -n, --dry-run      -q, --quiet        -d, --destination  eom) 

}

i have made sure there no space, tab or special symbols before , after eom cause of error find during research on google.

bash (bash -x) debugged output looks like:-

+ source /test/test1/script.sh ./test.sh: line 36: warning: here-document @ line 30 delimited end-of-file       (wanted `eom') ++ cat + usage='usage:test [-h] [-n] [-q] -h, --help        usage message -n, --dry-run      -q, --quiet        -d, --destination 

this sourcing script.sh usage used in 1 of function as: (however guess not cause of error may wrong)-

show_usage() {  declare -i rc=0 show_error "${@}" rc=${?} echo "${usage}" exit ${rc}   }   

please , getting rid of warning , how eom working here exactly?

when using here-document, make sure delimiter string on line. in case, right parenthesis taken part of word, matching delimiter not found. can safely move next line:

usage=$(cat <<eom usage:${basename} [-h] [-n] [-q] -h, --help        usage message -n, --dry-run      -q, --quiet        -d, --destination  eom ) 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -