Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I just wan't to ask, is it ok to put a GPL notice inside a small script or a snippet?

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see

Or just the Copyright notice will be enough?

share|improve this question
up vote 4 down vote accepted

You are correct that you should:

  • Assert Copyright
  • Grant people explicit rights to use, modify and distribute your code.

In many places, the idea of public domain is not recognized. In order for someone to be able to (legally) use your code, there must be something that says that they can, and under what conditions. For snippets, I highly recommend the 3 clause BSD style license. It asserts your copyright, tells people that they are free to do whatever they like with the code, so long as they preserve your copyright when distributing it via source and tells them that they can't use your name to endorse derived works of the code without your permission.

The GPL has very specific definitions of what should happen when you combine GPL covered work with something else. The GPL has to prevail as the dominate license in the code base, which means someone using your snippets inherits the GPL. The LGPL (known as the library GPL, or lesser GPL) is more suited for that, because it allows linking without inheriting the license. Still, if you're going to take the teeth out of the GPL, you might as well use a much simpler license.

Another excellent choice would be the MIT license, which is very similar to the three clause BSD style license.

Finally, if you must use the GPL, please indicate "Version 2 or later" if at all possible. This ensures that your code can work in places where a tree might be using "Version 2 Only", which is quite common. A substantial portion of the Linux kernel specifies version 2 only, GPL3 (while widely accepted) was met with a fair amount of criticism and rejection.

I'm not discounting the importance, significance or usefulness of the GPL. I'm just suggesting that it might not be the best choice for snippets and libraries.

share|improve this answer
Well explained. Thank you. – Ruel Nov 26 '10 at 6:40

Everything you need to know about that should be here:

Out of curiosity, why would you make a snippet GPL? Making a code snippet GPL pretty much makes it useless for anyone except those writing software that is also GPL. Seems to me the LGPL (or even the MIT) license would make more sense.

share|improve this answer
Actually, the snippets were intended for open source projects. That somebody may find it useful for their projects, and use/modify it for their code. – Ruel Nov 26 '10 at 3:53
Not all open source projects are GPL. In fact, many aren't. – Robert Harvey Nov 26 '10 at 3:58
Agreed with Robert Harvey. The implications of making something GPL effectively causes a flow of GPL to anything the uses it. There are some very long Q-and-A pages you should read, because imposing GPL can cause significant problems for others (including other open source not using GPL). A more generous license would create less trouble for others. Personally, I like the Boost license: – quickly_now Nov 26 '10 at 8:53
A useful reference for some of the many open source licenses: – quickly_now Nov 26 '10 at 8:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.