• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Insert header comment into every source file?

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    Insert header comment into every source file?

    Is there a tool I can use to insert a comment into every source file in one go... e.g a copyright notice or whatever?

    Sorry for all the threads today gearing up to a new project.
    Originally posted by MaryPoppins
    I'd still not breastfeed a nazi
    Originally posted by vetran
    Urine is quite nourishing

    #2
    Didn't we used to do this in DOS?

    COPY COPYRITE.TXT + C:\SYSTEM\SOURCE\*.SRC C:\SYSTEM\SOURCE2
    Drivelling in TPD is not a mental health issue. We're just community blogging, that's all.

    Xenophon said: "CUK Geek of the Week". A gingerjedi certified "Elitist Tw@t". Posting rated @ 5 lard points

    Comment


      #3
      I use a REXX edit macro
      Brexit is having a wee in the middle of the room at a house party because nobody is talking to you, and then complaining about the smell.

      Comment


        #4
        Every operating system should allow you to concat files.

        Comment


          #5
          Slightly more obscure solutions than I was expecting It's easy enough to write one even, but it seems like an obvious utility that must be floating around... I don't suppose Visual Studio has a way to do this natively by any chance?
          Originally posted by MaryPoppins
          I'd still not breastfeed a nazi
          Originally posted by vetran
          Urine is quite nourishing

          Comment


            #6
            Originally posted by d000hg View Post
            Slightly more obscure solutions than I was expecting
            Huh? How is a single line o/s command obscure?

            I suppose you could buy a macro programming language online, like WinBatch, and learn how to use it and use that, I suppose.

            Or learn how to do it in Python and write something in that.

            Or outsource it to Bob Shawadiwadi on Freelancers.net or whatever that site is called.

            Or write a pre-compiler that parses the source for required text and inserts it if not present, then re-compile the system.

            Reverse engineer the compiler to insert the text into the source.

            Rename every source file to have "®d000hgCo" appended to the name.

            Or use whatever programming language you are working with to write something.

            Or, FFS, write a macro in Word to do it!

            Get one of the admin staff to do it.

            Get the most junior developer on the team to do it.

            How many files are we talking about here? I could have copy 'n' pasted a copyright message in to 20 or 30 documents in the time it has taken me to write this.
            Drivelling in TPD is not a mental health issue. We're just community blogging, that's all.

            Xenophon said: "CUK Geek of the Week". A gingerjedi certified "Elitist Tw@t". Posting rated @ 5 lard points

            Comment


              #7
              Originally posted by d000hg View Post
              Is there a tool I can use to insert a comment into every source file in one go... e.g a copyright notice or whatever?

              Sorry for all the threads today gearing up to a new project.
              Code:
              cat copyright.txt code.c > code2.c
              I'm a bit rusty on Unix but
              Code:
              cat copyright.txt code.c > code.c
              might also work since cat operates on copies of the original files, not the files themselves. So the output could be sent back to one of the original files.

              EDIT :

              Since you are working in a windows environment use type instead of cat. The second option may not work since I dont know how type treats the original data.
              Last edited by DaveB; 22 October 2009, 12:54.
              "Being nice costs nothing and sometimes gets you extra bacon" - Pondlife.

              Comment


                #8
                I'd do this:

                Code:
                for file in *.c *.h
                do
                cat copyright.txt $file > mytemp
                mv mytemp $file
                done
                EDIT: I'd say "cat copyright.txt code.c > code.c" is risky, I've never heard of cat operating on copies of files. I could be wrong, but I've been around Unix a long time.

                Comment


                  #9
                  Originally posted by Platypus View Post
                  I'd do this:

                  Code:
                  for file in *.c *.h
                  do
                  cat copyright.txt $file > mytemp
                  mv mytemp $file
                  done
                  EDIT: I'd say "cat copyright.txt code.c > code.c" is risky, I've never heard of cat operating on copies of files. I could be wrong, but I've been around Unix a long time.
                  Your version is the safe way, I did say that cat copyright.txt code.c > code.c *might* work and that I was rusty. I'd test it first if I were you

                  From memory it's an "undocumented feature" of cat that redirecting the output to one of the original files will overwrite the contents of that file without warning, rather than barfing with an error message from trying to write to an open file.
                  "Being nice costs nothing and sometimes gets you extra bacon" - Pondlife.

                  Comment

                  Working...
                  X