cat and end of file statements
After discovering that I could create files with the cat command like this:
Quote:
I tried replacing it with "EOF" and it also works. So why use _ACEOF instead or any other EOF statement? |
There's no reason--it's completely arbitrary.
That said, I imagine the Autoconf developers deliberately chose to use _ACEOF to avoid problems. It's common for compiler developers to use an underscore as a prefix for certain compiler directives. Doing so is an attempt to create unique identifiers without using words/phrases a programmer might like. For instance "_DEBUG" or "__DEBUG" might be used by the compiler because it's extremely unlikely that a programmer would want to use that as a variable or function name. The autoconf developers are likely following that naming convention. Also, the "AC" likely stands for AutoConf. Another layer to prevent a naming conflict. If I'm not mistaken, the autoconf package allows the developer to include shell scripts of his/her own as part of the configuration process. Assuming that is the case, you can see why the autoconf developers wanted to avoid a naming conflict. Using "EOF" in way you demonstrate is common, and might easily be used in a script given to autoconf by the developer. There would be a very real risk that the configure script would go bonkers if the autoconf-generated scripts used EOF while the developer-included scripts used EOF as well. |
And why is there sometimes "cat <<\_ACEOF"?
I also currently have a problem in my script: The cat command seems to add everything in the script coming after the _ACEOF to the created file instead of considering it as part of the script. I'm trying to create a shellscript that creates a file if it doesn't exist. edit: Just solved that problem: There was a space after "_ACEOF". I still don't see why "\_ACEOF" is used. Also for uniqueness? |
All times are GMT -5. The time now is 06:08 PM. |