my sys_info_script as edited with emacs:
#!/bin/bash
# Program to output a system information page
declare -r TITLE="System Information Report For $HOSTNAME"
declare -r CURRENT_TIME="$(date +"%x %r %Z")"
declare -r TIMESTAMP="Generated $CURRENT_TIME, by $USER"
function report_uptime {
cat <<- _EOF_
<h2>System Uptime</h2>
<pre>$(uptime)</pre>
_EOF_
return
}
function report_disk_space {
cat <<- _EOF_
<h2>Disk Space Utilization</h2>
<pre>$(df -h)</pre>
_EOF_
return
}
function report_home_space {
cat <<- _EOF_
<h2>Home Space Utilization</h2>
<pre>$(du -sh /home/*)</pre>
_EOF_
return
}
cat << _EOF_
<html>
<head>
<title>$TITLE</title>
</head>
<body>
<h1>$TITLE</h1>
<p>$TIMESTAMP</p>
$(report_uptime)
$(report_disk_space)
$(report_home_space)
</body>
</html>
_EOF_
when i execute the script if get an unexpected end of file `syntax-error
the same file as edited by nano:
#!/bin/bash
# Program to output a system information page
declare -r TITLE="System Information Report For $HOSTNAME"
declare -r CURRENT_TIME="$(date +"%x %r %Z")"
declare -r TIMESTAMP="Generated $CURRENT_TIME, by $USER"
function report_uptime {
cat <<- _EOF_
<h2>System Uptime</h2>
<pre>$(uptime)</pre>
_EOF_
return
}
function report_disk_space {
cat <<- _EOF_
<h2>Disk Space Utilization</h2>
<pre>$(df -h)</pre>
_EOF_
return
}
function report_home_space {
cat <<- _EOF_
<h2>Home Space Utilization</h2>
<pre>$(du -sh /home/*)</pre>
_EOF_
return
}
cat << _EOF_
<html>
<head>
<title>$TITLE</title>
</head>
<body>
<h1>$TITLE</h1>
<p>$TIMESTAMP</p>
$(report_uptime)
$(report_disk_space)
$(report_home_space)
</body>
</html>
_EOF_
this one runs fine
the sdiff results on the cat -A of the two file (< emacs-edit and > nano-edit):
As you can see emacs's default space-indentation behavior is probably causing the trouble within here documents.
I'd like to continue to use emacs to edit shell scripts with here documents. How do I fix this issue?
Thanks!