• 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!

You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:

  • You are not logged in. If you are already registered, fill in the form below to log in, or follow the "Sign Up" link to register a new account.
  • You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
  • If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.

Previously on "Insert header comment into every source file?"

Collapse

  • DaveB
    replied
    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.

    Leave a comment:


  • Platypus
    replied
    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.

    Leave a comment:


  • DaveB
    replied
    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.

    Leave a comment:


  • BrowneIssue
    replied
    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.

    Leave a comment:


  • d000hg
    replied
    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?

    Leave a comment:


  • OrangeHopper
    replied
    Every operating system should allow you to concat files.

    Leave a comment:


  • darmstadt
    replied
    I use a REXX edit macro

    Leave a comment:


  • BrowneIssue
    replied
    Didn't we used to do this in DOS?

    COPY COPYRITE.TXT + C:\SYSTEM\SOURCE\*.SRC C:\SYSTEM\SOURCE2

    Leave a comment:


  • d000hg
    started a topic Insert header comment into every source file?

    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.
Working...
X