| Barry Margolin 2007-02-19, 7:15 pm |
| In article <m3d545rkce.fsf@localhost.localdomain>,
Gary Wessle <phddas@yahoo.com> wrote:
> Hi
>
> I have this script which is not mine but I did some modifications and
> not it is not producing the second file.
You don't have { } braces surrounding all the lines of the second bunch
of echo commands.
BTW, instead of a series of echo statements, I recommend using a
here-document, i.e.
cat <<EOF > $fn.h
#ifndef $ucbasefn
#define $ucbasefn
....
EOF
> please take a look.
>
> thanks
>
> #!/bin/sh
> while echo "Enter filename, or q to quit" ; read fn
> do
> if [ q = "${fn}" ] ; then exit 1 ; fi
> basefn=${fn##*/}
> ucbasefn=$(echo "$basefn" | tr '[a-z]' '[A-Z]')_H
> if [ -e "${fn}.h" ]
> then
> echo "${fn}.h already exists"
> elif [ -e "${fn}.cpp" ]
> then
> echo "${fn}.cpp already exists"
> else
> {
> echo "#ifndef ${ucbasefn}"
> echo "#define ${ucbasefn}"
> echo
> echo
> echo "class ${basefn}"
> echo "{"
> echo
> echo "public:"
> echo
> echo "};"
> echo
> echo "#endif // ${ucbasefn}"
> } > "${fn}.h"
> echo "#include \"${basefn}.h\""
> echo
> echo
> echo "${basefn}\:\:${basefn}():"
> echo "{"
> echo
> echo "}"
> > ${fn}.cpp
> break
> fi
> done
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
|